Re: New Euphoria features
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 24, 2005
- 466 views
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. See below: >> > #2; >> > 100% object oriented? :D If you want OO, use Java/C++ ) 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.
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 ) ...
which I think is a darn sight better than:
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] )
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