View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Re: [Xotcl] Real value of meta-class

From: Uwe Zdun <uwe.zdun_at_uni-essen.de>
Date: Tue, 30 Jan 2001 13:40:11 +0100

On Monday 29 January 2001 18:51, Rick Hedin wrote:
> Greetings.
>
> I worked through the example in the "Meta-Classes" section of the XOTcl
> tutorial. The result is the same whether myMetaClass is a metaclass or
> not. If you define it
>
> Class myMetaClass
>
> rather than
>
> Class myMetaClass -superclass Class

this is just a syntax example ... take a look at the next program example
in the tutorial:

  Class NoClassInfo -superclass Class
  ...<snip>...
  NoClassInfo Agent

you can see that "Agent" is of the class "NoClassInfo". Therefore,
changes on myMetaClass don't affect the Agent class.

If you do something, like:
  
  Class NoClassInfo
  ...<snip>...
  NoClassInfo Agent

this has an effect on "Agent" -> now it is not a class anymore, but an object
(and you've restricted the Object->info abilities).

Try now:

  Agent myAgent

which would in the first case, call:

  Agent create myAgent

and then create an object. Since Agent is not a class, you cannot derive
objects from it. Therefore, you now receive an error message:

  unable to dispatch method 'myAgent'

you will obtain the same result for any other class feature, like

  myAgent instproc ...
  myAgent instmixin ...

the sense of a metaclass is just to distinguish object and class
features ... for class object and class
features are available, for objects just the object features, like
"proc", "mixin", etc. are available.

>
> then
>
> Agent info superclass
>
> gives the same result.
>
> I understand, in theory, that one wants to derive a class from some "more
> basic" entity, but so far it seems to me that I can achieve everything I
> want to achieve by starting with a class, not a metaclass, and modifying
> it.
>
> Is there an example where being a metaclass results in different output?
>

Metaclasses give the programmer access to the class features. One important
class feature is how the language defines objects (in the Class->create and
Class->alloc methods). You require access to metaclasses only if you want to
mainpulate or extend the class features. Sometimes you may also want to
restrict certain class features, as for instance when you wrap C++ (or ITcl)
classes, which are non-dynamic. In most langauges without meta-classes or
meta-object protocolls you don't have access to these features. Thus most
often you cannot define a customized class system behavior in those languages.

Regards,

Uwe

-- 
Uwe Zdun
Specification of Software Systems, University of Essen
Phone: +49 201 81 00 332, Fax: +49 201 81 00 398
zdun_at_xotcl.org, uwe.zdun_at_uni-essen.de