GithubHelp home page GithubHelp logo

Comments (7)

nqafield avatar nqafield commented on August 16, 2024

I like the general idea and reasoning for your change (I find some of this stuff not as readable as I might like) but the fact that, in the new idea, if: is an object and then: is the name of an argument (even thought they look identical) is not at all obvious and so it seems confusing.

from eo.

yegor256 avatar yegor256 commented on August 16, 2024

@gukoff yeah, I agree with @pa9ey It does look more similar to the good old Java, but it's not OOP any more. We have to make if an object with 3 arguments. In your example we have if, then and else -- three objects.

Also, keep in mind that long methods is a bad idea in the first place. They will have to be short in order to be readable. It's like in Lisp -- long structures are not readable and developers avoid them.

from eo.

gukoff avatar gukoff commented on August 16, 2024

the fact that, in the new idea, if: is an object and then: is the name of an argument (even thought they look identical) is not at all obvious and so it seems confusing.

@pa9ey well, it's all about their order. The first one is a main thing being called, the others mean some additional information. Yes, it is pretty unusual and isn't obvious at first glance. But I got used to it very quickly, while writing this issue :)

We have to make if an object with 3 arguments

@yegor256 yup, and these arguments have to be objects.

In your example we have if, then and else -- three objects.

Hmm. What do you mean? if is some standard library object here, and then and else are just the names of its constructor parameters. The new constructor accepts three objects, but so does the old one in our current example from the README as well.

from eo.

gukoff avatar gukoff commented on August 16, 2024

Actually, I was talking primarily about constructors. A method call would look like this:

filesystem file: '/tmp/x.txt' mode: 'r'

Or, the more complex example:

filesystem
    file:
        stripped: '__new_name.txt__' by_symbol: '_'
    mode:
        if: 
            filesystem writable
        then: 'rw'
        else: 'r'

from eo.

MadridianFox avatar MadridianFox commented on August 16, 2024

I see three levels of syntax.
First, basic relations of objects - instantiating and invoking of methods. All that above will be translated to this level. It's technical level.
Second, user friendly expressions: control statements, operators, etc - all that forms logic of method.
Third, level of composition of objects. This we not only instantiate and invoke. This it has a sense, and will be comfortable to see names of arguments.

What we have - first level is as third level, but without optional elements.
Second level - sugar for more readable composition of low-level, senseless objects.

from eo.

astynax avatar astynax commented on August 16, 2024

Hello! May I bring some SmallTalk here? Take a look:

expr ifTrue: [statements to evaluate if expr] ifFalse: [statements to evaluate if not expr]

In the SmallTalk "if statement" is just a method (message) of some boolean expression, and ifTrue/ifFalse is just a named arguments of method if.

A smalltalk'ish version of fibonacci example will look like this:

create fibonacci(1) as Number:
  Number n
  bytes asBytes():
    lessThan: @n, 2
      ifTrue: 1
      ifFalse:
        plus:
          @n
          fibonacci:
            minus: @n, 1

And this example is even closer to FP: it looks just like a Church encoding of booleans:

true = (x, y) -> x
false = (x, y) -> y
if = (expr, then, else) -> expr(then, else)

if(lessThan(1, 2), "less", "greater") --> "less"

The main benefit of if as a method is type safety - if will be available only for "boolean" objects.

from eo.

yegor256 avatar yegor256 commented on August 16, 2024

@gukoff take a look at our new syntax, I believe you will like it

from eo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.