TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Frank Adam
from: John Gardeniers
date: 1996-08-21 01:14:20
subject: Re: Passing a var.

-=> On 17 Aug 96  00:57:02 <=-
-=> Frank Adam was heard to tell All <=-

    Hi Frank,

 FA> Does passing a pointer to a function effect performance, as opposed to
 FA> having the contents of said pointer global or local ?

    I can't answer for other compilers but I checked out how it's
handled by PCC and found that there's no real advantage either way.
The difference is only a couple of CPU clock cycles.  That's just
slightly less than 1% of sub-microscopic. :-)

 FA> Also, does re-entrancy mean, that one can have multiple instances of a
 FA> function/program ?  Yep, still trying to learn the right terminology.

    Stricktly speaking any function can be re-entrant, with the
possible exception of main(), however I think I know what you mean.
The word you're looking for is recursive.  The short answer is yes.
The long answer is yes, but will it exit correctly?

    If a routine uses only local variables it may be re-entered as
many times as your system/setup allows.  The limits are imposed by
such things as the size of the stack, etc.  Each time you enter the
routine it will create a new set of local variables (on the stack),
which are completely unknown to any other occurance of the same
routine.  While the variables used don't *have* to be local I'm sure
you can see that you have to use care in using global variables,
otherwise the contents may become meaningless.

    The trick to using recursion properly lies in clearly defining
exit conditions.  i.e.  You must be able to cleanly exit each
occurance of the routine(s) without leaving anything messed up.  The
first time I used recursion was in a simple game (a DOS version of
Windows Minesweeper).  Starting from the current position I had to
perform tests on adjacent cells.  Depending on the results the test
would then be applied to *it's* adjacent cells, etc.  etc.  By using
recursion I only had to write a routine to perform the tests on a
single cell.  If the tests returned the appropriate result the
routine would simply call itself with the new parameters and start
again.

        John

... Recursive (ri-kur-siv) adj.  See "Recursive."
--- FMail/386 1.02
* Origin: Does your bbs carry the Australian Fishing Conference? (3:639/102)
SEEN-BY: 50/99 620/243 623/630 632/107 348 360 633/371 634/388 396 635/301
SEEN-BY: 635/502 503 506 544 639/102 161 251 252 711/401 409 410 413 430 808
SEEN-BY: 711/809 932 934 712/515 713/888 714/906 800/1
@PATH: 639/102 252 635/503 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.