Re: Question about includes

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

Hi timmy,
Currently Euphoria, unlike many other languages, has been written as a
single pass interpreter. This means that you can only refer to a name
(variable, constant, procedure or function) if that name occurs earlier in
the text of your program. You cannot refer to something that occurs later on
in the text of the program code. It doesn't matter if its global or not. The
"global" keyword just means that if you define a name inside an include
file, that code after the include file can "see" the name, otherwise only
code in the include file can see it.

This is a bothersome limitation in Euphoria for a lot of people and to get
around it we have to do all sorts of (frequent!) code rearranging.

In your case, using global procedures inside an include file, means that the
include statement must occur early in your main file so that code after it
can see the procedure. It sounds like you have to move the include statement
away from the WinMain() call to earlier in your code. The difficulty is that
if any code inside the include file references variables or routines in your
main file, your must ensure that the include statement is after all those
definitions.

Another problem that might arise is if two or more routines refer to each
other. To get around this issue, you must define some new variables before
these interdependant routines and set these to the routine_id of the
approriate routines after the routines. Then instead of just calling the
routines you have to use the special call_func or call_proc statements.

<soapbox>
I just hope that one day, RDS can see what a waste of people's time this
continuous messing around with reorganising lines of code, and adding
superfluous (global) definitions, can be. A program, such as an interpreter
can do it much faster, in real-time, than we can. The larger the program,
the more probability one will have to change code lines around. This is a
negative reinforcement to writing professional applications. Euphoria has
special built-in language constructs that must be used as workarounds to
solve the forward-referencing problem, because its against RDS's view of
perfection. RDS sees the current way of doing things as more elegant, simple
and ideal. I believe it that this philosophy is contrary to most respected
theories on code developement and human thinking. Refer to Weinberg, Gilb,
McConnell, Dupre, MacGuire, Yourdan, de Bono, Booch, Wiegers, Gause, ...
<\soapbox>

------
Derek Parnell
Melbourne, Australia
(Vote [1] The Cheshire Cat for Internet Mascot)

----- Original Message -----
From: "timmy" <tim781 at PACBELL.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Saturday, January 27, 2001 6:43 AM
Subject: Question about includes


> Hi,
>
> I'm writting to ask how euphoria
> handles includes. I'm writting
> a win32lib program and want
> to make part of the menus and then
> the rest based on text files. The
> problem is that I can't put the global procedures
> in an include file, because it says
> some of the varibles have'nt been
> declared, even though I declared them
> and set them in the main .exw and put the
> neccessary include statement all the way down
> where I put WinMain.
>
> One of the menus is a song list which
> the users can edit. It takes alot of code
> and I also have other menus that can be edited.
> My main .exw is going to look like a
> gigantic Basic program if I can't break them up.
>
> Has anyone run into this problem? Is there
> a "best way" for writting win32lib programs?
>
> ...thanks
>
> timmy :)

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

Search



Quick Links

User menu

Not signed in.

Misc Menu