1. Routine

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.

new topic     » topic index » view message » categorize

2. Re: Routine

irv said...

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

new topic     » goto parent     » topic index » view message » categorize

3. Re: Routine

Hi

Whoa - ignore returns from functions Chris

new topic     » goto parent     » topic index » view message » categorize

4. Re: Routine

(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

new topic     » goto parent     » topic index » view message » categorize

5. Re: Routine

ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

6. Re: Routine

ChrisB said...

(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!

new topic     » goto parent     » topic index » view message » categorize

7. Re: Routine

jeremy said...
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?

new topic     » goto parent     » topic index » view message » categorize

8. Re: Routine

jimcbrown said...

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!

new topic     » goto parent     » topic index » view message » categorize

9. Re: Routine

euphoric said...

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

new topic     » goto parent     » topic index » view message » categorize

10. Re: Routine

jeremy said...
euphoric said...

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!

new topic     » goto parent     » topic index » view message » categorize

11. Re: Routine

euphoric said...
jeremy said...
euphoric said...

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

new topic     » goto parent     » topic index » view message » categorize

12. Re: Routine

ChrisB said...

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.

new topic     » goto parent     » topic index » view message » categorize

13. Re: Routine

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

new topic     » goto parent     » topic index » view message » categorize

14. Re: Routine

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
new topic     » goto parent     » topic index » view message » categorize

15. Re: Routine

ChrisB said...

An exit from a procedure would also be nice. (exit_proc ??)

Chris

It's called return (alone - without return value).

jiri

new topic     » goto parent     » topic index » view message » categorize

16. Re: Routine

jiri said...
ChrisB said...

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

new topic     » goto parent     » topic index » view message » categorize

17. Re: Routine

Always.

jiri

new topic     » goto parent     » topic index » view message » categorize

18. Re: Routine

Groan

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu