Re: Include decision
Pete Lomax wrote:
>
> On Mon, 06 Nov 2006 23:44:06 -0800, ZNorQ <guest at RapidEuphoria.com>
> wrote:
>
> >I used a program that is called "Sequencer" by Andrea Cini
> >(Not sure what that 'decipher' function you're referring to is supposed to
> >be..)
> (That one you mentioned, or something/anything like it.)
??? Must be me, my memory isn't exactly perfect.. Just forget I asked. :P
>
> >I can 'fine tune' the application according to the users need.
> I must admit I am a bit confused as to what optimisation you think you
> are achieving here, especially if the exe contains a 'sequenced' dll:
> ACTIVATE_TCP = FALSE:
> exe loads that 25K (plus code from tcp4u.ew) every time.
> ACTIVATE_TCP = TRUE:
> as above, plus (re-) creating tcp4w32.dll, plus loading the dll, and
> therefore effectively having two copies in memory at once.
>
> In both cases this is clearly sub-optimal. In the first case above,
> you seem to be especially concerned that it does not execute some 22
> statements and completely ignore an overhead several times that.
I never mentioned memory (ie. overhead?) being an issue, because it's not!
The topic which is 'do I want to include a file or not' - based on a ruling
factor which in this case is a constant beeing true or false.
This constant is part of a set of constants that enables me to EASILY
give/remove access to different parts of my program. The program is a set
of useful functions that is very much needed - but the need for the different
types of functions is variable from project to project. Now, I want to create
specific compiled releases of my program to each project in order not to
confuse the users with options they don't need or should not at all have
access to. TCP4U is just one part of that.
Back to the issue at hand;
A hopefully readable example of how the program handles the tcp part;
--
constant ACTIVATE_TCP = TRUE or FALSE
sequence TCPDLL
TCPDLL = {#00, ... <THE WHOLE DLL CODE IN HERE>...}
--
if ACTIVATE_TCP = TRUE then
save TCPDLL as "tcp4w32.dll" to disk
activate tcpwrapper
TCPDLL ={} -->> Clear the sequence to free 25k of mem
else TCPDLL = {} -->> Just clear sequence and ..
skip the tcplibrary -->> .. skip the tcp wrapper initializations.
end if
Instead of going into each part of the code removing everything that
has to do with the TCP library for each COMPILED release of the program
I distribute out to my user base, I just 'flip the switch' by adjusting
the constant to true or false instead.
I do this so that I don't need to 'remember' to include the tcp dll each
time - its baked into my program and saved to disk if necessary. You could
look at my program as one install file that extracts files needed.
Now, I wasn't really discussing wether this is good practise, or not - but
if it's possible - somehow - to include a file based on a set of rules,
ie. ACTIVATE_TCP being true or false.
> A better 'fine tuning' would be (obviously) to distribute either:
> a) dll + exe incorporating tcp4u.ew, or
> b) exe w/o any tcp code/capability at all.
Why is this obvious? Lets say that the tcp code is so incorporated into the
program, wouldn't it be better leave all tcp code - even the DLL - as is,
and just use a constant to flip it on or off? I'm talking about a compiled
distribution - an executable with the DLL incorporated. If I don't want the
user to have access to this part, the DLL in memory is just deleted, and never
saved to disk. The total size of the compiled program is a meg - there is
no problem concerning file-/memory size.
>
> Now I know you're going to say you don't want to do that, but unless
> you do, the whole 'fine tune' justification is meaningless - and it is
> precisely the meaningnessless of the justification that confuses me.
>
I'm sorry, but it's not very easy for me to explain, but I also think that
all this is just a tad offopic as the question was really how do I dynamically
include files.. What I understand is that in native Euphoria, this isn't
possible. One have to look at pre-prosessors, etc - and that is what I'm
looking into now.
> Of course you can create/load the dll every time, just not use it, and
> simply stop fretting about such an insignificant overhead?
It's not about overhead. And yes, I could just create the DLL and just
let the wrapper do the initialization and just don't use it. This is not
the issue.
If I do something backward, let me - I'm in a learning stage here.
The programming jargons aren't that familiar to me.. Hopefully some of
these jargons penetrates that brick wall in my brain.
>
> Regards,
> Pete
> PS An alternative to a pre-processor in this case could be:
> withTCP.exw:
> }}}
<eucode>
> --global procedure create_dll(sequence name) [see below]
> include tcp4u.ew
> global constant ACTIVATE_TCP = TRUE
> include myapp.exw
> </eucode>
{{{
> and woutTCP.exw:
> }}}
<eucode>
> ACTIVATE_TCP = FALSE
> include myapp.exw
> </eucode>
{{{
Yes, this is probably a good way to do it, but then remember that what I'm
looking for is constant declaration part in the beginning of the code - which is
a good clean overview of what access I want to give to the user. This was what
I was hoping for anyway.
>
> This means it depends on which program you run/install, which is
> better than relying on editing the source, as that can become quite a
> drag at ten times a day.
>
> PPS A better method of creating the dll would be to catch the open
> error, rather than doing it every time, eg:
> }}}
<eucode>
> global function link_dll(sequence name)
> atom handle
> integer r
> handle = open_dll( name )
>
> if handle = NULL then
> r = routine_id("create_dll")
> if r!=-1 then
> call_proc(r,{name})
> handle = open_dll( name)
> end if
> if handle = NULL then
> wait_abort("Couldn't find DLL " & name)
> end if
> end if
> return handle
>
> end function
> </eucode>
{{{
>
As far as I can see, this would have to be done in the 3rd party wrapper then?
Remember, I just utilize the TCP4U's functions, I don't do anything with the
wrapper itself - I want to leave that be.
When it comes to opening DLL's etc., I'm drawing a blank. Haven't wandered into
that turf yet.. But I understand what you're getting at in the above example.
Thanks for the feedback, Pete.
Ken / ZNorQ
|
Not Categorized, Please Help
|
|