syntax idea: simplifed ifs
Deewiant
deewiant.doesnotlike.spam at gmail.com
Tue Apr 11 10:44:19 PDT 2006
Charles wrote:
> dennis luehring wrote:
>> for example how often do we use constructs like
>>
>> if( x == 10 && x == 20 && x == 30 )
>>
>> simplified:
>> if( x == [10 && 20 && 30] )
>>
>> if( a >= h && b >= h && c >= h )
>>
>> simplified:
>> if( [a && b && c] >= h )
>>
>> (just an idea)
>>
>> ciao dennis
>
> I've often wanted this, gets my vote, if you cound find a syntax that
> keeps it context free.
How about just curly brackets? For instance:
if (x == {10 && 20 && 30})
There's no way "10 && 20 && 30" could be allowed by itself surrounded by curly
brackets anywhere else; in a function definition or the like it would need at
least a semicolon following, and since a while ago effectless expressions were
banned it wouldn't be allowed even then.
Although I must say I prefer BCS's suggestion, earlier. I think it also obviates
some people's wishes that "x in array" should work for non-associative arrays,
meaning "array contains x". According to BCS's ideas one could simply use "x ==
array".
More information about the Digitalmars-d
mailing list