Re: Including Files

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

Matt Lewis wrote:
> cklester wrote:
> > Can this please be considered?
> > 
> > I'd like to be able to include files using a variable. For example:
> > 
> > sequence s
> > s = dir("plugins")
> > for t=1 to length(s) do
> >    if not find(s,{".",".."}) then
> >        include s[t]
> >    end if
> > end for
> > 
> > Thanks! :)
> 
> I think the only 'reasonable' way to do this is to use something like
> ooeu's eval() (which it can do).  I haven't migrated that into the c
> backend yet, so you'd be stuck with the euphoria backend.  I have some
> ideas on how to do it, however, though it's going to be a lot of work.

If Euphoria currently knows what to do with this:

   include myinc.e

which is basically

   include the file 'myinc.e'

why can't it simply do something like this:

(pseudo-code)

   sequence s
   s = "myinc.e"
   include s

which would be the exact same thing as

   include the file 'myinc.e' as defined in the variable s

Instead of

1. parse filename from line of code
2. include filename contents

we would have

1. is include parameter a variable?
    Yes: parse filename from variable
     No: parse filename from line of code
2. include filename contents

It's the EXACT SAME THING, except for that little translation part.
But that happens before the include is invoked! Ultimately, the
interpreter should be using the exact same unaltered include code it uses
now, it's just that there might be a step or two extra before that in
determing from whence the filename should be gotten.

Do you see what I'm saying? The code used to include files now should not
have to change. It can just obtain the filename to include in a new way.

I hope that makes sense. It sure does in my head. 8)

Is this a single-pass/double-pass issue?

-=ck
"Programming in a state of Euphoria."
http://www.cklester.com/euphoria/

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

Search



Quick Links

User menu

Not signed in.

Misc Menu