1,154 karma · joined January 23, 2018
An ordinary identifier is composed of a leading alphabetic character which may be followed by one or more alphanumeric characters. It may also contain isolated, embedded apostrophes ' and/or hyphens -, provided that the next character is each time alphabetic.
https://docs.raku.org/language/syntax#Ordinary_identifiers
This means that '2-5-7' is NOT an identifier but the numerical value -10.
I agree :-)
> That doesn't mean I agree with every choice the Rakudo implementation has made
Indeed. Some of these choices have their roots in the late 1990's / early 2000's. Some of them make less sense now than they did then. FWIW, these are continuously evaluated by the current core team, to continue to improve Rakudo.
Only for those grapheme clusters that do not have a representation in Unicode!
Also, these negative i32s are really an implementation detail.
> but O(1) access to each grapheme is less important
Unless you want regexes to be a. correct in the unicode world, and b. be performant
grep(*.price < 10)
This is referred to as "Whatever-currying": https://docs.raku.org/type/Whatever* data.store.book.grep(*.price < 10).map(*.title)
Although personally I would write that as: data.store.book.map: { .title if .price < 10 }
which combines the filter / map into a single operation.my Int $a = 42; # ok
my Int $a = "foo"; # Type check failed in assignment to $a; expected Int but got Str ("foo")
Also, I'm unsure about MJD's feelings about adapting it to a Raku version.
For various reasons, I did not finish that: but what did got written, wound up as a 24-part blog series on dev.to: https://dev.to/lizmat/series/24075
The source code will be made available to allow community development of this project in the future.
$ raku -e 'say 9999999999999999.0 - 9999999999999998.0'
1
https://raku.org a = x ?? y !! z
And that's because a single : is used for many other semantics in the Raku Programming Language. And ?? and !! standout better in code. states.includes('VALID' | 'IN_PROGRESS')
is effectively the same as: states.includes('VALID') || states.includes('IN_PROGRESS')
See https://docs.raku.org/type/Junction$x ~~ $y is basically syntactic sugar for $y.ACCEPTS($x). Using ~~ involves an additional subroutine call, so there's a short-term efficiency issue (as in programs running more than a second or so the extra call will have been inlined).
But personally, I like the verbosity of $y.ACCEPTS($x) as it reads better for me, having been burnt by ~~ semantics in Perl, which was symmetrical.
This actually shows one of the secret powers of the Raku Programming Language: Junctions https://docs.raku.org/type/Junction
Alternately one could express this as:
$ rak '{.contains: <foo1 foo2 foo3 foo4 foo5>.all}'
Or using whatever currying: https://docs.raku.org/type/Whatever
$ rak '*.contains: <foo1 foo2 foo3 foo4 foo5>.all'
https://keyshorts.com/blogs/blog/37615873-how-to-identify-ma...
Indeed.
Also, it should be noted that the Raku Regex engine is not a state machine as such. The regex "slang" in Raku, is basically just another way to write code. Code that uses some state machine primitives underneath, for sure, but still code.
A grammar in Raku is nothing other than a class in which the methods are codegenned using the regex syntax. But a class nonetheless, which can also have attributes and "proper" methods.
This gives the Raku regex engine the flexibility needed to be able to parse Raku source code, and generate executable bytecode from that.
Well, but that's only one of the reasons why rak is a lot slower. There's something else going on, but I currently don't have the mindset to investigate this deeply.
- support for --ignoremark, which means you 'e' will match any accented 'e', such as éëêèęėē.
> I'm not totally clear on what kind of filtering `rak` does by default
By default, rak search all of the files that look like text, by reading the first 2K (if I remember correctly) and using some algorithm to determine "binaryness".
> I realize features and an expressive language is your main goal
Indeed.
> I wanted to see what it looked like from a perf perspective
The performance times you've given here, coincide with my findings. Which for the "sixteenth.txt" surprises me: a bare loop in Raku reading that file line-by-line finishes in 8 seconds for me. Which would be one order of magnitude less than the search result. Still not in `rg`'s ball park, but speed wasn't a big concern for me. But 8 -> 48 seconds is a pretty big difference, so I guess it's back to the drawing board for me on that one :-)
The angle brackets are syntactic sugar for word quoting.
<a b c>
is syntactic sugar for: ("a", "b", "c")
They can be used standalone. Or as postcircumfix on hashes: %foo<a> # the value of key "a" in hash %foo
%foo<a b c> # the values of keys "a", "b", "c" in hash %foo
There's a lot more to it than that, but that's the gist of it.https://docs.raku.org/language/quoting#Word_quoting:_%3C_%3E