haasn / -g-pl

/g/ programming language
13 stars 2 forks source link

Easier conditional? #18

Open haasn opened 12 years ago

haasn commented 12 years ago

Writing a full blown TIER list for a simple comparison is often a bit tedious, especially due to the 100% accurate terminator needed all over the place.

Should we introduce an alternate, shorter form of conditionals, eg. for one-liners?

graydude commented 12 years ago

If I'm not mistaken, a simple if could be written like this right?

foo > 5 TIER: 
    >mfw whatever;
100% accurate

Looking at parsing.txt, we could write this as:

foo > 5 TIER: >mfw whatever; 100% accurate

I don't really see the need to make this shorter. If you still think so, one option would be to distinguish between

tier list = tier , { tier } , newline ,  "100% accurate" ;
and
compact tier = limited expression , "TIER:" , full expression ;
compact tier list =  compact tier, newline  ;

So we can write:

foo > 5 TIER: >mfw whatever;
haasn commented 12 years ago

The compact tier idea wouldn't work, since it's ambiguous between

foo > 5 TIER: >mfw whatever;
foo < 4 TIER: >mfw whatever;

as two compact lists or a single full list, during parsing.

You're probably right, I'm just annoyed about the huge 100% accurate block. Maybe a short form that's just a %? Or would that be too obscure / golfish?

graydude commented 12 years ago

Ah yeah, I forgot about that. Parsing it as a single full list means that the second TIER can never be executed, as two compact lists means that it can be executed.