syntax idea: simplifed ifs
James Dunne
james.jdunne at gmail.com
Tue Apr 11 19:45:55 PDT 2006
Deewiant wrote:
> 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".
Not context-free.
'{' begins a statement. Having '{' also begin an expression would cause
problems due to expression-statements.
--
Regards,
James Dunne
More information about the Digitalmars-d
mailing list