doc icon indicating copy to clipboard operation
doc copied to clipboard

/<!>/ is ENODOC

Open gfldex opened this issue 3 years ago • 4 comments

The failing assertion¹ <!> is specced in S05-mass/stdrules.t but missing in /language/regexes .

Example:

    my @texts = 'One should love peace.', 'One should break peace.', 'One should hate peace.';
    my @unaccaptable-behaviour = <break hate>;
    say @texts.grep(/ [ @unaccaptable-behaviour && <!> || 'love' ] \s peace /);

¹) I made that name up. A better name … would be better.

gfldex avatar Apr 26 '22 14:04 gfldex

<?same>, <!same> and <at()> are also missing.

gfldex avatar Apr 26 '22 14:04 gfldex

Is it also the case for <?>?

FCO avatar Apr 27 '22 00:04 FCO

<?> is documented as "Always succeed" assertion.

gfldex avatar Apr 27 '22 08:04 gfldex

<?> is documented as "Always succeed" assertion.

From S05, <!> is "Inverse of <?>, viz., always returns false." The fact that <?> doc keeps "always" but switches True to "succeed" suggests to me the natural name for <!> in the doc would be "Always fails" assertion.

<?same>, <!same> ... <at()>

Looks to me like same and at are (currently) not in the Rakudo repo or roast but instead the NQP repo and its tests (code here, tests here). So, perhaps, they're not part of roast which means, perhaps, that they don't yet officially exist, which explains, perhaps, why they're not (yet?) documented?


If anyone is interested in the point at which the same assertion was added to Rakudo (well, NQP/nqp), see this match in #perl6.


From SO5:

/ <?same> / # true between two identical characters

My strawman proposal for its name in the doc for Raku, if/when it ever gets added to that rather than doc for NQP, is "Between two identical characters" assertion.

Also note, from SO5:

It is legal to use any of these assertions as named captures by omitting the punctuation at the front. However, capture entails some overhead in both memory and computation, so in general you want to suppress that for data you aren't interested in preserving.

I suggest the doc mentions something to that effect, if indeed we add same to Raku doc.

From S05:

To anchor to a particular position in the general case you can use the <at($pos)> assertion to say that the current position is the same as the position object you supply.

FWIW I'm pretty sure the type for $pos in the current implementation is assumed to be Int or perhaps Numeric coerced to Int.

raiph avatar Apr 28 '22 19:04 raiph