1. where is my mistake

Why this code doesn't work. Is this an error in my code or because identifiers
are unknown at runtime.


-- msg.e
procedure msg_print(sequence this)
  puts(1,this[2])
end procedure

integer rid_msg_print
--rid_msg_print=routine_id("msg_print")

global function new_message(sequence msg)
  return {routine_id("rid_msg_print"),msg}
end function


-- test_msg.exw
include msg.e

sequence msg
msg = new_message("bonjour chez-vous\n")

call_proc(msg[1],{msg})


running test_msg.exw result in:

test_msg.exw:6
invalid routine id

--> See ex.err


Jacques Deschênes

new topic     » topic index » view message » categorize

2. Re: where is my mistake

jacques deschênes wrote:
> 
> Why this code doesn't work.
> 
> }}}
<eucode>
> procedure msg_print(sequence this)
>   return {routine_id("rid_msg_print"),msg}
> </eucode>
{{{

Delete the "rid_" from the start of the routine name passed to routine_id

Regards,
Pete

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

3. Re: where is my mistake

jacques deschênes wrote:
> 
> 
> Why this code doesn't work. Is this an error in my code or because identifiers
> are unknown at runtime.
> 
> 
> }}}
<eucode>
> -- msg.e 
> procedure msg_print(sequence this)
>   puts(1,this[2])
> end procedure
> 
> integer rid_msg_print
> --rid_msg_print=routine_id("msg_print")
> 
> global function new_message(sequence msg)
>   return {routine_id("rid_msg_print"),msg}
> end function
> 
> </eucode>
{{{

> 
> }}}
<eucode>
> -- test_msg.exw
> include msg.e
> 
> sequence msg
> msg = new_message("bonjour chez-vous\n")
> 
> call_proc(msg[1],{msg})
> 
> </eucode>
{{{

> 
> running test_msg.exw result in:
> 
> test_msg.exw:6
> invalid routine id
> 
> --> See ex.err
> 
> 
> Jacques Deschênes

Interesting bug... or undocumented feature.

I've verified it on Windows by uncommenting and returning rid_msg_print and it
works. Returning a routine_id directly from a return statement doesn't seem to
work.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

4. Re: where is my mistake

Pete Lomax wrote:
> 
> jacques deschênes wrote:
> > 
> > Why this code doesn't work.
> > 
> > }}}
<eucode>
> > procedure msg_print(sequence this)
> >   return {routine_id("rid_msg_print"),msg}
> > </eucode>
{{{

> Delete the "rid_" from the start of the routine name passed to routine_id
> 
> Regards,
> Pete
D'oh! I even read this before replying.

It works if you do this.

--
"Any programming problem can be solved by adding a level of indirection."
--anonymous
"Any performance problem can be solved by removing a level of indirection."
--M. Haertel
"Premature optimization is the root of all evil in programming."
--C.A.R. Hoare
j.

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

5. Re: where is my mistake

Thanks Pete,
At first I did use rid_msg_print variable then I decided to modify the code to
call routine_id from inside new_message() but forgot to remove the rid_  prefix.
Sometimes we are blind to obvious mistake.

regards,
Jacques Deschênes



Pete Lomax wrote:
> 
> jacques deschênes wrote:
> > 
> > Why this code doesn't work.
> > 
> > }}}
<eucode>
> > procedure msg_print(sequence this)
> >   return {routine_id("rid_msg_print"),msg}
> > </eucode>
{{{

> Delete the "rid_" from the start of the routine name passed to routine_id
> 
> Regards,
> Pete

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

Search



Quick Links

User menu

Not signed in.

Misc Menu