[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Delayed semantical interpretation



On Thu, Sep 23, 1999 at 11:11:36AM -0700, Peter Scott wrote:
> At 01:36 PM 9/23/99 -0400, John Porter wrote:
> >Peter Scott wrote:
> > > At 09:36 AM 9/23/99 -0400, John Porter wrote:
> > >
> > > >foo { 'bar', 'quux' };
> > > >
> > > >was foo declared as foo($) or foo(&)?
> > >
> > > But both are compile-time errors due to too many arguments, and the second
> > > one also  loses with
> > >
> > >          Type of arg 1 to main::foo must be block (not constant item)
> > >
> > > (this even without -w or strict... gotta watch those prototypes).  I don't
> > > see it.
> >
> >Well, I don't know what you're doing wrong.
> >
> >% perl
> >sub foo1($) { print "foo1: @_\n" }
> >sub foo2(&) { print "foo2: @_\n" }
> >
> >foo1 { 'bar', 'quux' };
> >foo2 { 'bar', 'quux' };
> >^D
> >foo1: HASH(0xbc050)
> >foo2: CODE(0xc3bec)
> >
> >I get the exact same results on both 5.004_04 and 5.005_60,
> >with and without -w and strict.
> 
> Fascinating.  Why would this behavior be platform-dependent?

It's not.  It's syntax dependent.  Clearly, you're retyping the code,
rather than copying and pasting, because if you were copying it, those
would be curly braces and not parentheses:

> % perl
> sub foo1($) { print "foo1: @_\n" }
> sub foo2(&) { print "foo2: @_\n" }
> foo1 ( 'bar', 'quux' );
> Too many arguments for main::foo1 at - line 3, near "'quux' )"
> foo2 ( 'bar', 'quux' );
> Type of arg 1 to main::foo2 must be block (not constant item) at - line 4, 
> near "'quux' )"
> Too many arguments for main::foo2 at - line 4, near "'quux' )"
> ^D
> Execution of - aborted due to compilation errors.

It fooled me at first too.  :)

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe