What does this mean?

our sub outer ()
   our sub inner () { ... }

inner;  # defined?

I think this should be illegal. Nested named subs makes sense for 'my', with the rules of visibility matching the ability to clone the closure. But putting the nested sub into package scope is nonsense. It's really a different clone every time outer is called, and doesn't make sense to call unless outer is already pending.

If inner doesn't actually need anything from outer's block scope, then there is no reason to declare it nested. If you have something specific in mind, like creating specific clones on the fly, then the code in outer can explicitly post the version it creates to the package scope and make it clear exactly when it's being created.


our sub outer (::T $x)
   # explicitly create a new multi with every specialization
   state %didit;
   unless ++ %didit{ $x.HOW } {
      my multi sub inner (T $x)  {  ... }
      Package::<&inner> = &inner;

If anyone wants to show the proper syntax for doing that, I'd appreciate it.


Reply via email to