Re: eshewing CLOS-style OOP in Common Lisp?



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/
.



Relevant Pages

  • Re: Visual C++ vs Visual C#
    ... int main ... We've added namespaces and shift operators for no gain, ... scope, and using the same name in different scope. ... Still no pointers. ...
    (microsoft.public.vc.language)
  • vde2: vdeq intermittently sets wrong permissions
    ... vdeq sometimes sets inappropriate permissions on a temporary socket, ... int main ... Versions of packages vde2 depends on: ...
    (Ubuntu)
  • Re: C is too old? opinions?
    ... I am relativ new to the impressive and powerfull C language, but i thinks it is obsolete... ... Why has C not namespaces and a "area idea" where some methods and fields could be hidden from the outside? ... private int[] myStack; ... If i was a really good programmer (which i'm not... ...
    (comp.lang.c)
  • Re: APT problems (416 error and "uncaught exception") (RESOLVED)
    ... When running "aptitude update", the output ends with ... int, int, int, unsigned int, int, const PackageUniverse&) [with ... Sample output follows (issued command was "apt-get install ... Try 'apt-get -f install' with no packages (or ...
    (Debian-User)
  • Re: C is too old? opinions?
    ... I am relativ new to the impressive and powerfull C language, ... Why has C not namespaces and a "area idea" where some methods and ... private int[] myStack; ... public int pop(); ...
    (comp.lang.c)