1. Procs & Funcs
Hi All,
I've a question.
Suppose I include a .e file full of various routines(procs. & funcs), but
in my .ex file, I just use 1 of the routines. When I bind my .ex file,
will all the routines be included into the EXE file or only the one I
really used??
From,
Abhimanyu Lad
2. Re: Procs & Funcs
At 01:29 PM 5/3/98 +0530, Abhimanyu Lad wrote:
>Hi All,
>
>I've a question.
>Suppose I include a .e file full of various routines(procs. & funcs), but
>in my .ex file, I just use 1 of the routines. When I bind my .ex file,
>will all the routines be included into the EXE file or only the one I
>really used??
>
>From,
>Abhimanyu Lad
>
Good question: I tried a test:
string.e is about 6400 bytes, but it adds only about 3200 to
the compiled file when it is included (even if no routines in
string.e are called) The compiled file gets larger by a few
bites when an included routine is called: but by fewer bytes
than the call itself takes to write! Seems that the call is stored as
a "token".
TEST1 EX 34 using no includes
TEST1 EXE 176,450
TEST2 EX 52 include string.e, but make no calls
TEST2 EXE 179,668
TEST3 EX 62 call 1 routine in string.e
TEST3 EXE 179,675
TEST4 EX 85 call 1 routine in string.e twice
TEST4 EXE 179,692
TEST5 EX 90 call 2 routines in string.e
TEST5 EXE 179,690 source was 5 bytes larger than 4
--1
sequence s
s = "HELLO"
puts(1,s)
--2
include string.e
sequence s
s = "HELLO"
puts(1,s)
--3
include string.e
sequence s
s = trim("HELLO",' ')
puts(1,s)
--4
include string.e
sequence s
s = trim("HELLO",' ')
s = trim("HELLO",' ')
--5
include string.e
sequence s
s = trim("HELLO",' ')
s = expand_tabs("HELLO",5)
puts(1,s)
3. Re: Procs & Funcs
Abhimanyu Lad writes:
> Suppose I include a .e file full of various routines(procs. & funcs),
> but in my .ex file, I just use 1 of the routines. When I bind my
> .ex file, will all the routines be included into the EXE file or only
> the one I really used??
All of the routines and variables will be included, whether
you use them or not.
I've been thinking about making a smarter bind program that
would detect unused stuff, and leave it out of the
.exe file (or shrouded source file). It would have to make
2 passes through all of the code. The first to detect unreferenced
symbols. The second to emit code into the .exe file for the routines
and variables that are actually used. routine_id() would
complicate matters a bit.
Regards,
Rob Craig
Rapid Deployment Software
4. Re: Procs & Funcs
At 02:01 PM 5/3/98 -0400, Rob Craig wrote:
>I've been thinking about making a smarter bind program that
>would detect unused stuff, and leave it out of the
>.exe file (or shrouded source file). It would have to make
>2 passes through all of the code. The first to detect unreferenced
>symbols. The second to emit code into the .exe file for the routines
>and variables that are actually used. routine_id() would
>complicate matters a bit.
It certainly would. If you do this, please make it optional.
Routine_id is one of the most useful and powerful features of Euphoria.
I am presently implementing inheritance using a sequence of routine_id's.
Each object attaches its own "show" routine_id,
for example, to the end of a list of "show" routine_id's passed
(along with all the other properties) when a new object is
declared as an instance of ancestor x.
i.e.: bitmap_button = button
This makes inheritance simple, as it's only necessary
to declare the new object's added "show" behavior.
The generic "Show (object)" routine only has to say:
for i = 1 to length(object[SHOW]) do
call_proc(object[SHOW][i],{})
end for
which works with any object:
Show(button), Show(bitmap_button), etc.
Currently, I am building the sequence using routine_id #'s,
but It would work using a sequence of function "names",
or perhaps even *computed* names. (I don't yet know
of a reason to do this, but that doesn't mean that
someone smarter won't someday think of one.)
Irv
5. Re: Procs & Funcs
>Hi All,
>
>I've a question.
>Suppose I include a .e file full of various routines(procs. & funcs), but
>in my .ex file, I just use 1 of the routines. When I bind my .ex file,
>will all the routines be included into the EXE file or only the one I
>really used??
Actually your source code is appended (in shrouded form) to ex.exe. This
makes almost no overhead when running your app because Euphoria
"pre-compiles" you source code at 10.000 lines/sec (486) and the extra size
is minimun (170K ex.exe + ?K your source).
Regards,
Daniel Berstein.