Could a "slang" resolve this?

For some meanings of "resolve", I guess it could.
Though again there's a reason for why things are the way they are:

Allowing infix < without preceding space would conflict with the postcircumfix < > construct which is used in Perl 6 for indexing/slicing associative data structures (like hashes) with string keys.
As in %stuff<key> but not limited to explicit hash variables, i.e. it can follow arbitrary expressions:

$ perl6 > ('xx'..'zz').classify(*.substr(1))<z> xz yz zz > {aa => 11, bb => 22, cc => 33, dd => 44}<cc> 33 > %(<aa bb cc dd> Z=> (11, 22 ... *))<cc> 33 > sub foo { return {bar => 42} } > foo<bar> 42

I believe in the general case, the compiler simply replaces ...<key> with ...{'key'}, causing the { } postcircumfix operator to be dispatched on the return-value object of the preceding expression at run-time (or die with a run-time error if the operator is not defined for that object's type).

The problem with code like 1<2 is that (as far as I understand it) as soon as the parser sees the opening angle bracket sticking to the right of an expression, it assumes it found an instance of the < > postcircumfix and tries to parse the following text accordingly.
If the actual text there does not match that expectation, the parser aborts with a syntax error. In this case, the error handling code is smart enough to look at the surroundings and figure out that you probably meant to use the < infix operator (numeric comparison) there, so it prints that instead of a generic a "syntax error".

Now in theory the parser could be written so it would try both possibilities (postcircumfix < > and infix <) when it sees an angle bracket after an expression like that, and continue parsing both variants until one of them hits a syntax error down the road and can be eliminated.
But I'm pretty sure that would violate the design principle of keeping the Perl 6 grammar as deterministic and "self-clocking" as possible, which seems to be very important to Larry Wall (and for which authors of slangs/macros or of Perl 6 syntax highlighters / IDEs etc. will probably be grateful).

So if you want your slang to only change the meaning of those simple cases (< between two number literals) which the compiler's error handling code can already detect anyway, that would probably be reasonably safe, but if you also want expressions like $number<5 to be interpreted as numeric comparisons, that would likely lead to all kinds of parsing difficulties.


In reply to Re^2: Porting (old) code to something else by smls
in thread Porting (old) code to something else by Tux

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.