Re: Those of us who are C'ly challenged :>

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

Nate wondered:

> I would have thought that Euphoria read all of the code
> first, then ran the program.

Reading tha manual carefully can really save you a lot of grief. For
example, section 2.6 explains how Euphoria handles converting source
code.

Think of it this way: as Euphoria reads the file, it "compiles" that
code into an internal representation. As soon as the end of an un-nested
statement is reached, the code that was built is executed. For example,
as soon as Euphoria realizes it has reached the end of the statement:

        ? 1 + 2

it executes the code that was just created. Note that the EOL (end of
line) marker does *not* mark the end of a statement in Euphoria; you
could have just as easily written:

        ? 1 -- comments are ignored
                + 2

and it would run the same. If there are *nested* statements, Euphoria
waits until the end of the top-most statement is reached before
executing it. For example:

        for i = 1 to 10
                for j =  i to 10
                        ? {i,j}
                end for
        end for

doesn't execute until the second "end for" is reached. Some statements
have no visible execution behavior, such as:

        procedure foo()
                puts( 1, "foo!" )
        end procedure

Code has been generated, but the "procedure" statement essentially tells
Euphoria to store "foo"'s code for later execution, instead of running
it immediately. Statements like:

        integer x, y

also have no "visible" action - their execution does magical stuff in
the interpreter, out of our view.

-- David Cuny

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

Search



Quick Links

User menu

Not signed in.

Misc Menu