Topic: extention to n1611
Author: bekkah@web.de (Helium)
Date: Sun, 2 May 2004 19:45:23 +0000 (UTC) Raw View
Nobody replied. Does this mean that it's stupid?
We already have objects that behave like functions. Now we could have
functions that behave like objects.
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: nobody@example.com (Ian McCulloch)
Date: Sun, 2 May 2004 23:30:48 +0000 (UTC) Raw View
Helium wrote:
> Nobody replied. Does this mean that it's stupid?
>
> We already have objects that behave like functions. Now we could have
> functions that behave like objects.
We can already get the same effect as your original post, by
struct bar_type
{
int bar_;
void operator=(int value) { bar_ = value; }
operator int() const { return bar_; }
};
class Foo
{
public:
bar_type bar;
};
int main()
{
Foo foo;
foo.bar = 42; // calls bar_type::operator=(int value)
}
Does your proposal add anything extra?
Cheers,
Ian McCulloch
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: francis@robinton.demon.co.uk (Francis Glassborow)
Date: Mon, 3 May 2004 16:37:41 +0000 (UTC) Raw View
In article <194c1211.0405020130.5ee94a24@posting.google.com>, Helium
<bekkah@web.de> writes
>Nobody replied. Does this mean that it's stupid?
>
>We already have objects that behave like functions. Now we could have
>functions that behave like objects.
Nobody answered because the author of 1611 does not read this newsgroup
(or I do not think he does) and the rest of us have no opinion (well I
do, I think you are proposing to add complexity while the original
proposal has some useful potential for simplification.)
--
Francis Glassborow ACCU
Author of 'You Can Do It!' see http://www.spellen.org/youcandoit
For project ideas and contributions: http://www.spellen.org/youcandoit/projects
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: bekkah@web.de (Helium)
Date: Mon, 3 May 2004 16:38:04 +0000 (UTC) Raw View
> We can already get the same effect as your original post
[snip]
Right, but look at the code you need. It's way to unconvenient to be
usefull. And what about calculated states?
Or imagine you want to write a wrapper. You'd have to insert a pseudo
object for each state you want to wrap.
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]
Author: bekkah@web.de (Helium)
Date: Thu, 29 Apr 2004 16:56:18 +0000 (UTC) Raw View
n1611 proposes implicitly callable functions.
I suggst to extend this by allowing implicitly callable functions that
accept one parameter. Instead of using the operator () to call ist you
can use the operator =.
This way you have a more generaly and flexible alternative to
accessors as proposed in n1600 and n1615.
class Foo {
public:
void bar (int value) implicit
{
bar_ = value;
}
int bar () const implicit
{
return bar_;
}
private:
int bar_;
};
int main ()
{
Foo foo;
foo.bar = 42; // calls void Foo::bar (int value) implicit
}
---
[ 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.jamesd.demon.co.uk/csc/faq.html ]