On Fri, Nov 04, 2005 at 01:26:14PM -0600, Patrick R. Michaud wrote:
: A05 currently says:
: 
:     The first space in
: 
:          /[:w foo bar]/
: 
:     matches \s* before "foo". That's usually what you want, 
:     but if it's not what you want, you have a little problem. 
:     Unfortunately you can't just say:
: 
:          /[:wfoo bar]/
: 
:     That won't work because it'll look for the :wfoo modifier. 
:     However, there are several ways to get the effect you want:
: 
:         /[:w()foo bar]/ 
:         /[:w[]foo bar]/ 
:         /[:w\bfoo bar]/ 
:         /[:w::foo bar]/
: 
: I think this was discussed before, but I've lost the reference,
: so here's my question:  do the parens () and brackets [] have 
: the same meaning in this context, or is there some difference 
: between them that I'm overlooking?

Actually, I'd expect :w[] to be equivalent to :w([]), and a null array
would be 0 in a boolean context, so maybe that isn't equivalent.  I
think at the time the thinking was that scalars would always be
specified as :x(1) and lists would always be specified as :x[1,2,3],
but that seems a little bogus these days since it's perfectly possible
to write that as :x(1,2,3) and get a tuple/arglist if it gets evaluated
as a scalar.  And we also have :x{stuff} probably just being the equivalent
to :x({stuff}) for either hash or code values.

: Also, it seems sort of odd to me that ":w()" is the same as ":w(1)"
: and ":w" here -- I would've expected empty parens to connote 
: a null, undef, zero, or otherwise false value.  Is it generally 
: true that :xyz() as an adverb will be the same as :xyz(1)...?
: (I know that :xyz is the same as :xyz(1), but I'm curious about
: :xyz() ).

Think of it as being true not because the arguments are missing but
because the *first* argument is missing, and that argument defaults
to true.  :x is to :x() as .x is to .x(), where

    method x (Bool $arg = 1) {...}

Larry

Reply via email to