Revised RFC on range design for D2
Bruno Medeiros
brunodomedeiros+spam at com.gmail
Thu Oct 2 09:23:22 PDT 2008
Andrei Alexandrescu wrote:
> Bruno Medeiros wrote:
>> Sergey's argument (which is much more objective than subjective) is
>> not strictly against omitting parenthesis, but rather against
>> ambiguity (the dual possible ways to call zero-args functions), which
>> as has been shown, creates various possibilities for bugs when you mix
>> functions that return delegates. This ambiguity problem would also be
>> resolved if omitting parenthesis would be *the only way* of calling
>> functions with zero-args.
>
> Yah, he made great points. There are ambiguities. The counter-argument
> is that that would make the syntax of calling functions with no
> arguments inconsistent with the syntax of calling function with
> arguments. The "()" is a degenerate case of "(a, b, c)". So it's hard to
> keep everybody happy.
>
Yes, if we solved the ambiguity problem that way, we would make a lot of
people unhappy (myself included). But if we solved the problem the
*other way* (forbidding omittable parenthesis for normal zero-args
function), it would make, that I know of, only one person unhappy (you).
Note that this would not preclude that we implement another way to have
properties (see below).
>
>> These other principles are:
>>
>> 3 - Consistency of syntax - The same language feature should use the
>> same syntax, with as little variations as possible.
> >
>> This principle fails here because when you have functions with
>> parameters you have to use parenthesis, and only when you don't have
>> arguments you omit the parenthesis. But the zero-args case should not
>> be different from the n-args case. Of course, this could be solved by
>> having a syntax for the n-args case that also doesn't use parenthesis
>> (see my OP after Benji's thread)
>
> Great. Yes, that is consistency. I swear that all I wrote above was
> before I saw this :o).
>
Good, at least we agree on that after all.
>> But most importantly:
>> 4 - Common ground with other programming languages. There are several
>> things that are common with many, if not all, of the mainstream
>> programming languages (Java, C#, C/C++, Ruby, Python, etc.).
>> One of them is using parenthesis for calling functions! (See KennyTM's
>> post with the table describing function calling for several
>> languages.) Using parenthesis comes from math. And of that list, only
>> VB 6, Pascal and Perl, have the possibility of omitting parenthesis.
>> And frankly, VB6 and Pascal don't matter since they are pretty much
>> obsolete. And Perl is language with a hack-ish nature, IMO. Even Lisp
>> uses parenthesis for function calling! (even if in a different
>> position, and even if it's pretty much the only syntax it has).
>> This is a subjective principle, I can't tell you to want to like
>> having common ground with other languages, but c'mon... "writeln;"?
>> Seriously?? That's just hideous.
>
> I agree that 4 is a good principle. I'd even call it "consistency" -
> across languages that is. But let's not forget that C# defined an entire
> feature - properties - to fulfill what was perceived as a need. Also the
> Cecil language goes as far as requiring accessors for any field (and
> defining methods implicitly when missing). Eiffel also has properties
> that are obtained via syntactic conventions (getX and setX implement
> property x). People want to add properties to Java 7 (unfortunately the
> google search is clogged by a Java class called Properties so it needs
> some combing).
>
Yes, I was going to call it "consistency with other programming
languages", but renamed it so as to avoid confusion.
Anyways, we're not saying a properties feature is not useful. We're not
saying to just remove the implicit property function call and be done
with that. The suggestion is to *replace* the implicit property function
call with some other way for implementing properties, so that we don't
have the disadvantages of the implicit property function call.
> Eiffel also has properties
> that are obtained via syntactic conventions (getX and setX implement
> property x)
Hum, interesting, I just replied in another part of the thread with a
suggestion that is just like that (and didn't know about it).
--
Bruno Medeiros - Software Developer, MSc. in CS/E graduate
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
More information about the Digitalmars-d-announce
mailing list