[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: more info - performance with local procedures...
Kristin,
1) GLOBAL routines are the leanest, meanest, procedures that SQR has to offer.
2) LOCAL procedures without arguments are slightly slower than GLOBAL
procedures.
3) LOCAL procedures with arguments are even slower as the contents of the
arguments are copied into the procedure variable space.
4) LOCAL procedures with return-value arguments are the slowest of the bunch
since the data has to be copied into the the procedure variable space and then
back into the caller's variable space.
The more arguments to a LOCAL procedure the slower it gets because it has more
work to do for each invocation. Also, it is best to match up the types between
the caller and the callee. SQR will attempt to auto-convert mismatched types but
you will take a performance hit.
So, why use LOCAL procedures?
If you are writing a procedure that it to be included in many programs and
you want to insure that variables used within the procedure will not interfere
with the calling program.
If you want to reuse your code and the only thing that changes are small
pieces of the procedure as effected by the arguments to the procedure.
It promotes encapsulation and requires you to add special syntax in order to
effect variables not defined in the procedure itself by adding a leading
underscore (_) (i.e. #_global_variable).
Then, why use GLOBAL procedure?
They are faster.
In small to medium programs they are actually better to use. It really
depends on your coding style.
Does this make sense? Is your brain totally fried? And it is only Monday!
Peter
P.S. BTW -- SQR does not currently support pre-compiled routines (like a library
file) ... yet.
"Love, Kristin" wrote:
> OK, I'm lost.
>
> I thought global meant that you would make an SQC file and then reuse it
> later.
>
> I thought local meant your procedure is only in your program.
>
> How does global "negate data abstraction". What is data abstraction?
>
> How could having an SQC already compiled and waiting reduce reusability?
>
> I'm relly not trying to be combative: I'm totally confused now!
>
> :) Kristin
> I'm not a programmer, I just play one on TV
> > -----Original Message-----
> > From: Johnson, Dan [SMTP:Dan_Johnson@WRIGHTEXPRESS.COM]
> > Sent: Monday, August 30, 1999 5:12 PM
> > To: Multiple recipients of list SQR-USERS
> > Subject: Re: more info - performance with local procedures...
> >
> > If I learned one thing in school it's this; GLOBAL IS BAD! I don't
> > dispute the possibility that global procedures may be a little bit slower
> > and that if you want to save a few seconds you should write global code
> > but
> > in the meantime you are breaking several rules of the structured
> > programming
> > approach. Here's why you don't want to use global procedures:
> > 1. Negates data abstraction
> > 2. Drastically Reduces reusability
> > 3. Makes code less modular because of the above two problems
> > Sure SQR seems to promote the use of global procedures and variables but
> > it
> > is up to you, the anal retentive programmer, to take the path that leads
> > not
> > unto the land of evil globalness but instead take the road less traveled,
> > the road to the land of localness where all is pure and good. (boy, did
> > the
> > grammar check hate that sentence)
> >
> >