🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2216

Re: Proposal for a new access specifier

#2216
From: Alex Martelli
Date: Mon, 16 Oct 1995 15:04
63 lines
3952 bytes
ENGR@GSSI.MV.COM (Michael Furman) writes:
	...
>  1. Memory (default): regular C/C++ variable that will be mapped to some 
>memory.
>  2. Emitter: in this case you must specify access function to call when 
>somebody
>     will read value of this "variable".
>  3. Collector: in this case you must specify access function to call when 
>     somebody will write value of this "variable".
	...
>I think it does not break any existent code (but needs two or even three 
>extra reserved words).

>Any comments?

Sather simplifies this sort of approach, in its "syntactic sugar
expression" syntax production, by mapping syntactic sugar to fixed
names.  For example, "a[row,col] := b;" always maps to "a.aset(row,col,b)",
just as "a/b" always maps to "a.div(b)", etc.  In particular, in Sather,
"a:=b" maps to "a(b)", and a plain identifier "b" maps to "b()".

A mapping to fixed names seem to me to be a superior approach to the
extra complications of a user-definable mapping, for something
ultimately as minor as syntactic sugar.  Note that the fixed names are
not reserved words -- they're plain old identifiers of methods that the
class author will have to declare and define normally, they are subject
to normal overload resolution, etc etc.  If the user would like
"a=b" to actually call "a.set(b.get())", while the fixed mapping
would give "a(b())", nothing stops him or her from coding two simple
inline forwarding functions in the appropriate classes:
	(in a's class) bar operator()(foo X) {return set(X);}
	(in b's class) foo operator()() {return get();}

You could implement this as an upwards-compatible extension to C++ (no
chance that it will make it into the standard -- but nothing stops you
from taking GNU C++ and hacking this extension into it, just as it
already has several extensions to both ANSI C, and proposed-ANSI
C++...  if you make it popular enough, it will have a chance to get in
by the time the _next_ round of the standardization process rolls in,
early next century).  To avoid breaking any existing code, just have
the sugar-mapping extension kick in only when, without it, the code
would be ill-formed by present C++ language rules -- in particular, you
will have to decide whether this is worth breaking the
visibility-vs-access rule of C++ -- I suggest you don't, but rather
treat it as one more candidate for function-call overloading (with
priority lower than existing forms, so as to make sure existing correct
programs stay the same).


Could we move this discussion to comp.LANG.c++...?  It really has
little or nothing to do with the language _standard_, per se...


Alex
--
DISCLAIMER: these are TOTALLY personal opinions and viewpoints, NOT connected
in any way with my employer, nor any other organization or individual!
Email: martelli@cadlab.it                            Phone: +39 (51) 597313
CAD.LAB s.p.a., v. Ronzani 7/29, Casalecchio, Italia   Fax: +39 (51) 597120

[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <martelli.813830166@cadlab>
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
References: <199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net> <DG6q6J.EEt@mv.mv.com> <45d5r1$fk4@mujibur.inmind.com> <DGEovz.DKv@mv.mv.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews2.Eng.Sun.COM!taumet!clamage
From: martelli@cadlab.cadlab.it (Alex Martelli)
Newsgroups: comp.std.c++
Subject: Re: Proposal for a new access specifier
Date: 16 Oct 1995 15:04:04 GMT
Organization: Cad.Lab Spa, Bologna, Italia
Sender: nntpnews@cadlab.it (NNTP Posting Services)
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <martelli.813830166@cadlab>
References: <199509221547.JAA10782@ncar.ucar.EDU> <MATT.95Sep24112332@Austern> <44spqj$j37@nn.fast.net> <DG6q6J.EEt@mv.mv.com> <45d5r1$fk4@mujibur.inmind.com> <DGEovz.DKv@mv.mv.com>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Newsreader: NN version 6.5.0 #11
Followups-To: comp.lang.c++
Content-Length: 2916
X-Lines: 59
Originator: clamage@taumet