[LCP]global variable alternative

Joachim Bauernberger bj at gmx.net
Thu Apr 4 07:25:12 UTC 2002


Thanks Mike & Vincent,

I actually prefer practicality to purism at any time! :-)) 
...That's why I' ll stick with my original approach of keeping the 
global pointer to a local options structure. 
I also like Vincent's approach but since it's new to me and I am in a 
rush I will try it when I have more time on hand.

Thanks & Regards,
Joachim  

On Wednesday 03 April 2002 20:01, you wrote:
> Joachim,
>     The question is sort of "philosophical" and related to ALL
> programming languages (not specifically C).
> 
>     How much of a "purist" do you want to be? What's your philospophy
> with regard to structured programming and functions being "pure
> functions"?
> 
>     The "right" (ie: purist approach) this structure becomes an extra
> parameter to all functions.
> 
>     The "practical" programmer is likely to reason thusly. Once the
> structure has been initialized by the main process (or some
> initialization process which reads the user database and fills in the
> preferences) it never changes. In other words, it is from that point 
on
> "constant" data used by all the other functions to determine their
> behavior. Thus having those functions access it as a "global" makes
> sense.
> 
>     Mike
> 
> PS -- There are OTHER consderations which can come into play. Right 
now
> you are learning C and presumably all your links are "static" (ie: 
these
> functions are all LINKED and so references can be resolved). If 
working
> with a language where these might be DYNAMIC calls of functions (or
> prcesses) compiled separately and NOT linked together you would have 
to
> pass (the address of) the structure as an additional parameter.
> 
> PSS -- Anyone out there be able to explain to ME if/how C ever gets
> involved with something like "dynamic calls"?
> 
> 
> 
> _______________________________________________
> This is the Linux C Programming List
> :  http://lists.linux.org.au/listinfo/linuxcprogramming List
> 
> 

-- 
http://www.mXscan.org/




More information about the linuxCprogramming mailing list