* Fw: c++ "with" keyword
@ 2002-12-28 21:34 Norman Jonas
2002-12-29 6:14 ` Alexandre Oliva
0 siblings, 1 reply; 2+ messages in thread
From: Norman Jonas @ 2002-12-28 21:34 UTC (permalink / raw)
To: gcc
Since the several years I develop in c++ there is nothing I missed more than
the "with"
keyword as it is known by languages like Pascal. So I would like to know
what gcc
developer / user think of the idea to advance the c++ standard to add it.
Pro:
Very useful for many c++ developer
Slightly reduces code size / code to write
Contra:
Needs time until compiler developing companies implement it
To give an example of what I think the with keyword should be used :
struct S
{
int x;
int y;
};
int main()
{
S s;
with (s)
{
.x = 1;
.y = 2;
}
return 0;
}
and / or
class C
{
public:
void init ();
void next ();
}
int main()
{
C c;
with (c)
{
.init();
.next();
}
return 0;
}
This technique could be used in conjunction with structs as well as classes.
If there is enough reason to add this keyword to the c++ standard maybe the
ANSI consortium could be asked to add the "with" keyword to a new revision
of their c++ draft.
Norman Jonas
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Fw: c++ "with" keyword
2002-12-28 21:34 Fw: c++ "with" keyword Norman Jonas
@ 2002-12-29 6:14 ` Alexandre Oliva
0 siblings, 0 replies; 2+ messages in thread
From: Alexandre Oliva @ 2002-12-29 6:14 UTC (permalink / raw)
To: Norman Jonas; +Cc: gcc
On Dec 29, 2002, "Norman Jonas" <normanjonas@arcor.de> wrote:
> Since the several years I develop in c++ there is nothing I missed
> more than the "with" keyword as it is known by languages like
> Pascal. So I would like to know what gcc developer / user think of
> the idea to advance the c++ standard to add it.
There's a general trend against extensions in GCC these days. I don't
always agree with this stance, but I happen to agree with it in this
case. Pascal's `with' can be pretty much modeled in OO as the
implicit this. Wishing for the presence of `with' is, IMHO, generally
an indication that the code should be in a method of the class whose
members you're accessing. Besides, people often complain that C++ has
too much implicit behavior and room for ambiguities; `with' would just
add to it.
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{redhat.com, gcc.gnu.org}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-12-29 10:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-12-28 21:34 Fw: c++ "with" keyword Norman Jonas
2002-12-29 6:14 ` Alexandre Oliva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).