On Tue, Jun 12, 2018 at 2:16 PM, JJ Merelo <jjmer...@gmail.com> wrote:
> This is what the documentation says: https://docs.perl6.org/syntax/WHAT
> You can override it, but we'll pay no attention anyway, basically. So you
> can't achieve it otherwise, I guess.

It is easy to achieve.

    sub user-made-what ( ::Type ) { Type }

    say 42.&user-made-what; # says (Int)

>
> El mar., 12 jun. 2018 a las 21:14, JJ Merelo (<jjmer...@gmail.com>)
> escribió:
>>
>>
>>
>> El mar., 12 jun. 2018 a las 21:11, Brandon Allbery (<allber...@gmail.com>)
>> escribió:
>>>
>>> I should clarify this, but I'm not recalling full details at the moment
>>> which is why I didn't originally.
>>>
>>> Perl uses a metaobject protocol (MOP, which you'll see in various places
>>> in the docs). The "macro" to access the metaobject is the .HOW
>>> pseudo-method. If you do this for a normal class or object of that class,
>>> you get Perl6::Metamodel::ClassHOW back. This is what the .^method syntax is
>>> accessing; it's short for (thing).HOW.method((thing), ...). The metaclass
>>> doesn't magically know its children, so the object has to be used once to
>>> get at its metaclass and a second time to tell the metaclass what it is to
>>> introspect.
>>>
>>> I'm not seeing documentation for what .WHAT actually does; it (correctly)
>>> notes that it's implemented specially within the compiler (hence "macro")
>>> but not how you achieve it otherwise. Then again, .HOW has the same issue;
>>> there's a bit of a bootstrapping issue with getting at the metamodel, you
>>> need to have it first. Which is why it's wired into the compiler and gets
>>> those uppercase pseudo-method names.
>>
>>
>> All the metamodel is not exactly part of the language; it's part of the
>> compiler. So it's in the gray NOT-SPECCED zone regarding documentation of
>> "Perl 6" the language, as oposed to "Perl 6, the implementation by Rakudo".
>> But it's a gray zone and sometimes you fall short of documenting things like
>> WHAT. I'll see what we can in that area.
>>
>> JJ
>>
>
>
> --
> JJ

Reply via email to