HaloO,

Jon Lang wrote:
My thoughts:
.HOW returns information concerning the implementation type; .WHAT
returns information concerning the value type.

My addition to these thoughts is that the WHAT and HOW are
cascaded. Let's say we start at level 0 with the objects,
thingies or however we want to name the atoms of our discourse.
At the zero level HOW, WHAT etc. are vacuously identical with
the object. They fall apart on level 1 from each other and among
them selfs but they are all sets of level-0 objects. In general
a level n concept contains level 0..^n "objects" and is the name
for a something they share.


.HOW and .WHAT stringify to something resembling the declarations that
would be used to create them.

Yeah. Stringification is relatively easy.


 class Foo { }
 my Foo $x;   # $x is Foo protoobject
 say $x;          # Foo
 say $x.WHAT; # Foo
 # This means we can only assign to $x something that isa Foo?

.WHAT is a Foo; stringifies to "Foo".

Note that $x is not initialized. This means the say has to
give something like "undef of Foo".


 role Bar { }
 my Bar $x;   # $x is ???
 say $x;          # ???
 say $x.WHAT; # ???
 # This means we can only assign to $x something that does Bar?

This one's tricky: roles cannot be instantiated, so .WHAT cannot be a
Bar.

What? I would say it is a level 1 WHAT. The next level concept
$x.WHAT.WHAT is role. BTW, there are not very many levels up.


 My gut reaction is that it's an anonymous class that does Bar
and stringifies to "Bar".  As long as you don't have both a role and a
class named "Bar", this should not be a problem, since the value type
isn't concerned with the implementation.  If it is possible to have
both a role and a class with the same name, you might be able to look
at .WHAT.HOW (or .^WHAT) to figure out with which you're dealing.
That is, the implementation type of the value type ought to provide
more elaborate detail as to the nature of the value type.

Hmm, are these meta accessors commutative? I.e. are
$x.WHAT.HOW and $x.HOW.WHAT the identical level 2 entities?
I would rather opt for $x.HOW of a role .WHAT.WHAT to be
the level 1 undef which is a set of interesting level 0 values
of undef.


 subset EvenInt of Int where { $_ % 2  == 0 };
 my EvenInt $x;  # $x is ???
 say $x;              # ???
 say $x.WHAT;  # Failure?
 # This means we can only assign to $x something that matches the constraint

my guess: .WHAT is an EvenInt that stringifies to "EvenInt".  If you
want to know about the structure of EvenInt (e.g., which class is it
based on, and which subset restrictions have been applied to it), you
would refer to .WHAT.HOW.

I would argue that $x.WHAT.WHAT is subset. I think the
idea of introspection is to have $x.WHAT.of return Int
as a level 1 WHAT and $x.WHAT.where return the constraint
closure. That said I would expect $x.HOW to be the identical
level 1 HOW object that $x.WHAT.of.HOW returns. When Int.WHAT.WHAT
is a role then this is undef of Int.


 class Dog { }
 class Cat { }
 my Dog|Cat $x;  # $x is ???
 say $x;               # ???
 say $x.WHAT;  # Failure?
 # This means we can only assign to $x something that isa Dog or isa Cat

my guess: .WHAT is a Junction that stringifies to "Dog|Cat".  To
access the details as to which classes are in the junction and how
they are joined, refer to appropriate methods (I believe that Junction
includes a method that returns a Set of its members) or maybe to
.WHAT.HOW.

On level 1 the WHATs of Dog and Cat are distinct. Dog|Cat is a level 2
WHAT. The level 2 $x.WHAT.HOW is a union. $x.WHAT.WHAT is class.


As well:

  class Dog { }
  role Pet { }
  my Pet Dog $x;
  say $x;
  say $x.WHAT;

My guess is that .WHAT would be a (dis)Junction of a Dog and an
anonymous class; the anonymous class does Pet and stringifies to
"Pet", while the Junction stringifies to "Pet Dog".

Again the say $x should print "undef of Pet Dog". Similar to above
$x.WHAT.HOW is an intersection. But $x.WHAT.WHAT is role|class and
the question is what their common abstraction is. Though, whatever
it is, you get it with $x.WHAT.WHAT.WHAT. But you can't call .new
on it. The $x.HOW might be Dog but $x can't store an object created
by its .new method because Dog.new.WHAT is in the part of the level
1 Dog that is not part of the level 2 WHAT Pet Dog. So to initialize
you need

  my Pet Dog $x = .new does Pet;

After this $x.HOW.HOW is Dog. Since the anonymous class created by
does is not of interest the $x.WHAT remains the level 2 WHAT Pet Dog.


I know that this sounds like "turtles all the way down" but the
levels of abstraction are all derived from the source code. So,
as long as your source is finite so is the WHAT structure over
the objects. The worst that can happen is that there is a 1:1
mapping between a lower level at the one above it.
--

"The unavoidable price of reliability is simplicity" -- C.A.R. Hoare
"Simplicity does not precede complexity, but follows it." -- A.J. Perlis
1 + 2 + 3 + 4 + ... = -1/12  -- Srinivasa Ramanujan

Reply via email to