Comments (7)
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.
@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.
the fact that, in the new idea,
if:
is an object andthen:
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.
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.
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.
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.
@gukoff take a look at our new syntax, I believe you will like it
from eo.
Related Issues (20)
- BytesOf.java:34-38: This class requires refactoring. As a... HOT 4
- Data.java:196-199: This method should be refactored... HOT 2
- Can we use some static analysis like Sonar in CI on PR? HOT 1
- Failed build: daily HOT 10
- Add `+rt node` meta to work with js compiler HOT 1
- merge smaller libs into this repo HOT 7
- Printing PHI Expressions Extremely Slow HOT 4
- list.eo:208-211: The object does not work. After moving... HOT 2
- PhPackage need update HOT 2
- BytesRaw.java:33-36: Method {@link BytesOf#shift} should... HOT 2
- align-test-classes.xsl:27-28: Add link to corresponding... HOT 2
- remove-high-level-inner-classes.xsl:27-28: Create... HOT 14
- map.eo:105-112: Find a way to link hash code and index of... HOT 2
- text.eo:313-315: Implement text.replaced object. This... HOT 3
- Replace `int` and `float` with `number` HOT 1
- `eo-maven-plugin` allows attributes without names in an abstract object HOT 10
- Dataized.java:54-57: It is necessary to call {@link... HOT 2
- Dataized.java:64-67: It is necessary to call {@link... HOT 2
- PhDefault.java:65-68: It is necessary to call {@link... HOT 2
- PhTraced.java:50-53: It is necessary to call {@link... HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from eo.