Topic: C++0x - wish list
Author: "R. Sinoradzki" <sinoradz@student.uni-kl.de>
Date: Sun, 27 May 2001 17:01:13 GMT Raw View
Hi,
I have also a little question/wish. But don't flame me,
I am really new to this topic and probably I don't
see the whole problematic that comes with it.
My question: Will we ever see some synchronization mechanism
in C++0x ?
Background:
We had to write such things in our operating system course
and try it out with some standard concurrency problems.
I wrote some classes that behaved a bit like a monitor
(entering and leaving the pseudo-monitor through member
function). But a monitor is a language feature.
I had to add inline-functions enter() and leave() to each
public-method.
The code would have looked very nice, if I were able to
force the execution of some memberfunctions to pass a
synchronization mechanism automatically.
I would like to have something like that, but I know that
this is very specific and not every platform would have
adantages from it.
I hope this sounds not to weird after all.
Regards,
Ralf
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: =?iso-8859-1?Q?Andr=E9_P=F6nitz?= <poenitz@htwm.de>
Date: Mon, 28 May 2001 22:59:33 GMT Raw View
James Dennett <jdennett@acm.org> wrote:
> I think that what's asked for is the ability to have a class
> definition without the member function definitions, and then
> to be able to define the member functions without using repeated
> qualification.
That's what was asked for.
> Something like
>=20
> class foo {
> public:
> void bar1();
> void bar2();
> };
>=20
> namespace for class foo {
> void bar1() { /*...*/ }
> void bar2() { /*...*/ }
> }
>=20
> I don't see the need to write foo::bar1 and foo::bar2 as a big
> problem, but opinions may vary.
foo::bar1() and foo::bar2() are certainly not a problem.
But it gets messy in things like
template <
template <class foo_thing> class bar_qwertz,
class another_one
>
real_thing<bar_qwertz, another_one>::some_enum_type real_thing::bar1()
{
return short_function_call();
}
(compared to
some_enum_type real_thing::bar1()
{
return short_function_call();
}
at least)
When most of your function bodys much are shorter than the necessary
"qualification" it is certainly a question of readability, and it is
certainly easier to add 'just another template parameter' only once in
the "block header" than for every function individually.
I think it would not to hard for compiler vendors to implement such a
feature since it is basically already there: I could write everything
inline in the class definition and the compiler has to understand it
already today.
Andre'
--=20
Andr=E9 P=F6nitz ............................................. poenitz@ht=
wm.de
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: Marcin Tustin <mt500@ugnode3.ecs.soton.ac.uk>
Date: Fri, 25 May 2001 22:49:53 GMT Raw View
Andr=E9 P=F6nitz <poenitz@htwm.de> wrote:
> An item from my wish list (and again only "syntactic sugar"):
> How about some "block scope" for the implementation of class functions?
It sounds like you want to be able to write a class with the whole functi=
on
definition within the class declaration (Like in java). Unless I'm very m=
uch
mistaken this is already legal (g++ certainly allows it). Or are you aski=
ng
for something else?
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: James Dennett <jdennett@acm.org>
Date: Fri, 25 May 2001 23:20:43 GMT Raw View
Marcin Tustin wrote:
>=20
> Andr=E9 P=F6nitz <poenitz@htwm.de> wrote:
>=20
> > An item from my wish list (and again only "syntactic sugar"):
>=20
> > How about some "block scope" for the implementation of class function=
s?
>=20
> It sounds like you want to be able to write a class with the whole func=
tion
> definition within the class declaration (Like in java). Unless I'm very=
much
> mistaken this is already legal (g++ certainly allows it). Or are you as=
king
> for something else?
I think that what's asked for is the ability to have a class
definition without the member function definitions, and then
to be able to define the member functions without using repeated
qualification.
Something like
class foo {
public:
void bar1();
void bar2();
};
namespace for class foo {
void bar1() { /*...*/ }
void bar2() { /*...*/ }
}
I don't see the need to write foo::bar1 and foo::bar2 as a big
problem, but opinions may vary.
-- James Dennett
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: "Ken Hagan" <K.Hagan@thermoteknix.co.uk>
Date: Sun, 27 May 2001 02:58:45 GMT Raw View
James Dennett <jdennett@acm.org> wrote *something* like...
>
> struct foo { void bar1(); };
>
> namespace for class foo {
> void bar1() { /*...*/ }
> }
>
> I don't see the need to write foo::bar1 as a big problem, but
> opinions may vary.
(I've re-phrased the "quote".)
I don't have strong feelings either, but most of my classes have
longer names than "foo". Try it with a class template nested inside
another template. Give each template three or four parameters. :)
The next question is should we write
template<...> namespace foo { ... }
or
namespace template<...> foo {...}
?
Oh, and can we have templated namespaces in C++0x?
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: Dietmar Kuehl <dietmar_kuehl@yahoo.com>
Date: Sun, 27 May 2001 02:59:06 GMT Raw View
Hi,
James Dennett wrote:
> Something like
>
> class foo {
> public:
> void bar1();
> void bar2();
> };
>
> namespace for class foo {
> void bar1() { /*...*/ }
> void bar2() { /*...*/ }
> }
>
> I don't see the need to write foo::bar1 and foo::bar2 as a big
> problem, but opinions may vary.
If 'foo' happens to be spelled
template<typename cT, typename traits>
... std::basic_streambuf<cT, traits>
and you are using a return type depending on the class like
typename std::basic_streambuf<cT, traits>::int_type
you end up with function definitions looking like this
template <typename cT, typename traits>
typename std::basic_streambuf<cT, traits>::int_type
std::basic_streambuf<cT, traits>::sgetc() { ... }
to take an example from the standard C++ library (I have also templates
with many
more arguments). I see writing this stuff over and over again just to
separate
declaration from definition (this is why it is not written in the body
of the class
definition) definitely as a problem. It is not so much a problem with
simple classes
but with complex class templates most of the work is often just in
getting the
function header correct!
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: Marcin Tustin <mt500@ugnode2.ecs.soton.ac.uk>
Date: Sun, 27 May 2001 02:59:29 GMT Raw View
Well, yes, although it is only a minor irritation, it would improve
my productivity,for one.
James Dennett <jdennett@acm.org> wrote:
> I think that what's asked for is the ability to have a class
> definition without the member function definitions, and then
> to be able to define the member functions without using repeated
> qualification.
> Something like
> class foo {
> public:
> void bar2();
> };
> namespace for class foo {
> void bar2() { /*...*/ }
> }
> I don't see the need to write foo::bar1 and foo::bar2 as a big
> problem, but opinions may vary.
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: "Kaspar Daugaard" <kdaugaard@spam-me.bigbluebox.com>
Date: Mon, 21 May 2001 18:52:20 GMT Raw View
"Dennis Yelle" <dennis51@jps.net> wrote:
> I agree. I really hate to see the class name repeated
> over, and over, and over again. It really makes the
> code look ugly.
I found myself moving functions and nested classes out of a class the other
day, because the function definitions were almost unreadable, so I will have
to agree.
Maybe the syntax could be 'using class X {...}' to avoid introducing a new
keyword, even if this isn't completely consistent with the current meaning
of 'using'.
Best regards,
Kaspar
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: =?iso-8859-1?Q?Andr=E9_P=F6nitz?= <poenitz@htwm.de>
Date: Fri, 18 May 2001 16:46:46 GMT Raw View
An item from my wish list (and again only "syntactic sugar"):
How about some "block scope" for the implementation of class functions?
I usually have .h files like
template<FirstFancyType, SecondFancyType>
class some_wierd_name {
//
typedef FirstFancyType::foo own_type
//
own_type function1(); =20
[...]
void function10();
}
and .whatever files like
template<FirstFancyType, SecondFancyType>
some_wierd_name::some_wierd_name()
{ .. }
template<FirstFancyType, SecondFancyType>
some_wierd_name::own_type some_wierd_name::function1()
{ .. }
template<FirstFancyType, SecondFancyType>
void some_wierd_name::function1()
{ .. }
I think it would be really nice if the latter could written as something
like
template<FirstFancyType, SecondFancyType>
class some_wierd_name
{
own_type function1()
{ .. }
void function10();
{ .. }
}
Maybe it's just me, but most of my functions have three lines or less, so
repeating this whole mess a dozen times effectively makes the code much
harder to read. I sometimes even start to move things to inline functions
in the class declaration simply to prevent the extra typing and the clutt=
er.
I don't think this would be very difficult to implement since it is
available for class declarations already, and it is pretty consistent to
the usage of 'namespace {}' and 'extern "..." {...}'.
What do you think?
Andre'
--=20
Andr=E9 P=F6nitz ............................................. poenitz@ht=
wm.de
---
[ 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://www.research.att.com/~austern/csc/faq.html ]
Author: Dennis Yelle <dennis51@jps.net>
Date: Sat, 19 May 2001 00:40:52 GMT Raw View
Andr=E9 P=F6nitz wrote:
>=20
> An item from my wish list (and again only "syntactic sugar"):
>=20
> How about some "block scope" for the implementation of class functions?
[...]
> and .whatever files like
>=20
> template<FirstFancyType, SecondFancyType>
> some_wierd_name::some_wierd_name()
> { .. }
>=20
> template<FirstFancyType, SecondFancyType>
> some_wierd_name::own_type some_wierd_name::function1()
> { .. }
> I think it would be really nice if the latter could written as somethin=
g
> like
>=20
> template<FirstFancyType, SecondFancyType>
> class some_wierd_name
> {
> own_type function1()
> { .. }
> void function10();
> { .. }
> }
I agree. I really hate to see the class name repeated
over, and over, and over again. It really makes the
code look ugly.
Dennis Yelle
--=20
I am a computer programmer and I am looking for a job.
There is a link to my resume here: =20
http://table.jps.net/~vert/
---
[ 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://www.research.att.com/~austern/csc/faq.html ]