🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). Log available at irclogs.raku.org/raku/live.html . If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 6 September 2022.
lucs How can I fix this regex to match a non-digit printable character?: / <!digit> & <print> / 01:17
m: so 'x' ~~ / <!digit> & <print> / 01:18
camelia WARNINGS for <tmp>:
Useless use of "so " in expression "so 'x' ~~" in sink context (line 1)
lucs m: say so 'x' ~~ / <!digit> & <print> /
camelia False
lucs m: say so 'x' ~~ / <!digit> /
camelia True
lucs m: say so 'x' ~~ / <print> /
camelia True
guifa <!digit> is a negative lookaround. "They match, but they don't consume a character" per docs. 01:24
guifa m: (m/ <!digit> <print> /).so.say for <x 3> 01:25
camelia True
False
lucs Oh, I see, neat.
Thanks.
guifa (the opposite is a positive look around with <?digit> 01:26
m: (m/ <?digit> <print> /).so.say for <x 3>
camelia False
True
gugod <-digit> is probably what you want
lucs Well, I don't want to match a space. 01:27
guifa also 01:28
m: (m/ <+print -digit> /).so.say for <x 3>
camelia True
False
guifa the initial plus is important, because otherwise it gets interpreted as a method call
lucs I think I'd better go reread the regexes doc page... 01:29
But yeah, all that solves my problem. 01:30
Oh, by the way, in the description of the <punct> 01:32
character class, what does "(only Punct beyond ASCII)" mean?
Voldenet m: say so "。" ~~ /<punct>/ 01:35
camelia True
Voldenet m: say so "。、!?「」『』" ~~ /^<punct>+$/ 01:36
camelia True
Voldenet utf-8 punctuation is also matched
welp, unicode
lucs Okay, but why "only", shouldn't it be "also"? 01:37
m: say so ',' ~~ / <punct> / 01:38
camelia True
Voldenet "Symbols" but only <:P> ones 01:40
so… <punct> means punctuation (including unicode punctuation)
lucs I'm probably having trouble parsing the English there. 01:41
Voldenet it appears fairly confusing for me also 01:42
guifa yeah, I think it should just say "Including non-ASCII symbols" or something akin to that 01:44
gugod m: (m/ <+punct> /).so.say for qw/ , . : " ' < > = /; 01:45
camelia True
True
True
True
True
False
False
False
lucs Perhaps more precisely, Unicode points of the Pc, Pd, Pe, Pf, ... categories.
I'm really love the fact that for example Raku variable identifiers allow any characters from the L* Categories. 01:50
m: my $Džoo = 21; say $Džoo * 2
camelia 42
lucs It opens up the possibility of sigil-like notational devices, to name variables that somehow go together in a similar way. 01:51
gugod m: my $x = 41; my $xᅠ = 43; say ($xᅠ+ $x)/2; 01:53
camelia 42
gugod
or some amusements :)
guifa m: my @v = 3,4,5,7,8; my $v̄ = .sum / .elems with @v; say "The mean is $v̄" 01:55
camelia The mean is 5.4
lucs I've successfully (in my code) for example used variables named like $ᵢfoo for variables representing an index into an array (instead of $foo-ndx or something like that).
guifa: Yep, same idea.
Unfortunately, the current Vim syntax highlighter for Raku doesn't recognize those L* as being allowed in variable names, and the coloring suffers. 01:57
tonyo . 02:52
Anton Antonov Is there a way to serialize grammar objects? (So, they can be reused in different sessions.) I am/was thinking "CBOR::Simple" can be used... 11:07
Currently, I use grammar source code print-outs. (Via "Grammar::TokenProcessing".) 11:08
lizmat Grammars are basically classes 11:09
if grammars couldn't be serialized like classes , we wouldn't have a Raku based on a Raku grammar :-)
just put a grammar in a file as you would a class, and use it 11:10
Nemokosch hm, how to put it 11:11
a grammar is not like a usual class one would serialize because it doesn't revolve around data whatsoever 11:12
the "data" of a grammar is all "hardcoded" into methods
so "serializing" it, by usual terms, would mean basically a no-operation between using the very same "empty" (method-only/method-dominated) class twice 11:14
fair enough, you can call the source code of the grammar the serialization of it - with the usual security concerns of sharing code as data, if that is okay for the use-case 11:16
lizmat ah, ok, I guess I misunderstood the question 11:17
you should be able to call .raku on an instantiated Grammar object 11:18
it would basically give you a Match representation
m: grammar A { token TOP { .* } }; dd A.parse("foo") 11:19
camelia Match.new(:orig("foo"), :from(0), :pos(3))
Nemokosch I'm also not sure about the question but so far the way I understood it was a similar representation to, say, a Backus-Naur Form 11:20
Anton Antonov @lizmat "you should be able to call .raku on an instantiated Grammar object" -- I tried that on grammars I have generated and produced only the grammar (type) name. 11:22
Thanks for the interest lizmat and Nemokosch! My current solution is exemplified here : github.com/antononcube/Raku-Gramma...-code.raku 11:23
lizmat m: say Q|grammar A { token TOP { .* } }|.AST.statements.head.expression.DEPARSE 11:24
camelia grammar A { token TOP { .* } }
lizmat Anton Antonov ^ you want something like that ?
Anton Antonov @lizmat Yes, I just tried your example. Trying it on "bigger" grammars now. 🙂 11:25
tbrowder__ howdy, all 11:56
i wonder why module builders can't be easier to use. i would love to be able to run a raku script during the build portion without a giant hassle, 11:58
back later...
ugexe tbrowder__: its pretty simple to run a raku script during the build phase 15:50
what are you trying that isn't working as you expect?
kybr zef can't install Cairo because it can't find the library because I am on a mac and it is in /opt/homebrew/lib and zef doesn't know that. how do I tell zef where to look for the library? 16:04
ugexe raku doesn't know that 16:05
tonyo kybr: usan environment variable 16:06
most likely setting DYLD_LIBRARY_PATH
or LD_LIBRARY_PATH 16:07
ugexe tbrowder__: something like gist.github.com/ugexe/d2bb004eea9c...52deffe46f should work 16:10
kybr ugexe: i don't know how to use that 16:12
tonyo: no luck with DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH 16:13
tonyo try with LD_LIBRARY_PATH
that's a more standard one
kybr doesn't work. but thanks 16:14
a symlink worked 16:16
[Coke] symlink is the way to go. I think we have a writeup in some module's bug report somewhere. :| 17:06
I had similar issues on my m2 laptop trying to get something working with Nativecall
tonyo LD_LIBRARY_PATH is useful for testing things, it does work if set correctly 17:07
symlink is much easier/more permanent
patrickb docs.raku.org/language/nativecall#...is_ignored 18:31
tbrowder__ ugexe: that's great and helpful, but it need to be in the docs instead of or following the current entry. 20:27
if i get my current project working with it i'll take a shot at a doc PR. 20:28
thnx! 20:29
ugexe you could create a builder module to do it 20:43
see Distribution::Builder::MakeFromJSON
tbrowder__ er, i have trouble figuring out what's going on with that. 21:03
I can create a Makefile to run raku scripts. Can that be transformed into such a builder? 21:05
the immediate need i have is a way to search for certain font files on the host system, and copy them to a location known to the module after it is installed. 21:08
tonyo i've used LD_LIBRARY_PATH to write libyaml 21:11
bindings
tbrowder__ i would 21:14
disregard finger fumble... 21:15
ugexe i'm having trouble understanding what you are having trouble with. that sounds like it is just adding the appropriate `run ...` in the Build.rakumod file 21:35
if you show me what you think should work i can comment further 21:37
tbrowder__ No, the Build.rakumod is pretty clear, it's the other one that's not so clear. 21:47
regarding Build.pm, what is $dist-path on github/workflows? 21:49
er, Build.rakumod 21:50
$dist-path i guess is '.' from the author's view 21:55
ugexe It’ll be the directory the META6.json resides in 23:44