🦋 Welcome to Raku! raku.org/ | evalbot usage: 'p6: say 3;' or /msg camelia p6: ... | irclog: colabti.org/irclogger/irclogger_log/raku
Set by ChanServ on 14 October 2019.
Xliff Hi. I am trying to run my own RakuAST examples, but I keep getting errors that I am not seeing when I run files in t/12-spectest 02:42
I do this `RAKUDO_RAKUAST=1 perl6 test-ast.pl6`
And I get this error: "Cannot find method 'typed_panic' on object of type Raku::Grammar" 02:43
AlexDaniel codesections: hey 05:58
tellable6 2020-10-02T20:36:37Z #raku <Xliff> AlexDaniel: Yes. That's what I meant 05:59
Xliff jnthn: ^^ Errors when attempting to run RakuAST code from branch 06:44
tellable6 Xliff, I'll pass your message to jnthn
kylese Greetings! Sorry, probably I can't see the wood for the trees. But if there is, what is the recommended and native way of editing one single line or a few lines in a text file, preferable without re-writing the whole file, e.g. to (un-) comment some lines? (Or is it intended to call external tools, like 'sed'?) 07:37
moon-child my @lines = "fname".IO.lines; @lines[whatever] = '# ' ~ @lines[whatever]; spurt "fname", @lines.join("\n") 07:39
kylese moon-child, thank you! Works good. 07:59
colomon_ utterly baffled here. This morning I installed IO::String to help write some tests. Presumably when I did so it passed all its tests. But when I try to use “say” on an IO::String, I always get “Cannot do 'say' on a handle in binary mode”. But looking at the IO::String tests, they are almost ALL using say. What gives? 11:34
kylese colomon_, maybe the "String context operator" '~' ? (docs.raku.org/routine/~) (github.com/hoelzro/p6-io-string/) 11:44
colomon_ kylese: othedr way around: my $file = IO::String.new; $file.say: “Hello”; # fails with above message 11:59
kylese colomon_, my $file = IO::String.new; $file = open 'output.txt', :w; $file.say: “Hello”; $file.close; ? 12:57
timotimo that doesn't use IO::String though 12:59
timotimo $file is immediately overwritten with a regular IO::Handle 12:59
Xliff Will there be a code path for converting RakuAST to bytecode? What about the inverse operation? 14:46
moritz RakuAST currently produces QAST, so the old compilation chain that produces MAST and MovarVM bytecode also applies to it 14:52
no idea about deparsing bytecode; I think that's pretty much separate from RakuAST 14:53
Geth ecosystem: gfldex++ created pull request #553:
add Operator::DynvarOr
16:09
Geth ecosystem: a8039ef243 | (Wenzel P. P. Peppmeyer)++ (committed using GitHub Web editor) | META.list
add Operator::DynvarOr
16:21
ecosystem: ddbeefc73f | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | META.list
Merge pull request #553 from gfldex/patch-8

add Operator::DynvarOr Gonna merge this. Will figure it out later.
klebs hi everybody! 16:36
i was writing some raku just now, and i thought of a bit of syntax which would sometimes be very useful to me in my codebases 16:37
i thought id post it in here to see what you all think!
in some of my c and c++ programs, we could do something like this:
klebs #if 0 16:38
do_something();
#else
do_something_else();
#endif
i liked that syntax quite a bit, because i could flip that bit at compile time from zero to one to easily toggle which path the code took at runtime 16:39
klebs to me, it is much different than writing: 16:39
if 0 { do_something(); } else { do_something_else(); }
because that second way happens completely at runtime. to me, it indicates stylistically that it might be valid for one instance of the program to take either path at runtime 16:41
right now, in raku, i am basically just using block comments to comment blocks of code like so:
=for comment
**wait wrong keyword 'for', lets try this again:
=begin comment 16:42
stuff_i_dont_want_right_now();
=end comment
this is pretty good, but missing the flexibility of the c preprocessor stuff i described above 16:43
cutting right to the chase, what i am looking for is a clean way to switch between one of several blocks of code at *compile time*, with the same sort of semantics as the c preprocessor #if statements 16:45
sena_kun klebs, I am not sure words "flexibility" and "c preprocessor" are so close. The problem (IMO) is that the preprocessor is a completely separate language which knows absolutely nothing about actual code. Thus it is not only a horrible scary pain for everyone writing tooling, but also additional layer of complexity for the reader. E.g. you have variables A if Foo, but variables B if Bar, then you do some stuff with them without having even a real visual 16:46
difference (such as in if blocks, for example).
klebs totally agree :) 16:47
sena_kun klebs, is there a reason for e.g. conditionals to be strictly compile-time?
MasterDuke klebs: can't experiment myself right now, but the BEGIN phaser might be helpful 16:48
sena_kun I wonder if our optimizer is clever enough to do a right thing in `if True {} else { (something very big) }`
klebs really, at this moment, i would like a way to indicate to myself as the program writer that i am trying out several different options of code paths for this algorithm. only one of which is ever going to make it into the final program
the c preprocessor is ugly and hackish enough that it indicates to me that something needs to be cleaned up :) 16:49
actually, i take back the term 'ugly'
but 'hackish', i keep 16:50
i basically want a switch that i can flip *only during development* that indicates "take one of two paths"
the mechanism could be more flexible than "take one of two", but this is the common case, for me 16:51
klebs i basically want to know, whenever i look at that bit of code, no matter how far in the future, that i was experimenting with something and the two branches should never coexist at runtime 16:51
*should never coexist at runtime, or even in the final compilation unit 16:52
the c preprocessor was nice for this, but all that token pasting stuff was icky
there could already be something in raku that does exactly this or better, im just not quite sure what to grep for 16:53
maybe someone here has a trick they use for this kind of thing which is even better? 16:54
sena_kun Raku is different in this regard, as, of course, modules are precompiled, but you cannot really divide sources and executables.
So you can't do "I compiled it with flag foo, so now this flag is immovable", because the user will 1)compile it; 2)if needed, recompile it. Not consume a ready executable. 16:55
So not really sure what to suggest except comments.
klebs ah, yeah that makes total sense 16:57
sena_kun You can e.g. populate a constant with e.g. env var and then use it in conditionals. And this constant will be compile-time. But user will be able to run it with e.g. env var set to something different and will have different results.
Oops, last "run" implies "compile and run". 16:58
klebs at the end of the day, this is not exactly an essential feature, as i could write something like:
if 1 {
take_path_one(); 16:59
else{
take_path_two();
}
but it seems like the existing =begin comment feature is already so close to what i am looking for 17:00
what my mind wants to put in that spot is something that sounds like, "if 1, comment, else uncomment" 17:03
but that also does not indicate that i want a runtime "if" 17:04
the differences between these cases are indeed quite subtle, but i think important
it could be something like: 17:05
=begin comment(True)
codepath1();
=else
klebs codepath2(); 17:05
=end comment
timotimo a slang can be made for this purpose 17:06
klebs ah, this looks promising! 17:09
timotimo otherwise, your two paths could be in different modules and you can comment one use statement and uncomment the other, or use the "if" module if that still works and hasn't bit-rotted
or use a sub EXPORT to decide what to export
klebs thank you, these are all useful leads 17:10
creating a slang seems quite interesting to me, but I dont know very much about them. my understanding is that they can be used to modify the underlying grammar 17:11
timotimo of course building a slang is a little bit of work
that's right
there are slangs that add new stuff, like Slang::SQL, and there are slangs that modify existing stuff, like Slang::Tuxic 17:12
kiti_nomad[m] You shouldn't give up on D1
jdv79 the string formatter for DateTime is rounding - isn't it more conventional to just truncate? 17:13
kiti_nomad[m] You can develop two languages ​​at the same time like perl and raku.
Let them compete 17:14
klebs @timotimo the fact that this can even be done in raku is why I am 100% sold on raku, its infrastructure, and its ecosystem for the century
absolutely top notch functionality. this is the absolute highest caliber of engineering. i love raku 17:15
timotimo the argument against slangs is that you can make your code unreadable and unmodifiable for other developers, be that devs from the outside like opensource contributors, or devs from your team or company
klebs yeah, totally get that :)
sena_kun .oO ( another argument against slangs is they are not compatible with editors. totally so ) 17:16
timotimo comma gotta fix this man 17:17
klebs what are your thoughts on raku macros? I have read a few articles about them but have not yet fully understood 17:20
jdv79 lizmat: looks like you worked on time stuff. why is there rounding instead of truncating? 17:21
andrzejku what are modern raku books? 17:25
or best resources to learn 17:26
klebs github.com/Raku/doc
^that was incredibly useful to me 17:27
very high quality information
andrzejku ok 17:28
kiti_nomad[m] I am still learning perl😂 17:31
klebs have a nice day everybody! 17:35
thank you for the help sena_kun and timotimo! 17:36
rir_ colomon_, (As of @ 2 months ago.) Gnome::Gtk3 seems pretty good. I didn't know gtk at all, so found it a large bite. GTK::Simple was missing a couple widgets I felt necessary. 19:14
colomon_ rir_++ 19:24