Variable declarations

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

Just started working with Euphoria a couple of days ago, but have
been professionally programming for 20+ years.

I love the simplicity of Euphoria!  Am porting an existing app over
as my way of getting my feet wet.

Haven't dug in deep yet so this issue may have already been discussed,
or may be in the manual and I just missed it.

The manual states that variables must be declared before they are used,
what I didn't see is that at least in a proc/func definition, all the
declarations must come first ( this is just anecdotal and I may be missing
something stupid )

Here's an example:

procedure test()
  atom myatom
  myatom = 1
  sequence myseq
  myseq = "test"
end procedure


This is just sample code, I tried running it real quick and it seems to
demonstrate the error I was receiving.  On line: "sequence myseq" I 
get the exception: Syntax error - expected to see possibly 'end', not 
a type .  If I trade this line with the previous line, all is cool.

This seems to suggest that at least within and procedure or function
definition all the declarations must be made prior to any other code.

Is this correct?  Is it documented behavior?  It's not a problem for me
since enforcing declarations before code results in cleaner and easier
to read code, I just thought that if this was not documented, it would
go a long ways toward helping out the newbies!

Jim Hendricks
President
Biz Computing, Inc.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu