<< 05-10-2021 >>

00:01:14*Lord_Nightmare joined #nim
00:07:23*sagax quit (Remote host closed the connection)
00:08:34FromDiscord<el__maco> sent a code paste, see https://play.nim-lang.org/#ix=3ARo
00:08:44FromDiscord<el__maco> (edit) "https://play.nim-lang.org/#ix=3ARo" => "https://play.nim-lang.org/#ix=3ARp"
00:08:57FromDiscord<impbox [ftsf]> echo typeof(slice)
00:09:23FromDiscord<el__maco> ``seq[int]`` they say
00:10:49FromDiscord<impbox [ftsf]> https://nim-lang.org/docs/system.html#%5B%5D%2Carray%5BIdx%2CT%5D%2CHSlice%5BU%2CV%5D
00:29:52FromDiscord<el__maco> sent a code paste, see https://play.nim-lang.org/#ix=3ARs
00:31:32FromDiscord<timotheecour> copied; for sharing you'd need this PR: https://github.com/nim-lang/Nim/pull/14869 (there's also `--experimental:views` but it has documented limitations)
00:33:45FromDiscord<el__maco> right. Thanks for the answers
00:35:23FromDiscord<el__maco> I clearly need to think about this a bit more. If slice isn't the right mechanism for what I'm trying to do, and a pointer isn't an option, then what would be the right tool 🤔
00:35:41FromDiscord<impbox [ftsf]> @elmaco what are you trying to do?
00:38:54FromDiscord<el__maco> I have a relatively big two dimensional array, and I need to pick a subarray from it and read values from that
00:39:31FromDiscord<impbox [ftsf]> why not just read from your original array?
00:40:54FromDiscord<el__maco> I guess I could do that for now
00:42:13FromDiscord<impbox [ftsf]> what's the point of the slice?
00:46:37*Guest40 joined #nim
00:48:49FromDiscord<el__maco> I'm porting something I made in C(++), where I used a pointer to the array which makes the code much cleaner and probably faster too
00:52:22FromDiscord<el__maco> instead of saying something like ``big_array[row][col8+0],big_array[row][col8+1],...`` I basically do ``int p=big_array[row]+col8; p[0],p[1],...``
00:52:39FromDiscord<impbox [ftsf]> well you can do that in nim if you want, you could also make a view type
00:53:23FromDiscord<impbox [ftsf]> are you doing graphics surface stuff?
00:53:40FromDiscord<el__maco> kind of?
00:54:33FromDiscord<el__maco> I'm trying to evaluate Nim as a potential replacement for hobby projects
00:54:56FromDiscord<el__maco> started yesterday so I'm not very far yet 😅
00:55:01*greaser|q quit (Changing host)
00:55:01*greaser|q joined #nim
00:55:04*greaser|q is now known as GreaseMonkey
00:55:04FromDiscord<impbox [ftsf]> yup, doing a direct port of C++ code to nim is probably not as nice as doing it in a nimmy way
00:55:13FromDiscord<impbox [ftsf]> but you can just use a pointer for a direct mapping if you like
00:55:40FromDiscord<el__maco> I was able to obtain the pointer, but I wasn't able to say p[1]. Nim seems to want to only do p[]
00:55:58FromDiscord<ElegantBeef> Nope the issue is `ptr char` is indexable
00:56:03FromDiscord<ElegantBeef> (edit) "is" => "isnt"
00:56:08FromDiscord<ElegantBeef> you want `ptr UncheckedArray[char]`
00:56:11FromDiscord<impbox [ftsf]> `var p = cast[UncheckedArray[uint8]](myArray)`
00:56:22FromDiscord<ElegantBeef> it distinguishes pointers for type safety
00:56:24FromDiscord<impbox [ftsf]> (edit) "cast[UncheckedArray[uint8]](myArray)`" => "cast[ptr UncheckedArray[uint8]](myArray)`"
00:57:35FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ARy
00:57:35FromDiscord<impbox [ftsf]> can also do something like this to make it neater
00:58:14FromDiscord<impbox [ftsf]> then each index is a whole pixel
00:58:32FromDiscord<el__maco> seems ptr UncheckedArray might be what I'm looking for. However its 4am now and I really need to sleep so I'll have to return to this tomorrow. Thanks for the tips
01:02:49FromDiscord<el__maco> I feel like I got pretty far. My code compiles, and once I can figure out how to read png image to an Nim array I can start pulling my hair and debugging why the program isn't doing anything like its supposed to
01:04:08FromDiscord<impbox [ftsf]> you can check out nimPNG for reading a png
01:04:35FromDiscord<el__maco> sent a code paste, see https://play.nim-lang.org/#ix=3ARF
01:05:04FromDiscord<el__maco> because writing an image works, I assume I might have the pixels in "data", but the bridge from there to an Nim array is still unclear
01:06:00FromDiscord<el__maco> might just copy them or something, but that's for tomorrow
01:06:02FromDiscord<impbox [ftsf]> you might want `{.importc,cdecl.}`
01:06:12Guest40Hello everyone, is it possible cross a nim program to the linux version from the windows machine?
01:07:48FromDiscord<impbox [ftsf]> not familiar with lodepng sorry, but if you want to get up and running quick, i'd recommend using nimPNG
01:09:15FromDiscord<auxym> Hi, I'm looking into setting up something using rabbitMQ/ZeroMQ/Something similar. Does anyone have experience with something similar in Nim? A good library?
01:09:18FromDiscord<el__maco> I think that call fills ``w`` and ``h`` with the corresponding values, and ``data`` would be a pointer with wh pixels in it
01:10:14FromDiscord<impbox [ftsf]> ` error = lodepng_decode32_file(&image, &width, &height, filename);`↵`var error = lodepng_decode32_file(data
01:14:45*arkurious quit (Quit: Leaving)
01:21:32FromDiscord<impbox [ftsf]> @elmaco https://gist.github.com/ftsf/99669def17ea8ba0dd57d7fb6ad83ea1 this seems to work
01:25:45FromDiscord<el__maco> sent a code paste, see https://play.nim-lang.org/#ix=3ARK
01:26:04FromDiscord<el__maco> now I just have to figure out a way to return a variable sized array somehow 😅
01:26:09FromDiscord<ElegantBeef> `seq`
01:26:17FromDiscord<impbox [ftsf]> there's no variable sized arrays in nim use seqs
01:26:35FromDiscord<ElegantBeef> Also pixie exists 😛
01:26:37FromDiscord<el__maco> ``c`` is the result, and it is a seq
01:26:51FromDiscord<el__maco> but I'm adding each pixel with c.add 😭
01:27:07FromDiscord<impbox [ftsf]> yeah you can precreate the seq as the correct size
01:27:22FromDiscord<el__maco> how?
01:28:47FromDiscord<impbox [ftsf]> `result = newSeq[uint8](whchannels)`
01:30:34FromDiscord<el__maco> I guess I should then return that result from the function instead of the argument by reference
01:30:45FromDiscord<impbox [ftsf]> it's probably more idiomatic yes
01:31:13FromDiscord<impbox [ftsf]> though i'd recommend returning an object that includes the width and height
01:31:25FromDiscord<impbox [ftsf]> so you can reference it correctly after the call
01:32:09FromDiscord<impbox [ftsf]> you can also make a nice `[]` operator that takes x,y
01:32:34FromDiscord<impbox [ftsf]> so you can do `echo image[x,y]` instead of `echo image[x+yimage.w]`
01:33:34FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ARL
01:38:17*Guest40 quit (Quit: Client closed)
01:50:47NimEventerNew thread by Treeform: Show Nim: Use Nim code from other languages (genny + pixie-python), see https://forum.nim-lang.org/t/8479
01:56:04FromDiscord<impbox [ftsf]> @treeform nice! maybe i'll try with nico
01:56:07*stkrdknmibalz quit (Ping timeout: 252 seconds)
01:56:27FromDiscord<Elegantbeef> Impbox will have so much tooling to try with nico in the coming days 😜
01:56:42FromDiscord<impbox [ftsf]> \o/ exciting
01:57:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3ARO
01:57:48FromDiscord<Elegantbeef> only downside is if you have overloads you need to explicitly make the alias
01:58:09FromDiscord<treeform> In reply to @impbox "<@!107140179025735680> nice! maybe i'll": That would be a great project for this. Many people could use the nico.
01:58:22FromDiscord<impbox [ftsf]> mmm nico uses quite a few overloads, maybe i can get rid of some and replace with default args
01:58:29FromDiscord<treeform> we support overloads
01:58:41FromDiscord<Elegantbeef> Well treeform we're talking about two different things 😀
01:58:59FromDiscord<treeform> See: https://github.com/treeform/pixie/blob/master/bindings/bindings.nim#L129-L130
01:59:20FromDiscord<impbox [ftsf]> @treeform how does that work when exporting to C?
01:59:25FromDiscord<Elegantbeef> I'm talking about nimscripter which will require more work for supporing overloads
02:00:17FromDiscord<treeform> In reply to @impbox "<@!107140179025735680> how does that": C gets prefixed with the first arguments type
02:00:31FromDiscord<treeform> so `draw_image` and `draw_mask`
02:00:44FromDiscord<treeform> the python thing works with just draw (as python supports overloading kind of)
02:00:47FromDiscord<Elegantbeef> Suffixed
02:00:52FromDiscord<impbox [ftsf]> gotcha
02:00:58FromDiscord<impbox [ftsf]> postprefixed
02:01:03FromDiscord<treeform> midfixed
02:01:03FromDiscord<Elegantbeef> Lol
02:01:22*stutonk joined #nim
02:01:49*vicfred quit (Quit: Leaving)
02:04:29stutonkAnyone know what kind of thing I should pass in on the Nim side to receive a callee-allocated array pointer from a wrapped C function?
02:04:36FromDiscord<Elegantbeef> Emitting a proc with all permutations of typeclasses is fun!
02:04:47*stkrdknmibalz joined #nim
02:04:50FromDiscord<Elegantbeef> `ptr UncheckedArray[T]`
02:05:08FromDiscord<Elegantbeef> Depends on the C proc though
02:07:31stutonkThis is the official Nim binding for Xlib. The proc is XQueryTree. The parameter in question is a `PPWindow` which is a `ptr PWindow` and a PWindow is a `ptr Window`.
02:09:16stutonkWhatever I try that typechecks crashes with a nil deref
02:09:40FromDiscord<Elegantbeef> You make some `var yourWindow: PWindow` and pass those into your proc
02:12:15FromDiscord<Elegantbeef> So for that proc you will do something like https://play.nim-lang.org/#ix=3ARS
02:14:30*krux02 quit (Quit: Leaving)
02:20:21stutonkThe children part of that doesn't typecheck
02:24:03stutonkAnd casting it causes a SIGSEGV
02:25:11FromDiscord<Elegantbeef> `proc XQueryTree(para1: PDisplay, para2: Window, para3: PWindow, para4: PWindow, para5: PPWindow, para6: Pcuint)`
02:25:33FromDiscord<Elegantbeef> Without proper output cannot say much
02:29:53stutonkRight. `ptr UncheckedArray[PWindow]` doesn't typecheck as a `ptr ptr Window` and casting it to one causes a segfault. The compiler also won't let me cast the other way
02:30:17FromDiscord<Elegantbeef> So use a PPWindow
02:31:08stutonkI can just create a var of type `PPWindow` but can't do anything with it. I don't know how to cast it so it can be indexed like an array
02:39:35stutonkAnd it looks like just using a var of type `PPWindow` in the call at all typechecks but causes a segfault
02:39:41FromDiscord<retkid> how can i convert seq to an immutable type?
02:44:08stutonkYou mean to an array? Or do you mean to just make a particular seq immutable?
02:44:38FromDiscord<retkid> i have no preference
02:44:43FromDiscord<Elegantbeef> `let immSeq = otherSeq`
02:44:44FromDiscord<retkid> just want my seq to be immutable
02:44:57FromDiscord<retkid> In reply to @Elegantbeef "`let immSeq = otherSeq`": that works
02:45:00stutonkYeah, just use a let binding
02:45:18FromDiscord<retkid> i thought there would be a more elegant solution
03:07:17FromDiscord<Elegantbeef> @geekrelief\: We're now at https://play.nim-lang.org/#ix=3ARZ which generates overloads as such https://play.nim-lang.org/#ix=3AS1
03:07:37FromDiscord<Elegantbeef> It presently doesnt generate overloads for every single parameter, but eitherway it's nicer
03:08:53FromDiscord<Elegantbeef> When there is ambiguity one needs to make a procedure now, which makes it a tinge better, but ideally all of those symbols would get caught/exported
03:13:47FromDiscord<retkid> normally i dont like oop
03:13:51FromDiscord<retkid> java kinda ruined it fo me
03:13:52FromDiscord<retkid> (edit) "fo" => "for"
03:14:13stutonkAlright, Elegantbeef. I figured it out. It looks like the solution was to use a var of type `PWindow` and then calling the function with `ppwVar.addr` For some reason, directly using a `ptr ptr` segfaults. Then I can cast to a `ptr UncheckedArray[Window] and it works as expected. Thank you for your help
03:14:15FromDiscord<retkid> but when I do it in Nim, i feel like "woah this actually makes sense"
03:14:22FromDiscord<Elegantbeef> But nim isnt oop
03:14:31FromDiscord<retkid> you can do oop in nim
03:14:32FromDiscord<cabboose> HERETIC
03:14:36FromDiscord<cabboose> HERETIC
03:14:52FromDiscord<cabboose> Nah kidding. What do you mean by oop in nim though
03:15:05FromDiscord<retkid> type x = ref object of RootObj
03:15:08FromDiscord<Elegantbeef> I mean you can do OOP in Nim, and it's not too different to Java if you arent using interfaces and the like
03:15:11FromDiscord<retkid> is technically oop
03:15:25FromDiscord<retkid> yes but in Java it sucksa
03:15:28FromDiscord<retkid> and in Nim it makes sesne
03:15:31FromDiscord<retkid> (edit) "sesne" => "sense"
03:15:43FromDiscord<retkid> like for example
03:15:46FromDiscord<cabboose> Definitely covers inheritance to a degree and dynamic dispatching
03:17:50FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3AS3
03:18:15FromDiscord<retkid> i prefer nim here
03:18:17stutonkIt's simpler because Nim objects don't encapsulate behavior. They're basically syntactic sugar over C structs
03:18:20FromDiscord<retkid> (edit) "https://play.nim-lang.org/#ix=3AS3" => "https://play.nim-lang.org/#ix=3AS4"
03:18:29FromDiscord<retkid> well yea i was about to point out
03:18:36FromDiscord<retkid> i dont like how methods aren't in the class body
03:18:43FromDiscord<retkid> it looks strange to me
03:19:21FromDiscord<retkid> I'd probably like it if they did what Kotlin does with reflections
03:19:27stutonkYeah, it's a lot like Common Lisp's generic functions
03:19:49FromDiscord<Elegantbeef> There are a multitude of macros that give class like declaration
03:19:56FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3AS5
03:21:07FromDiscord<retkid> In reply to @stutonk "Yeah, it's a lot": been thinking about learning a lisp dialect
03:21:10FromDiscord<retkid> like racket
03:21:49stutonkRacket is pretty sweet. Especially for experimental programming
03:24:48FromDiscord<retkid> Clojure looks disgusting
03:26:12stutonkIt's actually also pretty nice once you wrap your head around the level of immutability it imposes. The only thing really painful about it is the error messages and some of the namespacing stuff
03:26:38FromDiscord<retkid> yea
03:26:42FromDiscord<retkid> that looks not fun
03:26:58stutonkNim is right there in the sweetspot of compiler magic and helpful type system though
03:27:13FromDiscord<retkid> I solve all my problems with lists and arrayas
03:27:15FromDiscord<retkid> (edit) "arrayas" => "arrays and sets"
03:27:38FromDiscord<retkid> if I go to a functional programming language I'll learn stuff but I dunno if i want to learn that lession lol
03:29:45stutonkWhat lesson do you mean?
03:30:51FromDiscord<retkid> about solving problems with immutability \
03:31:53stutonkIn the S-expression languages it's pretty natural. You don't even notice you're doing it
03:33:06stutonkThe only real hurdle there is just understanding how recursion works
03:35:01stutonkAnd really, there are functions that simplify most iteration tasks like `map` and `fold`
03:36:28stutonkAnd in Clojure they have the threading macros for threading a piece of data through a sequence of functions
03:40:44FromDiscord<NullCode> man it still takes me too long to do simple nim things
03:41:20FromDiscord<NullCode> took me 40 minutes to make a proc that returns battery percentage
03:42:02stutonkIs that on a *Nix system?
03:44:33FromDiscord<NullCode> win
03:45:42stutonkIs there some kind of complicated API for it on Windows? On Linux all you have to do is read from a specific file
03:46:48FromDiscord<NullCode> yeah on nix it's really easy
03:46:53FromDiscord<NullCode> on win is easy too tbh
03:47:19FromDiscord<NullCode> you just need to extract battery percentage from a command output
03:47:27FromDiscord<NullCode> `WMIC PATH Win32_Battery Get EstimatedChargeRemaining`
03:47:43stutonkWhat was difficult doing it with Nim?
03:49:14FromDiscord<NullCode> nothing at all
03:49:18FromDiscord<NullCode> it's just, I'm an idiot
03:49:36FromDiscord<NullCode> and still can't memorize what the regex procs do
03:49:43FromDiscord<NullCode> (edit) "regex" => "important"
03:49:46FromDiscord<Elegantbeef> Easy dont use regex
03:49:53FromDiscord<NullCode> i need to dig around docs everytime i wanna do something
03:50:11FromDiscord<NullCode> mainly os, (str|seq)utils and regex
03:50:14FromDiscord<NullCode> In reply to @Elegantbeef "Easy dont use regex": lmao
03:50:30FromDiscord<NullCode> (edit) "os," => "os(proc),"
03:50:35FromDiscord<NullCode> what do i do then
03:51:00FromDiscord<Elegantbeef> I generally use scanf from strscans
03:51:03FromDiscord<NullCode> can't think of easier way than `findAndCaptureAll(output, reg_string).join()`
03:51:15FromDiscord<NullCode> In reply to @Elegantbeef "I generally use scanf": and here i am having no idea about strscans
03:51:17FromDiscord<NullCode> wait lemme see docs
04:00:21*stutonk quit (Quit: Client closed)
04:05:23*Terry[m] is now known as Theodore[m]
04:06:01*supakeen quit (Quit: WeeChat 3.3)
04:06:28FromDiscord<NullCode> i have arrived after reading docs
04:06:31*supakeen joined #nim
04:06:34FromDiscord<NullCode> and my head is still spinning
04:06:59FromDiscord<Elegantbeef> It's just a regex alternative for simple string -\> variables
04:07:17FromDiscord<NullCode> yeah i think i can use it now
04:08:30FromDiscord<NullCode> btw question about strscans
04:08:44FromDiscord<NullCode> do i have to copy the entire string to match the vals i need
04:08:47FromDiscord<NullCode> https://media.discordapp.net/attachments/371759389889003532/894798245916729374/unknown.png
04:09:09FromDiscord<Elegantbeef> Yea for somethings
04:09:16FromDiscord<NullCode> like do "EstimatedChargeRemaining$i$i"
04:09:25FromDiscord<NullCode> because then it might not work
04:09:27FromDiscord<Elegantbeef> well just one `$i`
04:09:32FromDiscord<NullCode> oh
04:09:38FromDiscord<NullCode> (edit) ""EstimatedChargeRemaining$i$i"" => "`"EstimatedChargeRemaining$i$i"`"
04:09:47FromDiscord<NullCode> ok then all good
04:19:11FromDiscord<NullCode> https://media.discordapp.net/attachments/371759389889003532/894800862998831136/unknown.png
04:19:13FromDiscord<NullCode> uhh what
04:19:33FromDiscord<NullCode> should be 77
04:19:34FromDiscord<impbox [ftsf]> is there a reason you're posting screenshots of text?
04:19:36FromDiscord<NullCode> https://media.discordapp.net/attachments/371759389889003532/894800967663505418/unknown.png
04:19:40FromDiscord<impbox [ftsf]> just post the text
04:19:48FromDiscord<NullCode> In reply to @impbox "is there a reason": idk lmfao
04:19:57FromDiscord<NullCode> didn't even notice i was sending screenshots of text
04:20:01FromDiscord<Elegantbeef> yo ucan jusut do `result` instead of \`life
04:20:20FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3AS8
04:20:29FromDiscord<NullCode> In reply to @Elegantbeef "yo ucan jusut do": alright
04:20:59FromDiscord<impbox [ftsf]> if the if passing?
04:21:19FromDiscord<impbox [ftsf]> (edit) "if" => "is"
04:22:05FromDiscord<NullCode> In reply to @Elegantbeef "yo ucan jusut do": `Error: type mismatch: got <bool> but expected 'int'`
04:22:14FromDiscord<NullCode> doing the if statement is better
04:22:21FromDiscord<NullCode> In reply to @impbox "is the if passing?": i think so
04:22:28FromDiscord<NullCode> wait i forgot doing something important
04:22:33FromDiscord<Elegantbeef> `discard scanf()`
04:22:59FromDiscord<impbox [ftsf]> well it might fail, so you shouldn't discard it
04:23:28FromDiscord<Elegantbeef> If it fails it'll be `0` so it's up to you
04:23:47FromDiscord<impbox [ftsf]> but it could also actually be 0
04:23:56FromDiscord<NullCode> In reply to @impbox "but it could also": yes
04:24:24FromDiscord<NullCode> why is it 0 and not 80
04:24:26FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3ASb
04:24:40FromDiscord<NullCode> here's what I'm doing
04:24:42FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3ASc
04:25:12FromDiscord<NullCode> I'm just wondering if i should use regex instead
04:25:15FromDiscord<Elegantbeef> there is a space
04:25:21FromDiscord<NullCode> oh
04:25:23FromDiscord<NullCode> siht
04:25:26FromDiscord<NullCode> (edit) "siht" => "shit"
04:25:33FromDiscord<Elegantbeef> I mean you can use regex if you want
04:26:02FromDiscord<NullCode> now that i yeeted the space
04:26:03FromDiscord<NullCode> fixed
04:26:04FromDiscord<NullCode> thanks a lot
04:26:07FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3ASd
04:26:12FromDiscord<NullCode> In reply to @Elegantbeef "I mean you can": nah ill keep using this
04:26:39FromDiscord<impbox [ftsf]> sent a code paste, see https://play.nim-lang.org/#ix=3ASe
04:26:57FromDiscord<impbox [ftsf]> (edit) "https://play.nim-lang.org/#ix=3ASe" => "https://play.nim-lang.org/#ix=3ASf"
04:28:01FromDiscord<NullCode> hmm yeah that works
04:28:29FromDiscord<NullCode> are there any benefits to doing `std/strscans`
04:28:35FromDiscord<impbox [ftsf]> it makes beef happy
04:28:55FromDiscord<NullCode> alright making beef happy too
04:29:34FromDiscord<impbox [ftsf]> it makes sure it imports from the standard library, even if you had a local file called strscans.nim it'd use the standard library one
04:33:12FromDiscord<cabboose> Also new std library modules will enforce that iirc
04:33:36FromDiscord<cabboose> Like setutils will need the std prefix
04:35:36FromDiscord<NullCode> bruh
04:35:54FromDiscord<NullCode> ig I'm gonna put std/ on every built in lib then
04:36:10FromDiscord<impbox [ftsf]> beef is gonna be so happy
04:36:47FromDiscord<NullCode> XD
04:37:15*Guest20 joined #nim
04:37:21FromDiscord<NullCode> sent a long message, see http://ix.io/3ASg
04:37:35*Guest20 quit (Client Quit)
04:37:41FromDiscord<impbox [ftsf]> `"EstimatedChargeRemaining$s$i"`
04:37:43FromDiscord<NullCode> (edit) "http://ix.io/3ASg" => "http://ix.io/3ASh"
04:38:01FromDiscord<impbox [ftsf]> `$s Skips optional whitespace.`
04:38:14FromDiscord<NullCode> thats faster?
04:38:16FromDiscord<NullCode> amazing
04:38:26FromDiscord<NullCode> man i still have so much to learn from nim
04:38:26FromDiscord<impbox [ftsf]> very likely faster than doing a string replace
04:38:30FromDiscord<NullCode> it's kinda depressing
04:38:38FromDiscord<NullCode> In reply to @impbox "very likely faster than": i see
04:38:39FromDiscord<impbox [ftsf]> lots to learn means lots of fun to be had
04:39:50FromDiscord<impbox [ftsf]> string replace is relatively expensive
04:40:34FromDiscord<impbox [ftsf]> but likely none of this will matter for your use case unless you're doing stuff for realtime
04:40:41*rockcavera quit (Remote host closed the connection)
04:41:24FromDiscord<NullCode> I'm planning on making an exe that runs in background
04:41:31FromDiscord<NullCode> and shouts at you when battery is toolow
04:41:35FromDiscord<NullCode> (edit) "toolow" => "too low"
04:41:48FromDiscord<NullCode> (it's a personal project because my laptop keeps shutting down at 5%)
04:42:09FromDiscord<impbox [ftsf]> yaa, just remember, optimise later when you need to
04:42:17FromDiscord<NullCode> yup
04:42:24FromDiscord<impbox [ftsf]> as long as it works ( '')b
04:44:41FromDiscord<NullCode> well it needs to be fast too :D
04:46:11FromDiscord<impbox [ftsf]> works and slow is better than not working at all, can always make it faster later
04:49:13FromDiscord<NullCode> unless you're an idiot who knows only 5% of a language lmfao
04:54:41*User11 joined #nim
04:57:30*dongbei joined #nim
05:00:17dongbeihiya, i'm trying to figure out how to use a .so library compiled from a .cpp in nim. when I used c2nim on the header file it generated a bunch of `discard "foward declaration of blah"` for a struct blah. the .so has the definition but I don't know how to bring it in.
05:01:44dongbeievery time I try to compile my server.nim file i get the compiler error "Error: undeclared identifier: 'blah'"
05:02:28dongbeidoes anyone have experience with getting c libraries into a nim prog?
05:15:33FromDiscord<retkid> so
05:15:44FromDiscord<retkid> i have imports which are conflicting
05:15:52FromDiscord<retkid> (edit) "are" => "has" | "hasconflicting ... " added "variables"
05:15:57FromDiscord<retkid> json, and tables
05:16:10FromDiscord<retkid> .keys on a table returns the json version...
05:16:20FromDiscord<retkid> whats the solution for this
05:19:50FromDiscord<retkid> sent a code paste, see https://play.nim-lang.org/#ix=3ASp
05:19:59FromDiscord<retkid> (edit) "https://play.nim-lang.org/#ix=3ASp" => "https://play.nim-lang.org/#ix=3ASq"
05:20:09FromDiscord<Elegantbeef> keys is an iterator so that's just bad usage
05:20:16FromDiscord<retkid> wait yea i just noticed that
05:20:19FromDiscord<retkid> lets see
05:21:23FromDiscord<retkid> the only reason it wasn't red when i removed Json was because everything else was red 🤦‍♀️
05:29:23FromDiscord<impbox [ftsf]> @dongbei you'll need to wrap the cpp header to expose the procs to nim
05:29:42FromDiscord<impbox [ftsf]> c2nim might do that for you, but you might be better of doing it by hand
05:29:48FromDiscord<impbox [ftsf]> or at least tweaking the output
05:50:30*kaliyuga_ joined #nim
05:50:30*User11 quit (Read error: Connection reset by peer)
05:51:18*kaliyuga_ quit (Client Quit)
06:02:13FromDiscord<geekrelief> In reply to @Elegantbeef "<@109484839480107008>\: We're now at": I'm a little confused with what the output https://play.nim-lang.org/#ix=3AS1 is supposed to mean. How do the procs with `discard` get implemented?
06:02:56FromDiscord<Elegantbeef> Those are implemented by the Nim binary
06:03:23FromDiscord<Elegantbeef> When you call `loadScript`
06:03:54FromDiscord<Elegantbeef> They need a body for obvious reasons but the VM overrides their functionality on load
06:04:04FromDiscord<Elegantbeef> So a simple `discard` works
06:04:09FromDiscord<geekrelief> In reply to @Elegantbeef "Those are implemented by": I'm not sure I follow. What's the Nim binary you're talking about?
06:04:19FromDiscord<Elegantbeef> The binary you're scripting
06:04:44FromDiscord<Elegantbeef> `implNimscriptModule` generates a list of the VM procs + overriding logic
06:04:56FromDiscord<geekrelief> So in the samples script only 4 procs work?
06:05:04FromDiscord<geekrelief> `background`, `stroke`, etc.
06:05:43FromDiscord<Elegantbeef> No all the procs work, the ones with discard are implemented in the VM by code generated with `implNimscriptModule`
06:06:09FromDiscord<Elegantbeef> It's all an implementation detail that no one will see unless they name procs similarly
06:06:38FromDiscord<geekrelief> ok, I guess I'll trust it just works. I'll have to read your code to understand what's going on.
06:06:53FromDiscord<geekrelief> But implNimscriptModule does all the magic I guess.
06:07:18FromDiscord<geekrelief> nice work!
06:17:40NimEventerNew thread by Xflywind: Contribution-friendly issues for Hacktoberfest 2021, see https://forum.nim-lang.org/t/8480
06:19:55FromDiscord<Elegantbeef> Fun, got the generating code for properties done, now global variables can be used in `exportTo` block
06:20:10FromDiscord<geekrelief> In reply to @Elegantbeef "No all the procs": nice!
06:20:23FromDiscord<geekrelief> I skimmed over the code for `expose.nim`
06:20:30FromDiscord<Elegantbeef> But there is a reprocudable bug on the call due to dumb stuff i'm doing
06:20:35FromDiscord<Elegantbeef> Yea i know it needs comments 😛
06:20:35FromDiscord<geekrelief> I'll have to play with this more tomorrow
06:21:14FromDiscord<geekrelief> no worries. I've gotten used to reading code without comments though.
06:21:39FromDiscord<geekrelief> I'll just bug you if there's something I don't understand. 😄
06:22:16FromDiscord<geekrelief> heading to bed g'night
06:22:22FromDiscord<Elegantbeef> Buh bye
06:30:59*neurocyte013288 joined #nim
06:30:59*neurocyte013288 quit (Changing host)
06:30:59*neurocyte013288 joined #nim
06:53:09FromDiscord<NullCode> question
06:53:13FromDiscord<NullCode> https://media.discordapp.net/attachments/371759389889003532/894839629260419114/unknown.png
06:53:21FromDiscord<NullCode> how to safely exit after getting SIGINT
06:53:42*jjido joined #nim
06:56:18Amun-RaNullCode: https://nim-lang.org/docs/system.html#setControlCHook
06:56:35Amun-Raalso: https://rosettacode.org/wiki/Handle_a_signal#Nim
06:58:16FromDiscord<NullCode> thamk
07:05:50FromDiscord<Mike> Hey, if anyone is awake\: is there a way for me to do something like `readChar(stdin)`, but not line buffered?
07:06:30FromDiscord<Mike> As in I want to get the character that a user types immediately and not have to wait for a newline
07:06:47FromDiscord<Elegantbeef> `terminal.getch`?
07:07:17FromDiscord<Elegantbeef> that blocks until a character is entered, not sure that's what you want either though
07:07:46FromDiscord<Mike> No that is actually what I want
07:08:16FromDiscord<Mike> That's perfect, thank you ❤️
07:08:42FromDiscord<Elegantbeef> No problem
07:23:14FromDiscord<NullCode> nice I've arrived to the part where i wanna play some audio
07:23:55*max22- joined #nim
07:26:08*PMunch joined #nim
07:38:35*max22- quit (Ping timeout: 246 seconds)
07:43:47*TechAspirer is now known as kayabaNerve
07:45:15*pro joined #nim
07:46:25*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
07:54:56*Vladar joined #nim
07:59:55FromDiscord<haxscramper> Is casting `set[I]` to unsigned integers considered an implementation detail exploitation, or this is an acceptable way to interface with C's `unsigned int flags` for passing multiple enum values at once?
08:00:40FromDiscord<Elegantbeef> I'd say it's acceptable, given the logic of how sets work
08:01:25FromDiscord<Elegantbeef> Bitsets afterall are just human friendly abstractions ontop of bitwise ops
08:02:26*pro quit (Quit: WeeChat 3.3)
08:05:51NimEventerNew Nimble package! feta - A domain-specific for general purpose office automation. The language is embedded in Nim and allows for quick and easy integration of different office software environments., see https://github.com/FlorianRauls/office-DSL-thesis
08:05:54nrds<R2D299> itHub: 7"2021 Bachelor Thesis repository for development of an office automatization DSL in Nim"
08:08:44*sagax joined #nim
08:12:39*kayabaNerve quit (*.net *.split)
08:12:40*FromDiscord quit (*.net *.split)
08:12:40*Freneticks quit (*.net *.split)
08:12:40*mst quit (*.net *.split)
08:24:23*kayabaNerve joined #nim
08:24:23*FromDiscord joined #nim
08:24:23*Freneticks joined #nim
08:24:23*mst joined #nim
08:54:11*max22- joined #nim
08:59:55FromDiscord<kunitoki> Hey there ! I've tried registering multiple times with different email addresses in the forum but i keep not getting the confirmation emails so i cannot post. And now i run out of email addresses... Anything can be done ?
09:01:03FromDiscord<kunitoki> in some cases my user is even broken, can't login. keep getting unknown error in the login page
09:02:36FromDiscord<xflywind> In reply to @kunitoki "Hey there ! I've": You may contact with @dom96 or other admins.
09:02:57FromDiscord<xflywind> (edit) "admins." => "admins of Nim forum."
09:13:58FromDiscord<enthus1ast> sent a long message, see https://paste.rs/fQJ
09:15:03FromDiscord<enthus1ast> i've build the libhydrogen normally with their makefile, and also with their cmake/make
09:18:51FromDiscord<dom96> In reply to @flywind "You may contact with": make sure to ask people for their nick, that way I can immediately fix it
09:18:58FromDiscord<dom96> instead of asking for their nick 🙂
09:24:08PMunchWell this is annoying. I get an error from macros saying an identifier isn't defined, but outputting the `repr` and then importing that as a file works just fine..
09:27:51FromDiscord<enthus1ast> when i look with objdump -t ↵all the functions are there... https://gist.github.com/enthus1ast/8b8660989eac3d8ccb23978e1f852969
09:32:00FromDiscord<Varriount> In reply to @PMunch "Well this is annoying.": Sounds like a compiler bug then.
09:32:08PMunchYeah probably
09:34:08FromDiscord<enthus1ast> mhh i got it working
09:34:18FromDiscord<enthus1ast> i've linked from the commandline
09:34:28FromDiscord<enthus1ast> not from the wrapper pragma
09:35:11FromDiscord<Varriount> I wonder how well something like dependency injection could be done with Nim macros. I've been looking at https://python-dependency-injector.ets-labs.org/ for use in something at work, and the concept struck me as one that Nim could possibly do quite well.
09:43:49*Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in)
09:44:08*Gustavo6046 joined #nim
09:48:11PMunchNew version of Futhark: https://github.com/pmunch/futhark it now supports a wide range of #DEFINE statements and the renaming scheme is vastly improved
09:48:13nrds<R2D299> itHub: 7"Automatic wrapping of C headers in Nim"
09:53:41*dongbei quit (Quit: leaving)
09:57:18FromDiscord<impbox [ftsf]> i always read that lib's name as fthat, and it makes snse because that's what I think about having to writing C wrappers.
09:57:21FromDiscord<impbox [ftsf]> (edit) "writing" => "write"
10:00:58PMunchHmm, I think the renaming is a bit messed up in the new version..
10:01:02PMunchDamn it
10:01:04FromDiscord<Rika> I keep on reading “fut hark”
10:02:58PMunchThat would be pretty close to how you're supposed to pronounce it
10:03:34FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3ATn
10:03:42FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3ATo
10:04:11FromDiscord<haxscramper> Version string is not guaranteed to be stable, but I don't think they will break it so drastically any time sonn
10:04:20FromDiscord<haxscramper> So for C compiler include paths I use this
10:04:40PMunchThe problem is though that we don't know if they're compiling against clang or GCC
10:04:50PMunchOr even if they are on Linux for that matter..
10:05:13FromDiscord<haxscramper> You can do additional heuristics and checks
10:05:38FromDiscord<haxscramper> ah, and by they way, do you generate fully hardcoded include paths?
10:06:17FromDiscord<haxscramper> Like, it does not really matter what compiler they use if you cut down wrappers before they reach into things like `bits/features.h` or `bits/endian.h`
10:06:30FromDiscord<haxscramper> And if you are in the library wrappers it is all the same
10:17:19PMunchI basically just feed those paths to clang and then query clang for the types in the original files I wanted to include
10:17:51PMunchSo if there are some differences in those file it might bubble up. But I haven't noticed any issues with cross-using the headers yet
11:07:28*krux02 joined #nim
11:11:37FromDiscord<Goel> So into a proc, since i can't write `else: break` to end a loop if the earliers conditions are not met, using `else: return` does the same?
11:14:57FromDiscord<Rika> You can break a loop
11:15:10FromDiscord<Rika> What’s the full picture
11:15:29FromDiscord<NullCode> can you break an if else tho
11:15:37FromDiscord<NullCode> I don't know about that
11:16:52FromDiscord<NullCode> (edit) "don't know about that" => "said previously was stupid"
11:18:43FromDiscord<Rika> BRB checking irc to read what you said
11:24:51FromDiscord<NullCode> alright
11:25:05FromDiscord<NullCode> wait, you can check in irc if discord users edit message?
11:25:06FromDiscord<NullCode> oh NO
11:25:31FromDiscord<Rika> Of course
11:26:03FromDiscord<NullCode> too bad
11:26:29FromDiscord<Rika> > break an if else↵Bruh
11:26:29FromDiscord<Goel> sent a code paste, see https://play.nim-lang.org/#ix=3ATR
11:26:32FromDiscord<NullCode> ive sent shit i wasnt meant to in another irc bridge server
11:26:41*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
11:26:44FromDiscord<NullCode> In reply to @Rika "> break an if": yeah totally stupid
11:26:50FromDiscord<Rika> sent a code paste, see https://paste.rs/5rj
11:26:59FromDiscord<NullCode> now delete thanks
11:27:23FromDiscord<Goel> What do you mean there is not loop?
11:27:32FromDiscord<NullCode> if else aint a loop
11:27:37FromDiscord<NullCode> it's a condition statement
11:27:47FromDiscord<NullCode> and also, try `else: discard`
11:28:00FromDiscord<NullCode> it works for me (although idk about loops)
11:28:05FromDiscord<NullCode> (edit) "loops)" => "procs)"
11:28:22FromDiscord<Rika> Did you know that you’re not required to put an else
11:28:43FromDiscord<Rika> Else discard is equivalent to not having an else section
11:28:56FromDiscord<Goel> Nope doesn't work with else: discard, and if i delete the `else` doesn't work either as expected
11:29:12FromDiscord<Goel> Only works with `else: return`
11:29:26FromDiscord<NullCode> well whatever works for you
11:29:53FromDiscord<NullCode> btw
11:29:59FromDiscord<NullCode> how can i play an audio file using nim
11:30:22FromDiscord<NullCode> https://gist.github.com/zacharycarter/846869eb3423e20af04dea226b65c18f
11:30:26FromDiscord<NullCode> hmm just found this
11:31:06FromDiscord<Goel> https://nimble.directory/search?query=audio+player
11:31:59FromDiscord<NullCode> oh shit I've never seen nimble.directory
11:32:01FromDiscord<NullCode> this is cool
11:33:55FromDiscord<Goel> Oh yes it is, bookmark it immediatly! :nimble:
11:37:39FromDiscord<Rika> Honestly I just search on GitHub or other hubs because there’s a lot of stuff not on nimble
11:40:00FromDiscord<NullCode> yeah I've been searching on github too
11:40:12FromDiscord<NullCode> but I don't know, it's a lil cumbersome
11:40:18FromDiscord<NullCode> having to hit next page every now and again
11:40:29FromDiscord<NullCode> sometimes, a shorter list is better
11:40:36FromDiscord<Rika> Isn’t it the same issue on the directory
11:40:44FromDiscord<Rika> You can filter by language in GitHub
11:41:44FromDiscord<NullCode> i don't see a next page on directory
11:41:45FromDiscord<NullCode> so yeah
11:41:52FromDiscord<NullCode> lemme search for something a lil more vague
11:42:18FromDiscord<NullCode> nope
11:42:22FromDiscord<NullCode> everything''s inside a single page
11:42:27FromDiscord<NullCode> (edit) "everything''s" => "everything's"
11:42:35FromDiscord<NullCode> thats one of the things i love about nim docs
11:45:21FromDiscord<Rika> Eh some people aren’t a fan of infinite scroll
11:46:05FromDiscord<NullCode> why not
11:46:14FromDiscord<NullCode> just control f on one page only
11:48:21FromDiscord<tbrekalo> how can I return string view from a function?
11:48:37FromDiscord<enthus1ast> when a c function gets an array, it must be a ptr right? ↵Do i need to do this in nim as well? (so addr arr[0]) or is this handled automatically?
11:48:38FromDiscord<NullCode> string view?
11:49:30FromDiscord<tbrekalo> let str = "aabbcc"↵and I want to return from a funciton str[2 .. 4] without making a copy of data
11:51:44FromDiscord<auxym> nim has copy semantics. why do you want to do this?
11:51:49FromDiscord<Rika> In reply to @NullCode "why not": If the page unloads you lose your position
11:51:51FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3ATX
11:52:05FromDiscord<NullCode> In reply to @Rika "If the page unloads": just control f there again
11:52:08FromDiscord<enthus1ast> afaik this is a copy↵(@NullCode)
11:52:13FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=3ATZ
11:52:16FromDiscord<NullCode> oh
11:52:21FromDiscord<auxym> afaik also
11:52:41FromDiscord<Rika> Why do you want no copies?
11:52:49FromDiscord<tbrekalo> large amounts of data
11:53:00FromDiscord<Rika> There are experimental views afaik
11:53:07FromDiscord<enthus1ast> i'm not aware of a build in way, but i know there was a discussion about this somewhere on github, you could however build it yourself for your usecase
11:53:38FromDiscord<tbrekalo> I saw the view experimental feature; wondering was there a standard way of doing it
11:53:44FromDiscord<tbrekalo> without experimental features
11:54:13FromDiscord<tbrekalo> but I have a large string and I need to format it that after each 80 chars comes a new line in the output
11:54:39FromDiscord<Rika> https://nim-lang.org/docs/manual_experimental.html#view-types ?
11:54:45FromDiscord<Rika> No
11:54:57FromDiscord<Rika> You can do it in an unsafe way
11:55:03FromDiscord<Rika> Non experimental but still unsafe
11:55:18*max22- quit (Ping timeout: 268 seconds)
11:55:28FromDiscord<auxym> what is "large"? Are you sure copies are really a problem? If so could you just return indices into it or something like that, instead of a view?
11:55:29FromDiscord<Rika> In reply to @tbrekalo "but I have a": You need to construct a new string for this anyway…
11:55:55FromDiscord<Rika> Unless you already use ropes or a gap buffer
11:56:04FromDiscord<auxym> Yeah, making a copy of 80 bytes shouln't be an issue
11:56:29FromDiscord<Rika> You can’t do that with no copying afaik
11:56:55FromDiscord<tbrekalo> ehhh.... I still think in tearms of c++ while doing nim
11:57:21FromDiscord<Rika> We’re slowly getting to views but I don’t see how views would help with the modification you propose
11:57:32FromDiscord<Rika> You want to insert something, which means shifting memory
11:57:39FromDiscord<Rika> Or just constructing a new string
11:57:42FromDiscord<enthus1ast> would the memory grow when you insert newline?
11:57:49FromDiscord<Rika> Exactly what I mean
11:59:13FromDiscord<tbrekalo> Would save me an extra copy; maybe.. give me a moment
11:59:43FromDiscord<tbrekalo> an extra copy per line format
12:00:08FromDiscord<Rika> Mind showing why
12:00:09FromDiscord<Rika> ?
12:00:35*pro joined #nim
12:00:47FromDiscord<tbrekalo> give me few mins to code it up
12:02:00FromDiscord<Rika> Sorry
12:02:22*pro quit (Client Quit)
12:06:00FromDiscord<Marvel> is there a way to do something like `if a+ b == c and x + y == z` in nim? i tried `&`, `&&`, `and` but none worked
12:06:01*supakeen quit (Quit: WeeChat 3.3)
12:06:14FromDiscord<enthus1ast> and
12:06:31FromDiscord<enthus1ast> could be that you must overload and
12:06:32*supakeen joined #nim
12:06:49FromDiscord<Marvel> huh
12:06:56FromDiscord<Marvel> when i do that i get type mismatch
12:07:19FromDiscord<Rika> Avoid having unequal spaces around operators
12:07:52FromDiscord<Rika> !eval echo 1+1==2 and 2+2==4
12:07:53NimBottrue
12:10:08FromDiscord<tbrekalo> Data is once copied into a temporary which is returned from a function and that temporary is then used to copy data onto the result variable; unless compiler omits the return temporary https://media.discordapp.net/attachments/371759389889003532/894919381694439495/unknown.png
12:11:39FromDiscord<Rika> If you want to not use experimental, return the indices and access them in the loop perhaps
12:11:56FromDiscord<tbrekalo> In reply to @Rika "If you want to": ye; was thinking about that
12:11:56FromDiscord<Rika> I can see that it would still copy though
12:12:08FromDiscord<tbrekalo> ye but one copy instead of two
12:12:11FromDiscord<Rika> But I believe it is unavoidable since Nim doesn’t really have the support yet
12:12:36FromDiscord<tbrekalo> thanks
12:34:26FromDiscord<enthus1ast> to answer my question\: no need to get the addr of an array for c interopt, (just call the correct functions ;) )
12:54:31FromDiscord<juan_carlos> So I am responding like questions about Nim, one of the questions is "Maximum length of string", what would be the best answer ?.
12:54:39*arkurious joined #nim
12:54:57FromDiscord<juan_carlos> "No limit" ?, "Limited by memory capacity" ?
12:58:09FromDiscord<demotomohiro> I think it is `min(memory space size, available memory size)`
13:00:04FromDiscord<Rika> What language has a coded maximum string length?
13:02:03*rockcavera joined #nim
13:02:03*rockcavera quit (Changing host)
13:02:03*rockcavera joined #nim
13:04:51FromDiscord<el__maco> Pascal had a maximum length of 255, because the first byte of the string array was its length
13:05:42*Guest9 joined #nim
13:07:00Guest9Hello everyone. I have a quite naive question. Is it possible to omit the proc definition/prototyped even if the proc is used before it is implemented? Like in Java?
13:08:58FromDiscord<demotomohiro> You can do it like C.↵Just declare it like↵`proc foo(a: int)`
13:09:04*rockcavera quit (Remote host closed the connection)
13:09:11FromDiscord<Rika> In reply to @el__maco "Pascal had a maximum": Ah I guess technically Nim has this limit as well, except it’s 2^32 or was it 64?
13:09:34FromDiscord<Rika> In reply to @demotomohiro "You can do it": But the proc has to be implemented later in the same file
13:10:35FromDiscord<el__maco> you can also avoid forward declararing if you use the most awesome feature of Nim, code reordering
13:10:57FromDiscord<el__maco> <https://nim-lang.github.io/Nim/manual_experimental.html#code-reordering>
13:11:08Guest9I will have a look the reordering. Thank you
13:11:59FromDiscord<el__maco> its experimental feature so there might be some caveats, but so far its been working well for me
13:12:53FromDiscord<juan_carlos> I think the only caveat of code reordering is that is not aware of macro-generated proc.
13:13:14Guest9Understood. Actually it is ok to me to put lots of function prototype at the beginning of the program since I used the C language daily. Just curious.
13:14:27FromDiscord<el__maco> personally I find it rather silly that its 2021 and we're still forward declaring functions. A clerical task that's trivial for the computer to do 😔
13:16:30Guest9I think the forward declaring functions is good for software quality in some sense, I think.
13:16:34FromDiscord<juan_carlos> I kinda like that functions are declared from top to bottom tho.
13:17:08FromDiscord<juan_carlos> In Python I have to jump around top-bottom and back to find randomly placed function declarations.
13:17:18Guest9You can write the functions definition first and fill the implementation later. Make sure everything matches.
13:18:25FromDiscord<juan_carlos> I think is not trivial, I think is speeds up parsing a lot.
13:19:34FromDiscord<el__maco> I think computer science curriculums need more Bret Victor in them 😔
13:22:24FromDiscord<el__maco> the modern computer is mind boggingly fast. Scanning through a megabyte of text to find some symbol names is not slow at all, or it should not be at least 🤷‍♂️
13:23:29FromDiscord<xflywind> there are two PRs which intend to solve the forward declare issue
13:23:30FromDiscord<xflywind> https://github.com/nim-lang/Nim/pull/18818
13:23:38FromDiscord<xflywind> https://github.com/nim-lang/Nim/pull/18822
13:36:45*dukester joined #nim
13:38:59*rockcavera joined #nim
13:38:59*rockcavera quit (Changing host)
13:38:59*rockcavera joined #nim
13:39:32dukesternoob here! Is there program structure that I should follow? Any main() ? Or is Nim code just free-flow; anything goes - except indentation.
13:40:44FromDiscord<juan_carlos> A `main()` is ok, not mandatory tho.
13:40:59FromDiscord<juan_carlos> If is named `potato()` it will work anyway.
13:41:40dukesterOK thanks
13:43:14*dukester left #nim (Leaving)
13:46:15FromDiscord<NullCode> In reply to @dukester "noob here! Is there": anything goes lmao
13:46:27FromDiscord<NullCode> you can do whatever you want, functionally nothing will happen
13:46:32FromDiscord<NullCode> well it might look bad, but yea
13:48:29FromDiscord<NullCode> anywho, i need some pointers on nigui
13:48:38FromDiscord<NullCode> https://github.com/trustable-code/NiGui/
13:48:40nrds<R2D299> itHub: 7"Cross-platform desktop GUI toolkit written in Nim"
13:48:53FromDiscord<NullCode> specially, https://github.com/trustable-code/NiGui/blob/1f453d5dac6f42e2bbfd260215c5269324a45603/src/nigui.nim#L2840
13:49:14FromDiscord<NullCode> i wanna turn the editable into `false`, but i dont understand how
13:57:07*asd quit (Ping timeout: 250 seconds)
13:57:32*Guest9 quit (Quit: Ping timeout (120 seconds))
14:00:51FromDiscord<NullCode> ok nvm, no need
14:01:09FromDiscord<NullCode> i need some other pointers on niGui now
14:03:12FromDiscord<NullCode> this doesn't work
14:03:15FromDiscord<NullCode> sent a code paste, see https://play.nim-lang.org/#ix=3AUL
14:03:17FromDiscord<NullCode> (i don't expect this to work)
14:03:33FromDiscord<NullCode> but i need to periodically add some shit to the textBox
14:03:45FromDiscord<NullCode> (edit) "textBox" => "textArea without the use of buttons and stuff"
14:03:49FromDiscord<NullCode> i wanted it to be automatic
14:04:06FromDiscord<NullCode> is there a way to do this with Nim/any other "light" gui lib
14:04:32FromDiscord<NullCode> (edit) "https://play.nim-lang.org/#ix=3AUL" => "https://play.nim-lang.org/#ix=3AUM"
14:13:13*max22- joined #nim
14:23:15*dukester joined #nim
14:28:55*asd joined #nim
14:31:23*Vladar quit (Quit: Leaving)
14:41:59FromDiscord<Archion> Hi
14:44:34FromDiscord<NullCode> hi
14:45:30FromDiscord<enthus1ast> @NullCode\: you need to to it via timeouts
14:46:06FromDiscord<enthus1ast> or, what i like to do, is to drive an async loop via gui timeouts/callbacks, and code the stuff with async procs
14:46:16FromDiscord<enthus1ast> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/894958482221064202): @NullCode\: you need to do it via timeouts
14:47:04FromDiscord<enthus1ast> https://github.com/trustable-code/NiGui/blob/1f453d5dac6f42e2bbfd260215c5269324a45603/src/nigui.nim#L549
14:47:22FromDiscord<enthus1ast> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/894958482221064202): @NullCode\: you need to do it via \~\~timeouts\~\~ Timers
14:48:26FromDiscord<enthus1ast> the app.run() blocks the execution so your loop is run after the gui loop is done
14:48:37FromDiscord<NullCode> i see
14:49:26FromDiscord<NullCode> lemme see if i can figure out timers
14:50:03FromDiscord<enthus1ast> https://github.com/trustable-code/NiGui/blob/732acf350fbd46e058eeb852b80edfc2142d4004/examples/example_08_timers.nim
14:50:37FromDiscord<NullCode> yeah I'm seeing that one
14:50:50FromDiscord<NullCode> it uses buttons so yeah
14:51:08FromDiscord<enthus1ast> so?
14:51:21FromDiscord<enthus1ast> just call the startRepeatingTimer somewhere
14:51:33FromDiscord<enthus1ast> (before the call to app.run() )
14:52:43FromDiscord<enthus1ast> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/894959951598997524): just call the startTimer / startRepeatingTimer somewhere
14:56:37*dukester left #nim (Leaving)
14:56:57FromDiscord<NullCode> https://media.discordapp.net/attachments/371759389889003532/894961360222453790/unknown.png
14:57:01FromDiscord<NullCode> amazing
14:57:05FromDiscord<NullCode> thanks lots
14:59:35*dukester joined #nim
15:03:01*dukester left #nim (#nim)
15:17:35*Gustavo6046_ joined #nim
15:18:01*Gustavo6046 quit (Ping timeout: 252 seconds)
15:20:25*Gustavo6046_ is now known as Gustavo6046
15:41:47*NeoCron joined #nim
15:45:58FromDiscord<xflywind> !eval const _ =12; echo _
15:46:00NimBot12
15:52:00FromDiscord<Archion> !eval const =12; echo
15:52:01NimBotCompile failed: /usercode/in.nim(1, 7) Error: identifier expected, but got '='
15:52:04FromDiscord<Archion> What
15:53:17FromDiscord<xflywind> well, the text is `!eval const _ = 12; echo _`
15:53:28FromDiscord<Archion> O_o
15:53:46FromDiscord<Archion> !eval const e=12; echo e
15:53:48NimBot12
15:54:15FromDiscord<xflywind> however
15:54:16FromDiscord<xflywind> !eval let _ = 12; echo _
15:54:17NimBotCompile failed: /usercode/in.nim(1, 18) Error: undeclared identifier: '_'
15:57:47FromDiscord<Archion> !eval int xd=3+4; echo xd
15:57:48NimBotCompile failed: /usercode/in.nim(1, 5) Error: undeclared identifier: 'xd'
15:58:14FromDiscord<enthus1ast> let xd\: int
15:58:58FromDiscord<enthus1ast> !eval let xd\:int = 3 + 4; echo xd
15:58:59NimBotCompile failed: /usercode/in.nim(1, 9) Error: ':' or '=' expected, but got 'int'
15:59:20FromDiscord<enthus1ast> !eval let xd\: int = 3 + 4; echo xd
15:59:22NimBotCompile failed: /usercode/in.nim(1, 10) Error: ':' or '=' expected, but got 'int'
16:00:04FromDiscord<enthus1ast> bridge must break something
16:02:11Amun-Ra!eval let xd: int = 3 + 4; echo xd
16:02:12NimBot7
16:02:35Amun-Rait appears it escapes :
16:09:17FromDiscord<cgay (Carl Gay)> Hi folks. I was just trying the Playground and when I set it to generate C++ code instead of C I get a 502 error. Just using the default example\: https://play.nim-lang.org/#ix=2lK1
16:09:49FromDiscord<cgay (Carl Gay)> Just want to let someone know in case you're not aware of it yet. Not really a problem for me. Thanks.
16:22:24FromDiscord<gnu+linux user> yes you are correct
16:24:14FromDiscord<gnu+linux user> {using \n defeeats whole urpose of using nim for crossplatofrm)
16:26:18FromDiscord<iffy (Matt Haggard)> I'm working on fixing choosenim, which means fixing zippy. Is there a better way to convert bitmasks to a set of enums as I'm doing here? https://github.com/iffy/zippy/blob/master/src/zippy/tarballs.nim#L38 If you don't want to click, I'm just doing this for every bit I want to check\: `if filemode.masked(TUREAD) != 0: result.incl(fpUserRead)`
16:27:11FromDiscord<cabboose> bra
16:27:12FromDiscord<cabboose> jesus christ
16:27:26FromDiscord<cabboose> is that
16:27:28FromDiscord<cabboose> is that
16:27:33FromDiscord<cabboose> is that blank space
16:27:38FromDiscord<cabboose> they are in perfect 3s
16:27:52FromDiscord<cabboose> anyway, are those enums in order
16:28:07FromDiscord<cabboose> where are they defined
16:29:17FromDiscord<iffy (Matt Haggard)> The enums are from the stdlib\: https://nim-lang.org/docs/os.html#FilePermission
16:29:40FromDiscord<enthus1ast> does not look too bad imho, its readable an all that
16:30:43FromDiscord<cabboose> well now it really depends on how a set of flags are cast into an int
16:31:16FromDiscord<cabboose> https://github.com/nim-works/loony/blob/main/loony/ward.nim
16:31:27FromDiscord<cabboose> that does int-\>set stuff
16:31:57FromDiscord<cabboose> if it was just cast from set -\> int then you can just do the same thing the other way
16:32:03FromDiscord<cabboose> enum sets are just bit sets anyway
16:32:45FromDiscord<treeform> In reply to @iffy (Matt Haggard) "I'm working on fixing": Do you mean to add stream tarball functionlity?
16:35:26FromDiscord<iffy (Matt Haggard)> treeform\: no, just preserving permissions un untar/unzip
16:36:41FromDiscord<treeform> Oh that should not be hard
16:36:58FromDiscord<treeform> Choosenim relies on that?
16:41:32FromDiscord<iffy (Matt Haggard)> it does in the newest version
16:41:42FromDiscord<iffy (Matt Haggard)> I've got tars working -- now trying to understand zip files
17:09:34FromDiscord<iffy (Matt Haggard)> oh, you can just use `and` instead of `masked`
17:12:14FromDiscord<cabboose> why dun you just make it so you can cast between them
17:12:56FromDiscord<iffy (Matt Haggard)> That sounds great. How do you suggest doing that?
17:13:24FromDiscord<cabboose> did you look at the link
17:13:37FromDiscord<cabboose> or just give me sample code and i'll do it
17:14:02FromDiscord<iffy (Matt Haggard)> https://github.com/iffy/zippy/blob/master/src/zippy/tarballs.nim#L38
17:15:55FromDiscord<iffy (Matt Haggard)> I looked at the link, but I think casting depends on controlling the order the enums are defined (or their value), right?
17:28:40FromDiscord<cabboose> yeah
17:29:04FromDiscord<cabboose> you wouldnt have a problem if the os flags werent in the wrong order
17:31:09FromDiscord<cabboose> so im just going to rotate them
17:31:11FromDiscord<cabboose> and then cast them to a set
17:31:14FromDiscord<cabboose> and that should be fine
17:31:31FromDiscord<cabboose> im just retarded and have to figure out what the binary representations are of these constants you have here
17:32:05FromDiscord<juan_carlos> sent a long message, see http://ix.io/3AVX
17:32:25FromDiscord<cabboose> is websocket a ref?
17:32:58FromDiscord<juan_carlos> Yes, ooh
17:33:47FromDiscord<cabboose> you can probably set the destroy for the actual object itself
17:34:19FromDiscord<treeform> is this `ws`'s WebSocket or some other one?
17:35:16FromDiscord<juan_carlos> Sorry, you right, error message is not too helpful for ref. 😛
17:37:37FromDiscord<cabboose> can you try cast the filemode into a uint16, rotate left 10 positions, decrement by 1 and then cast?
17:38:24FromDiscord<cabboose> or just rotate right
17:38:28FromDiscord<cabboose> whatever floats your jimmies
17:41:56FromDiscord<cabboose> hah hold on
17:43:55FromDiscord<cabboose> omg screw it im just going to rearrange the damn bits manually
17:47:19NimEventerNew question by Alex Craft: Iterate over multiple tuples in Nim?, see https://stackoverflow.com/questions/69455064/iterate-over-multiple-tuples-in-nim
17:52:21FromDiscord<iffy (Matt Haggard)> hehe... cabboose, tag my name when you're done so I can see the result
18:03:27FromDiscord<cabboose> sent a code paste, see https://play.nim-lang.org/#ix=3AW6
18:03:48FromDiscord<cabboose> there you go. That wouldnt have taken so long if my eyes werent bleeding
18:03:54FromDiscord<cabboose> annoying.
18:05:24FromDiscord<cabboose> sent a code paste, see https://play.nim-lang.org/#ix=3AW9
18:17:31NimEventerNew thread by Pixeye: Macro work strange behavior, see https://forum.nim-lang.org/t/8481
18:21:32FromDiscord<el__maco> I think I got my first Nim program working, yay. A quick benchmark seems to indicate a ~20% performance penalty compared to the C program I modeled it after. Not ideal, but also could be worse I guess
18:22:09FromDiscord<enthus1ast> maybe you can speed it up
18:24:10FromDiscord<enthus1ast> -d\:release --opt\:speed --passl\:-flto --passc\:-flto
18:24:37FromDiscord<el__maco> I used ``-d:danger -d:release --opt:speed``
18:27:14FromDiscord<el__maco> ``Command line warning D9002 : ignoring unknown option '-flto'``
18:28:01FromDiscord<el__maco> ah, I'm using msvc that must be why
18:28:04FromDiscord<Rika> -d:release not needed when -d:danger
18:28:59FromDiscord<enthus1ast> idk if and how msvc can do link time optimization
18:31:30FromDiscord<el__maco> I'm sure there are things I could do to improve the performance. The C counterpart is using 32 bit ints like C++ does. And there are some pointer shenanigans that probably could be more efficiently expressed if I knew how
18:32:48FromDiscord<enthus1ast> what do you mean?
18:35:14FromDiscord<el__maco> I mean I have not looked at the end result that the nim compiler produced, but I'm fairly sure there are things I could do to reduce overhead. Kinda depends on how smart the compiler is optimizing multidimensional array access
18:36:29FromDiscord<el__maco> there's more of that in the code compared to the C side where its mostly just dereferencing pointers
18:38:16FromDiscord<el__maco> how stable is the compiler I'm wondering
18:38:45FromDiscord<el__maco> I already got into a weird situation that looked kinda like a compiler bug, but I'm not sure 😅
18:48:47FromDiscord<Schelz> hi, how can I read the input from keyboard, not input type.
18:51:18FromDiscord<enthus1ast> stdin.readLine()
18:51:45FromDiscord<enthus1ast> but you should be more specific
18:52:49FromDiscord<Schelz> for example in a game idk know how to check if (w, a, s, d) is pressed or not
18:53:12FromDiscord<Schelz> (edit) removed "idk know how"
18:53:16FromDiscord<enthus1ast> this depends on the engine you're useing
18:54:13FromDiscord<Schelz> for example win32api.GetAsyncKeyState(0x20)
18:56:33FromDiscord<enthus1ast> yes on windows you could certainly do this, but i would read the engine's manual how you're supposed to get keyboard input
18:57:55FromDiscord<enthus1ast> afaik GetAsyncKeyState also get you keypresses when the windows is not active, certainly not what you want
19:02:05FromDiscord<Schelz> thx 😊
19:10:01nrds<Prestige99> Are there any c++ nim wrappers I could check out? I'm thinking of wrapping box2d if it's possible
19:21:35FromDiscord<qb> sent a code paste, see https://play.nim-lang.org/#ix=3AWw
19:21:39FromDiscord<qb> How could i realize that piece of python code?
19:32:44FromDiscord<enthus1ast> you define a type and cast the memory to this type
19:32:54FromDiscord<enthus1ast> but it depends i think
19:33:19FromDiscord<enthus1ast> better parse then cast i guess
19:35:17FromDiscord<enthus1ast> https://github.com/OpenSystemsLab/struct.nim
19:35:20nrds<R2D299> itHub: 7"Python-like 'struct' for Nim"
19:43:54FromDiscord<dom96> @iffy thanks for looking into fixing that in zippy, fwiw choosenim actually has functionality to add the +x perms after extracting
19:44:13FromDiscord<dom96> I was planning to patch that
19:44:36FromDiscord<dom96> [iffy (Matt Haggard)](https://matrix.to/#/@iffy-529c6cd8ed5ab0b3bf04da13:gitter.im)\: ^
19:58:24FromDiscord<dom96> oh, I see it's already in latest zippy, nice
20:17:13*neurocyte013288 quit (Quit: The Lounge - https://thelounge.chat)
20:22:01FromDiscord<dom96> I don't suppose anyone's around to test a new choosenim release for me? 🙂
20:22:13FromDiscord<dom96> (edit) "for" => "with"
20:24:51FromDiscord<dom96> ooh, Github's release notes auto-gen is nice: https://github.com/dom96/choosenim/releases/tag/v0.8.2
20:25:48FromDiscord<dom96> I'm gonna go make food, once I eat I'll create a macOS binary and finalise release
20:25:52FromDiscord<dom96> testing appreciated
20:30:34FromDiscord<ynfle (ynfle)> @dom96 I can try. I'm on macOS
20:46:19FromDiscord<dom96> added a macos binary, give it a go
20:50:52*xet7 quit (Remote host closed the connection)
20:51:58*jjido joined #nim
20:52:45*xet7 joined #nim
20:56:42FromDiscord<treeform> is it arm mac or intel mac?
20:59:48FromDiscord<dom96> intel
21:01:11FromDiscord<dom96> I've updated the `stable` channel, so you should be able to run `choosenim update self` now to update
21:01:29FromDiscord<dom96> (edit) "I've updated the `stable` ... channel," added "choosenim"
21:30:00FromDiscord<tandy> works good \:)↵(@dom96)
21:41:51*PMunch quit (Quit: leaving)
21:44:16nrds<Prestige99> Does c2nim not support c++? Trying it on a header file and gettingillegal storage access errors
21:45:18FromDiscord<Elegantbeef> It can convert some amount of C++
21:46:33nrds<Prestige99> You know of any guides I could check out on how to manually wrap a c++ lib?
21:47:16nrds<Prestige99> I've only modified existing c wrappers
21:51:16nrds<Prestige99> this is interesting, c2nim is operating on a header file and ate 15G RAM until I killed it
21:52:55*NeoCron quit (Quit: Leaving)
21:59:05FromDiscord<Elegantbeef> shooting gumber a message would probably be the easiest 😛 I've never touched C+
21:59:23nrds<Prestige99> Same..
21:59:42nrds<Prestige99> I'm just surprised I can't find much on how to write wrappers
22:07:22FromDiscord<treeform> I think c2nim supports simple C++ project, but not big C++ project is simple.
22:07:29FromDiscord<ynfle (ynfle)> @dom96 what should I be testing?
22:08:03FromDiscord<treeform> I was trying to sure that c2nim with steamworks (huge C++ api) not luck. I even have hard time reading the C++ code is so convoluted.
22:09:59FromDiscord<dom96> In reply to @ynfle (ynfle) "@dom96 what should I": Whatever comes to mind 🙂
22:13:01*Gustavo6046 quit (Ping timeout: 245 seconds)
22:18:08*mst quit (Changing host)
22:18:08*mst joined #nim
22:19:29nrds<Prestige99> @treeform: Yeah I was trying with box2d, no dice
22:23:47FromDiscord<treeform> In reply to @nrds "<Prestige> <@107140179025735680>: Yeah I": I tried making a pure nim 2d physics engine, its hard, I don't recommend. https://cdn.discordapp.com/attachments/706542664643772436/820900286716968960/bMxrOg2pig.gif
22:24:16nrds<Prestige99> That looks awesome. But yeah it's very hard
22:25:28nrds<Prestige99> probably would be better off just converting box2d to Nim, eh
22:25:43FromDiscord<treeform> you could try https://github.com/oprypin/nim-chipmunk
22:25:46nrds<R2D299> itHub: 7"Nim bindings to Chipmunk, a fast and lightweight 2D game physics library"
22:27:14nrds<Prestige99> Yeah been trying that, been having some problems I'm still figuring out
22:41:06FromDiscord<tandy> is there a nim library for escaping paths for unix commands?
22:41:43FromDiscord<tandy> i have paths with $s, brackets, etc, that i need to escape
22:43:51FromDiscord<tandy> https://nim-lang.org/docs/strutils.html#escape%2Cstring%2Cstring%2Cstring
22:43:52FromDiscord<tandy> maybe this
22:46:09FromDiscord<tandy> hmm no
22:50:25FromDiscord<Elegantbeef> quoteShell\`
23:02:43FromDiscord<tandy> woah thats it
23:02:47FromDiscord<tandy> thank you beef
23:24:17*max22- quit (Remote host closed the connection)
23:36:42FromDiscord<Elegantbeef> @Bung\: i know it's really late, but nimscripter now seems to support json Nim \<-\> Nimscript
23:36:49FromDiscord<impbox [ftsf]> \o/
23:37:09FromDiscord<Elegantbeef> sorry for the delay, but yea thought you'd be interested given the interest a few months ago
23:38:30FromDiscord<Elegantbeef> I was the culprit of all my interop issues with these macros 😀
23:39:07FromDiscord<Elegantbeef> Accidently was only getting the last entry in the reclist instead of just the entry in the reclist which resulted in it attempting to index an empty node