phao
Joined: 31 Aug 2007 Posts: 33
|
Posted: Mon Oct 08, 2007 1:36 pm Post subject: new eScript operator |
|
|
well, i dont know if i'm in the right section, because this would be an Ecompile feature suggestion, if there is a better place for this post, let me know.
I think it'd be nice if I could use ? : operator in eScript, i think this operator will save a lot of lines of code and if/else lines.
It isnt hard write if/else lines, but when you do this everytime, you think that it could be good to have something to 'compress it'.
For who doesnt know ? : operator, i'll explain:
| Code: |
return (1 == 2 ? "hi, 1 is equal to 2" : "no no no");
|
it'll see if 1 is equal to 2 if yes it'll return the thing after the ?, if no it'll return the thing after :
so something like this
| Code: |
user := there is a user flag? 1: 0;
|
instead of doing
| Code: |
if there is a user flag
user equal to 1
else
user equal to 0
endif
|
yeah, i know a lot of people will say it's useless, but save a lot of boring lines of code.
this feature is used in languages like C, C++, JavaScript, and others, and it comes from functional programming, if you have programmed in Scheme or Common Lisp you've seen something like (if (pred) (true action) (false action)) and, IMO, it's a lot practical, for me eScript could be 100% functional programming heheheh (just kidding) |
|