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

Heredoc issue in pugs.

11 views
Skip to first unread message

Yiyi Hu

unread,
Aug 22, 2006, 2:16:11 PM8/22/06
to perl6-l...@perl.org
#!/usr/bin/env pugs

my $a = q:t /END/
test
END;

$a.perl.say;

Above example works ok in pugs, But the problem is.
From S02

Heredocs are no longer written with <<, but with an adverb on any
other quote construct:

print qq:to/END/;
Give $amount to the man behind curtain number $curtain.
END

Which is correct?

Larry Wall

unread,
Aug 22, 2006, 2:44:18 PM8/22/06
to perl6-l...@perl.org
On Wed, Aug 23, 2006 at 02:16:11AM +0800, Yiyi Hu wrote:
: #!/usr/bin/env pugs

Both of them are. See the table further down that says:

Short Long Meaning
===== ==== =======
...
:t :to Interpret result as heredoc terminator
...

Larry

Daniel Hulme

unread,
Aug 22, 2006, 3:12:09 PM8/22/06
to perl6-l...@perl.org
> : my $a = q:t /END/
> : test
> : END;

> : print qq:to/END/;


> : Give $amount to the man behind curtain number $curtain.
> : END

> : Which is correct?

> Both of them are. See the table further down that says:

What about the semicolon? After the terminator, or after the opening
line?

--
"Your inertially corrupt space-time disagrees with me." -- Will McCarthy
http://surreal.istic.org/ It sounded right in my head.

Larry Wall

unread,
Aug 22, 2006, 3:38:16 PM8/22/06
to perl6-l...@perl.org
On Tue, Aug 22, 2006 at 08:12:09PM +0100, Daniel Hulme wrote:
: > : my $a = q:t /END/

: > : test
: > : END;
:
: > : print qq:to/END/;
: > : Give $amount to the man behind curtain number $curtain.
: > : END
:
: > : Which is correct?
:
: > Both of them are. See the table further down that says:
:
: What about the semicolon? After the terminator, or after the opening
: line?

Ah, missed that, thanks. On the opening line is correct, just as in
Perl 5. The heredoc is just a term with some indirection, and the
indirection is completely line oriented. The terminator must still
be on a line by itself, with nothing but whitespace. We could just
as easily have a POD indirection that said

print qq:from/FOO/;

and it would go looking for the nearest =begin FOO block to insert.
So syntactically, it's only sort of happenstance that with heredocs
the document happens to be "here". The inline-ness of it is secondary
to the line-orientedness of it, in my mind. And it is often not,
in fact, truly inline, as demonstrated by

print qq:to/FOO/, qq:to/BAR/;
...
FOO
...
BAR

It's really just a way to abstract a large string containing newlines
into a single token that doesn't.

Larry

Luke Palmer

unread,
Aug 22, 2006, 4:32:52 PM8/22/06
to perl6-l...@perl.org
On 8/22/06, Larry Wall <la...@wall.org> wrote:
> print qq:from/FOO/;

On a somewhat related, somewhat unrelated note, I am a little bit
worried about the false duality of :to and :from.

Luke

Larry Wall

unread,
Aug 22, 2006, 5:34:34 PM8/22/06
to perl6-l...@perl.org

Well, that's kinda why theres's no :from actually. It was probably
not beneficial to bring in a counterfactual example. Pod docs would
actually come in through %=POD<FOO> or some such. Heredocs are a
little more special because they have to interpolate from the local
lexical pad, so in that sense they really are a bit more in-line-ish.

Larry

Nathan Gray

unread,
Aug 22, 2006, 2:47:09 PM8/22/06
to Yiyi Hu, perl6-l...@perl.org
On Wed, Aug 23, 2006 at 02:16:11AM +0800, Yiyi Hu wrote:

If I remember correctly, Larry and Audrey discussed this at the
Chicago hackathon and updated the Synopsis at that time.

So my guess is that the Synopsis is correct.

-kolibrie

0 new messages