On Sunday 02 September 2001 08:18 pm, Michael G Schwern wrote:
> On Sun, Sep 02, 2001 at 07:47:37PM -0400, Bryan C. Warnock wrote:
> > Are prototypes going to be checked at runtime now?
> >
> > The following parses, but doesn't do anything, including warn.
> >
> > my $a = sub ($) { print };
>
> Warning because you said you take an argument and then did nothing
> with it... that could be useful (I can actually think of a few
> situations where you'd want to do that, but they're rare) but it would
> involve scanning the subroutine at compile time to see if you use @_
> and what bits of it you use and if they're the right bits, etc...
>
>
> But since the current prototyping system... has a highly positive
> pressure gradient compared to the surrounding air, hopefully we
> won't be saddled with it in Perl 6 and will be able to write something
> more sensible, like RFC 57 suggests:
>
>     my $a = sub ($foo) { print }
>
> then it's simply a matter of seeing if that declared variable is ever
> used in the sub.

Oh.  That's not even what I was talking about, but I see your point.  I 
shall file that question away for later.

I was referring to the prototype not being checked at all.

my $a = sub ($) { my $b = shift; print $b, "\n" };
$a->();

Nothing (other than the undefinedness of $b).  I would expect either
   a) a prototype mismatch error, or
   b) A "prototype is useless with an anonymous subroutine" warning.






-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to