On Thu, Mar 12, 2009 at 06:29:19PM -0700, Jon Lang wrote:
: > +To declare an item that is parsed as a simple term, you must use the
: > +form C<< term:<foo> >>, or some other form of constant declaration such
: > +as an enum declaration.  Such a term never looks for its arguments,
: > +is never considered a list prefix operator, and may not work with
: > +subsequent parentheses because it will be parsed as a function call
: > +instead of the intended term.  (The function in question may or
: > +may not exist.)  For example, C<rand> is a simple term in Perl 6
: > +and does not allow parens, because there is no C<rand()> function
: > +(though there's a C<$n.rand> method).
: 
: So if I were to say:
: 
:     rand $n:
: 
: is the compiler smart enough to notice that trailing colon and
: recognize this as an indirect method call rather than two adjacent
: terms?

No, currently under STD you get:

    Obsolete use of rand(N); in Perl 6 please use N.rand or (1..N).pick instead 
at (eval) line 1:

: Or would I have to say:
: 
:     rand($n:)
: 
: to get the indirect method call?

That would work, but then why not:

    rand*$n
    $n*rand
    $n.rand
    (1..$n).pick

In fact, given that you usually want to integerize anyway, I could
almost argue myself out of supporting the $n.rand form as well...

Larry

Reply via email to