1. conditional includes

Hey all,
Here's an addition to the wish list (or passioned debate) for Eu: scripted
include code.

Such as this pseudocode:

for loop 50 to 0 do
 if exists(RootFileName & sprint(loop) & ".ew" ) then
   include RootFileName & sprint(loop) & ".ew"
   exit
 end if
end for

This would pick up the most recent version of RootFileName to include,
saving editing the files which include it. Given that Eu can determine if a
file has been loaded already and not reload it, some of us (read: "me") use
a standard header approach and just include everything up front. Wasteful, i
suppose, but at the moment i'm not concerned. That code snippet could be
expanded to see if anything in *.ew is called (simply by reading the file
that's being compiled) and if not, then don't bother including it.

This approach would also be handy for those using othe people's files as
includes to not need to edit all their files to use the next edition of
win32lib, for instance.

I can see how this could be a major problem as far as implementing it in the
compiler, making a pre-processor or a interpreter-within-compiler necessary,
so i don't expect it in the next release of Eu, if ever,, but it's a
thought.

Kat

new topic     » topic index » view message » categorize

2. Re: conditional includes

Kat,

While it might not fit exactly what you need, a few people
have already found a way around this. Basically, you could
do something like:

   IncludeList = {}

   if (include_win32lib ()) then
      IncludeList = IncludeList & "include win32lib.ew\n"
   end if
   if (include_magiclib ()) then
      IncludeList = IncludeList & "include magiclib.e\n"
   end if
     .
     .
   -- etc.

   fn = open ("junk8209.tmp", "w")
   for i = 1 to length (IncludeList) do
      puts (fn, IncludeList[i])
   end for
   close (fn)

   include junk8209.tmp

   -- the rest of your code follows

The only downside is that this has to be done outside of
all routines. Hopefully that doesn't present a problem--
you can just put it at the beginning of your code file.

Hope this helps,


Rod Jackson

P.S. -- As I found out, you can even write include files
that execute code immediately and create/include OTHER
files, but only about 10 levels deep....

----------
From:   Kat[SMTP:KSMiTH at PELL.NET]
Sent:   Sunday, December 19, 1999 2:11 PM
To:     EUPHORIA at LISTSERV.MUOHIO.EDU
Subject:        conditional includes

Hey all,
Here's an addition to the wish list (or passioned debate) for Eu: scripted
include code.

Such as this pseudocode:

for loop 50 to 0 do
 if exists(RootFileName & sprint(loop) & ".ew" ) then
   include RootFileName & sprint(loop) & ".ew"
   exit
 end if
end for

This would pick up the most recent version of RootFileName to include,
saving editing the files which include it. Given that Eu can determine if a
file has been loaded already and not reload it, some of us (read: "me") use
a standard header approach and just include everything up front. Wasteful, i
suppose, but at the moment i'm not concerned. That code snippet could be
expanded to see if anything in *.ew is called (simply by reading the file
that's being compiled) and if not, then don't bother including it.

This approach would also be handy for those using othe people's files as
includes to not need to edit all their files to use the next edition of
win32lib, for instance.

I can see how this could be a major problem as far as implementing it in the
compiler, making a pre-processor or a interpreter-within-compiler necessary,
so i don't expect it in the next release of Eu, if ever,, but it's a
thought.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: conditional includes

Actually, you might want to avoid doing the work yourself
and just check the Euphoria archives... I believe there
is a "conditional include" library there already...


Rod Jackson

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu