In creating some new Perl 6 programs I've run across several instances
I'm confused about, to wit:

Example 1
---------------

> my %h; say 'false' if !%h<a>:exists;
Unexpected named parameter 'exists' passed

Example 2
---------------

> my %h; say 'false' if not %h<a>:exists;
false

It looks like '!' doesn't work as I thought it was supposed to.  But,
I just discovered that when I use parens, it works.

Example 3
---------------

> my %h; say 'false' if !(%h<a>:exists);
false

I presume the parens would cure the similar things I've noticed with
other classes.

When I look at the docs on Operators I see this:

<quote>
prefix !

multi sub prefix:<!>(Mu) returns Bool:D

Negated boolean context operator.

Coerces the argument to Bool by calling the Bool method on it, and
returns the negation of the result. Note that this collapses
Junctions.
</quote>

<quote>
prefix not

multi sub prefix:<not>(Mu $x) returns Bool:D

Evaluates its argument in boolean context (and thus collapses
Junctions), and negates the result.
</quote>

Those two definitions look very similar to my eyes, but I think the
subtle difference is intentional.But they are not identical.

Is there some rule of thumb here that a Perl 6 wannabe can grasp in
Perl 5 terms (e.g., prefer 'not' over '!')?  Or am I going to have to
go deep early into the object class structure?

Many thanks.

-Tom

Reply via email to