<< 29-09-2024 >>

00:00:11*albe quit (Quit: The Lounge - https://thelounge.chat)
00:03:06*albe joined #nim
00:23:10FromDiscord<aa4003771> Hello
00:23:10*beholders_eye quit (Read error: Connection reset by peer)
00:29:17*beholders_eye joined #nim
00:50:41*beholders_eye quit (Read error: Connection reset by peer)
00:53:45*om3ga quit (Quit: Bye)
00:54:27*om3ga joined #nim
00:56:38*beholders_eye joined #nim
01:06:27*beholders_eye quit (Read error: Connection reset by peer)
01:11:58*beholders_eye joined #nim
01:48:08*beholders_eye quit (Ping timeout: 255 seconds)
02:30:46FromDiscord<aurelian5014> sent a code paste, see https://play.nim-lang.org/#pasty=FObjAWNt
02:31:00FromDiscord<aurelian5014> (edit) "https://play.nim-lang.org/#pasty=zydXcjcb" => "https://play.nim-lang.org/#pasty=WvqKkhoc"
02:34:59FromDiscord<Elegantbeef> `[0u8, 0, 0, 0]`
03:45:28FromDiscord<k0ts> https://nim-lang.org/docs/manual.html#types-array-and-sequence-types
03:45:43FromDiscord<k0ts> > `The element type of this array expression is inferred from the type of the first element.`
03:45:56FromDiscord<k0ts> > `let z = [1.0, 2, 3, 4] # the type of z is array[0..3, float]`
04:05:07FromDiscord<aurelian5014> perfect, thanks
04:05:58*lucasta quit (Remote host closed the connection)
05:27:29*derpydoo joined #nim
06:31:46FromDiscord<zectbumo> when was the website last updated? I found a broken link but when I looked in the source code it is correct, has been for 4 years 🤨↵https://github.com/nim-lang/Nim/blob/4f5c0efaf24e863b26b16d7998eac3bdd830e7be/lib/pure/net.nim#L24
06:32:18FromDiscord<zectbumo> (edit) "link" => "anchor"
06:33:03FromDiscord<zectbumo> broken anchor can be found here in the SSL section when clicking on "newContext". It has one too many Cstring arguments↵https://nim-lang.org/1.4.4/net.html#newContext%2Cstring%2Cstring%2Cstring%2Cstring%2Cstring
06:34:49FromDiscord<zectbumo> nevermind. I see it is old docs 1.4.4 I was looking at
07:14:41*ntat joined #nim
07:48:53FromDiscord<renegattoo> What is the status of Nim for Arduino?↵Are there any working tools for integration with the arduino ecosystem (including it's libraries and api)?
07:49:49FromDiscord<renegattoo> I found `ardunimo` but the last commit was made 8 years ago.
08:07:49FromDiscord<renegattoo> Found also https://github.com/zevv/nim-arduino.↵@zevv1474 is that project in a usable state at the moment, or it has already outdated?
08:41:38FromDiscord<pmunch> That was basically just an experiment IIRC
08:56:05*alexdaguy joined #nim
09:47:28FromDiscord<blashyrk> sent a code paste, see https://play.nim-lang.org/#pasty=SCeFSyNO
10:03:06*derpydoo quit (Ping timeout: 246 seconds)
10:05:28*om3ga quit (Ping timeout: 252 seconds)
10:36:06*ntat quit (Quit: Leaving)
10:45:44*beholders_eye joined #nim
10:51:08*coldfeet joined #nim
11:09:53*beholders_eye quit (Ping timeout: 244 seconds)
11:54:31*alexdaguy quit (Quit: WeeChat 4.4.2)
11:58:08*coldfeet quit (Remote host closed the connection)
12:45:22*deadmarshal_ quit (Quit: IRCNow and Forever!)
13:16:26*coldfeet joined #nim
13:27:53*deadmarshal_ joined #nim
14:04:53*mfg joined #nim
14:08:02*SchweinDeBurg quit (Quit: WeeChat 4.5.0-dev)
14:08:26*SchweinDeBurg joined #nim
14:11:40*mfg quit (Quit: leaving)
14:12:45*mfg joined #nim
14:33:10*ntat joined #nim
15:22:46*beholders_eye joined #nim
15:30:17*beholders_eye quit (Ping timeout: 265 seconds)
16:55:03*disso-peach joined #nim
17:05:19*PMunch joined #nim
17:38:18*coldfeet quit (Quit: Lost terminal)
17:40:28*coldfeet joined #nim
17:44:13FromDiscord<leorize> it's more beneficial to replicate the entire struct in nim if you can
17:44:14FromDiscord<leorize> included types lacks a lot of CT features like alignment and size checks
17:44:14FromDiscord<leorize> and obviously, you need the header itself to be included
17:53:13FromDiscord<aurelian5014> when I slice a string, is the new string a view or new allocation?
18:09:38FromDiscord<leorize> new allocation
18:11:39*PMunch quit (Quit: leaving)
18:23:55FromDiscord<aurelian5014> can I get a reference with the slice range?
18:30:10*PMunch joined #nim
18:31:47*beholders_eye joined #nim
18:36:21FromDiscord<aurelian5014> sent a code paste, see https://play.nim-lang.org/#pasty=AjLLiDVL
18:38:22FromDiscord<aurelian5014> (edit) "https://play.nim-lang.org/#pasty=zmRBHTgU" => "https://play.nim-lang.org/#pasty=ktNfCiXc"
18:48:09*disso-peach quit (Quit: Leaving)
19:00:00*beholders_eye quit (Ping timeout: 246 seconds)
19:02:36*coldfeet quit (Quit: Lost terminal)
19:04:49FromDiscord<Elegantbeef> @aurelian5014 indexing gets a char, slicing allocates
19:05:06FromDiscord<Elegantbeef> `toOpenArray` does not allocate, but it cannot be held onto right now
19:06:54FromDiscord<aurelian5014> In reply to @Elegantbeef "<@294829438363762699> indexing gets a": indexing `seq[string]` gets char?
19:07:08FromDiscord<Elegantbeef> No it copies
19:07:23FromDiscord<aurelian5014> so deep copy
19:07:38FromDiscord<Elegantbeef> Yes Nim strings are considered value-like
19:07:47FromDiscord<aurelian5014> gotcha, thx
19:08:18FromDiscord<Elegantbeef> you can do `--expandArc:procedureNameHere` to see the IR of implicit copies
19:08:23FromDiscord<aurelian5014> nice
19:08:34FromDiscord<aurelian5014> I'm so used to ptr + len
19:08:59FromDiscord<Elegantbeef> Well that's what a string is, it's also what a openarray is
19:09:38FromDiscord<aurelian5014> right, but I didn't expect slicing a string to copy the heap data
19:10:06FromDiscord<Elegantbeef> it is a performance trap
19:10:54FromDiscord<aurelian5014> came from rust where `&str` is the workhorse 🙂
19:11:32FromDiscord<Elegantbeef> Yea there is no borrowing here
19:11:49FromDiscord<Elegantbeef> There is an experimental flag for borrowing, but it's wholly unusable
19:14:33FromDiscord<aurelian5014> In reply to @Elegantbeef "it is a performance": how so?
19:14:50FromDiscord<Elegantbeef> Cause `a[b..c]` allocates a new string
19:15:04FromDiscord<Elegantbeef> So if you slice a lot your hotpath is the heap allocator
19:15:40FromDiscord<aurelian5014> ah, you were referring to slicing in Nim
19:17:05FromDiscord<SmaamX> Is there anything like(that can be an alternative) sklearn for nim?
19:17:56FromDiscord<Elegantbeef> scinim has a bit of ML adjacent stuff
19:19:32FromDiscord<aurelian5014> I guess slices don't point to the source for safety reasons
19:19:58FromDiscord<Elegantbeef> Correct without borrowing you need immutable strings
19:20:31FromDiscord<Elegantbeef> Nim has mutable strings, so it's just not possible to safely slice a string
19:20:59FromDiscord<Elegantbeef> Araq did have an experiment but ran into the fact that you cannot convert to a `cstring` without mutating the underlying string
19:22:55FromDiscord<Elegantbeef> You also could of course make your own `StringSlice` if you want
19:23:06FromDiscord<Elegantbeef> But again it's wholly unsafe so you need to ensure lifetimes yourself
19:40:52FromDiscord<kapendev> What is the alternative? Make a custom object that is ptr + len?
19:41:17FromDiscord<Elegantbeef> The alternative is your own string type and slice that is not unsafe 😛
19:41:38FromDiscord<Elegantbeef> You can just do `template mySlice(): untyped = toOpenArray(str, start ,stop)` then use `mySlice()`
19:43:36*mfg quit (Quit: leaving)
20:06:45FromDiscord<aurelian5014> https://github.com/planetis-m/ssostrings
20:06:48FromDiscord<aurelian5014> nice
20:32:00*ntat quit (Quit: Leaving)
20:32:14*PMunch quit (Quit: leaving)
21:03:48FromDiscord<kapendev> Slicing is "safe". Depends on what we talk about i guess.
21:04:46FromDiscord<Elegantbeef> Slicing is not safe if you want it to not allocate
21:05:37FromDiscord<Elegantbeef> It's a borrow with no safety if you do `(data: str[start].addr, len: start..stop.len)`
21:05:56FromDiscord<aurelian5014> In reply to @kapendev "Slicing is "safe". Depends": not if the backing data dies
21:06:12*lucasta joined #nim
21:07:16FromDiscord<aurelian5014> though with RC, I guess that could be made safe
21:07:35FromDiscord<Elegantbeef> Nim's strings do not have a RC
21:07:45FromDiscord<aurelian5014> ah
21:07:55FromDiscord<Elegantbeef> You can always do what pmunch's stringslice does and move the string to a `ref string`
21:08:20FromDiscord<aurelian5014> for now I'm just getting a feel of the memory ops
21:08:38FromDiscord<Elegantbeef> https://github.com/PMunch/strslice/blob/master/src/strslice.nim
21:09:14FromDiscord<Elegantbeef> You do need to move the string to the stringslice which means a new `newStringSlice` which as a `sink` there is no `sink` already
21:09:19FromDiscord<Elegantbeef> "PRs welcome" 😄
21:10:08FromDiscord<aurelian5014> sent a code paste, see https://play.nim-lang.org/#pasty=pQDHzRXA
21:10:35FromDiscord<aurelian5014> the sending part is missing ofc
21:18:42FromDiscord<Elegantbeef> That' is one way of doing whatever you're doing
21:22:17FromDiscord<aurelian5014> ideally I'd take references and build this message without extra copies
21:23:40FromDiscord<Elegantbeef> Well you can always annotate `sink` and take ownership of a `seq[string]`
21:23:43FromDiscord<kapendev> In reply to @aurelian5014 "not if the backing": Don't know nim very well. I was thinking that in a gc language the data will be valid until it is collected.
21:24:03FromDiscord<Elegantbeef> Well that's sorta true
21:24:24FromDiscord<Elegantbeef> Nim with arc is deterministically collected, but the issue with holding onto a string is there is no refcount
21:24:40FromDiscord<Elegantbeef> So there is no life extension as such it'll be a dangling pointer to the heap
21:25:02FromDiscord<kapendev> Ah ok
21:25:06FromDiscord<Elegantbeef> @aurelian5014 what do you mean by "enum string"?
21:25:17FromDiscord<aurelian5014> `$domain`
21:25:29FromDiscord<Elegantbeef> That calls a `$` procedure
21:25:48FromDiscord<aurelian5014> right...
21:26:09FromDiscord<Elegantbeef> Given it's a runtime invocation it's likely not a literal
21:26:12FromDiscord<aurelian5014> const lookup table is easy enough
21:26:58FromDiscord<Elegantbeef> You can always if you want to get a literal do `const names: array[Domain, string] = ["bleh", "Meh", "huh"]`
21:27:02FromDiscord<Elegantbeef> then do `names[domain]`
21:27:21FromDiscord<Elegantbeef> I do not get exactly what you're doing anyway \`= "\\0\\
21:27:22FromDiscord<Elegantbeef> whoops
21:27:26FromDiscord<Elegantbeef> with the `\0\0\0\0`?
21:27:39FromDiscord<aurelian5014> that's just what the server wants
21:27:48FromDiscord<Elegantbeef> Is that just you attempting `newStringOfCap(4)`?
21:27:55FromDiscord<Elegantbeef> Or even `newString(4)`?
21:28:34FromDiscord<Elegantbeef> I see
21:28:42FromDiscord<aurelian5014> well that would reallocate the buffer when it fills up, which I don't want. now I'm just wondering if `for arg in args` copies
21:29:03FromDiscord<Elegantbeef> nope it's a lent
21:29:26FromDiscord<Elegantbeef> > well that would reallocate the buffer when it fills up↵Nope you do `newString` once so it's the same as the above
21:29:57FromDiscord<Elegantbeef> The `\0\0\0\0` is fine and probably more clear than just a `newString(4)`
21:30:02FromDiscord<aurelian5014> In reply to @Elegantbeef "> well that would": never mind, what I said made no sense
21:30:13FromDiscord<aurelian5014> it's the same
21:30:31FromDiscord<Elegantbeef> That's what I said!
21:30:39FromDiscord<aurelian5014> lol reading is hard sometimes
21:30:46FromDiscord<aurelian5014> skull issue
21:31:44FromDiscord<Elegantbeef> Certainly you should check if the `buf.len < 251` 😄
21:32:18FromDiscord<Elegantbeef> Or https://github.com/termermc/nim-stack-strings/ if you want to be stylish about your fixed size buffer
21:32:48FromDiscord<aurelian5014> hell yea, I use CompactString all over the place in rust
21:33:06FromDiscord<Elegantbeef> Really though I imagine the best thing to do is `var buf {.global.} = newStringOfCap(255 + 4)` followed by `buf.setLen(4);buf[0..3] = "\0\0\0\0"`
21:33:06FromDiscord<aurelian5014> (edit) "hell yea, I use CompactString ... all" added "and ArrayString"
21:33:49FromDiscord<Elegantbeef> Though stack strings has `tryAdd` so that's fine you can safely recover
21:34:06FromDiscord<aurelian5014> this language is so good
21:34:22FromDiscord<Elegantbeef> Welcome to the honeymoon period
21:36:46FromDiscord<fabric.input_output> you should be safe unless you have big expectations and ambitions for certain things
21:45:25FromDiscord<aurelian5014> I've been trying it for a day and it's already more usable than swift
21:46:37FromDiscord<fabric.input_output> not sure how swift works
21:47:05FromDiscord<Elegantbeef> I'm too stubborn to try swift the whole `_ bleh: T` is just ugh
21:47:20FromDiscord<Elegantbeef> Forcing the names of parameters to be used when invoking a procedure is just so why
21:47:36FromDiscord<Elegantbeef> It does at least do a bunch of interesting things
21:47:54FromDiscord<Elegantbeef> Polymorphic FFI for instance
21:48:44FromDiscord<aurelian5014> local reasoning is sorely lacking
21:49:25FromDiscord<Elegantbeef> In what regard?
21:49:50FromDiscord<aurelian5014> it was pretty much impossible for me to discover what was happening
21:50:10FromDiscord<Elegantbeef> Due to protocols?
21:50:23FromDiscord<aurelian5014> I gave up after a few days
21:52:35FromDiscord<aurelian5014> I was hoping to avoid rust's lifetimes and instead I got a mountain of oop crap
21:54:00FromDiscord<Elegantbeef> Well it is the progeny of obj-c so you walked into it
21:54:25FromDiscord<aurelian5014> hopefully hylo takes off
21:55:44FromDiscord<Elegantbeef> Well I just hope it's not too hard to fork to remove the swiftism of forced parameter names 😄
21:56:11FromDiscord<aurelian5014> ugh yea
21:56:25FromDiscord<aurelian5014> try expressions alone make nim > swift for me
21:57:34FromDiscord<aurelian5014> sent a code paste, see https://play.nim-lang.org/#pasty=QEQobADy
21:58:05FromDiscord<aurelian5014> (edit) "https://play.nim-lang.org/#pasty=ALeUQSHB" => "https://play.nim-lang.org/#pasty=YDcDmxCN"
21:58:21FromDiscord<aurelian5014> (edit) "https://play.nim-lang.org/#pasty=sYPaDFWO" => "https://play.nim-lang.org/#pasty=njajZOZt"
21:58:22FromDiscord<Elegantbeef> Expressions are rad
22:00:25FromDiscord<aurelian5014> sent a code paste, see https://play.nim-lang.org/#pasty=EemFQSlq
22:03:41FromDiscord<Elegantbeef> Well i disagree
22:04:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=DCzEdcuq
22:04:45FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=XUlcPXUz
22:12:37FromDiscord<fabric.input_output> mm I like immediate assignment more
22:18:48FromDiscord<Elegantbeef> Yea it's better
22:22:27*beholders_eye joined #nim
22:58:10*beholders_eye quit (Read error: Connection reset by peer)
23:03:46*beholders_eye joined #nim
23:12:19FromDiscord<.bobbbob> take the declarative programming pill
23:12:25FromDiscord<.bobbbob> shame nim cant return from a loop like rust can
23:17:44FromDiscord<aurelian5014> zig for-else is legit
23:18:03FromDiscord<fabric.input_output> In reply to @.bobbbob "shame nim cant return": when macro make you can
23:18:48FromDiscord<.bobbbob> In reply to @fabric.input_output "when macro make you": I keep forgetting you can do whatever you want with macros
23:19:41FromDiscord<aurelian5014> which reminds me, I need one to create a type with a subset of another's fields
23:40:56FromDiscord<Elegantbeef> @aurelian5014 https://github.com/beef331/micros/blob/master/tests/t_tsinspiredmacros.nim is a silly approach of that
23:45:24FromDiscord<aurelian5014> thanks!
23:57:53FromDiscord<Robyn [She/Her]> In reply to @.bobbbob "shame nim cant return": like transforming loops to closure iterators?