This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
Nemokosch | rf: where did you find the spec, then? | 00:00 | |
rf | In the HTTP headers of any HTTP response | 00:01 | |
And there's an RFC for it somewhere I'm sure | |||
Nemokosch | this one? www.rfc-editor.org/rfc/rfc2616#section-3.3 | ||
ToddAndMargo | "put" does not work either in binary mode | 00:02 | |
Nemokosch | ToddAndMargo: try write docs.raku.org/routine/write | 00:03 | |
rf | www.w3.org/Protocols/rfc2616/rfc26...l#sec3.3.1 | ||
This spec | |||
Looks like we found the same one on different websites | |||
ToddAndMargo | Type check failed in binding to parameter '$buf'; expected Blob but got Str ("¼ÐWå¿ñå?¸\x[1B]±\tï...) | 00:04 | |
rf | Do Blob.new($MyScrambleStr) | ||
Instead of just passing the Str | 00:05 | ||
ToddAndMargo | my $MyScrambleBuf = Blob.new( $MyScrambleStr ); | 00:07 | |
No such private method 'throw-typecheck-element' on Blob | |||
Nemokosch | the error is not so nice but surely you can do better at converting a string into a blob 😛 | 00:08 | |
ToddAndMargo | Buf.new gave the same error | 00:09 | |
Nemokosch | rather look for a conversion method... like encode | 00:10 | |
ToddAndMargo | I am trying to write a scrambled text file to a binary file. spurt gives me a zero length file. The string looks like this: ¼ÐWå¿ñå?¸\x[1B]±\tï | 00:11 | |
I need what is written to be exactly what is in the string. No conversion. It is a cypher | 00:12 | ||
slurp read it back just fine, if i can get into the file to start with | 00:13 | ||
Nemokosch | if you want no conversion, you shouldn't read it as text in the first place | ||
ToddAndMargo | how do I get it from my string into something that I can binarily write the file? | 00:15 | |
Nemokosch | rf: not sure if there is a module for that exact standard but you could consider taking a look at raku.land/zef:raku-community-modul...me::Format | 00:16 | |
ToddAndMargo | Looking at my scramble module, I see I did everything as a bug and at the last moment converted it to a string. So, I will turn it into two and give back either a string of a buf. | 00:20 | |
rf | Looks like that module will do it | 00:30 | |
Thanks | 00:31 | ||
01:07
Kaiepi joined
03:21
rf left
|
|||
ToddAndMargo | Everything is now bufs and binary. And it is working. Thank you all for the help! signing off | 04:10 | |
Read Example: | |||
my $MyScrambleBuf = buf8.new; # the .new is required of a buffer | |||
my $FileHandle = open "$WanIpFileName", :r, :bin; | |||
# enter number of bytes in the () or emply for all | |||
$MyScrambleBu = $FileHandle.read(); | |||
$FileHandle.close; | |||
Write Example: | |||
my $MyScrambleBuf = buf8.new; # the .new is required of a buffer | |||
my $FileHandle = open "$WanIpFileName", :rw, :bin; | |||
$MyScrambleBuf = $FileHandle.write( $MyScrambleBuf ); | |||
$FileHandle.close; | |||
04:12
ToddAndMargo left
04:21
Heptite left
06:31
Kaiepi left
09:12
dakkar joined
10:32
Heptite joined
10:56
Kaiepi joined
11:01
Heptite left
|
|||
yabobay | if i have a big long list, is it computationally expensive to create a list that's everything but the first 3 elements of the list? | 12:23 | |
Nemokosch | I think copying a list is kinda expensive because lists aren't deeply immutable | 12:29 | |
codesections has been working on implementing deeply immutable lists that don't have to be actually copied | |||
lizmat | yabobay do you actually need that list to exist, or do you need that list to iterate over? | 12:33 | |
yabobay | to iterate over | ||
lizmat | if the latter, then: (list).tail(*-3) would do the trick | ||
yabobay | if i put that in a variable what happens? | 12:34 | |
lizmat | m: dd (1..10).tail(*-3) | ||
camelia | (4, 5, 6, 7, 8, 9, 10).Seq | ||
lizmat | if you put it into a variable *then* it will get copied | ||
yabobay | oh, ok | ||
lizmat | m: dd (1..10).skip(3) # another way | ||
camelia | (4, 5, 6, 7, 8, 9, 10).Seq | ||
Nemokosch | what if one binds a variable to it? | 12:35 | |
lizmat | then you'd be binding to the Seq | 12:36 | |
Nemokosch | that wouldn't copy but would it "do the right thing"? | ||
lizmat | which is fine, if you know what you're doing :-) | ||
again, you would be binding to the Seq | |||
and that by itself wouldn't do anything | |||
m: my $a := (1..5).map(*.say); say "bound"; Nil for $a | 12:37 | ||
camelia | bound 1 2 3 4 5 |
||
lizmat | you'd have to use the Seq in an iteratiing context | 12:38 | |
m: my $a := (1..5).map(*.say); say "bound"; $a.iterator.sink-all # basically what happens with the "for" | |||
camelia | bound 1 2 3 4 5 |
||
12:38
discord-raku-bot left,
discord-raku-bot joined
|
|||
yabobay | remind me what binding does: if i edit something in the bound array, the original array also changes? | 12:38 | |
Nemokosch | do Seqs get exhausted by one iteration? | 12:39 | |
yep | 12:40 | ||
yabobay | ``` | 12:41 | |
Type check failed in binding; expected Positional but got Seq (((65, 66, 67, 255), ...) | |||
in sub bitmap2file at png2file.raku line 61 | |||
in block <unit> at png2file.raku line 70 | |||
``` | |||
getting this error when doing skip(3) on a list | |||
Nemokosch | the way I like to describe the situation is: when you bind a variable to something, the variable IS that something | ||
ngl I find this kinda stupid... a Seq is not a Positional, only "PositionalBindFailover" | 12:42 | ||
you could of course just use $ or \ (which always binds on initialization anyway) | 12:43 | ||
or you could try .list but I wouldn't know if that "copies" | 12:44 | ||
yabobay | so using $ worked but it feels like this *isn't* one of those times where it's just me who thinks this is unnecessary | ||
Nemokosch | yeah no. What is the point of @ if basically all list operations produce a type that cannot even be bound to it | 12:47 | |
yabobay | the point of @ is that it's for lists | ||
lizmat | yabobay code ? | 12:48 | |
yabobay | ```pl | 12:49 | |
sub bitmap2file(@bitmap) { | |||
# the first 3 pixels of the bitmap tell us how many bytes of | |||
# information are stored in the last pixel. the rest of the bitmap | |||
# is the actual information we want. | |||
my $header := @bitmap.head(3); | |||
my $contents := @bitmap.skip(3); | |||
my $colorsThatAreActuallyInTheLastPixel = 0; | |||
for $header -> @p { | |||
++$colorsThatAreActuallyInTheLastPixel | |||
if @p[3] == 255; # that's the alpha channel | |||
} | |||
say $contents.map: *.head(3); | |||
} | |||
``` | |||
that last line i just added right now. is that one expensive? | |||
Nemokosch | is nqp::isconcrete about reification? | 12:53 | |
I don't think it does anything you wouldn't want it to | 12:54 | ||
12:56
discord-raku-bot left,
discord-raku-bot joined
|
|||
lizmat | yabobay for @bitmap.head(3) { ... handle header }; for @bitmap.skip(3) { ... handle actual bitmap } | 12:56 | |
no need to copy anything, I'd say | 12:57 | ||
yabobay | i'm only doing it like that to communicate it to someone who reads the code (that someone will probably be me after i forget how it works) | ||
also i thought this actually does no copying at all | 12:58 | ||
Nemokosch | well this doesn't | ||
lizmat | but the $contents variable, when iterated over, already skips the first 3 in bitmap, so why the .map: *.head(3) there ?? | ||
yabobay | *inside* contents, there are other lists, of which i need only 3 elements | 12:59 | |
lizmat | ok, when then you run into problems if you'd want to iterate over $contents more than once | 13:00 | |
Nemokosch | *I take your brain to another dimension... pay close attention* 🎶 | ||
yabobay | why? it's not modifying contents, is it? | ||
lizmat | m: my $a := (1..5).skip(3); .say for $a; .say for $a | ||
camelia | 4 The iterator of this Seq is already in use/consumed by another Seq (you might solve this by adding .cache on usages of the Seq, or by assigning the Seq into an array) in block <unit> at <tmp> line 1 5 |
||
yabobay | huh. | 13:01 | |
Nemokosch | the irony is that this is asking for copying basically xD | ||
lizmat | now, if you would add .cache to the Seq, that's just basically copying for you under the hood | ||
yabobay | ok i think i might just do this using good ol' array indices? | ||
lizmat | depends | ||
Nemokosch | you can do slices I think | 13:02 | |
slices don't seem to copy, thank heavens | |||
yabobay | they don't? | 13:03 | |
Nemokosch | m: my @funny = 1, 2, 54, 23, 13, 15, 34; say @funny[^3][2] =:= @funny[2]; | ||
lizmat | m: my @funny = 1, 2, 54, 23, 13, 15, 34; say @funny[^3][2] =:= @funny[2]; | ||
camelia | True | ||
yabobay | huh | 13:04 | |
m: my @funny = 1, 2, 54, 23, 13, 15, 34; say @funny.head(3)[2] =:= @funny[2]; | |||
Nemokosch | 😂 | ||
lizmat | m: my @funny = 1, 2, 54, 23, 13, 15, 34; say @funny.head(3)[2] =:= @funny[2]; | ||
camelia | True | ||
Nemokosch | the difference is that head returns a Seq | ||
lizmat is starting to feel like a bot now :-) | |||
Nemokosch | [^3] returns a List | ||
yabobay | do those have any practical difference ? | 13:05 | |
Nemokosch | lizmat: fyi those evals do run here, they just aren't sent over | ||
lizmat | aha... ok | ||
Nemokosch | well, as you can see, one is a Positional and the other isn't | 13:06 | |
one gets exhausted after one turn of iteration, the other doesn't | |||
I think [^3] actually does copy, in some sense. It creates a very shallow copy where all the elements are bound to the sufficient positions | 13:07 | ||
but really, I'd assume that's the best it can get without immutable data structures | |||
yabobay | this is kind of a significantly more stupid question, but i have the buf8 i wanna save to a file in a variable, what should i name the variable? i want something v generic. right now i have it called $stream | 13:09 | |
lizmat | "There are only three hard problems in computer science: Cache invalidation, naming things, and off-by-one errors" | 13:10 | |
:-) | |||
Nemokosch | two problems 😛 | 13:11 | |
$payload? $content, possibly $binary-content? | 13:12 | ||
yabobay | well we already have $content | ||
there truly cant be a more generic variable name than that | |||
fileData is another pretty vague one i could use | 13:13 | ||
13:15
dakkar left
13:16
dakkar joined,
dakkar left
13:17
dakkar joined,
dakkar left
14:14
dakkar joined
|
|||
p6steve | I'm not a raku core guy, and I shun esoterica like the MOP, but I think I know raku from 'coderland' pretty well having coded in it for 5 years or so ... it's worrying me that here on raku-beginner there is a very high % of stuff that makes me scratch my head (for example in the dialogue in the last couple of pages, I have been lost in Seq, Slip, Arrays, binding, slices, skip, rotor, nqp, and so on) ... no | 14:21 | |
14:22
Kaiepi left
|
|||
lizmat | well, all of that is under the hood, mostly | 14:22 | |
14:22
Kaiepi joined
|
|||
lizmat | and I wouldn't call explicit binding a beginner's feature for sure | 14:22 | |
p6steve | If you read to the end of my recent blog post p6steve.wordpress.com/2022/12/24/on-sigils/ you will see that I quote two bits of advice that I picked up and regurgitated... (i) do not use $ with any kind of list unless you want a suprise! (ii) while raku also gives us Seq and List types, you want to use Array unless you are an expert | 14:23 | |
sooo --- may I v. gently suggest that we move over to the main raku channel when we lift the hood??? | 14:24 | ||
sorry to nag | 14:25 | ||
lizmat | no worries :-) | 14:27 | |
Nemokosch | regarding the communication channels... tbh I think it's only worth talking about this if we are "serious about it". I'm still thinking about making a case "against IRC" (more accurately, pro something-real-time-that-has-forum-like-features) | 14:33 | |
for IRC where users are disposable entities and there is no central history, it absolutely feels like dialogues are the units of communication, hence why should it matter what others talked about "pages ago" | 14:35 | ||
now the rare thing happened that Discord users were more active and therefore it might feel a little different | 14:36 | ||
but the first-class channel is still the IRC channel as far as I'm concerned, it's just a fun fact that we join via discord | 14:37 | ||
p6steve | seems to me from other groups I am in that Discord is a good compromise (since we have bridge to IRC) perticulalry for beginners / newcomers who want to dabble (as I do over in Rust, Python and Polars land) | ||
Nemokosch | the problem with Discord is mostly the ethical part with FOSS in mind | ||
p6steve | don;t know if that counts as "forum features" | ||
ethical++ | 14:38 | ||
Nemokosch | I suspect many users, especially "power users", just wouldn't be willing to move to discord. | ||
or Slack, for that matter | 14:39 | ||
p6steve | personally I would weight "ability-to-attact-newbies-ness" above "hatred-of-corporate-greed-and-controlity" | ||
(but that's just me) | 14:40 | ||
Nemokosch | same for me but it's easy to say when I have traded these values a long time ago anyway | 14:42 | |
Kaiepi | i really wish something other than discord would be the popular means of chatting nowadays, but i also hate forums and mailing lists | ||
irc i put up with ig | |||
p6steve | discord is quite of the moment and does help raku seem a bit cooler | 14:43 | |
Nemokosch | for example, I'm the kind of person who is happy to use a Google/Microsoft/FB login everywhere, rather than register to individual services | ||
that's why Mastodon sort of stuff was immediately unappealing | 14:44 | ||
I get frustrated by new identities beyond rational | |||
p6steve | yeah, but geeks are a high % of disord and a low % of mastodon (or soon will be) | ||
I will take some pain to kick that Tesla guy in the teeth | 14:45 | ||
Nemokosch | 😂 | ||
ngl I wouldn't shed a tear over the Twitter community but we're kinda pushing far | 14:46 | ||
anyway, I'm sure somebody has thought about this before: why not make something like discord/slack, something that is easy to use and isn't corporatist spyware? | |||
something that functions similar to Mastodon but for this real-time-forum functionality | 14:47 | ||
p6steve | i would only use it if its build on cro | ||
Nemokosch | 😂 | ||
lizmat | I'm surprised it would be ok to use a MS/G/FB login | ||
I have none of them, because of corporations lurking | 14:48 | ||
Nemokosch | Matrix came up every now and then, I don't know what it's like in practice | ||
avuserow also named something else, lemme check | 14:49 | ||
Mattermost | |||
14:50
jgaz joined
|
|||
After a quick glimpse, I'm afraid Mattermost would still be too alien from the requirements and demands of this community | 14:50 | ||
lizmat | it's nice, but it's also a single corporation | ||
what happens with all of your dialogue when it goes down, or gets bought by MS / Meta | 14:51 | ||
Nemokosch | I think at the end of the day, it's good to have a server one way or another, central at least regarding the community. Something that messages do go through and can do logging and stuff like that. | 14:53 | |
also, something that manages identities in a richer way IRC channels are usually set up. Something that I really miss from discord is the concept of roles - they can manage not only your permissions but also put you in a mentionable entity, hence opt into something you care about/identify with | 14:56 | ||
15:07
Heptite joined
17:37
dakkar left
18:10
thowe joined
18:39
jgaz left
18:55
jgaz joined
19:02
ab5tract joined
19:21
ab5tract left
19:25
ab5tract joined
19:29
Kaiepi left
19:43
jgaz left
|
|||
Rog | I do have in the works a chat client that would be a bit more like discord but with self-hosting | 19:45 | |
But that’s who-knows-how-many months or years away | |||
19:49
ab5tract left
20:09
Kaiepi joined
20:12
jgaz joined
20:33
ab5tract joined
20:43
ab5tract left
21:10
ab5tract joined
21:19
ab5tract left
21:51
jaguart left
22:11
jgaz left,
jaguart joined
|
|||
jaguart | p6steve: nice 🙂 | 22:16 | |
I have a question about how you lay out your dev work. I has App1 and App2 in dev, they use lib1 and lib2 modules - which I will probably have to tweak too - each thing is going into it's own distribution. **How do you set up your dev / early testing directory structure? ** (and associated RAKULIB ) I'm thinking a dev area with links? What about the meta6's? | 22:19 | ||
23:11
Heptite left
|