Re: eshewing CLOS-style OOP in Common Lisp?
- From: "John Thingstad" <john.thingstad@xxxxxxxxx>
- Date: Mon, 19 Feb 2007 05:19:19 +0100
On Mon, 19 Feb 2007 02:59:40 +0100, Kaz Kylheku <kkylheku@xxxxxxxxx> wrote:
On Feb 18, 4:00 pm, "John Thingstad" <john.things...@xxxxxxxxx> wrote:On Mon, 19 Feb 2007 00:05:16 +0100, Kaz Kylheku <kkylh...@xxxxxxxxx> wrote:
> The symbol Draw is not properly namespaced in C++; in fact the
> language doesn't have a clean concept of a symbol So when you perform
> inheritance from these classes, there is a clash:
> class LotteryWidget : public Lottery, public GraphicsObject {
> public:
> void Draw(); // oops, what is this?
> };
> There is no such problem in Lisp, where classes do not serve as half-
> baked symbol namespaces.
[ snip ]
Erm.. C++ understands symbols. And it has namespaces.
In fact namespaces in C++ function about as packages in Lisp.
You must be working with some different C++ from the one that I have
been using to earn a living for more than a decade now.
The C++ that I think I know doesn't have anything as cleanly layered
and organized as Lisp symbols or packages.
class LotteryWidget : public lottery:Lottery, public
graphics:graphicsobject
{
public:
void Draw(): lottery:Draw() graphis:draw() {}
Is this some new syntax? The most recent C++ document I have is ISO
14882:2003, which still only defines a :: operator for scope
resolution. A colon after the function parameter list is allowed only
in constructor definitions, to introduce the member initializer list.
Sorry went a bkit fast there.
class definitions do indeed use ::
void Draw(): lottery::Draw(), graphis::draw() {}
class singelton
{
static int var;
static int get () { return var; }
static void set(int val) { var = val; }
}
singelton::set(5);
Anyhow I was thinking of namespaces.
These have the same function as packages except they can be nested.
(some implementations extend the package definition to allow nesting like ACL)
int i;
namespace A
{
int a, b, c;
namespace B
{
int i, j, k;
}
}
int main()
{
A::a++;
A::B::i++; // B's i
::i++; // the global I
}
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
.
- Follow-Ups:
- Re: eshewing CLOS-style OOP in Common Lisp?
- From: Kaz Kylheku
- Re: eshewing CLOS-style OOP in Common Lisp?
- References:
- eshewing CLOS-style OOP in Common Lisp?
- From: Peter Michaux
- Re: eshewing CLOS-style OOP in Common Lisp?
- From: Kaz Kylheku
- Re: eshewing CLOS-style OOP in Common Lisp?
- From: John Thingstad
- Re: eshewing CLOS-style OOP in Common Lisp?
- From: Kaz Kylheku
- eshewing CLOS-style OOP in Common Lisp?
- Prev by Date: Re: eshewing CLOS-style OOP in Common Lisp?
- Next by Date: attn: sallyann - genuinely super money - fisyo - (1/1)
- Previous by thread: Re: eshewing CLOS-style OOP in Common Lisp?
- Next by thread: Re: eshewing CLOS-style OOP in Common Lisp?
- Index(es):
Relevant Pages
|