1. Routine
- Posted by irv Apr 09, 2009
- 902 views
OK, I svn'd the latest version, and installed Euphoria Interpreter 4.0.0 development (r1880) for Linux from eubins.
My GTK library uses a variable named 'routine'.
That now gives an error. Easily fixed.
But what does 'routine' now do?
Searching the docs is hopeless here, routine is far too common a word.
Thanks.
2. Re: Routine
- Posted by jeremy (admin) Apr 09, 2009
- 942 views
OK, I svn'd the latest version, and installed Euphoria Interpreter 4.0.0 development (r1880) for Linux from eubins.
My GTK library uses a variable named 'routine'.
That now gives an error. Easily fixed.
But what does 'routine' now do?
Searching the docs is hopeless here, routine is far too common a word.
It was made a reserved word for possible future use for creating a general routine that could be either a procedure or function determined simply if a return statement exists. The fact that we can now ignore return value makes the distinction between procedure and function simply it's name. public routine abc() return 10 end routine was discussed for about 5 minutes before we decided that we have bigger things to deal with, we tabled the whole discussion for later. No one knows if it will happen or not, but we are trying to get all major breaking issues out of the way with 4.0, so it was reserved but is not used.
Jeremy
3. Re: Routine
- Posted by ChrisB (moderator) Apr 09, 2009
- 917 views
Hi
Whoa - ignore returns from functions Chris
4. Re: Routine
- Posted by ChrisB (moderator) Apr 09, 2009
- 882 views
(Dropped some of the post)
When did this happen. It will make life quite a bit easier, but are there performance hits, or any other hidden lurking problems????
Chris
5. Re: Routine
- Posted by jeremy (admin) Apr 09, 2009
- 915 views
Whoa - ignore returns from functions!? When did this happen. It will make life much easier. Is there a speed difference, are there any consequences? Tell me. Now.
Chris,
There is no speed difference, yet. There may be. Once beta hits, Matt will be moving to optimisations. It's possible that we can omit the return value and save something there, however, I wouldn't expect it to be much.
I am not sure exactly when it happened, but it was some time ago. This is now valid code:
function times2(integer a) return a * 2 end function times2(10)
There would not be much point to that, but, it is possible.
Now, when you say it will make life much easier... That's debated. In almost all reasons a function is a function for a reason. For instance, I fear (I know) we will start seeing code like this:
create_directory("john_doe") fh = open("john_doe/hello.txt", "w")
Ug! This avoids handling the error. Now, there are valid times when you can safely ignore a functions result, but in general it's a bad practice.
Jeremy
6. Re: Routine
- Posted by jimcbrown (admin) Apr 09, 2009
- 892 views
(Dropped some of the post)
When did this happen. It will make life quite a bit easier, but are there performance hits, or any other hidden lurking problems????
Chris
I always envisioned, a method called get_routine_id_is_func_or_not() method. So I could then write code like this:
integer r_id = routine_id("r")
....
integer r_is_a_func = get_routine_id_is_func_or_not()
if r_is_a_func then ret = call_func(r_id, {}) else call_proc(r_id, {}) end if
Additionally, maybe a get_number_of_parameters_and_their_types_from_routine_id() as well!
7. Re: Routine
- Posted by euphoric (admin) Apr 09, 2009
- 917 views
create_directory("john_doe") fh = open("john_doe/hello.txt", "w")
Ug! This avoids handling the error. Now, there are valid times when you can safely ignore a functions result, but in general it's a bad practice.
It's probably not worth the time and effort to code it. Maybe I've forgotten something I once knew about it... Is there a pros/cons list?
8. Re: Routine
- Posted by euphoric (admin) Apr 09, 2009
- 879 views
I always envisioned, a method called get_routine_id_is_func_or_not() method... Additionally, maybe a get_number_of_parameters_and_their_types_from_routine_id() as well!
This should go in feature requests. COME ON!
9. Re: Routine
- Posted by jeremy (admin) Apr 09, 2009
- 852 views
It's probably not worth the time and effort to code it. Maybe I've forgotten something I once knew about it... Is there a pros/cons list?
Code what? Pros/Cons for what?
Jeremy
10. Re: Routine
- Posted by euphoric (admin) Apr 09, 2009
- 863 views
It's probably not worth the time and effort to code it. Maybe I've forgotten something I once knew about it... Is there a pros/cons list?
Code what? Pros/Cons for what?
Ignoring function return values. COME ON!
11. Re: Routine
- Posted by jeremy (admin) Apr 09, 2009
- 886 views
It's probably not worth the time and effort to code it. Maybe I've forgotten something I once knew about it... Is there a pros/cons list?
Code what? Pros/Cons for what?
Ignoring function return values. COME ON!
Um, probably not worth the time and effort to code it? I'm confused. It's been done long ago and was very easy. A pros and cons? The pro is you don't have to use function values you don't want and the cons are most function values you should be paying attention to, if you don't use them it 98% of the time it means one of a few things... you don't know what you're doing, you don't care if the function err's and your application crashes or finally you don't care if the function fails, such as closing a database connection after your application failed at some point. The other 2% of the time you may have a valid reason for ignoring it.
Jeremy
12. Re: Routine
- Posted by DerekParnell (admin) Apr 09, 2009
- 853 views
Hi
Whoa - ignore returns from functions!!!??? When did this happen. It will make life much easier. Is there a speed difference, are there any consequences??? Tell me. Now.
Chris
It is experiemental at this stage, that is why it wasn't announced. There are some issues that still need investigating. It might not be in the final 4.0 either, so don't get too excited or annoyed.
13. Re: Routine
- Posted by ChrisB (moderator) Apr 10, 2009
- 818 views
Hi
I tend to use
function bl(integer blah) --some stuff return 0 --otherwise some other stuff return 0 end function global object VOID VOID = bl(whatever)
and use this this wherever I need a function or procedure - just make exiting the function easier (perhaps I shouldn't do this, but its a habit)
An exit from a procedure would also be nice. (exit_proc ??)
Chris
14. Re: Routine
- Posted by ChrisB (moderator) Apr 10, 2009
- 904 views
And something new I just discovered the other day, and thought wow
function blah() return 1 or 0 or whatever end if if blah then end if Chris
15. Re: Routine
- Posted by jiri Apr 10, 2009
- 853 views
An exit from a procedure would also be nice. (exit_proc ??)
Chris
It's called return (alone - without return value).
jiri
16. Re: Routine
- Posted by ChrisB (moderator) Apr 10, 2009
- 814 views
An exit from a procedure would also be nice. (exit_proc ??)
Chris
It's called return (alone - without return value).
jiri
Hi
What, has euphoria always been able to do this, or is this another new feature?
Chris