1. Euphoria question routine_id

I have a problem that I can not find a solution to. 
I have a rotine that receives a parameter as a number. 
I need to know if it is a just a low number or if it is a 
routine_id. 
If the call_back() returned a -1 instead of reporting an error 
when it contained a bad routine_id that would be fine. 
 
It seems that this is a inconsistency why shouldn't 
call_back() do the same as routine_id() ? 

new topic     » topic index » view message » categorize

2. Re: Euphoria question routine_id

In my BBCMF code, I've standardized on a function return sequence that provides a success boolean and the result. For instance:

function sample_func(sequence s)
  if length(s) > 25 then 
     return {1,s[1..25]} -- success 
  else 
     return {0,""}       -- fail 
  end if 
end function 

This is similar to how value() behaves. I did this to remove the ambiguities (that Bernie just posted about) because I use a lot of routine_id() and call_func/proc().

YMMV

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

3. Re: Euphoria question routine_id

bernie said...

I have a problem that I can not find a solution to. I have a rotine that receives a parameter as a number. I need to know if it is a just a low number or if it is a routine_id.

If the call_back() returned a -1 instead of reporting an error when it contained a bad routine_id that would be fine.

It seems that this is a inconsistency why shouldn't call_back() do the same as routine_id() ?

There is no inherent way to determine this. A routine id is just a number. Even if it's a valid routine id, does not mean that the code that is using the number means for it to be a routine id. The only way, it seems is to pass some additional metadata to indicate that it's meant to be a routine id.

I'd actually say that a call back should be zero if it's invalid, since it's really a pointer, and the null pointer is a pretty well known thing. But that's a good idea.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu