🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel! Set by lizmat on 25 August 2021. |
|||
00:08
reportable6 left,
reportable6 joined
|
|||
Voldenet | Bscan: cool vscode support, as an improvement consider using nqp::getcomp('Raku').compile for massive performance boost and some additional checks | 00:19 | |
00:39
frost joined
|
|||
Bscan🍺 | Thanks voldenet! I'll take a look at getcomp. Additional checks (or symbol information) would certainly be nice. The Perl Navigator has Perl::Critic and inspects the symbol table for various features, so I'm certainly looking for additional sources of information for the Raku version. | 00:51 | |
01:39
linkable6 left,
evalable6 left
01:42
evalable6 joined,
linkable6 joined
01:46
melezhik joined
|
|||
melezhik | .tell patrickb sparkyci did see your new commits in DevelExecRunerGenerator, I restarted the daemon and new build succeded - sparrowhub.io:2222/report/346 , I am working on SparkyCI stability ... | 01:47 | |
tellable6 | melezhik, I'll pass your message to patrickb | ||
melezhik | .tell SmokeMachine - thanks! I will think about badges , first I want to make SparkyCI works stable ... but yeah I agree badges would be convenient ... | 01:48 | |
tellable6 | melezhik, I'll pass your message to SmokeMachine | ||
01:51
kjp left
01:56
hythm left
01:58
kjp joined
02:25
melezhik left
03:25
statisfiable6 left,
releasable6 left,
nativecallable6 left,
tellable6 left,
sourceable6 left,
greppable6 left,
shareable6 left,
linkable6 left,
bisectable6 left,
committable6 left,
notable6 left,
coverable6 left,
unicodable6 left,
reportable6 left,
evalable6 left,
quotable6 left,
benchable6 left,
bloatable6 left
03:26
unicodable6 joined,
bisectable6 joined,
sourceable6 joined,
releasable6 joined,
committable6 joined,
Guest35 left
03:27
evalable6 joined,
linkable6 joined,
greppable6 joined,
shareable6 joined,
coverable6 joined,
tellable6 joined,
notable6 joined,
benchable6 joined
03:28
nativecallable6 joined,
reportable6 joined,
quotable6 joined,
bloatable6 joined,
statisfiable6 joined
03:37
frost left
04:08
defaultxr left
04:25
BinGOs left,
Altreus left,
bingos joined,
Altreus joined
04:28
zostay left,
Matthew|m left,
maettu left,
dpk left,
JRaspass left,
maettu joined,
dpk joined,
zostay joined,
JRaspass joined
04:31
Matthew|m joined
04:41
Altai-man joined
04:44
sena_kun left
05:44
tellable6 left,
quotable6 left,
releasable6 left,
greppable6 left,
evalable6 left,
nativecallable6 left,
shareable6 left,
notable6 left,
statisfiable6 left,
reportable6 left,
bisectable6 left,
bloatable6 left,
unicodable6 left,
sourceable6 left,
committable6 left,
coverable6 left,
linkable6 left,
benchable6 left,
quotable6 joined,
releasable6 joined,
bisectable6 joined
05:45
unicodable6 joined,
bloatable6 joined,
tellable6 joined,
sourceable6 joined,
shareable6 joined
05:46
greppable6 joined,
benchable6 joined,
evalable6 joined,
reportable6 joined,
nativecallable6 joined,
statisfiable6 joined,
committable6 joined,
coverable6 joined,
linkable6 joined
05:47
notable6 joined
06:08
reportable6 left
06:10
reportable6 joined
06:27
lichtkind joined
06:39
abraxxa joined
06:44
abraxxa left
06:59
JRaspass left,
JRaspass joined,
abraxxa joined
07:30
Sgeo left
|
|||
Nemokosch | > <Voldenet> m: my @sth = <this>; given @sth { $_ = "this won't work" }; say @sth | 08:15 | |
well, why does this not work? | |||
and what does this have to do with "immutable values" anyway | 08:16 | ||
08:16
m_athias left,
nine left
08:17
nine joined,
m_athias joined
|
|||
MasterDuke | weekly: marketplace.visualstudio.com/items...-navigator | 08:19 | |
notable6 | MasterDuke, Noted! (weekly) | ||
Nemokosch | > <Voldenet> m: my @sth = <this>; given @sth { @_ = "it also works" }; say @sth | ||
this also doesn't work as one can see by the input but I wouldn't have expected this to work anyway | |||
there is no hint that @_ would exist as a topic variable so no surprise that it is indeed not a topic variable | |||
aaah, yet another example that sigils were a mistake | 08:24 | ||
if you assign the same arrays to a scalar container, it works flawlessly | |||
08:52
frost joined
09:00
grondilu joined
|
|||
grondilu | m: say 0x<aa ff> | 09:01 | |
camelia | ===SORRY!=== Error while compiling <tmp> Confused at <tmp>:1 ------> say 0⏏x<aa ff> |
||
grondilu | m: say :16<aa ff> | ||
camelia | ===SORRY!=== Error while compiling <tmp> Malformed radix number at <tmp>:1 ------> say :16<aa⏏ ff> expecting any of: number in radix notation |
||
grondilu thought one of these would work | |||
m: say <aa ff>.map({:16($_)}) # feels verbose | 09:03 | ||
camelia | (170 255) | ||
09:04
silug left
|
|||
grondilu | m: say blob8.new: <aa ff>.map({:16($_)}) | 09:04 | |
camelia | Blob[uint8]:0x<AA FF> | ||
grondilu | in the output here the 0x<.. .. ...> notation is used | ||
09:05
silug joined
|
|||
Nemokosch | what is the goal? | 09:05 | |
grondilu | to make list of integer from their hex representation | ||
integer*s* | 09:06 | ||
Nemokosch | I don't think you can just pass a list instead of a number 🤔 | 09:07 | |
tbh this feels just like passing a sequence of values instead of a value to any function | 09:08 | ||
if you have two numbers, why not just write them? (0xaa, 0xff) | 09:12 | ||
and if you have an indefinite number of values, resorting to some literal syntax isn't a good idea anyway | 09:13 | ||
grondilu | often blobs on the web are displayed as a sequence of bytes in hex. It would be convenient to be able to paste that and turn it into the relevant raku code easily. | 09:53 | |
like for test vectors in crypto | |||
Nemokosch | well you can stick to the "verbose" solution, although at that point I'd rather use a whatever curry | 09:56 | |
09:57
Nemokosch joined
|
|||
Nemokosch | m: dd <beef cab>.map(*.&parse-base: 16) | 09:57 | |
camelia | (48879, 3243).Seq | ||
09:58
Nemokosch left
|
|||
grondilu | m: dd <beef cab>>>.&parse-base: 16 | 09:59 | |
camelia | (48879, 3243) | ||
grondilu | works, but still verbose IMHO | 10:00 | |
it is better than .map({:16($_)}), though | |||
Nemokosch | well if you want something shorter, define it for yourself, this is Raku after all | 10:03 | |
10:03
Nemokosch joined
|
|||
Nemokosch | m: sub hex(@nums) { @nums>>.&parse-base: 16 } dd hex <beef cab> | 10:04 | |
camelia | ===SORRY!=== Error while compiling <tmp> Strange text after block (missing semicolon or comma?) at <tmp>:1 ------> b hex(@nums) { @nums>>.&parse-base: 16 }⏏ dd hex <beef cab> expecting any of: infix infix… |
||
Nemokosch | oh okay | ||
m: sub hex(@nums) { @nums>>.&parse-base: 16 }; dd hex <beef cab> | |||
camelia | (48879, 3243) | ||
10:04
Nemokosch left
10:07
Sankalp joined
|
|||
Nemokosch | you could define an operator as well ofc but that may not work in REPL | 10:07 | |
10:14
thegargler joined,
Altai-man left
10:15
Altai-man joined
10:27
thegargler left
10:42
sena_kun joined
10:51
frost left,
frost joined
|
|||
Geth | doc: a6177bce97 | (Peter du Marchie van Voorthuysen)++ | 3 files Document X::Cannot::Empty |
10:55 | |
doc: 159c26ca3e | (Peter du Marchie van Voorthuysen)++ | doc/Type/X/Cannot/Empty.pod6 Add example of failing with X::Cannot::Empty |
|||
doc: 199e96b00c | Altai-man++ (committed using GitHub Web editor) | 3 files Merge pull request #4070 from dumarchie/master Document X::Cannot::Empty |
|||
linkable6 | Link: docs.raku.org/type/X::Cannot::Empty | ||
problem-solving: e5b8cbf16d | (Juan Julián Merelo Guervós)++ (committed using GitHub Web editor) | .github/CODEOWNERS Remove self as owner of that section I can no longer claim responsibility for the documentation repo *de facto*. It's only sensible to remove myself from here too. |
11:08 | ||
problem-solving: 894e41f708 | (Elizabeth Mattijsen)++ | .github/CODEOWNERS Fix formatting in CODEOWNERS |
11:09 | ||
11:47
jaguart joined
12:01
frost left
|
|||
El_Che | what does JJ's commit mean? | 12:02 | |
lizmat | It means he's relinquishing final responsibility for the Raku documentation | 12:07 | |
12:07
reportable6 left
12:08
reportable6 joined
|
|||
lizmat | and that we need someone else to take that responsibility :-) | 12:21 | |
12:37
frost joined
12:42
lichtkind left
|
|||
El_Che | oh, sad | 12:45 | |
lizmat | afk for a few hours, the sun is shining :-) & | 12:59 | |
Nemokosch | 😂 | 13:00 | |
13:03
frost left
13:07
shareable6 left
13:10
shareable6 joined
|
|||
[Coke] | ... trying to use raku to run the equiv of "start google.com" from a raku script. I suspect I might need to actually launch 'cmd' and pass args; anyone done this? (windows, obvs.) | 13:17 | |
13:17
Sankalp left
|
|||
japhb | Oh there has *got* to be a more direct way than indirecting via cmd ... but if I ever knew it, it has faded from my memory | 13:18 | |
[Coke] | eh. I can make this a shell script (it's small and dumb and start works there.) | 13:20 | |
Nemokosch | the windows nerds | 13:26 | |
13:53
[Coke] left
13:56
[Coke] joined
|
|||
[Coke] | (windows nerds) it's probably worse that I wrote something intended to be used under 'git bash' only on windows. | 13:59 | |
but at least now I have my "open this list of ticket numbers in bug tracking that's listed in someone's excel file". which I was working on the script instead of looking at the tickets, because... yak shaving. | |||
this 30 minutes will definitely save me 10m later. | 14:00 | ||
14:00
melezhik joined
|
|||
melezhik | SmokeMachine: patrickb sparkyci won't trigger new builds in few hours, I will fix this once I get an access to my laptop ... | 14:01 | |
japhb | Time well spent | ||
tellable6 | hey melezhik, you have a message: gist.github.com/7580851da811ceb7b0...09facb849d | ||
14:06
jaguart left
14:07
melezhik left
14:12
Guest35 joined
|
|||
Nemokosch | at the end of the day, it's good to know that Raku stuff actually works on Windows 🙂 | 14:13 | |
14:17
Sgeo joined
|
|||
[Coke] | Use it every day for devops/scripty things. | 14:29 | |
15:17
evalable6 left,
linkable6 left
15:18
linkable6 joined
15:19
evalable6 joined
|
|||
Nemokosch | Does map put its argument(s) into Scalar containers? | 15:30 | |
[Coke] | m: my \a = 3; my @a=[\a,3]; @a.map({$_.VAR.say}) | 15:35 | |
camelia | \(3) 3 |
||
Nemokosch | from all I see, @two-dimensional-array.map(* Z <1 2 3>) doesn't work as intended | ||
and @two-dimensional-array.map(*.List Z <1 2 3>) does | 15:36 | ||
15:39
Nemokosch joined
|
|||
Nemokosch | m: [[1,2], [3,4]].map(*.raku.say); | 15:39 | |
camelia | $[1, 2] $[3, 4] |
||
15:39
Nemokosch left
|
|||
[Coke] | m: my @a=(1,2;3,4); @a.map({dd $_, @$_}) | 15:40 | |
camelia | List @a = $(1, 2) (1, 2) List @a = $(3, 4) (3, 4) |
||
Nemokosch | what I particularly don't get is... what is this, if it's apparently not a List/Array? | 15:42 | |
because *.List or *.Array fixes it | |||
[Coke] | dd: ($(1,2)).WHAT | 15:44 | |
m: dd: ($(1,2)).WHAT | |||
camelia | ( no output ) | ||
[Coke] | m: ($(1,2)).WHAT.say | ||
camelia | (List) | ||
[Coke] | m: say $(1,2).elems; say (1,2).elems | ||
camelia | 2 2 |
||
[Coke] | m: my $a = $(1,2); my @a = $(1,2); dd $a, @a | 15:46 | |
camelia | List $a = $(1, 2) Array @a = [(1, 2),] |
||
[Coke] | Sorry, I should have tested more of those "off screen" first. | 15:48 | |
Nemokosch | The difference between types and containers is fuzzy at times | 15:51 | |
Like okay, map treats the argument as a scalar | 15:52 | ||
but then what do .Array and .List do that turns this scalar into a positional container, whatever the name is | 15:53 | ||
it's even inconsistent at times: Z and X do pay attention to this "scalarness", hyper and even reduce don't | 16:00 | ||
16:08
abraxxa left
16:32
grondilu left
|
|||
Geth | ¦ problem-solving: lizmat assigned to codesections Issue Taking responsibility for Raku Documentation issues github.com/Raku/problem-solving/issues/324 | 16:38 | |
¦ problem-solving: lizmat unassigned from codesections Issue Taking responsibility for Raku Documentation issues github.com/Raku/problem-solving/issues/324 | |||
16:48
jaguart joined
16:50
saint- joined
|
|||
lizmat | and yet another Rakudo Weekly News hits the Net: rakudoweekly.blog/2022/05/02/2022-18-period/ | 16:59 | |
CIAvash | I think that's happening because `map` is capturing everything. And those are items. | 17:16 | |
m: my (|c) := [[1,2],[3,4]]; dd c | |||
camelia | \($[1, 2], $[3, 4]) | ||
CIAvash | so, if they are items, they need to be decontainerized: | 17:17 | |
gfldex | lizmat: I did not know that I can start the REPL like that. Are there any spec tests? :-> | ||
CIAvash | m: say [[1,2],[3,4]].map: *<> Z <1 2 3> | ||
camelia | (((1 1) (2 2)) ((3 1) (4 2))) | ||
lizmat | gfldex: I don't think so... | ||
and it's going to be pretty tricky perhaps to write tests for that? | 17:18 | ||
hmmm... I guess it could be part of the normal repl tests.... hmmm | |||
gfldex | :-> ← that's my "I'm-being-cheeky-face" | ||
CIAvash | And that's happening because Arrays have containers. Lists don't | 17:22 | |
m: say ((1,2),(3,4)).map: * Z <1 2 3> | |||
camelia | (((1 1) (2 2)) ((3 1) (4 2))) | ||
Nemokosch | Okay but then why does even *.Array fix the containerisation? | 17:24 | |
17:28
sena_kun left
|
|||
CIAvash | Because the `item` becomes an `Array`? | 17:31 | |
17:33
melezhik joined
|
|||
Nemokosch | it was an Array though? | 17:33 | |
17:33
melezhik left,
Nemokosch joined
|
|||
Nemokosch | m: dd [[1, 2], [3,4]].map({ .WHAT }) | 17:34 | |
camelia | (Array, Array).Seq | ||
17:34
Nemokosch left
17:35
Nemokosch joined
|
|||
Nemokosch | m: dd [[1, 2], [3,4]].map({ $_ Z [5, 6] }) #doesn't work | 17:35 | |
camelia | ((($[1, 2], 5),).Seq, (($[3, 4], 5),).Seq).Seq | ||
Nemokosch | dd: [[1, 2], [3,4]].map({ .Array Z [5, 6] }) #does work | ||
m dd: [[1, 2], [3,4]].map({ .Array Z [5, 6] }) #does work | |||
almost, damn | |||
m: dd [[1, 2], [3,4]].map({ .Array Z [5, 6] }) #does work | 17:36 | ||
camelia | (((1, 5), (2, 6)).Seq, ((3, 5), (4, 6)).Seq).Seq | ||
CIAvash | actually it's not related to map, it's just Arrays having containers | ||
m: my @a = [[1,2], [3,4]]; say @a[0].raku | |||
camelia | $[1, 2] | ||
CIAvash | it's itemized Array | 17:37 | |
Nemokosch | anyway, it's not often desirable and rather confusing | ||
some stuff cares about type, including the reduce and hyper meta-operators | 17:38 | ||
some stuff cares about containers, like foreach and zip | |||
CIAvash | m: say [1,2] Z [3,4]; say $[1,2] Z [3,4] # like this | ||
camelia | ((1 3) (2 4)) (([1 2] 3)) |
||
Nemokosch | and it feels very quirky that I take an array that is itemized for some reason, convert it to an Array and suddenly it is containerized properly | 17:40 | |
this takes me back to yesterday | |||
if you set a @-sigilled variable to the topic variable, you cannot assign to it because Rakudo will claim it's "immutable" | |||
I've spent like half a year with Raku scripts, I've watched lizmat's presentation about sigils and still, most WAT's I come across are with sigil-dependent stuff and containerisation | 17:42 | ||
I saw in your examples that zen-slicing changed the behavior, I would say that's a clear-looking solution; I don't know what it did or where this is described but it seems like the cleanest solution | 17:44 | ||
17:46
Nemokosch left
|
|||
CIAvash | maybe those functions you used that don't care about containers, are probably not `nodal`? docs.raku.org/routine/is%20nodal | 17:46 | |
17:47
melezhik joined
|
|||
Nemokosch | I would also really like a working example of `nodal` with some non-method | 17:48 | |
with an infix hyper, even | |||
17:50
melezhik left
|
|||
but I don't think this is related to that map-zip example I've given | 17:50 | ||
Anyway, I'm reaching the point where I should probably collect my concerns about the whole containerisation stuff and make a post to Reddit | |||
This map-zip stuff is something that I think we can sort out and I will eventually understand | 17:51 | ||
CIAvash | no, I mentioned nodal because you mentioned hyper-operators | ||
Nemokosch | but @variables as topic being immutable is an annoyance and the infamous (@a, @b) = (@b, @a) is plain satanic in my opinion | 17:52 | |
CIAvash | m: say [[1,2],[3,4]].map: -> @a { @a Z <1 2 3> } # another way to change containers | ||
camelia | (((1 1) (2 2)) ((3 1) (4 2))) | ||
CIAvash | m: say [[1,2],[3,4]].map: -> $a { $a Z <1 2 3> } # same thing happening to $_ | 17:53 | |
camelia | ((([1 2] 1)) (([3 4] 1))) | ||
Nemokosch | yes, I know this one; once I started suspecting that map takes scalar items, I expected this to work | 17:54 | |
or @$_ to work (also does) | |||
but I wondered if there is a clean way to change it within a whatever curry | 17:55 | ||
CIAvash | Can you give an example for "but @variables as topic being immutable" | ||
the clean way is either using `List`s or using `<>`. | 17:56 | ||
Nemokosch | *.List and *.Array work but I find them confusing - in fact I still don't really know why they change the containerisation and how this fits into the big picture | ||
so yeah, so far I like *<> the most | |||
or *[] | |||
perhaps I could have used lists, I think it seemed easier to generate the data as an array | 17:57 | ||
anyway, you know | 17:58 | ||
so apparently it works as expected if the outer dimension is a List | |||
perhaps there can be a logical framework around this | |||
but I ask myself the question - who will remember nuances like that, among mortal users? | 17:59 | ||
CIAvash | I think Arrays have containers so you can modify them, unlike Lists. Then there is flattening, iterating, ... docs.raku.org/language/containers | 18:00 | |
Nemokosch | Lists still aren't immutable enough to be hashable, for example | ||
okay, so this is the implication of (shallow) immutability | 18:02 | ||
(personally I also don't think the type hierarchy helps here, i.e Arrays descending from Lists) | |||
I'll have to study this part thoroughly | 18:03 | ||
CIAvash | If I'm not mistaken codesections is working on the immutability issue | 18:04 | |
18:04
Nemokosch joined
|
|||
Nemokosch | Anyway, let me show you the two increasingly annoying things | 18:04 | |
And there are ValueLists that are hashable (or some related implication of deep immutability); they will be built in from 6.e from what I know | 18:05 | ||
That's good news for sure | |||
Nemokosch | so here's one: | ||
m: my @array = <1 2 3>; $_ = <4 5 6> given @array; | 18:06 | ||
camelia | Cannot assign to an immutable value in block <unit> at <tmp> line 1 |
||
18:06
reportable6 left
|
|||
Nemokosch | of course if I type out @array, it will work | 18:06 | |
I don't know of an easy workaround for the left handside though | 18:07 | ||
18:07
reportable6 joined
|
|||
Nemokosch | m: my $item-array = <1 2 3>; $_ = <4 5 6> given $item-array; | 18:08 | |
camelia | ( no output ) | ||
Nemokosch | dang, works with the scalar sigil | ||
I can't help but think that the so-called "item assignment" is more reliable overall | 18:09 | ||
Nemokosch | And now let's perform the summoning ceremony of Raku | 18:10 | |
m: my @a = <1>; my @b = <2>; (@a, @b ) = (@b, @a); dd @a; dd @b; | 18:11 | ||
camelia | Array @a = ((my @Array_5770288009536) = [[], @Array_5770288009536]) Array @b = [] |
||
Nemokosch | again, this would work as intended, had you used $ | 18:13 | |
And yes, I asked about this, I think Jonathan Worthington explained the behavior (list assignment, STORE is called, it pushes all the values to the emptied @a variable so nothing is left for @b) but I still think this is too horrifying to be acceptable... | 18:15 | ||
18:17
Nemokosch left
|
|||
CIAvash | yes, again it's because of containers, I know why it's immutable but not sure about `@a` being a value and `$a` being a container/variable | 18:23 | |
m: my @a = 1,2,3; given @a -> $a is raw { $a = [4,5,6] }; dd @a; | 18:24 | ||
camelia | Cannot assign to an immutable value in block <unit> at <tmp> line 1 |
||
CIAvash | m: my @a = 1,2,3; given @a -> @b { @b = [4,5,6] }; dd @a; | 18:25 | |
camelia | Array @a = [4, 5, 6] | ||
CIAvash | m: my @a = 1,2,3; given @a <-> $a { $a = [4,5,6] }; dd @a; | ||
camelia | Parameter '$a' expects a writable container (variable) as an argument, but got '[1 2 3]' (Array) as a value without a container. in block <unit> at <tmp> line 1 |
||
CIAvash | m: my $a = [1,2,3]; given $a <-> $b { $b = [4,5,6] }; dd $a; | 18:26 | |
camelia | Array $a = $[4, 5, 6] | ||
Nemokosch | hmmm | 18:27 | |
does this mean that "item assignments" are literally impossible to list containered variables? | 18:28 | ||
maybe all you have is this STORE method hidden behind "list assignments"? | 18:29 | ||
18:31
rypervenche left
|
|||
CIAvash | apparently, I try to avoid mutability as much as I can and don't do these kind of things. | 18:31 | |
Nemokosch | I mean that's not a bad idea but that doesn't mean it should be a can of worms, right? 😄 | 18:32 | |
and especially this (@a, @b) = (@b, @a) | 18:33 | ||
turns out it's not even easy to swap two variables if they happen to have this sigil | |||
I mean, other than using a temporary third variable like back in the days | |||
and for me, stuff like this definitely ruins my confidence with anything that seems like pattern matching | 18:34 | ||
18:36
rypervenche joined
18:56
jaguart left
19:12
p6steve joined
19:13
ecocode left
19:16
ecocode joined
19:32
Altai-man left
19:33
sena_kun joined
|
|||
SmokeMachine | I've been reading about Erlang's way of doing RPC and that seemed interesting. Then I've started writing this (github.com/FCO/Supervisor), do you think something like this would make sense? | 19:48 | |
tellable6 | 2022-05-02T01:48:51Z #raku <melezhik> SmokeMachine - thanks! I will think about badges , first I want to make SparkyCI works stable ... but yeah I agree badges would be convenient ... | ||
p6steve | smokemachine: heck yes | 20:00 | |
20:21
sena_kun left
20:23
sena_kun joined
20:24
charsbar left,
charsbar joined
|
|||
SmokeMachine | p6steve: thanks! I think I’ll continue trying it… | 20:30 | |
20:34
jjido joined
21:05
hythm joined
21:35
jjido left
|
|||
Voldenet | Nekomosch: Whenever I actually need to manage references (so, change instance of objects and so on), I use `$`, but when I care about collections, I use @ and % | 22:30 | |
22:35
evalable6 left,
linkable6 left
22:37
linkable6 joined
22:38
evalable6 joined
|
|||
Voldenet | erm, typo Nemokosch ^ | 22:41 | |
it's not true perl way, but I strongly prefer storing everything in $ even in perl5, because it makes passing arguments more predictable IMO | 22:47 | ||
22:49
hythm left
23:06
jujo joined
|
|||
jujo | hello people, what is the idiomatic way to read stdin until eof? | 23:07 | |
Voldenet | m: for lines() { .say } | ||
camelia | »Wann treffen wir drei wieder zusamm?« »Um die siebente Stund‘, am Brückendamm.« »Am Mittelpfeiler.« »Ich lösche die Flamm.« »Ich mit« »Ich komme vom Norden her.« »Und ich vom Süden.… |
||
Voldenet | m: $*IN.slurp.say | 23:08 | |
camelia | »Wann treffen wir drei wieder zusamm?« »Um die siebente Stund‘, am Brückendamm.« »Am Mittelpfeiler.« »Ich lösche die Flamm.« »Ich mit« »Ich komme vom Norden her.« »Und ich vom Süden.… |
||
jujo | thanks, why use a label? | 23:10 | |
also where can I read about the methods of the dynamic $*IN | |||
Voldenet | docs.raku.org/language/variables#i...entry-$*IN | 23:11 | |
jujo | thankyou again :) | ||
Voldenet | (the `m:` is a bot command for evaluation, not a label) | 23:12 | |
m: invalid-code | |||
camelia | ===SORRY!=== Error while compiling <tmp> Undeclared routine: invalid-code used at line 1 |
||
jujo | oooooooohhhhhh | ||
23:17
TempIRCLogger left
|
|||
perryprog | m: valid-code | 23:18 | |
camelia | ===SORRY!=== Error while compiling <tmp> Undeclared routine: valid-code used at line 1 |
||
perryprog | :( | ||
Voldenet | it's not perl, you can't just type in random things and expect it to work! :> | 23:19 | |
perryprog | haha | 23:21 | |
m: P == NP | 23:22 | ||
camelia | ===SORRY!=== Error while compiling <tmp> Preceding context expects a term, but found infix == instead. at <tmp>:1 ------> P ==⏏ NP |
||
perryprog | that works in Perl 5, dangit! | ||
jujo | if I want my program to behave differently depending on if I pass it files or I pipe a stream to it, how should I do it | 23:26 | |
nvm | 23:28 | ||
just found out | |||
Voldenet | probably just use "-" as argument, it's standard way to do it | 23:29 | |
eh, apparently .slurp won't do what you want | 23:32 | ||
because slurp returns available content for $*IN | |||
jujo | I'm declaring main with a slurpy array as argument | 23:33 | |
Voldenet | $*IN.slurp-rest is the method | ||
jujo | and if it is empty I just treat it as input from stdin | ||
(I could do some parsing before deciding) | |||
is it too hacky? | 23:34 | ||
Voldenet | makes sense | 23:36 | |
> sub MAIN(IO() :$file = "-") { $file.open.slurp-rest.chars.say } | 23:38 | ||
that's how I'd do it | |||
jujo | oh I see, I was just reading about the builtin arg parsing, very interesting | 23:45 | |
what if I want to have rest args after some flags? | |||
Voldenet | > sub MAIN(IO() $in, :$out = "out") { $in.say; $out.say; } | 23:48 | |
if you want multiple unnamed arguments, you can use *@whatever as args, so | 23:50 | ||
> sub MAIN(*@c, :$out = "out") { @c.join(";").say; $out.say; } | 23:51 | ||
keep in mind that in that case, named arguments must appear before unnamed ones | |||
jujo | ok I understand | ||
thanks again! | |||
you can declare MAIN as multi right? | 23:52 | ||
Voldenet | Yes | ||
docs.raku.org/language/create-cli#___top | 23:53 | ||
jujo | Thanks again, I will read it | 23:56 |