According to S12, it is possible to supply the object layout to bless(), like so:

$object = $class.bless(:CREATE[:repr<P6opaque>] :k1($v1) :k2($v2))

But in the section "Introspection", "layout" is a class trait. Does this mean that classes have a default layout that can be overriden for individual objects?

If the answer is "yes", what is the reason that somebody would want to have some objects of the same class as P6Opaque and others as PyDict? I can imagine needing to be able to *convert* from one layout to another, but then the converted object appears to me to belong to a different class (probably in a different language) and then layout should perhaps be an adverb for something like convert() or cast()*, instead of for bless().

Another reason for saying that the object laid out differently is a different class is that if for whatever reason you want some object either as P6Opaque or PyDict then you may also want both representations simultaneously, effectively requiring "two objects".

What am I missing? A good example of the need of overriding the default class layout will suffice...

--abhijit

* maybe not even then, because we'd be saying
  $current_obj.cast($otherclass), and $otherclass would know it's own
  layout.

Abhijit Mahabal http://www.cs.indiana.edu/~amahabal/

Reply via email to