PenUltima Online

It is currently Sat Sep 06, 2008 10:34 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: new eScript operator
PostPosted: Mon Oct 08, 2007 9:36 am 
Offline

Joined: Fri Aug 31, 2007 2:25 pm
Posts: 58
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)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Oct 09, 2007 8:54 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1127
Location: Southern Central USA
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.

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl