in reply to Re^2: Removing CODE slot in typeglob / Reversing "use subs ...;"
in thread Removing CODE slot in typeglob / Reversing "use subs ...;"

I wonder, is that a design accident or intended? you can assign to a typeglob slot (assigning a specific ref to that typeglob), but you cannot undef its value, you have to destroy the whole glob. You cannot assign e.g. an 'undefined subref' to a CODE slot, because... no such thing. Something undef is not a CODE ref.

Did you get told the rationale behind that? Does anybody know? Cloning a typeglob to get rid of one entry in it looks like "useless use of hoops" to me. IMHO there should be a syntax to remove slots, keys, values and all, as delete does with plain hashes.

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
  • Comment on Re^3: Removing CODE slot in typeglob / Reversing "use subs ...;"

Replies are listed 'Best First'.
Re^4: Removing CODE slot in typeglob / Reversing "use subs ...;"
by stvn (Monsignor) on Jan 04, 2008 at 17:10 UTC
    Did you get told the rationale behind that? Does anybody know?

    No one told me or gave me any rationale. Most just shrugged and said "yeah its kinda messed up like that". You might note the distinct lack of typeglobs in Perl 6, I don't think they are really thought of as having been that great an idea in the end.

    -stvn
Re^4: Removing CODE slot in typeglob / Reversing "use subs ...;"
by Anonymous Monk on Jan 04, 2008 at 10:51 UTC
    It has to do with the method cache