Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

say and print (pugs)

5 views
Skip to first unread message

Ovid

unread,
Apr 8, 2005, 2:07:06 AM4/8/05
to perl6-l...@perl.org
You know, this should be simple and maybe I'm overlooking something
obvious. I was trying out Pugs and my first program worked great:

for 1 .. 6 -> $var {
say $var;
}

The second version didn't:

for 1 .. 6 {
say;
}

For the life of me, I can't recall if "say" (or "print", for that
matter) should default to the current topic. So I figured I would
check the docs. Grepping for "say" or "print" is like trying to sip
from a firehose. I realize it's unlikely that we have an index for the
Perl6 docs, but though it would be nice. I guess we can wait for the
phantom volunteer on that :)

In any event, where the heck do I find the docs for "say" and "print"?
Perl6::say doesn't default to $_, but I'm not sure if that
implementation is correct, either.

Cheers,
Ovid

--
If this message is a response to a question on a mailing list, please send
follow up questions to the list.

Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/

Luke Palmer

unread,
Apr 8, 2005, 2:20:08 AM4/8/05
to Ovid, perl6-l...@perl.org
Ovid writes:
> You know, this should be simple and maybe I'm overlooking something
> obvious. I was trying out Pugs and my first program worked great:
>
> for 1 .. 6 -> $var {
> say $var;
> }
>
> The second version didn't:
>
> for 1 .. 6 {
> say;
> }
>
> For the life of me, I can't recall if "say" (or "print", for that
> matter) should default to the current topic. So I figured I would
> check the docs. Grepping for "say" or "print" is like trying to sip
> from a firehose. I realize it's unlikely that we have an index for the
> Perl6 docs, but though it would be nice. I guess we can wait for the
> phantom volunteer on that :)

Well, say does default to $_. But grepping the synopses can be a bit
difficult. I don't believe the semantics of say are spelled out in the
synopses anyway :-)

Once the perl 6 implementation gets more mature, I'd love to start a
"learners reference". It's an idea I've had for a while. Basically,
when you see an expression like:

begin $handle: $x <== 1..5;

You might not understand all of it. You'd look up 'begin' in this
document, to find nothing (which would be indicative that it is
user-defined, not that it isn't in this document. This document would
have a very brief description of everything, with information about
where to find more information). Then you'd look up <==, because that's
the next biggest thing you don't understand. And it would tell you.
Then you'd look up :, and look through the examples to see which one
matches the context you're looking at (that's how we would handle
overloaded symbols). A document like this makes it a lot less scary to
add new syntax to the core (which may or may not be a good thing), and
will certainly improve the learnability of Perl 6 by reading rather than
writing, a property that Perl 5 never had.

Luke

0 new messages