1. Re: goto / global variables

> Your proposed "static" keyword is unnecessary because
> "static" is the *default* in Euphoria. All symbols are "static"
> unless they are declared with "global" in front of their declaration.
> For a symbol to be accessible from another file you *must*
> declare it as "global".

A static variable is defined in a procedure, but does not lose its
value after exiting the procedure, in other words :

--------------------------
integer var

procedure test()
    integer static_var

    if var=5 then
        static_var=var
    end if
    ?static_var
end procedure

var=5
test()
var=6
test()
----------------------------

With static variables, this piece of code would display:

5
5

However, it gives an error: "static_var has not been assigned a
value". Which means that variables defined in a procedure are NOT
static.

Regards,
              Michael Bolin

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu