Re: New Euphoria features
- Posted by ZNorQ <znorq at holhaug.com> Feb 24, 2005
- 460 views
Pete Lomax wrote: > > ZNorQ wrote: > >> > > >> > IF I'm so lucky, I would wish for the following features; > >> > > >> > #1; > >> > Select Case > >> > Case .. or .. > >> > Case Else > >> > end Select > >> > > >> > I hate having to use IF / ELSIF in this case. > Sorry, but that is a truly AWFUL way to ask for change. You give > absolutely no reason /why/ it would be better. Note that this must not > be about personal preference, it must be a genuine gain, for all. Hey, did I step on your toes here? I'm not asking for any changes, the subject was brougth up, I answered what additions I'd like to see in Euphoria (I kinda take back the OOP preference - like Eu programming style the way it is). And why shouldn't I mention this as my personal preference? I can't speak for the whole community what they want! Anyone is welcome to agree or disagree as much as they whan, and yes - I think it IS a genuine gain - for all. I'm sorry I didn't give my reason why it would be better with the inclusion of "Select Case", so here it is (remember, my English is poor, and so is my programming knowlege. I do not know all the technical words/jargons, but I hope you understand.) 'Select case' is a good way to checking the content of a SINGLE variable's (of any type) content without having to restate the whole expression each time. Especially if there is a lot to consider. It's clean, and gives you a good overview. By using IF / ELSIF you have to retype the expression - or - using alot's of 'OR' statements. PS! We still need IF / ELSIF! :D > See below: > > >> > #2; > >> > 100% object oriented? :D > If you want OO, use Java/C++ ) > Yes, I totally agree with you on this one - I do take this one back! :D > CChris wrote: > > >Pointers are supposed to be unsafe, hard to debug etc. I don't fully agree > >with that view. > >However, some solution to the problem you state is needed. Creating aliases > >for things, like in: > > > >ref current_task running_tasks[priority][task_id][TASK_NAME] > >--do some stuff, using "current_task" as a macro > I agree wholeheartedly, thought I would prefer alias, and further that > it is only available inside routines, since I think it adds complexity > if not defined locally. > > }}} <eucode> > alias rt to running_tasks[priority][task_id][TASK_NAME] > alias st to sleeping_tasks[priority][task_id][TASK_NAME] > > if equal( rt, task_to_kill ) then > rt = kill_task( rt ) > elsif equal( st, task_to_kill ) then > st = kill_task( st ) > ... > </eucode> {{{ > > which I think is a darn sight better than: > > }}} <eucode> > if equal( running_tasks[priority][task_id][TASK_NAME], > task_to_kill ) then > running_tasks[priority][task_id][TASK_NAME] = kill_task( > running_tasks[priority][task_id][TASK_NAME] ) > elsif equal( sleeping_tasks[priority][task_id][TASK_NAME], > task_to_kill ) then > sleeping_tasks[priority][task_id][TASK_NAME] = kill_task( > sleeping_tasks[priority][task_id][TASK_NAME] ) > </eucode> {{{ > > Note that an alias is not "efficient", for that you probably need > local var(s), (I couldn't see a way with the above to improve matters > anyway, given refcount issues). It performs all the work that the > longhand version does, unless someone has a bright idea. > > Though as I've said before, the only way you'll get anywhere with this > is to implement it in the open source eu.ex, sorry. > > Regards, > Pete > >