home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc10.cs.uiuc.edu!pjl
- From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
- Subject: Re: Proposal: auto T&
- Message-ID: <1992Aug21.041354.7852@sunb10.cs.uiuc.edu>
- Sender: news@sunb10.cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <1992Aug20.171342.3589@sunb10.cs.uiuc.edu> <9223406.29682@mulga.cs.mu.OZ.AU> <1992Aug20.213417.5690@sunb10.cs.uiuc.edu> <171m8oINNdu7@early-bird.think.com>
- Distribution: usa
- Date: Fri, 21 Aug 1992 04:13:54 GMT
- Lines: 48
-
- In <171m8oINNdu7@early-bird.think.com> barmar@think.com (Barry Margolin) writes:
-
- >In article <1992Aug20.213417.5690@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
- >>In <9223406.29682@mulga.cs.mu.OZ.AU> fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON) writes:
- >>>What do you mean by "it's not reentrant"? Why not?
- >>
- >>*****> Because the "slot" allocated in the caller would first receive
- >> the temporary generated by "stringfunction( b )" then it would
- >> be clobbered by "stringfunction( c )"
-
- >I think the rest of us understood that enough temporaries would be
- >allocated so that there would be no clobbering.
-
- >> The problem with that is, what does the compiler do if a
- >> function returning an auto& calls itself?
-
- >That's what stack frames are for. Each stack frame for the function would
- >contain space for all the temporaries that are returned.
-
- >The easiest way to understand this is to transform the program into a
- >version where the temporaries are explicit. Thus,
-
- > String a, b, c; // also assume + has been overloaded
- > // ...
- > a = stringfunction( b ) + stringfunction( c );
-
- >is equivalent to:
-
- > String a, b, c, temp1, temp2;
- > // ...
- > temp1 = stringfunction(b);
- > temp2 = stringfunction(c);
- > a = temp1 + temp2;
-
- >Your claim of non-reentrancy suggests that you think the temporaries would
- >be static, not automatic.
-
- *****> You're right; I stand corrected. What I was thinking was that
- the return-value _always_ was in the first caller of a recursive
- calling sequence; I forgot to make the mental leap where yet
- another slot would be created in the next stack frame just like
- everything else.
-
- Apologies for any confusion.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-