Re: Checking if routine id is of a procedure or a of function?

new topic     » goto parent     » topic index » view thread      » older message » newer message

David Guy wrote:

> There does not seem to be a way to check if a routine id (obtained via
> routine_id()) represents a procedure or a function.
>
> I'm thinking of using callbacks to notify a running program of certain
> events. The program would pass in a routine id, and the routine would be
> called when the event occures. Some events need a function (return value
> required), some only need a procedure. I would like to be able to check that
> the correct type of routine has been provided (as opposed to just requiring
> that only functions be used and having to always return a value,) but it
> seems I can not.
>
> Something like this would be nice:
>
>   if func_id(routine_id) then ...
>   if proc_id(routine_id) then ...
>
> DGuy

You can add this information yourself, e.g.:

constant FUNC=1, PROC=2

sequence r_info1, r_info2

function my_func()
   return 27
end function
r_info1 = {routine_id("my_func"), FUNC}

procedure my_proc()
   puts(1, "Hello\n")
end procedure
r_info2 = {routine_id("my_proc"), PROC}


Regards,
   Juergen

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu