From 1236758874891245333
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,fb1a92fa405c930c
X-Google-Attributes: gidf78e5,public
From: James.Kanze@dresdner-bank.com
Subject: Re: nested functions
Date: 1999/06/24
Message-ID: <7ktm8m$aco$1@nnrp1.deja.com>#1/1
X-Deja-AN: 493509836
Approved: Valentin Bonnard <bonnard@clipper.ens.fr>
References: <7jd4c5$nup$1@nnrp1.deja.com> <7jfkcr$na6$1@engnews1.eng.sun.com> <7jjq0g$tlu$1@nnrp1.deja.com> <slrn7lrin4.ajs.sbnaran@localhost.localdomain> <7k5ssr$pll$1@nnrp1.deja.com> <7k8ori$ra6$1@nnrp1.deja.com>
X-Original-Date: Thu, 24 Jun 1999 16:27:19 GMT
X-Http-User-Agent: Mozilla/4.6 [en] (WinNT; I)
X-Http-Proxy: 1.0 x30.deja.com:80 (Squid/1.1.22) for client 193.194.7.84
Organization: Deja.com - Share what you know. Learn what you don't.
X-Article-Creation-Date: Thu Jun 24 16:27:19 1999 GMT
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUAN3KWaqwEuYhIxRhxAQFhwgH+KCVH7OP6Nwieu4tM/giX+jjejUE/ja4k 4a6bzALaqlOJWtY9f2hS4Nvj3OEHEG/sj6Mge6gWIy/qG8Vs1QDjsQ== =7Ydr
Newsgroups: comp.std.c++

In article <7k8ori$ra6$1@nnrp1.deja.com>,
  gbush@my-deja.com wrote:
> In article <7k5ssr$pll$1@nnrp1.deja.com>,
>   James.Kanze@dresdner-bank.com wrote:
> >
> > It's important to note that I have *not* done the work necessary to
> > present a formal proposal, and that these are mostly just ideas off
the
> > top of my head.  However, my basic idea is that __local_context
would be
> > defined as containing non-const references to all visible local
> > variables and parameters, with the same name as the variable, and
> > initialized to refer to the variable.  I'm not sure whether these
> > members should be protected or public -- I think I rather favor
> > protected.  And of course, this just defines the semantic; most
> > compilers will be able to implement the actual accesses directly,
> > without the intervening reference.

> Though I like the idea of local context, it doesn't seem very clear
how
> it should be defined. Why const references are not to be included in
> __local_context?

Good point.  The class should contain non-const references to non-const
visible objects, and const references to const visible objects.

Note that the use of references is only to explain the semantics.  I do
not expect the compiler to actually implement it this way.  (Or better
said, I expect that in this particular case, the references take zero
memory.)

> Then you may need to have more than one local context if you have more
> than one local class. For example,
> void f()
> {
>   int i1;
>   // __local_context1 includes i1
>   struct S1: __local_context1 {} s1;
>   int i2;
>   // __local_context2 includes i1, s1, i2
>   struct S2: __local_context2 {} s2;
>   // and what kind of __local_context
>   // the following class inherited
>   struct S3: S1 {}; // ???
> }
> It's certainly not a good idea to have multiple __local_context
classes.
> Therefore there should be one __local_context class but it's contents,
> so to speak, is changing depending where it is used. So it's not
really
> a class in C++ definition, but some kind of pseudo-class.

Each use of __local_context defines a new (nameless) class.

--
James Kanze                         mailto:
James.Kanze@dresdner-bank.com
Conseils en informatique orientie objet/
                        Beratung in objekt orientierter
Datenverarbeitung
Ziegelh|ttenweg 17a, 60598 Frankfurt, Germany  Tel. +49 (069) 63 19 86
27


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



