Hi,
Parens-free call expression allow to provide some actions
/decoratively/. From this, the consequence of easy and elegant DSLs
(domain specific languages). For example:
class Account {
attributes "customer", "cart"
}
Thus, call to `attribute` function looks like not the imperative call,
but like a declaration that instances of Account class has those attributes.
Ruby uses exactly this approach of its attr_accessor, private, etc.
"keywords" which in fact are just functions placed on the very basic class:
class Foo
attr_accessor :x, :y
end
foo = Foo.new
foo.x = 10
foo.y = 20
which in fact is just a syntactic sugar (not at grammar, but at
application level via simple `attr_accessor` function) for the:
class Foo
def x
end
def x=(value)
end
def y
end
def y=(value)
end
end
That is, create getter and setter for every needed property (yes, in
Ruby all public properties are accessors). Thus, this function does it
behind the scene: attr_accessor(:x, :y), however being called /without/
parens, it elegantly looks like a declarative keyword. Another example
as is said, `private` function which also without parens looks like an
operator.
Besides, If -> will be accepted, in many cases (being passed as
callback) they will much more elegantly look without parens of call
expressions.
So what do you think? If the idea is good, may it bring some problems
with parsers and grammar?
P.S.: some examples of declarative DSLs:
https://github.com/jashkenas/coffee-script/wiki/%5BExtensibility%5D-Writing-DSLs
Dmitry.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss