property syntax strawman
Michel Fortin
michel.fortin at michelf.com
Sun Aug 2 17:53:35 PDT 2009
On 2009-08-02 20:18:51 -0400, "Robert Jacques" <sandford at jhu.edu> said:
> I also like the idea of omitting parenthesis for functions with no argument.
I like it too. But the problem with the current approach D are:
1. A syntax that permits function to be called both without and with
empty parenthesis creates ambiguities when it returns a callable type
(a delegate or an object with an opCall member).
2. We want properties to be nouns, and actions to be verbs. In english
a lot of words are both nouns and verbs, which makes it impractical to
distinguish a property from a function by its name alone.
Solving 1 involves having a way to say functions that can and must be
called without parenthesis. Unless we want to force all functions with
no parameter to be called without "()", we must have some kind of flag
to tell us that a function expects or does not expect "()".
Solving 2 involves making a difference in the call syntax between
property and action functions. Since the idea behind a property is to
mimic a field, it follows that the best differentiator for properties
is the lack of parenthesis.
I'd be glad too if we could continue to skip parenthesis for calls to
functions with no arguments, but I think fixing the two problems above
is more important.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list