clarification needed: assigning function value and forward reference
- Posted by _tom (admin) Apr 09, 2010
- 1292 views
This first demo shows that it is possible use a routine that is declared after the request to use it:
include std/console.e display("#1 test forward referencing of routines" ) one() --two() ? two() procedure one() display("this is one") end procedure function two() display("this is two") return "" end function two() --------------------------------------------- -- executes with the display... -- #1 test forward referencing of routines -- this is one -- this is two -- {} -- this is two
The the odd thing is that the first time two() is used it must assign a value to something. The second time two() is used, a value does not have to be assigned.
include std/console.e display("#2 test forward referencing of routines" ) one() two() procedure one() display("this is one") end procedure function two() display("this is two") return "" end function two() ----------------------------------------------- -- crashes with the message... -- scope2.ex:8 -- <0068>:: expected a procedure, not a function -- two() -- ^
How do I understand (and document) this activity?