Revised RFC on range design for D2

Bruno Medeiros brunodomedeiros+spam at com.gmail
Thu Oct 2 05:33:34 PDT 2008


Andrei Alexandrescu wrote:
> 
> I _believe_ a language should obey the principles 1 and 2 (economy of 
> syntax and giving syntactic priority to frequent use cases). Based on 
> that belief, I _think_ D should drop the trailing parens.
> 
> I agree that somebody could _believe_ in some other principles that 
> replace or override mine and then _think_ that keeping trailing parens 
> is a good thing. Sergey did just that by showing us some very good 
> examples when absence of trailing parens leads to ambiguity. Then there 
> is room for meaningful discussion.
> 
> It is also possible that somebody simply _believes_ the trailing parens 
> should be kept because they make code clearer to them. That's fair too, 
> as long as there is understanding that that belief comes to a certain 
> extent at odds with principles 1 and 2 (which anyone is free to simply 
> not believe).
> 
> The only place that needs work is when the connection between belief and 
> thought is unclear, or when the belief is simply wrong.
> 
> 
> Andrei

Good post.


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.


Anyways, I also agree with principles 1 and 2. But I also agree with 
some other principles that sometimes conflict with those first ones 
(which is what is happening here). And in each such scenario I would 
have to weight in to see which principle I would give priority.

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)

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.


-- 
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