On Tue, Feb 05, 2008 at 11:57:37AM -0800, Jonathan Lang wrote:
: Larry Wall wrote:
: > : Is it forbidden to use placeholder parameters in conjunction with
: > : "my"?  Or would it simply not do anything useful?  I ask because "Do
: > : what I mean" would seem to imply that 'my Dog $^foo' would specify
: > : $^foo's type as 'Dog'.  Though if you start doing too much of that,
: > : you're almost certainly better off explicitly defining a signature.
: >
: > Indeed.
: 
: So we're agreed that it could be abused if permitted.  Still, is it permitted?

No.  The only twigils currently permitted in a signature (and what
follows a declarator is a signature even if it doesn't look like it)
are "." and "!".  I don't see a good case for relaxing this.

I don't think we should allow a "my" to retroactively override a
parameter's type in any case.

: > : Also, how much trouble would we get in if we spelled the ubiquitous
: > : alias for a method's invocant as C< $^_ > instead of C< $self >?
: >
: > Then we're back to confusing people over the difference between the
: > object and the topic, and the topic-as-self breaks as soon as you
: > topicalize some other way.  And you can always throw in a "$_ := self"
: > or a "given self" if you really want it.  Plus $.foo is still only
: > one character longer than .foo so it doesn't really get you much most
: > of the time.
: 
: Huh.  My intention was not to topicalize the invocant.  Rather, I
: thought that $_ and $^_ would be treated as two separate variables: $_
: would be the topic, while $^_ would be the invocant.  I'm trying to
: think of why this distinction might not be.

Right now the placeholder twigils are specced in terms of rewrite rules
to twigil-less signatures, so the real variables never actually carry
the twigil.  Therefore $^foo and $foo are the same underlying variable
as it currently stands, just as $+foo really maps to a contextual
variable name somewhere that has no '+' as part of its name.  Note
also that $!foo and $foo are likewise really the same variable within
a method.  The $! form is just more emphatically private.

: Unless I'm missing something, it would be very much like what we have
: now, except that '$self' would be spelled '$^_' (shorter and not tied
: to English, but instead evocative of "I'm using a parameter that I may
: not have declared in the signature, sort of like what placeholder
: parameters do" and "I'm using the parameter that defines what this
: routine is talking about, sort of like what the topic variable does").

There is no $self, it's just the 0-ary function "self".  There is only a
variable if you specify it explicitly as the invocant in a signature.

Besides $^_ is just uglier than anything else I've seen today...

Larry

Reply via email to