At 10:11 PM 9/2/2001 -0400, Bryan C. Warnock wrote:
>On Sunday 02 September 2001 07:49 pm, Dan Sugalski wrote:
> > On Sun, 2 Sep 2001, Bryan C. Warnock wrote:
> > > Are prototypes going to be checked at runtime now?
> >
> > For methods, at least. Dunno about subs, that's Larry's call. I could make
> > a good language case for and against it. It adds overhead on sub calls,
> > which is a bad thing generally. (I'd be OK with the declaration "All
> > prototyped subs must have their prototypes known before the BEGIN phase is
> > done"... :)
>
>Well, here's a simple, yet stupid, idea.  (And I'd be content with having
>prototype declarations being a compile-time only requirement, too.)
>
>Code injection, a la Perl's -p and -n switch.
>
>sub foo (protoype) {
>     code
>}
>
>is compiled as
>
>sub foo { {
>     my $proto = prototype;
>     # prototype checking code here.  Must be non-destructive on @_
>     }
>     code
>}

A clever idea, and one I'd not though of. That's probably the best way to 
do it. Has some other issues, like do we allow prototypes like:

   sub foo ($$) {};

to be called as:

   foo(@bar)

if @bar has two elements in it?

We'll still have the case where we use prototypes to define calling 
conventions, in which case we won't allow subs to change their calling 
signature. (No sense checking registers 0-4 if the caller thought it was 
0-3, and if we pass enough info to know how many were used we might as well 
go and I'm OK with that, though. :)

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to