new DIP5: Properties 2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 28 16:43:04 PDT 2009
Chad J wrote:
> Andrei Alexandrescu wrote:
>> My perception is that there are a few vocal people. The protests have
>> been historically against the stupid "writeln = 42" which we must get
>> rid of.
>>
>
> Seems odd to me. I thought the unpopular bit was the lack of
> lvalue-ness and how "array.length++;" did not work. No idiot would
> write "writefln = 42;" in serious code. It's easy to avoid since you
> have be rather intentional about it.
Oh, yes. That needs fixing too!
>> I have a dream.
>>
>
> I feel like ranting ;)
>
>> * Parameterless functions still can be called without "()". People will
>> realize that it's a prejudice to believe that this impedes code
>> understanding, and their eyes and wrists will thank them.
>>
>
> Earlier I was thinking yeah ok w/e that's fine. Now I'm thinking these
> are just evil. But only when the function returns a value-type. void
> functions are alright. Ref returns may or may not be alright.
>
> It's not because of "writefln = 42;".
>
> It's because of this:
>
> // Library code
> struct Rectangle
> {
> float x,y,w,h;
> // etc blah blah
> }
>
> class Widget
> {
> Rectangle _rect; // eww no optional backing storage
> Rectangle rect() { return _rect; }
> //...
> }
>
> // User code (probably test code in this case...)
> auto widget = new Widget(...);
> widget.rect.w = 200;
> widget.rect.h = 100;
>
> // End
> A few hours later this poor library developer takes a break from the
> debugger and writes a small experiment. The conclusion is
> "AARRGGGHHH!". He runs to the news group to bitch and moan, and someone
> responds, "yeesh use ref return and RTFM already". Bad day.
This serious problem has already been mentioned once. Incidentally I
think it was Steve who mentioned it. It is big and relates to the fact
that you could call member functions against rvalues. Could you please
add it to bugzilla?
> This is only the example that pops to mind. I am sure there are cases
> where the library writer may intentionally NOT ref return, and the user
> will miss this and get bitten. When the library writer and user are the
> same, things only goes downhill.
>
>> * The syntax "foo = bar" is rewritten into "foo(bar)" IF AND ONLY IF the
>> expression "auto __x = foo, __x = bar" is compilable.
>>
>
> I seem to know exactly what you said with great mathematical precision
> and certainty. I have no idea what this actually DOES though :/
>
> (In another post you mentioned this being a guarantee of a getter, but
> there seems to be more to it, such as type equality between foo and bar.)
>
>> * The non-uniformity regarding parameterless functions returning
>> parameterless functions is acknowledged but considered minor.
>>
>
> O.O
>
> R-R-Really?!
>
> So you're just going to give up?
Well that kind of sucks. I agree.
Andrei
More information about the Digitalmars-d
mailing list