1. clarification needed: assigning function value and forward reference

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?

new topic     » topic index » view message » categorize

2. Re: clarification needed: assigning function value and forward reference

This makes no sense.

This is clearly a bug.

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

3. Re: clarification needed: assigning function value and forward reference

_tom said...

This first demo shows that it is possible use a routine that is declared after the request to use it:

I've added a unit test and opened ticket:150 for this issue.

Matt

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

4. Re: clarification needed: assigning function value and forward reference

mattlewis said...
_tom said...

This first demo shows that it is possible use a routine that is declared after the request to use it:

I've added a unit test and opened ticket:150 for this issue.

This is now fixed in svn:3156.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu