Re: Introspection?

new topic     » goto parent     » topic index » view thread      » older message » newer message
axtens_bruce said...
procedure Hello(sequence place) 
    puts(1, "Hello, " & place & "!\n") 
end procedure 
 
Hello("World") 

Is there any way for Hello to be able to see its own name so that one might code

procedure Hello(sequence place) 
    puts(1, me() & ", " & place & "!\n") 
end procedure 
 
Hello("World") 

I can't think of a good reason right now for that ability. Just curious.

-Bruce

Hi

Are you asking for recursion, where a procedure calls itself?

procedure Hello(sequence place) 
    --puts(1, me() & ", " & place & "!\n") 
    Hello("Continent on ") 
    puts(1, place) 
end procedure 
 
Hello("World") 

This does wok but watch for the infinite loops. Set a break flag

integer break_flag = 0 
procedure Hello(sequence place) 
    if break_flag > 1 then return end if 
    break_flag += 1 
    
    Hello("Continent on ") 
    puts(1, place) 
 
end procedure 
 
Hello("World") 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu