pugs-comm...@feather.perl6.nl wrote:
Modified:
docs/Perl6/Spec/S02-bits.pod
Log:
[S02] remove 1/2 and +2-3i literal forms, now rely on angle dwimmery for
literals,
or constant folding otherwise.
<snip>
I find this an interesting change, and I can see how it would simplify some
things, even though I would miss the old behavior.
But this reminds me of what I see as a tangential issue, which I want to raise.
How would Perl 6 support someone wanting to write a numeric literal that is so
long that they would want to split it over multiple source code lines, such as a
very long integer that takes a few hundred or thousand characters to write, or
an X/Y rational composed of 2 such integers, but they want to keep their source
code under the 80 chars per line mark.
I'm not currently aware that Perl 6 provides some kind of "continuation marker"
that one could put between pieces of such a literal, so that they could split
those pieces otherwise with whitespace but then the parser would treat the code
as if said whitespace wasn't there, but I think Perl 6 should have this. It
would need to work both outside any quoting constructs as well as inside any
angle dwimmery.
On one hand I would think the mnemonics of "~", which are stitching things
together, would work great for a continuation marker, but that "~" seems to
already be established in Perl 6 as indicating a string data context, such that
it is used for casting things into Str or catenating 2 strings. However, I will
use "~" below for the sake of illustration.
my $some_pi = 3.141592653589793238462643383279
~ 5028841971693993751058209749445923078164
~ 0628620899862803482534211706798214808651
~ 3282306647093844609550582231725359408128;
my $a_rat = <48111745028410270193
~ 8521105559/64462294895493038196
~ 442881097566593344612847564823>;
As a slight extension to this, one should be able to use that same continuation
character between 2 consecutive string literals so that they are parsed as if
they were one string literal, so that one could also split those over source
code lines, without the vaguarities of source code line endings affecting the
value of the string like a here-doc or literal line breaks would. I grant that
this could be redundant with regular constant folding of the already defined "~"
operator, but using the continuation marker instead for this could spare concern
about precedence issues same as <1/2> does versus 1/2 after today's changes.
my $a_string = 'hello this world'
~ ' how are you today';
Now I think in the wider world some precedent exists for using the logical-not
character ¬ as a continuation marker, but that isn't an ASCII symbol and we
would want something ASCII for the continuation marker. Also I think using the
backslash for such a marker would be a bad idea.
While this isn't an operator per se, if it had to be put in the precedence
table, I would think it would have the highest possible precedence; it would be
eliminated during one of the earliest parsing phases, during tokenization I
believe, and then all the other parsing rules would come into effect following
that elimination, except for the big one that any literal continuation chars
inside a quoted string are taken as normal characters as usual.
So can we please have this continuation marker thing, and what do you think it
should look like?
Thank you in advance.
-- Darren Duncan