Ouch: return values as lvalue

Lionello Lunesu lio at lunesu.remove.com
Tue Jan 30 23:53:30 PST 2007


Hasan Aljudy wrote:
> 
> 
> Andrei Alexandrescu (See Website For Email) wrote:
>> Joel C. Salomon wrote:
>>> Andrei Alexandrescu (See Website For Email) wrote:
>>>> Joel C. Salomon wrote:
>>>>> Andrei Alexandrescu (See Website For Email) wrote:
>>>>>> It's a long discussion. I agree that non-templated code without 
>>>>>> effect should issue a compile-time error (not warning) _____as 
>>>>>> long as under no change of type definitions etc., the code could 
>>>>>> make sense_____.
>>>>>
>>>>> while(func() == 0)
>>>>>     ;
>>>>>
>>>>> — or do you only mean that extremely short-lived (effect-less) 
>>>>> /assignments/ should be errors?
>>>>
>>>> Code in general. Consider:
>>>>
>>>> 1 + 1 == 2;
>>>>
>>>> The code above isn't an error but it also doesn't do anything. It 
>>>> should be flagged as an error.
>>>>
>>>> The empty statement in your example is not "code" the way I meant it 
>>>> above.
>>>
>>> And the lack of a preprocessor means statements like that are 
>>> unlikely to happen “by accident”.  (I’m afraid I’m still thinking in 
>>> C.)  Unless this is the sort of thing a code generator might write.
>>
>> Which is exactly what templates do. But, as I show in another post, 
>> all you really need is an alias.
>>
>> Andrei
> 
> so a template *could* theoretically generate code like that for some input.
> Then .. if the compiler issued an error for it .. don't you think the 
> situation would be "the compiler is getting in your way"?

Yes, that's probably why Walter is opposed to warnings. See his post.

L.



More information about the Digitalmars-d mailing list