On Fri, Sep 07, 2007 at 03:00:36PM +0100, Wim Vanderbauwhede wrote:
: On 07/09/2007, Chas Owens <[EMAIL PROTECTED]> wrote:
: >
: > On 9/7/07, Wim Vanderbauwhede <[EMAIL PROTECTED]> wrote:
: > > The following program works fine in pugs r17041 (which is the rev of
: > > /usr/bin/pugs on feather):
: > >
: > > my $r=\{say $x+1};
: > > my $x=2;
: > > $r();
: > >
: > > With r17041, this gives 3;
: > > However, on the latest pugs (r17615 or later), it gives an error:
: > > ***
: > >     Unexpected "$r"
: > >     expecting "=", "::", context, ":" or "("
: > >     Variable "$x" requires predeclaration or explicit package name
: > >     at pugs_var_bug.p6 line 1, column 4
: > > It would think that the r17041 result is correct.
: >
: > You can't use variables before declaring them, think use strict.
: 
: I agree with that, but I am not _using_ the variable, I am just creating a
: Code object for later execution.
: On execution of the Code object, the variables it accesses should of course
: be declared -- which they are.
: But on creation of a Code object, that is not necessarily the case.

Um, you can't even mention the variable without declaring it, or the
compiler will have no idea what you *mean* by the variable.  Older
pugs was buggy in that it didn't check for non-declaration till
run time, and that has since been fixed.  You seem to be suggesting
that declarations should come from the dynamic scope rather than
the lexical scope.  That would make it difficult to write closures,
and impossible to catch typos at compile time.

Larry

Reply via email to