Re: Pointers to global and stack variables

Alex Colvin <alexc@TheWorld.com>
30 Nov 2005 17:29:11 -0500

          From comp.compilers

Related articles
Pointers to global and stack variables shreyas76@gmail.com (shrey) (2005-11-26)
Re: Pointers to global and stack variables henry@spsystems.net (2005-11-27)
Re: Pointers to global and stack variables 148f3wg02@sneakemail.com (Karsten Nyblad) (2005-11-29)
Re: Pointers to global and stack variables alexc@TheWorld.com (Alex Colvin) (2005-11-30)
| List of all articles for this month |

From: Alex Colvin <alexc@TheWorld.com>
Newsgroups: comp.compilers
Date: 30 Nov 2005 17:29:11 -0500
Organization: The World : www.TheWorld.com : Since 1989
References: 05-11-118 05-11-126
Keywords: design, storage
Posted-Date: 30 Nov 2005 17:29:11 EST

>> I am trying to understand what might be a few major and general
>>reasons why programmers might have pointers to global and stack data as
>>compared to pointers to heap which are essential to building data
>>structures...


There are a couple of uses that I can think of. The most important is
call-by-reference. You want to be able to pass the address of a local
or global variable for modification, or pass a pointer to large object
to avoid copying.


In languages like Pascal, this doesn't look like a pointer (which can
really only point to the heap), but in C it's a pointer just like a
heap pointer.


In Java this is necessarily a heap pointer - you can't call by
reference and you can't point to a non-object.


Another use, as was pointed out, is statically constructed linked
structures.
--
mac the naïf


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.