Revised RFC on range design for D2

Fawzi Mohamed fmohamed at mac.com
Thu Oct 2 11:16:07 PDT 2008


Here comes another person that would be unhappy without omittable parenthesis.

Having properties is a very useful thing, one should be able to make a 
public field of a structure private and controlling access via methods 
with minimal or no changes to the external code.

This is a very nice feature to have.
D reaches this with a minimal change to the language:
optional parenthesis, and setter functions.

It might take a little to get used coming from other languages, but it 
works well.

It does have some limitation (no +=,-=,...) but is very compact, and 
simple to explain.

I like it very much.

Removing it would be very bad.
The other option is to replace it with a full fledged property mechanism.
This might overcome some of the limitations of the current approach, 
but would it be economical?
A language should not be perfect in all things, compactness is also an 
advantage.

Fawzi

On 2008-10-02 19:26:55 +0200, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> Bruno Medeiros wrote:
>> 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).
> 
> So there is a cabal. I knew it! :o)
> 
> I'm not that sure about "lot" and "one", and numbers-based arguments 
> aren't that strong to begin with. Language design is complex and full 
> of tradeoffs. In each decision there are consequences. If we require 
> "()" then we must come with a separate thing for properties - an 
> addition to the language. Then many people (maybe even including some 
> the "lot" of people you mentioned) will cry foul: "where's my simple 
> language?" etc. Maybe some people will say, hey, you were already there 
> with the omittable "()" and the "=" thing, why didn't you just make the 
> latter less trigger happy and we'd be home free?
> 
> One thing that often is a casualty of these discussion is keeping the 
> eye on the big picture.
> 
> Andrei




More information about the Digitalmars-d-announce mailing list