Re: Including Files

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

cklester wrote:
> 
> 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

Well, for one thing, when things are being parsed, s hasn't been 
assigned any value.
 
> 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?

The issue is that you're asking to be able to execute code during parsing,
which is not how euphoria works (2.5 and later, anyway).  I agree, however,
that your simple example is exactly the same.  So I'd ask you why you would
want to do it that way?

OK, I know the answer is that you'd want to do some other calculations to
either create the sequence dynamically, or include it conditionally.  You
might do better with a preprocessor for the conditional include situation.

You mentioned plugins.  I really think the dll idea is a better way to go,
because you could really load them dynamically (and unload them, if you
really wanted to).  Otherwise, some sort of preprocessor is probably better,
so that you could keep some sort of ini file that identified the plugins
you wanted, and before the code was actually executed, you could create the
includes that you really wanted.  That's basically what some others have done
in their dynamic inclusion schemes for 2.5.

Matt

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

Search



Quick Links

User menu

Not signed in.

Misc Menu