This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Fw: c++ "with" keyword
- From: "Norman Jonas" <normanjonas at arcor dot de>
- To: <gcc at gcc dot gnu dot org>
- Date: Sun, 29 Dec 2002 03:44:21 +0100
- Subject: Fw: c++ "with" keyword
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