Is $heredoc = «END; the same as $heredoc = <<END; ?
thomas
I certainly hope not.
Quoting the delimiter is needed, by the way.
How is <<'END' disambiguated from <<'qw' list>>, anyway?
Regards,
Juerd
To get the qw// parse you must put a space between the << and the
quote. This is no hardship semantically, since qw// has always thrown
away initial and trailing whitespace.
Under one way of looking at it, it's just kind of a longest token
rule, since << as a term only ever means qw, and the heredoc tokens
are actually just long opening quotes: <<', <<", <<q/, etc. that have
to match a trailing quote.
Larry
Seeing the « in the context of a here-doc made me think "can you do a
»<< here-doc?"
So, something like :
@text = »<<END;
text1
END
text2
END
text3
END
text4
END
for @text { ...}
The hard question about this is: how do you know when you've hit the
last END? especially if the text you're loading looks like Perl code, or
if you have different <<END later in your code?
btw, should it be »<<, <<«, or »<<«?
-- Rod Adams
Nope, you can only hyper operators, not terms.
: So, something like :
:
: @text = »<<END;
: text1
: END
:
: text2
: END
:
: text3
: END
:
: text4
: END
:
: for @text { ...}
:
:
:
: The hard question about this is: how do you know when you've hit the
: last END? especially if the text you're loading looks like Perl code, or
: if you have different <<END later in your code?
I think you have a really good place for a split there. Then there's
no ambiguity about which is the internal separator and which is the
final delimiter.
: btw, should it be »<<, <<«, or »<<«?
Er, can I pick D?
Larry
Is whitespace between q and the delimiters still valid? Would it be
after <<? Would that mean using q as the first element in a qw-list will
hurt?
I hope the first answer is 'no' and all other questions are thus
rendered irrelevant. Not that I think getting rid of alphanumeric
delimiters is a good idea, though. I just fear complex parsing and
seemingly random syntax errors.
Juerd
Whitespace is certainly not allowed after <<q. Whether that means a
bare q should disallow whitespace is another matter. Certainly we've
taken the step of disallowing whitespace between a sub name and its
parentheses, so it's possible we could do it to q// as well, as long as
it's still possible to put whitespace between a two-part quote:
tr[a-z]
[A-Z];
But allowing the first whitespace was just a matter of being consistent.
I don't think it's a consistency we have to be consistent about, though.
Larry
> On Thu, Nov 25, 2004 at 11:59:21AM -0600, Rod Adams wrote:
> : Seeing the « in the context of a here-doc made me think "can you do a
> : »<< here-doc?"
>
> Nope, you can only hyper operators, not terms.
Incidentally, just like mathematically (albeit slightly loosely) an
element of a set can be thought of as a function from any singleton, would
it be possible for Perl 6 to provide a fast (under the syntactical point
of view) way to promote a term to a function returning it?
Michele
--
Not really. It was an insider joke. If you need to ask, you won't
get the answer. I never said I was a nice guy.
- David Kastrup in comp.text.tex, "Re: \slash and /"
sub mysub($x) {
return sub { $x }; # the sub{$x} is the construct
}
?
David
or the perl6
$xsub = { $x };
I am a little confused if the following is valid perl6:
our &xsub = { $x };
I believe that would work and install this function in the package global
symbol table because &xsub is the reference to the function xsub.
If you wanted to get a function for each element in an array @a, I suppose
you can say:
sub makefunc($x){{$x}}
@funcarray = @a>>.makefunc;
And that can also be shortened to:
@funcarray = @a>>{my $x=$^x;{$x}};
--abhijit
>> Incidentally, just like mathematically (albeit slightly loosely) an
>> element of a set can be thought of as a function from any singleton,
>> would it be possible for Perl 6 to provide a fast (under the syntactical
^^^^
^^^^
>> point of view) way to promote a term to a function returning it?
>>
> What's wrong with the perl 5:
>
> sub mysub($x) {
> return sub { $x }; # the sub{$x} is the construct
> }
>
> ?
^^^^
^^^^
Michele
--
The amount of repetition repetition isn't that great.
- Ignacy Sawicki in comp.text.tex
thread "Bug in FeynMF's Queues?"
> or the perl6
>
> $xsub = { $x };
Sorry, I was missing the obvious...
Michele
--
> [...] is like requiring to play tennis with a square ball.
Which admittedly makes the game more interesting.
- Giuseppe "Oblomov" Bilotta in comp.text.tex (edited)
> I am a little confused if the following is valid perl6:
>
> our &xsub = { $x };
No. Illegal attempt to assign to a reference. You want aliasing/binding instead:
our &xsub := { $x };
(I like to think of := as "assignment to symbol table entry".)
> If you wanted to get a function for each element in an array @a, I
> suppose you can say:
>
> sub makefunc($x){{$x}}
> @funcarray = @a>>.makefunc;
You're attempting to call a sub as a method. You want:
@funcarray = »makefunc« @a;
Damian
Unaries only take "hyper" on one side, so that would just be:
@funcarray = makefunc« @a;
And if makefunc is declared with a single argument, it can probably be
called as a method anyway, since we try to keep those indistinguishable.
Possibly it would need to be declared multi.
Larry
No, not an error. Lexical pads work just like symbol tables in Perl 6.
You can muck around with them, too. Hooray!
In fact, I expect that piece of code to be rather common in Perl 6.
Luke