PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
new eScript operator

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions
Display posts from previous:   

Author Message
phao



Joined: 31 Aug 2007
Posts: 33

PostPosted: Mon Oct 08, 2007 1:36 pm    Post subject: new eScript operator Reply with quote

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 Smile heheheh (just kidding)

Author Message
Yukiko



Joined: 02 Feb 2006
Posts: 1080
Location: Southern Central USA

PostPosted: Wed Oct 10, 2007 12:54 am    Post subject: Reply with quote

I can understand why this might be a nice addition to eScript. It does seem to be a time-saver for entering code.

I have a couple objections to implementing this. One is readability of code. Currently if statements are easily found and recognized. Using symbols rather than pseudo-linguistic statements reduces the readability factor.

My second objection is that the more you add cryptic constructs to a language the harder it is to learn, especially for people who have little or no previous programming experience. Many of us were blessed with some prior knowledge of programming when we came to POL but a lot were not and I think this might make it a little harder for those folks to learn eScript.

Ofcourse I am assuming that the POL developers want eScript to be easily learned by people.

Post new topic   Reply to topic    PenUltima Online Forum Index -> Feature Suggestions All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty