2 ms·
I'm glad that you found the syntax reasonable as a whole. :D Regarding to functions and atoms, their syntax choices are a trade-off. If I have "(x, y) -> x + y"
by josevalim 16y ago
I'm glad that you found the syntax reasonable as a whole. :D Regarding to functions and atoms, their syntax choices are a trade-off. If I have "(x, y) -> x + y" for functions, I need explicit parens when invoking a method (otherwise we will have ambiguity), so I prefer to have this flexibility on method invocations. A similar choice happened to atoms. As I preferred to save ":" for dicts, as in { x: y }, the syntax would get very confusing if I allowed: { :x: :y }. That said, I have chosen 'atom, which is common in some Lisp dialects.
- Ezku 16y agoHaving now read the entirety of the readme, I'm left a bit unclear on the object model's semantics. If I declare a mixin in an object, those become class methods? Whereas declaring a prototype results in instance methods? Also, "set_ivar" seems like a needlessly complex and obscure statement.
- josevalim 16y ago1) About mixins and prototypes, exactly. 2) Yes, adding a syntax to easily change instance variable values is one of the most asked features. The tricky part is, we cannot do the following: @foo = "bar" Because that is pattern matching and in Erlang/Elixir, we cannot modify objects in place. The expression above needs to return a new object. I was thinking about something like @{'foo : "bar"}, but I haven't decided yet. Suggestions are welcome. :D