1. Re: goto / global variables

> >Craig Gilbert wrote:
> >>Read-only?  Isn't that essentially what a 'constant' is?
> >Not exactly.  By read-only I meant a local variable which is visible
> >globally.
> >Outside of its scope it could be read but not written to.
> >Colin Taylor
>         Gotcha.  At the local level it would be 'normal', externally it =
would
> seem like a gobal constant.
>         Quite a neat idea, actually.  A 'viewport' variable, obviating t=
he need
> for access functions to check on the state of local vars w/out endangeri=
ng
> their state.

In theory this approach shouldn=B4t be taken, cause is against to
modern OO methodologies. As I stated in a previous mail, the best
solution would be to have STATIC variables, so to read the value of
an external variable (declared as static in other .e file)  you
should call a function (method?). Example:

--This is file MODULE.E
static myvar
global function read_myvar()
        return myvar
end function
global procedure write_myvar(atom value)
        myvar =3D value
end procedure
-- End file

-- This is file PROGRAM.EX
atom test_value
write_myvar(100)                --Now myvar holds the value '100'
test_value =3D read_myvar()     --test_value
write_myvar(test_value*2)       --Nowmyvar holds value '200'
myvar =3D 100                   --Error! you can't reach myvar directly
--End file

With this approach we can easily adopt OOP... each class definition
would be contained in a module file (.e), and there declare it's
methods. I think the posibility of declaring static variables isn't
hard to implemet (for RDS) and doesn't break Euphoria simplicity, and
the benefits would be worth it!

Regards,
  Daniel Berstein
  danielberstein at usa.net
  http://www.geocities.com/SiliconValley/Heights/9316

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu