home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!munnari.oz.au!mel.dit.csiro.au!mineng.dmpe.CSIRO.AU!dmssyd.syd.dms.CSIRO.AU!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Tagged Pointers
- Message-ID: <1992Aug18.013357.19262@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1992Aug14.234242.8418@ucc.su.OZ.AU> <1992Aug17.174931.1376@fcom.cc.utah.edu>
- Date: Tue, 18 Aug 1992 01:33:57 GMT
- Lines: 70
-
- In article <1992Aug17.174931.1376@fcom.cc.utah.edu> swillden@news.ccutah.edu (Shawn Willden) writes:
- >maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- >
- >: It all depends on whether tagged pointers are a genuine
- >: type or not. If it is, all the above things must be distinct.
- >: If not (I suggested not in my post) then maybe we can make
- >: a pointer to a tagged union work as if it were a tagged
- >: pointer. This would homogenise the interface. More work
- >: for the compiler, less for the programmmer. Less control
- >: for the programmer too.
- >
- >Hmmm. It appears I didn't explain myself very well because that is
- >precisely what *I* was suggesting. I suppose the difference lies in
- >my consideration of TP's and TU's as different types but (as I said)
- >
- > 1) *TP yields a TU
- > 2) &TU yields a TP
- >
- >whereas you suggested that they not be actual *types* but that we
- >make them work like the above anyway. Same effect, different words.
- >Have I got this right?
-
- I'll have to think on this carefully, everytime I try
- to reply I get confused :-)
-
- >
- >: So the issue is whether a tagged pointer is a proper type
- >: or just a sort of syntactic sugaring that supports a new
- >: mechanism for genericity. My thinking was the latter.
- >
- >I think your thinking is better :-) TP couldn't be a proper type
- >anyway. If anything, TP would be a *family* of types.
- >
- >: Any comments?
- >
- >Getting back to the question that started this exchange (should we have
- >tagged references?), I think that they're probably unnecessary for the
- >case I was presenting (by which I mean that they don't greatly simplify
- >anything). If I have a TP and wish to pass a reference to what it points
- >to to a function I can just say:
- >
- >void foo([T1,T2,T3]& fred) // fred is a ref to a TU, not a tagged ref.
- > {...}
- >
- >void bar();
- > {
- > [T1,T2,T3]* barney;
- > ...
- > foo(*barney); // *barney is a TU, foo gets a ref to it.
- > }
- >
- >at least that is what the programmer may think. In fact TU and TP are not
- >types but the syntax of the sugar looks right. Actually, does it really
- >matter whether we call [T1,T2,T3]& a ref to a tagged union or a tagged
- >ref?
- >
-
- Yes. The compiler has to know where to find the tag,
- next to the pointer, or where the pointer is pointing.
- The rule has to be next to the pointer. So taking the address
- or making a reference to a tagged union has to copy the tag.
-
- To work out the exact rules I think in terms of the implementation.
- I'll have a go soon, perhaps while on holidays.
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;--------------- SCIENTIFIC AND ENGINEERING SOFTWARE ------------------
-