Re: Forward reference to included function

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

I don't see the difference between declared and defined in euphoria.

I was seeing "defined" as a variable after being assigned a value. But, since you can use atom(x) before an assignment I now understand how we just need "declared".

This probably means I can do a search and replace on all (most) occurances of "define" in the documentation and replace them with "declare".

This simplifies the first diagram.

mattlewis said...

Second diagram: This isn't quite right. A variable or constant declared anywhere in the file at top level is visible from inside a routine that is located anywhere in the file.

This I don't understand:

It suggests to me that this should work:

foo() 
procedure foo() 
 ? x 
end procedure 
atom x = 1 
-- variable x has not been assigned a value  

But what actually works is:

atom x = 1 
foo() 
procedure foo() 
	? x 
end procedure 
mattlewis said...

Both of these are subject to the caveat that code at a higher scope level cannot see variables declared at a lower level (e.g., a variable declared within a loop is not visible outside of that loop). I may have higher/lower confused.

Creating a diagram to explain nested scopes is going to take some work.

_tom

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

Search



Quick Links

User menu

Not signed in.

Misc Menu