Revised RFC on range design for D2 (lazy)
Fawzi Mohamed
fmohamed at mac.com
Fri Oct 3 03:37:24 PDT 2008
On 2008-10-03 12:05:17 +0200, Bruno Medeiros
<brunodomedeiros+spam at com.gmail> said:
> Andrei Alexandrescu wrote:
>> Sean Kelly wrote:
>>> == Quote from Andrei Alexandrescu (SeeWebsiteForEmail at erdani.org)'s article
>>>> Bruno Medeiros wrote:
>>>>> I don't understand that. You stated "It violates economy of syntax.", so
>>>>> it violates your Principle 1 of language design. So how can you be
>>>>> happy with that (apart from the assignment issue)? Does fixing this
>>>>> problem violate some other principle or concern of yours?
>>>> I think keeping the language simple is also a good goal.
>>>
>>> I apologize if this has been brought up before, but I'm not sure that
>>> simplicity
>>> is a good thing if it can result in unpredictable behavior. For example:
>>>
>>> import std.stdio;
>>>
>>> class C
>>> {
>>> this( bool delegate() p )
>>> {
>>> version( a )
>>> cond = p;
>>> version( b )
>>> ptr = p;
>>> }
>>> version( a )
>>> {
>>> bool delegate() cond;
>>> }
>>> version( b )
>>> {
>>> bool delegate() ptr;
>>> bool delegate() cond() { return ptr; }
>>> }
>>> }
>>>
>>> void main()
>>> {
>>> bool test() { writefln( "hi" ); return false; }
>>> auto c = new C( &test );
>>> if( c.cond() )
>>> writefln( "true" );
>>> }
>>>
>>> Running version=a prints "hi" while version=b prints "true." If there were
>>> some way in the language to say "cond() is a property" then this issue would
>>> not be silently introduced when changing cond from a variable to a method.
>>
>> Oh how I am with you on this. I've always thought mentioning a delegate
>> name should NOT EVER evaluate the delegate. Walter definitely took the
>> wrong turn down that alley there. And guess what. He got ambushed by
>> the "lazy" keyword right there. I told Walter to not do that "lazy"
>> keyword, he disregarded, but the time will come when that stone will be
>> turned.
>>
>>
>> Andrei
>
> Hold it right there! Are you saying that the existence of 'lazy'
> somehow required, or helped justify the existence of the omittable
> parenthesis functionality? How is that?
> I think you are accusing innocents ('lazy') or wrongdoing. 'lazy' has
> nothing to do with the omittable parenthesis functionality, I think
> they are completely orthogonal. Prove me wrong otherwise.
I think that he meant that lazy automatically evaluates a delegate, and
that he thinks it is wrong.
He said it because he thought that the problem shown by Sean was
connected with automatically evaluating a delegate, which it is not,
but let's not start another sub-thread...
Fawzi
More information about the Digitalmars-d-announce
mailing list