>From S12- which I'm just reading due to a blog post from jwrthngtn, I
haven't thought this through-
You can have multiple multi variables of the same name in the same
scope, and they all share the same storage location and type. These
are declared by one proto declaration at the top, in which case you
may leave the multi  implicit on the rest of the declarations in the
same scope. You might do this when you suspect you'll have multiple
declarations of the same variable name (such code might be produced by
a macro or by a code generator, for instance) and you wish to suppress
any possible warnings about redefinition.

Despite the danger of confusion, for the sake of being orthogonal, I'd
prefer multi vars be the same as multi subs/methods, in that they'd
have different long names referring to different things.

# Different type signatures means different long names, different
storage locations
my multi Dog $spot;
my multi Stain $spot;

# implicit typing to set each multi var
$spot = new Dog;
$spot = new Stain;

# Presuming only Dog can wag a tail this works

# This fails with dispatch-like exception, presuming both Dogs and
Stains implement this

That might be helpful for polymorphic attributes.

Or it could be that the silencing warnings on redeclaring variables
should not be spelled "multi," since it isn't quite the same as the
other uses of that keyword.


Reply via email to