Ingo,

On Jul 11, 2005, at 12:30 PM, Ingo Blechschmidt wrote:
I am not sure about this. I think that .isa as a class method should
behave much as it does for an instance method. If we start supporting
things like Bar.isa(Class) then we start exposing the soft underbelly
of the meta-model to the outside world. Which IMO might not be a good
idea.
ah, you mean there could be problems, when, for example, Bar is not
actually a Class, but a PersistentClass or something, and one tries to
check whether a given $obj is a class by using .isa? I.e.:
  my $obj = get_a_class_or_something_else();
  if $obj.isa(Class) {...}    # XXX
Actually I was thinking that MyClass.isa(...) would work much as it did 
in Perl 5 (like an instance). But that access to the underlying MyClass 
class instance would not be as simple. Something like ::MyClass would 
provide access to the Class instance.
  class Foo {}
  Foo.isa(Object) # true
  Foo.isa(Foo)    # true
  Foo.isa(Class)  # false

  ::Foo.isa(Object) # true
  ::Foo.isa(Class)  # true
  ::Foo.isa(Foo)    # false

However, this is not speced anywhere, so I am just really making stuff up out of my head :)
IIRC, Larry once said that Class is actually a role, so then both the
builtin standard class object and PersistentClass .does(Class), so this
shouldn't be a problem, because one should use .does anyway (or ~~).
Yes, most of the basic types (Array, Scalar, Class, Hash, etc.) I 
always assumed would be Roles, while the concrete classes which 
incorporate these roles will be in the Perl6::* namespace.
But again, I am just making stuff up here :)

Stevan

So, to fix the above snippet:
  my $obj = get_a_class_or_something_else();
  if $obj.does(Class) {...}   # or
  if $obj ~~ Class    {...}


--Ingo

--
Linux, the choice of a GNU | There are no answers, only
generation on a dual AMD   | cross-references.
Athlon!                    |




Reply via email to