Variable declarations
- Posted by Jim Hendricks <jim at bizcomputinginc.com> Sep 18, 2004
- 457 views
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.