It's been pointed out to me that A12 mentions:

Coercions to other classes can also be defined:

   multi sub *coerce:as (Us $us, Them ::to) { to.transmogrify($us) }

Such coercions allow both explicit conversion:

   $them = $us as Them;

as well as implicit conversions:

   my Them $them = $us;


I read S12 in detail (actually all the S's) before posting. Neither S12 nor S13 mentions C<coerce:<as>>, so I missed the A12 mention of it in my prep work.


Reading it now, my C<as>is a bit different, since I'll allowing options for defining the encoding and Unicode level. There may be other options that make sense in some contexts. Of course one could view the different encodings and levels as subclasses of Str, which I considered at some point, but it felt like it was going to get rather cumbersome given the cross product effect of the two properties.

Also, it is unclear if C<coerce:<as>> returns an lvalue or not, which my C<.as> does.

There's likely room for unification of the two ideas.

-- Rod Adams



Reply via email to