<< 17-10-2022 >>

00:04:46*krux02 quit (Ping timeout: 260 seconds)
00:18:43arkanoidAnother question. What's the proper way to export C headers from nim? I'd like to call nim code from ffi interface of another language
00:19:35arkanoidThe headers generated by nim c backend are ugly, and variable, is there a way to export them nicely?
00:20:22FromDiscord<Rika> Weren’t they designed to be ugly
00:20:54FromDiscord<exelotl> is this using the --header option?
00:21:32FromDiscord<exelotl> as that's unsupported I believe (though I depend on it 😭)
00:21:40FromDiscord<Rika> Ah that option
00:22:34arkanoidOh, wait, there's exportc https://nim-lang.org/docs/backends.html#interfacing-backend-code-calling-nim
00:22:36FromDiscord<Rika> Unfortunate it was culled but manpower is hard to come by (iirc)
00:24:18FromDiscord<exelotl> exportc just removes name mangling so that you can declare the proc as "extern" in C code and call it
00:24:40arkanoidIs NimMain required to be called even with ARC/ORC?
00:24:48FromDiscord<Rika> Technically yes
00:24:57FromDiscord<Rika> Globals are set there
00:24:57arkanoidI mean, what's the runtime after ARC/ORC?
00:25:02arkanoidOh! Ok
00:27:46FromDiscord<exelotl> if you're making a library and want to produce a .so/DLL + header so you can call it from C, genny is good for that: https://github.com/treeform/genny
00:28:39*arkurious quit (Quit: Leaving)
00:28:39arkanoidSweeeet
00:29:08arkanoidtreeform quality 👌
00:30:22arkanoidI don't see where NimMain is defined in maths.c example file here https://nim-lang.org/docs/backends.html#backend-code-calling-nim-nim-invocation-example-from-c
00:31:25arkanoidThe example has forward definition for fibs, but not for NimMain
00:36:49FromDiscord<exelotl> NimMain is generated by the compiler
00:47:11FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dns
00:47:57FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=4dnt
00:48:45FromDiscord<sOkam!> Oh, i guess i was missing the name of each field before. Tried something similar but wasn't working 🤷‍♂️
00:48:49FromDiscord<sOkam!> tyty
00:49:31FromDiscord<sOkam!> Is it possible to initialize objects without giving the name of the field, like with C structs?
00:50:48FromDiscord<sOkam!> C has both options, so wonder if there is the option here too
00:56:16FromDiscord<exelotl> nope there's not, but then it's common in Nim to make an `initFoo` procedure to use as a constructor
01:05:15qwr&nim... https://devclass.com/2022/10/11/like-c-before-it-breaking-change-in-go-may-fix-design-decision-that-makes-programs-incorrect/
01:08:09FromDiscord<Rika> Bad site I can’t even see the code
01:08:29FromDiscord<Rika> Nim doesn’t have this issue
01:08:32FromDiscord<Rika> I don’t think it does
01:12:22*def- quit (Quit: -)
01:12:37*def- joined #nim
01:27:46*wallabra joined #nim
02:08:22FromDiscord<Elegantbeef> It has a similar issue, but yea it doesnt have the same issuue
02:10:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnE
02:10:35*rockcavera joined #nim
02:10:35*rockcavera quit (Changing host)
02:10:35*rockcavera joined #nim
02:45:08FromDiscord<Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=4dnQ
02:45:32FromDiscord<Elegantbeef> That's slightly different though
02:46:49FromDiscord<huantian> I feel like that’s the default behavior for most programming langs
02:47:02FromDiscord<Elegantbeef> It is things generally arent automatically raised to closure
02:48:40FromDiscord<Tanguy> I think if you assign to a variable beforehand it works, so looks very similar
02:49:04FromDiscord<Tanguy> Or maybe I'm confused actually
02:49:07FromDiscord<Elegantbeef> Nope it doesnt work that way eiither
02:49:17FromDiscord<Elegantbeef> It'd be a pointer to the same value in the end
02:50:36FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnT
02:51:55FromDiscord<Elegantbeef> Oh god the code is here, but it's not rendering properly
02:52:05FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1031399171187552256/image.png
02:52:13FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1031399203693400104/image.png
02:54:56FromDiscord<huantian> In reply to @Elegantbeef "Nope it doesnt work": well it does right?
02:55:01FromDiscord<huantian> since you make a copy when assigining an int in nim
02:55:15FromDiscord<Elegantbeef> Except the variable is the same address
02:55:43FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnV
02:57:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4dnW
02:57:29FromDiscord<Elegantbeef> Where `capture x` is expanded into `proc (x: int): auto = add(myProcs, proc (): int = result = x)(x)`
02:59:15FromDiscord<Elegantbeef> Whoops that shouldnt be `assert p() == 10` now
02:59:25FromDiscord<Elegantbeef> Should be `assert p in 0..10` 😛
03:06:28FromDiscord<huantian> huh yeah
03:06:51FromDiscord<huantian> ig I was thinking of c# lol
03:58:01*rockcavera quit (Remote host closed the connection)
04:26:24*derpydoo joined #nim
05:10:06*sagax joined #nim
05:13:03*sagax quit (*.net *.split)
05:13:03*xet7 quit (*.net *.split)
05:13:04*mahlon quit (*.net *.split)
05:13:04*notchris quit (*.net *.split)
05:13:05*drewr quit (*.net *.split)
05:13:13*notchris joined #nim
05:13:41*mahlon joined #nim
05:14:48*xet7 joined #nim
05:24:26*sagax joined #nim
05:26:30*xet7 quit (Ping timeout: 264 seconds)
05:56:50*kenran joined #nim
06:22:18FromDiscord<Bung> any reason koch.exe silently quite on win10?
06:55:16Amun-RaI guess https://nim-lang.org/docs/times.html#initTime%2Cint64%2CNanosecondRange
06:55:27Amun-Rasorry, paste from backlog
07:06:28*kenran` joined #nim
07:07:53*kenran quit (Ping timeout: 250 seconds)
07:18:30*sagax quit (Remote host closed the connection)
07:34:19*PMunch joined #nim
08:03:39*xet7 joined #nim
08:11:03*derpydoo quit (Quit: derpydoo)
08:13:17FromDiscord<planetis> Does the .align pragma work with -d:useMalloc?
08:16:01*derpydoo joined #nim
08:32:48*derpydoo quit (Quit: derpydoo)
08:54:13*wallabra_ joined #nim
08:56:12*wallabra quit (Ping timeout: 264 seconds)
08:56:14*wallabra_ is now known as wallabra
09:00:09*TrueBlue[m] quit (Quit: You have been kicked for being idle)
09:05:48*wallabra quit (Ping timeout: 264 seconds)
09:27:58PMunch@planetis, doubtful. It will likely align by default though based on platform
09:53:36FromDiscord<planetis> I see, tried it myself and doesn't seem like it. I have a weird issue with UB due to incorrect alignment that poped up only after the threaded allocator. Can't tell what it's about, but my code could have always been incorrect but now it crashes.
10:06:34*xet7 quit (Remote host closed the connection)
11:29:11*jmdaemon quit (Ping timeout: 250 seconds)
12:06:52*xet7 joined #nim
12:12:59NimEventerNew Nimble package! jtr - jtr is a commmand of JSON tree viewer with type, see https://github.com/u1and0/jtr
12:14:10NimEventerNew thread by pietroppeter: Working towards a Nim Devroom at FOSDEM 2023 (physical event), see https://forum.nim-lang.org/t/9534
12:16:30*xet7 quit (Remote host closed the connection)
12:19:52*arkurious joined #nim
12:36:51*derpydoo joined #nim
12:45:11FromDiscord<Horizon [She/Her]> I wonder if there'd be a point to forking nano and adding a plugin system with it (in Nim ofc)
12:45:41FromDiscord<Horizon [She/Her]> A Nimscript plugin system for nano would be neat to add stuff like autocompletion
12:47:08FromDiscord<Rika> But wouldn’t that be antithetical to the idea of nano
12:49:22FromDiscord<Horizon [She/Her]> Yes, but that's why it's a fork↵↵Plus it's simple, and familiar to use, being able to just open it up and get decent autocompletion and such is appealing to me, even if it isn't to others
12:50:23FromDiscord<Horizon [She/Her]> It's likely not what everyone wants or is looking for like, at all, but people who do want something like nano but nicer and more convenient to use? Then let's give them that option
13:00:58FromDiscord<ChocolettePalette> It's a better idea to write an Emacs plugin or smth with Nano key bindings. The new fork would be an overkill and it's generally a bad thing to develop something brand new just to fix a tiny issue considering that the number of programmers grows slower than the number of the programs they make
13:04:33FromDiscord<Horizon [She/Her]> I've never used Emacs tbh
13:32:54PMunchUgh, the times module seriously needs a "second subpart" specifier..
13:33:35PMunchA timestamp like this is impossible to parse with the times module: 2022-10-12T12:51:58.6727057Z
13:57:25*PMunch quit (Quit: Leaving)
14:09:46Amun-Rawhy?
14:12:22Amun-Raah, it doesn't use %
14:13:52FromDiscord<ShalokShalom> In reply to @Isofruit "If you're checking out": What would speak for Prologue?
14:14:55Amun-RaI'm not a fan of custom format specifiers
14:32:21FromDiscord<auxym> @Horizon [She/Her] micro is sort of like nano and supports lua scripts (https://micro-editor.github.io/) sort of OT though
14:32:44FromDiscord<ShalokShalom> Yeah, it's great!
14:32:56FromDiscord<ShalokShalom> Love micro
14:34:49FromDiscord<ShalokShalom> There is also a lsp implementation...↵↵https://github.com/AndCake/micro-plugin-lsp
14:36:57FromDiscord<Horizon [She/Her]> In reply to @auxym "<@909883978717204561> micro is": Haven't used micro much, the keybinds aren't like nano which is slightly annoying, i prefer nano because it's quick an easy but also wish it had autocomplete
14:37:21FromDiscord<ShalokShalom> The keybindings can be changed?
14:37:53FromDiscord<ShalokShalom> https://github.com/zyedidia/micro/blob/master/runtime/help/keybindings.md
14:37:56FromDiscord<Horizon [She/Her]> From what I've messed around with, exact nano keybinds for stuff like cut, paste, exit and saving ain't doable
14:38:06FromDiscord<Horizon [She/Her]> I've messed with it a while ago though so may of changed?
14:38:21FromDiscord<ShalokShalom> Write a plugin, otherwise 😅
14:39:34FromDiscord<Horizon [She/Her]> Yeah I'll probably have to haha
14:47:15FromDiscord<Phil> In reply to @ShalokShalom "What would speak for": Less magic, IMO more understandable, middleware support which makes creating some extensions easier, I'd argue better docs
14:47:41FromDiscord<ShalokShalom> K
14:50:36FromDiscord<Phil> Jester points with more concise syntax that focuses reduces the amount of code on screen to the absolute minimum and... Likely some other things but I haven't used jester so the first one is all I'm aware of
14:51:09FromDiscord<Phil> (edit) removed "focuses"
14:59:42FromDiscord<ShalokShalom> Sad, that its almost always 'good thing here, good thing there' and by that, some kind of tradeoffs
15:05:48*pbsds joined #nim
15:07:43FromDiscord<Phil> The only way you can achieve "Throw away boilerplate" to this scale is through macro magic, which will make things more of an "You need to know X to understand" by virtue of being macro magic
15:09:23FromDiscord<Phil> Prologues "Boilerplate", which stems 99% from the procs that set up routes, is imo stuff that allows you to simply set stuff up.↵Yeah its more typing, but it feels more familiar to how frameworks in other languages do it as well (django and java in my case as basis of experience)
15:09:58FromDiscord<Phil> (edit) removed "simply" | "up.↵Yeah" => "up in a simple and likely somewhat familiar manner that is more understandable in how it connects things.↵Yeah"
15:10:47FromDiscord<Phil> "addRoute" on an object that represents my server is immediately understandable for example.
15:13:23FromDiscord<Phil> Concise via throwing out syntax that explicitly states actions that always need to happen for any application (connecting a route to your web-application)↵vs↵Understandability via Boilerplate from keeping syntax that explicitly states things that always need to happen for any application
15:16:33FromDiscord<ShalokShalom> https://surrealdb.com/
15:16:38FromDiscord<ShalokShalom> Nim binding when
15:18:21*kenran` quit (Remote host closed the connection)
15:18:47*rockcavera joined #nim
15:18:47*rockcavera quit (Changing host)
15:18:47*rockcavera joined #nim
15:20:53FromDiscord<Phil> ~~right after mongo and elastic search packages~~
15:36:49FromDiscord<Phil> Turns out we have a mongo package, so only elastic search then
15:41:24*rez joined #nim
15:49:35FromDiscord<wick3dr0se> If anyone has time, could they check the validity of my notes? It's rather short currently (~2 min read)↵↵https://github.com/wick3dr0se/learn-nim
16:05:52FromDiscord<Phil> Do you only care about syntax or do you also want hints when to use what?
16:07:06FromDiscord<Phil> Specifically case statements at a glance are the kind of things where you need to learn their purpose and how to appreciate them first, thus the question
16:09:29FromDiscord<wick3dr0se> Well I'm keeping a seperate personal file for examples like common functions/procedures. I am very familiar with case statements in C and BASH but I want any corrections
16:10:34FromDiscord<wick3dr0se> Maybe I'm not right about when to use if vs case. That would definitely help
16:12:24FromDiscord<Phil> Prefer let over var in general. Only use var if you're absolutely forced to
16:12:50FromDiscord<wick3dr0se> Really? Is that because let is immutable?
16:13:30FromDiscord<wick3dr0se> I was confused by let with a heavy shell background. `let` is much different then and not as performant
16:13:38FromDiscord<Phil> Aye. Let gives your reader the guarantee that you won't change the value of something, making reading easier
16:14:16FromDiscord<Phil> If you can, use const, that just isn't always viable since you can't know everything at compile time
16:14:17FromDiscord<wick3dr0se> Ok good to know. So prefer const or let if defining
16:16:45FromDiscord<Phil> Aye. Case statements are as usual, they are there to cover all possibilities of a value, I would generally prefer them over if else trees, though I'd only break them out if you want to cover at least 3 (case1, case2 and default / case3 )different cases, but that's specific rule is personal preferences
16:17:37FromDiscord<wick3dr0se> Ok that's what I wrote was 3 or more conditions for case. I think that's a good point to prefer a case
16:17:57FromDiscord<Phil> Use enums whenever possible instead of magic numbers/strings, though that's true for any language
16:18:30FromDiscord<wick3dr0se> Whats the difference between object and enum?
16:18:43FromDiscord<Phil> Question, do you differentiate between what you wrote down as data types and objects?
16:18:59FromDiscord<wick3dr0se> I'm not very familiar with enums either
16:19:20FromDiscord<wick3dr0se> No I'm not sure what you mean
16:23:08*xet7 joined #nim
16:23:29FromDiscord<Phil> sent a long message, see http://ix.io/4dql
16:24:06FromDiscord<Phil> Another benefit is general readability.↵PowerState.Off is more readable than just 0, you know what is meant
16:25:57FromDiscord<wick3dr0se> Yea that makes a lot of sense now. Magic numbers as in numbers that are hard to interpret or could easily be changed ig. So the enums defines constant names for these values, which I can see being better all around
16:26:05FromDiscord<Phil> A third benefit is case statements. If you case over an enum and don't provide a default case, the compiler will error out telling you that you also need to handle enum value Z that you've forgotten.↵Particularly useful if you expand the number of values in an enum, as the compiler will tell you if something is missing in your code
16:26:38FromDiscord<Phil> (edit) "forgotten.↵Particularly" => "forgotten, should you not have a case for every possible enum value.↵Particularly"
16:27:01FromDiscord<wick3dr0se> Unless you do else: discard?
16:27:08*PMunch joined #nim
16:27:16FromDiscord<Phil> Basically, enums represent a finite amount of values that are allowed for a given variable
16:27:27PMunchHype! Just saw that the NimConf presentation are now scheduled on YouTube :)
16:27:33FromDiscord<Phil> Correct, else discard would be handling the default case
16:27:52FromDiscord<Phil> The default case being any case you didn't cover
16:28:50FromDiscord<wick3dr0se> Ok so I'm really thinking enums is a lot like a dictionary in BASH lol
16:29:45FromDiscord<Phil> In reply to @wick3dr0se "No I'm not sure": An object is strictly speaking also a data type, though you didn't list it there.↵I was thinking you might be differentiating between ref types, which get allocated on the heap, Vs value types that get allocated on the stack
16:30:45FromDiscord<Phil> In which case your list would be true for languages like java, but not quite for Nim where everything can be a ref or a value type (some exceptions apply)
16:31:19FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4dqp
16:31:52FromDiscord<wick3dr0se> (edit) "https://play.nim-lang.org/#ix=4dqp" => "https://play.nim-lang.org/#ix=4dqr"
16:32:13FromDiscord<wick3dr0se> I'll have to look more into objects vs data types now
16:32:45FromDiscord<Phil> I haven't written much in bash, but I don't think at a glance that the analogy holds true. There are similarities, but dicts in bash are most likely analogous to tables in Nim
16:33:43FromDiscord<Phil> Your life becomes easier if you think of it all as just types, with objects and tuples allowing you to group different values together in a package
16:34:06FromDiscord<Phil> (edit) "Your life becomes easier if you think of it all as just types, with objects and tuples allowing you to group different values together in a package ... " added "that you can simply pass back and forth"
16:34:37FromDiscord<wick3dr0se> Thanks a ton for all the info! I have some to study now and I'll make some changes once I know a proper difference
16:36:01FromDiscord<Phil> When also is somewhat special as it will literally cut out the piece of code inside of it if the condition is false
16:36:57FromDiscord<Phil> That is important because the compiler will not evaluate that piece of code. So you can write completely syntactically wrong code if you hide it behind a when false statement
16:37:53FromDiscord<Phil> Your project should still be able to compile because that invalid code behind when false is never actually there, it gets cut out
16:39:58FromDiscord<Phil> That allows some funky stuff like removing a feature from a binary if a specific compiler flag is set or not set
16:40:14FromDiscord<Phil> (edit) "That allows some funky stuff like removing a feature from a binary if a specific ... compiler" added "custom"
16:41:14FromDiscord<wick3dr0se> Oh wow that's cool but confusing a bit at the same time. I would think the false if statements wouldnt be seen by the compiler either unless true
16:41:43FromDiscord<Phil> That's only true for if, not when, hence why it's its own keyword
16:42:46FromDiscord<Phil> A lot of packages make use of that for example to cut out any logging from their packages unless the user provides a specific flag to remove any hits to performance these flags might otherwise have
16:43:44FromDiscord<Phil> (edit) "flags" => "logging calls"
16:44:39FromDiscord<wick3dr0se> Ok that makes more sense to me. I just have a hard time telling the difference. I know you could achieve the same affect with an if but basically the difference is false if statements are seen by the compiler and false when statements are not?
16:45:39FromDiscord<wick3dr0se> I know I'm going to have to read something details about this when statement. I'll have to look that one up to undsrstsnd it likely
16:46:19FromDiscord<Phil> In reply to @wick3dr0se "Ok that makes more": Aye
16:46:38FromDiscord<wick3dr0se> (edit) "something" => "some more" | "undsrstsnd" => "understand" | "likely" => "fully"
16:48:26FromDiscord<Phil> When statements are also heavily used with generics, but that's a topic for a different time.↵On that note: You may not yet have generics in your list, but the following is useful to keep in mind for them:↵Generics are not actually code, they themselves do not get compiled. ↵They are a template that the compiler-preprocessor (or something) copy pastes wherever you use the generic with a specific type that is needed there
16:49:25FromDiscord<wick3dr0se> I guess its just really confusing to me because an if statement stops executing when a condition evaluates as true. So wouldn't a when statement be quicker/better than if? Idk why you'd ever want to evaluate a false statement
16:50:15FromDiscord<Phil> In reply to @wick3dr0se "I guess its just": Keep in mind when only works with booleans you know at compile-time.↵If works with booleans you know at compile- and runtime.↵How familiar are you with the differences between the two?
16:50:59FromDiscord<wick3dr0se> Ok I got you. So when works with constants and if works with mutable variables that could be supplied as arguments for example
16:51:58FromDiscord<Phil> When works only with const (aka compile-time variables), if works with const, let and var. I'd be hesitant to say "Mutable variables" because that only means var. "Runtime variables" would be the thing that encompasses let and var both and is the intended usecase for if
16:52:56FromDiscord<wick3dr0se> Ok I get that because let becomes a constant value but can be initialized at runtime by a function or something
16:53:52FromDiscord<Phil> let becomes a constant value in the sense that you can't change it, aye, not in the sense that you can know its value before the program actually runs
16:54:06FromDiscord<Phil> (edit) "becomes a" => "variables represent" | "it," => "them,"
16:54:17FromDiscord<Phil> The latter is what const is for
16:55:35FromDiscord<wick3dr0se> Ok I get that! Thanks a lot man. You've helped more than reading for an hour lol
16:56:13FromDiscord<wick3dr0se> I'll jump into objects/data types and generics next
16:56:17FromDiscord<Phil> Happy to help. I assume I've bombarded you with more than enough for now.↵There is more about various other things, but I think what you've got right now already is a decent chunk
16:56:28FromDiscord<wick3dr0se> Yea no lie lol
16:56:42FromDiscord<wick3dr0se> I'll come back later with an updated list lol
16:56:56FromDiscord<wick3dr0se> Prob not today
16:57:08FromDiscord<Phil> Fun fact though, if you want to play around with nim in scripting in it like bash, you can type in `nim secret` into the terminal
16:57:29FromDiscord<Phil> It'll open a REPL like in python where you can do stuff like write `5 + 2` and it'll respond with the answer
16:57:45FromDiscord<wick3dr0se> So it becomes an interpeter?
16:57:59FromDiscord<wick3dr0se> Thats awesome
16:58:02FromDiscord<Phil> Aye.↵Nim secret (aka the VM) is what nim uses to evaluate macros and such
16:58:18*PMunch quit (Quit: leaving)
16:58:26FromDiscord<wick3dr0se> Def gonna try that out
16:58:28FromDiscord<Phil> You don't have access to all nim libraries with it as some just can't be used the way the VM does, but for normal stuff it should be enough
16:59:20FromDiscord<wick3dr0se> Been trying to figure out how to script in Nim since I saw it's capable of high-level workings like Python is
16:59:55FromDiscord<auxym> INim works pretty well for me for a REPL, though it actually compiles to C on the fly, rather than run in the nim VM
17:00:02FromDiscord<Phil> If you want to use it with full library access, try inim.↵Inim is not strictly speaking a REPL, it works by basically writing a file with whatever you enter and compile it every time you enter a line
17:00:17FromDiscord<Phil> Auxym was faster 😄
17:00:21FromDiscord<wick3dr0se> Lmao
17:00:58FromDiscord<wick3dr0se> I'll try both. You guys are a lot of help here
17:01:00FromDiscord<Phil> Installing inim is also pretty straight forward, `nimble install inim` and then just type `inim` in the terminal
17:01:09FromDiscord<Phil> Happy to help
17:01:24FromDiscord<wick3dr0se> I'll be back once my brian isn't close to metlting
17:01:37FromDiscord<Phil> Understandable, felt similar to me start of the year when I got into nim 😄
17:02:52FromDiscord<wick3dr0se> Lol my BASH and not very proficent C, does not compare! I absolutely love Nim so far tho. I'm grateful to be learning it before it's mainstream
17:21:26FromDiscord<jos> ok so i got my sexpr based compilation working for wasm
17:21:29FromDiscord<jos> now i wanna emit the binary format
17:21:34FromDiscord<jos> i am lookin for
17:21:45FromDiscord<jos> a good lib to write structs to binary, i think
17:21:56FromDiscord<jos> like something like
17:22:33FromDiscord<jos> sent a code paste, see https://play.nim-lang.org/#ix=4dqB
17:22:54FromDiscord<jos> and then i want to flatten that into a byte array `@[id, size[0], size[1], size[2], size[3], contents[0] ... contents[n]]`
17:23:32FromDiscord<jos> that might be overkill or even kind of shitty for a compiler so i will settle for something like just a way to write it out manually like you would with python's `struct` module
17:44:53FromDiscord<Horizon [She/Her]> In reply to @ShalokShalom "https://surrealdb.com/": Are there C bindings? :P
17:45:21FromDiscord<Horizon [She/Her]> Probably could use Futhark to wrap it up, then add some destructor magic to make it work well with the GC
18:03:18FromDiscord<Horizon [She/Her]> Question: How am i supposed to compile my C code with Nim code?
18:03:32FromDiscord<Horizon [She/Her]> I'm including Nim code in an existing C project
18:07:32FromDiscord<Phil> In reply to @jos "ok so i got": Missunderstandings of `sexpr` incomiiiiiiing (why yes, I indeed have the sense of humour of a 14 year old in some respects)
18:08:08FromDiscord<jos> wat
18:09:43FromDiscord<Phil> s-expression I assume, can also be read sex-pression
18:09:58FromDiscord<jos> :cartired:
18:10:03FromDiscord<jos> sip
18:14:54*hellstabber joined #nim
18:15:51*hellstabber left #nim (#nim)
18:33:17FromDiscord<Phil> I don't know what changed, but something changed, because I've never seen my endpoint that gives me an overview over the most recently updated articles on my webpage be that flopping fast
18:35:17FromDiscord<Phil> That mofo is busting through somewhere between 24 and 48 sqlite-DB queries, parsing that into objects, then parsing those objects into JSON with truncated texts after 30 words in under 30 ms at the moment. That took like 120ms before and I'm semi-certain I didn't touch the parsing code... maybe the shared CPU of my server is just not being used at the moment
18:35:49FromDiscord<Phil> (edit) "moment." => "moment (plus another 30ms of latency)."
18:55:49FromDiscord<ShalokShalom> In reply to @Event Horizon "Are there C bindings?": Yep ↵↵And JavaScript
18:55:50FromDiscord<ShalokShalom> https://github.com/surrealdb/surrealdb.c
18:59:12FromDiscord<Horizon [She/Her]> @ShalokShalom yeah then you can just use Futhark to make the bare minimum C bindings, then just add ontop of that
19:03:13FromDiscord<ShalokShalom> Mhn
19:10:39FromDiscord<Takemichi Hanagaki> Does Nim have any eval function?
19:11:26FromDiscord<Patitotective> futhark calls me https://azul.rs
19:11:55FromDiscord<Patitotective> In reply to @Takemichi Hanagaki "Does Nim have any": to evaluate code at runtime? no
19:12:18FromDiscord<Patitotective> (edit) "no" => "dont think so"
19:12:32FromDiscord<Takemichi Hanagaki> In reply to @Patitotective "to evaluate code at": Ohh, thanks!
19:12:48FromDiscord<Patitotective> what do you want to do?
19:47:36*wallabra joined #nim
20:06:39FromDiscord<wick3dr0se> Is there a library for setting wallpapers?
20:07:51FromDiscord<jos> i looked around and i still can't find a good way to write binary data with a specific endianness in nim
20:08:05FromDiscord<jos> casting is kind of dense, looking for something with an interface more like serde
20:08:27FromDiscord<Elegantbeef> Frosty + https://nim-lang.org/docs/endians.html
20:12:23FromDiscord<jos> that looks good, is there something like a ByteStream in nim std
20:12:30FromDiscord<jos> in std/streams i only see file and string
20:12:46FromDiscord<Elegantbeef> What's special about a byte stream?
20:12:59FromDiscord<Elegantbeef> It's just a string stream by a different name
20:13:14FromDiscord<jos> i figure string is probably char, maybe even utf8, instead of the byte data type
20:13:18FromDiscord<jos> not sure
20:13:21FromDiscord<jos> relatively new to nim
20:13:59FromDiscord<Elegantbeef> strings in Nim are just byte sequences with a `\0` at the end
20:14:00FromDiscord<Elegantbeef> utf8 encoded strings are bytes
20:15:42FromDiscord<jos> well yeah but if the data type i'm reading out is char or codepoint or something
20:15:49FromDiscord<jos> prolly gonna run into weird issues, no?
20:15:57FromDiscord<Elegantbeef> Why?
20:16:08FromDiscord<Elegantbeef> Most Nim string operations are not unicode aware
20:16:12FromDiscord<Elegantbeef> That's what `std/unicode` is for
20:16:34FromDiscord<jos> is byte an alias for char?
20:16:42FromDiscord<Elegantbeef> A vast majority of string operations are only byte aware
20:16:52FromDiscord<jos> eh
20:17:10FromDiscord<jos> it's definitely odd
20:17:27FromDiscord<jos> the only reason it feels normal is because c did it first for weird reasons
20:17:34FromDiscord<Elegantbeef> They're both 1 byte
20:17:34FromDiscord<Elegantbeef> They're distinct tpyes
20:17:35FromDiscord<Elegantbeef> !eval echo ord("🐧"[0])
20:17:39NimBot240
20:18:09FromDiscord<Elegantbeef> It makes sense as it removes a bunch of noob traps
20:18:27FromDiscord<Elegantbeef> `[]` being O(1) is much easier to understand than `[]` being O(n)
20:18:52FromDiscord<Elegantbeef> If one cares about unicode they use the unicode module and everything is fine
20:19:15FromDiscord<Elegantbeef> https://github.com/beef331/recyclable/blob/master/src/recyclable/unicodestrs.nim stuff like this also can be made
20:19:19*LuxuryMode joined #nim
20:20:23FromDiscord<jos> well i mean i agree with a lot of what you're saying but we're pretty far away from where we started
20:20:36FromDiscord<jos> i just want stream[byte] instead of stream[char] for ergonomics reasons
20:20:43FromDiscord<jos> it doesn't look like it exists, is there an alternative?
20:20:46FromDiscord<Elegantbeef> It literally doesnt matter
20:20:54FromDiscord<Elegantbeef> You read from the stream using operations
20:21:14FromDiscord<Elegantbeef> https://nim-lang.org/docs/streams.html#readUint8%2CStream
20:21:18FromDiscord<jos> i mean at the bare minimum i'm going to have to cast the char to a byte because the rest of my api assumes byte for bytes
20:21:28FromDiscord<Elegantbeef> https://nim-lang.org/docs/streams.html#readData%2CStream%2Cpointer%2Cint
20:21:37FromDiscord<Elegantbeef> The internal data doesnt matter
20:21:52FromDiscord<jos> oh i see
20:22:01FromDiscord<jos> that's probably tru
20:22:17FromDiscord<Elegantbeef> you can also use `myStrStream.data.toOpenArrayByte(0, myStrStream.getPos())` if you want to pass it to a `openArray[byte]`
20:22:24FromDiscord<jos> yes that was my next question
20:22:27FromDiscord<jos> that sounds fine though
20:22:29FromDiscord<jos> i can use this for now, thanks
20:22:37FromDiscord<Elegantbeef> No problem
20:23:31FromDiscord<Elegantbeef> thought i made it clear which is why i want on the tangent of the unicode 😛
20:24:03FromDiscord<jos> well i didn't realize it was just an internal representation
20:24:23FromDiscord<jos> i didn't look at the api, once i saw that each data type had a method to read out, it made sense
20:24:33FromDiscord<jos> but given what i was asking for that should have been obvious
20:24:36FromDiscord<jos> 🙂
20:51:16qwroperating on bytes is often good enough - if you treat offsets as pointers to utf-8 text, and not as actual symbol offsets, which they are not
20:53:37qwrand often enough, that imho its actually rare to care how many symbols somewhere actually is - that's usually important when formatting text into some layout using fixed-width characters
20:59:00qwror when doing long-term data storage, like database - then you need to be sure what the actual encoding is
21:01:11qwrfor that it is useful to have separate text type, like the unicodestr referred by Elegantbeef
21:17:30FromDiscord<Takemichi Hanagaki> In reply to @Patitotective "what do you want": Just create a simple REPL. 🙂
21:17:53arkanoidis there a nim package that deals with uncertainties and error propagation?
21:18:05FromDiscord<Takemichi Hanagaki> In reply to @Takemichi Hanagaki "Just create a simple": Most a prototype than a project.↵I was think do it using nimScript.
21:18:54FromDiscord<Takemichi Hanagaki> Just to learn to do terminal applications with nim.
21:23:20FromDiscord<Horizon [She/Her]> A friend talked about constant pointers, but what does that mean? And are they doable in Nim? (I'm clueless about it)
21:23:48FromDiscord<Elegantbeef> `--experimental:strictFuncs` and `ref T`
21:23:49FromDiscord<Elegantbeef> Done
21:24:25FromDiscord<Recruit_main707> strictFuncs still experimental? :(
21:24:31FromDiscord<Horizon [She/Her]> Oh so constant pointers are reference types?
21:24:42FromDiscord<Horizon [She/Her]> In reply to @Recruit_main707 "strictFuncs still experimental? :(": Iirc they're being made standard in Nim 2.0
21:25:40FromDiscord<Recruit_main707> reference types are just pointer types, and with strict funcs arguments cannot be mutated
21:26:33FromDiscord<haywireSSC> sent a code paste, see https://play.nim-lang.org/#ix=4drI
21:27:11FromDiscord<haywireSSC> If the name doesn't have letters and is something like `====` it works like this but with letters doesn't
21:27:24FromDiscord<haywireSSC> (edit) "`====`" => "\`====\`"
21:27:37FromDiscord<Recruit_main707> iirc you cant, the closest you can get is `a.myFunc b`
21:27:46FromDiscord<haywireSSC> Oh
21:27:58FromDiscord<haywireSSC> Ty
21:28:05FromDiscord<Recruit_main707> np
21:28:31FromDiscord<Horizon [She/Her]> In reply to @Recruit_main707 "reference types are just": Ah
21:28:39FromDiscord<haywireSSC> Another question, do you know how I would use the callconv pragma?
21:29:39FromDiscord<Recruit_main707> for a single function?
21:30:09arkanoidis there a tool that converts all snake_case to camelCase?
21:30:16FromDiscord<haywireSSC> Yeah, I couldn't find what options to give it
21:30:19FromDiscord<Recruit_main707> `proc name(args) {.[calling convention (cdecl, nimcall, etc).}`
21:30:27arkanoidI'm porting python code and it would save me some time
21:30:32FromDiscord<Recruit_main707> forgot closing ] but you get it :P
21:30:41FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/xv8
21:30:45FromDiscord<haywireSSC> Thanks!
21:31:26FromDiscord<haywireSSC> In reply to @Recruit_main707 "forgot closing ] but": What do the [] do?
21:32:20FromDiscord<Recruit_main707> it means that whatever its written its not what you are supposed to write exactly, but that its an explanation
21:32:22FromDiscord<Elegantbeef> Recruit is just being funky
21:34:05FromDiscord<haywireSSC> In reply to @arkanoid "is there a tool": https://media.discordapp.net/attachments/371759389889003532/1031681532588462130/Screenshot_20221017-223338_Samsung_Internet.jpg
21:34:28FromDiscord<Recruit_main707> time zone reveal 👀
21:34:43FromDiscord<haywireSSC> In reply to @Recruit_main707 "it means that whatever": Ah lol k
21:35:18FromDiscord<haywireSSC> In reply to @Recruit_main707 "time zone reveal 👀": Bri'ish time heh
21:35:28FromDiscord<Elegantbeef> Fucking tea drinkers
21:35:49FromDiscord<Recruit_main707> the T word
21:36:12FromDiscord<haywireSSC> In reply to @Elegantbeef "Fucking tea drinkers": Yup
21:36:19*om3ga quit (Read error: Connection reset by peer)
21:37:31*om3ga joined #nim
21:44:18*jmdaemon joined #nim
22:12:34FromDiscord<auxym> In reply to @jos "i looked around and": https://justine.lol/endian.html scroll to the bottom for the WRITExLE/BE macros, pretty straightforward to translate in nim. Also the article is worth a read, justine is the author of cosmopolitan-libc and a bunch of other bit hacks, she knows her stuff.
22:17:17FromDiscord<auxym> In reply to @Elegantbeef "strings in Nim are": wut. I thought nim strings stored the length in a separate field, basically the same as a seq[char]. Not null terminated
22:18:20FromDiscord<Elegantbeef> They do both
22:18:38FromDiscord<Elegantbeef> Notice how i said "they're just byte sequences", then followed it with "a \\0 at the end" 😄
22:19:39FromDiscord<auxym> didn't know they stored an extra null byte at the end. For easy conversion to cstring I guess?
22:19:46FromDiscord<Elegantbeef> Yes 0 cost cstrings
22:19:54FromDiscord<Elegantbeef> Almost all languages with pascal strings do this
22:20:03FromDiscord<auxym> that's a nice extra for the cost of 1 byte I guess
22:22:43FromDiscord<Elegantbeef> It's a very beneficial feature for like next to no effort
22:24:31FromDiscord<Elegantbeef> For any FFI interop you dont need to do any extra allocations, so you are become speed
22:28:28FromDiscord<jos> In reply to @auxym "https://justine.lol/endian.html scroll to the": I mean the stuff in std/endians is good for this I just want a nice interface to write binary data in general
22:29:00FromDiscord<jos> higher level than just write(littleEndian16(val))
22:38:37FromDiscord<auxym> hm, does `shallowCopy` actually do anything for refs? Seems like it's just doing an assignment like `=`.
22:39:27FromDiscord<Elegantbeef> It doesnt increment/decrement the ref counter. It's removed with `orc`/ `arc`
22:42:08FromDiscord<auxym> Any way to copy data from one ref to the other, but no deepCopy of nested refs? low level copyMem with pointers I guess?
22:42:42FromDiscord<Elegantbeef> `myRef[] = myOtherRef[]`
22:42:58FromDiscord<Elegantbeef> That will copy strings/seqs, but only those
22:44:03FromDiscord<auxym> Sounds like what I need, but surely it will also copy other value-type fields like ints, plain objects, etc?
22:44:55FromDiscord<Elegantbeef> of course it copies those
22:45:03FromDiscord<auxym> yeah, looks like it's working as expected, ty 👍
22:45:05arkanoidlineinfos.nim(287) raiseRecoverableError Error: unhandled exception: cannot extract number from invalid AST node [ERecoverableError]
22:45:22arkanoidwhat kind of error is this?
22:45:25FromDiscord<Elegantbeef> How else do you have contiguous data that isnt a refernce auxym 😄
22:46:12FromDiscord<auxym> yeah I know lol. Was just surprised by the fact that shallowCopy was not actually copying anything
22:46:33FromDiscord<Elegantbeef> ShallowCopy is pretty much a fancy `ptr`
22:49:05arkanoidproc foo[A,B,C](a: A, b: B): C, how can I pass generic argument C when calling foo? I don't remember the syntax
22:55:27FromDiscord<Generic> you need to explicitly instantiate it
22:55:38FromDiscord<Generic> e.g. foo[int, int, int]()
22:56:25arkanoidGeneric, but A and B can be implicitly acquired by arguments
23:01:09FromDiscord<Generic> then put C first
23:01:29FromDiscord<Generic> proc foo[C,A,B](a: A, b: B): C
23:01:51FromDiscord<Generic> foo[int](1,2) so that A and B should be int should work, though I'm not 100% sure
23:08:37arkanoidGeneric, nope, it asks for 3 even if I send 1 and 2 are implicit
23:09:24FromDiscord<huantian> Perhaps you can use a typedesc
23:09:40FromDiscord<huantian> But you’d have to pass the type as a parameter
23:10:31FromDiscord<huantian> `proc foo[A, B, C](a: A, b: B, _: typedesc[C]): C`
23:12:03FromDiscord<Generic> what about auto?
23:13:52arkanoidhuantian, your solutions works! Thanks!
23:14:15arkanoidGeneric, I was using auto, but I was getting weird macro errors from within compiler
23:15:03FromDiscord<Generic> ah
23:23:49arkanoidGeneric, I've just made "auto" work! I didn't know I could cast to auto
23:24:09arkanoidreturn 0.auto is valid
23:24:09qwrElegantbeef: you're right, in go-lang the for has worse issue due by allowing to take direct ref of loop variable, nim has only closure capture fun
23:24:37FromDiscord<Generic> you could cast to auto
23:24:38FromDiscord<Generic> ?
23:24:41FromDiscord<Generic> til
23:41:30arkanoidI have "type Percent = range[0.00001..0.99999]". If I sum or subtract two Percent variables, the resulting type is float. What's the correct way to enforce the range?
23:41:57arkanoidshould I make it distinct and rewrite/borrow the ops, or should I cast after the op?