<< 15-05-2023 >>

00:15:41*rockcavera joined #nim
01:42:03FromDiscord<voidwalker> is there some "paths" module so that I can get a distinct path type ? seq[string] just doesn't feel right
01:42:17FromDiscord<voidwalker> (edit) "is there some "paths" module so that I can get a distinct ... path" added "filesystem"
01:43:24FromDiscord<huantian> unfortunately I don't think we have like a python pathlib equivalent
01:43:53FromDiscord<amadan> If it's like jsony then taggy is probably fastest (https://github.com/treeform/taggy)
01:45:48*lucasta quit (Remote host closed the connection)
01:46:05FromDiscord<voidwalker> I found this, but it seems a bit under developed: https://github.com/achesak/nim-pythonpathlib/blob/master/pythonpathlib.nim
01:48:20FromDiscord<Elegantbeef> Devel has static typed paths
01:48:59FromDiscord<Elegantbeef> https://nim-lang.github.io/Nim/paths.html if using devel
01:49:31FromDiscord<huantian> dang I guess i have to start using devel now
01:54:05*nanxiao joined #nim
02:01:06FromDiscord<voidwalker> blah, nim arch pkg 2+ months outdated now. let's see if aur package compiles
02:01:14FromDiscord<voidwalker> (edit) "blah, nim arch pkg 2+ months outdated now. let's see if aur ... package" added "-git"
02:01:41FromDiscord<Elegantbeef> One day people will learn gitnim/choosenim are the way to install Nim if you want to swap between versions
02:08:41FromDiscord<voidwalker> Hint: Binary 'nim' isn't in your PATH. Ensure that '/home/sgm/.nimble/bin' is in your PATH.
02:08:46FromDiscord<voidwalker> why doesn't it do paths as well
02:09:25FromDiscord<huantian> huh?
02:09:32FromDiscord<voidwalker> `choosenim devel`
02:09:56FromDiscord<Elegantbeef> Did you not add `.nimble/bin` to your path?
02:13:12FromDiscord<voidwalker> oh I guess there's not any universal way to add to PATH
02:13:19FromDiscord<voidwalker> (edit) "any" => "one"
02:13:31FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vQQ
02:13:31FromDiscord<Elegantbeef> Nope depending on shell and desired way of doing it's fun
02:14:15FromDiscord<Elegantbeef> `nvim ~/.config/fish/config.fish` add `fish_addpath ~/.nimble/bin`
02:14:42FromDiscord<Elegantbeef> Fish users unite
02:15:10FromDiscord<voidwalker> i really don't care for shells, it's just what cachyOS has as default, and it works
02:15:11FromDiscord<Rika> You like swimming?
02:15:32FromDiscord<Elegantbeef> I really just like it's out of the box auto complete
02:15:36FromDiscord<Elegantbeef> It's top notch
02:20:20FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vQR
02:20:54FromDiscord<voidwalker> fish_add_path
02:22:52FromDiscord<voidwalker> well, project compiles on devel fine. I guess I didn't do anything too fancy so far
02:23:04FromDiscord<Elegantbeef> Right my bad, set you up for failure
02:23:32FromDiscord<voidwalker> funny I am switching to devel for damn paths
02:24:08FromDiscord<Elegantbeef> The fun part is there is nothing develly about them
02:24:27FromDiscord<Elegantbeef> If the stdlib wasnt attached to the compiler you could use it in stable
02:24:32FromDiscord<voidwalker> feels like a super late addition.. how come they didn't realise sooner to make this ?
02:24:51FromDiscord<Elegantbeef> Cause 0.x already had string paths
02:24:58FromDiscord<Elegantbeef> So it had to wait until a 2.0 to replace
02:25:27*lumo_e joined #nim
02:26:18FromDiscord<Elegantbeef> After the 1.0 release we're now in "No breaking changes" land
02:26:27FromDiscord<Elegantbeef> Which means breaking changes need to wait until major releases
02:27:12FromDiscord<voidwalker> lots of things left to break
02:30:41FromDiscord<Goat> So many CLI libraries to try.
02:39:44*lumo_e quit (Quit: Quit)
02:40:03*lumo_e joined #nim
03:24:40*pharonix71 quit (Remote host closed the connection)
03:25:08*pharonix71 joined #nim
03:33:00FromDiscord<voidwalker> do the paths in std\paths automatically convert to a string ? Or how do I get their string value ? They are distinct string
03:33:48FromDiscord<Elegantbeef> `string(MyPath)`
03:34:21FromDiscord<voidwalker> oh ok, wonder why there isn't a $
03:34:52FromDiscord<turtlebasket> Is there any documentation on how to use nim without a C stdlib (i.e. using `gcc -freestanding`)?
03:37:37FromDiscord<demotomohiro> I tried that long time ago:↵https://internet-of-tomohiro.netlify.app/nim/nim4k.en.html
03:39:56FromDiscord<turtlebasket> hmm.. issue is that the generated C source including `string.h` despite my not using the `string` type
03:40:11FromDiscord<Elegantbeef> I mean Nim's string doesnt come from `string.h` anyway
03:40:32FromDiscord<turtlebasket> wait what↵then I wonder why it's even there to begin with 😵‍💫
03:40:52FromDiscord<Elegantbeef> Cause it has Cstring operations
03:41:06FromDiscord<Elegantbeef> You best bet is likely to write your own nimbase.h
03:41:11FromDiscord<voidwalker> are they going to change all the path operating procs, like file procs, to use Path instead of string ?
03:41:18FromDiscord<Elegantbeef> They already have
03:41:40FromDiscord<voidwalker> [1] proc newFileStream(filename: string; mode: FileMode = fmRead; bufSize: int = -1): owned
03:42:22FromDiscord<Elegantbeef> I guess PR time for you? 😄
03:42:36FromDiscord<Elegantbeef> Add a new overload that takes in a `Path`
03:44:15*nanxiao quit (Quit: Client closed)
03:44:21FromDiscord<voidwalker> [1] proc openAsync(filename: string; mode = fmRead): AsyncFile
03:44:51FromDiscord<Elegantbeef> io/os were replaced with the statically typed versions
03:45:05FromDiscord<Elegantbeef> Everything else still uses strings, so i'd suggest open a PR if it bothers you enough
03:49:04FromDiscord<voidwalker> what is the best practice concerning path separators and portable code ?
03:49:35FromDiscord<Elegantbeef> use `/` or `joinPath`
03:50:00FromDiscord<voidwalker> I remember in free pascal there was some const that was automatically set to the correct char depending on platform
03:50:16FromDiscord<Elegantbeef> That's what nim does aswell
03:50:55FromDiscord<voidwalker> so If I have a `it.path.split("/").mapIt`
03:51:21FromDiscord<voidwalker> there's no split to path components in std/paths as I can see
03:52:02FromDiscord<Elegantbeef> `splitPath` `parentDir`
03:52:08FromDiscord<Elegantbeef> `parentDirs`
03:54:32FromDiscord<voidwalker> parentDirs won't work, only gives the parent dirs, not all elements
03:56:38FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRa
03:57:21FromDiscord<voidwalker> well, I will just use string split, as it's raw data anyway, not actually to be used as a Path
03:57:38FromDiscord<voidwalker> so there's no magic keyword for cross platform path delimitator?
03:57:46FromDiscord<voidwalker> if I want to use it for string manipulation
03:57:50FromDiscord<Elegantbeef> I said there was a constant
03:58:04FromDiscord<voidwalker> which one ?
03:58:10FromDiscord<Elegantbeef> `DirSep`
03:58:22FromDiscord<Elegantbeef> https://nim-lang.github.io/Nim/osseps.html declared in this odd module
04:13:49FromDiscord<voidwalker> ah lol, and strutils split has `char` sep, while join only has string
04:14:14FromDiscord<voidwalker> $DirSep it is : D
04:15:30FromDiscord<demotomohiro> MS Windows uses both '\' and '/' as path separaters.↵os module aware that.
04:15:43FromDiscord<demotomohiro> both '\\' and '/'
04:19:13*lumo_e quit (Quit: Quit)
05:03:20FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vRl
05:06:05FromDiscord<Elegantbeef> Use cpFile instead of writing each one i'd say
05:07:08*rockcavera quit (Remote host closed the connection)
05:08:07FromDiscord<voidwalker> https://nim-lang.github.io/Nim/nimscript.html#cpFile%2Cstring%2Cstring ?
05:08:32FromDiscord<Elegantbeef> nope that's nimscript
05:08:37FromDiscord<Elegantbeef> it's copyFile from os i guess
05:09:23FromDiscord<voidwalker> how do you copy a file that does not exist to begin with ?
05:09:36FromDiscord<Elegantbeef> Write a file once to tmp then copy it from there
05:10:16FromDiscord<voidwalker> so basically one extra step.. for what ?
05:10:41FromDiscord<Elegantbeef> You arent writing a file each time you're letting the OS do it's thing
05:11:00FromDiscord<voidwalker> oh, it's non blocking
05:12:50FromDiscord<voidwalker> so I create it in tmp instead of actual destination (with writeFile?) copy it to destination I want with cpFile, and then open it so I can setFilePos so it gets the desired length ?
05:13:01FromDiscord<voidwalker> sounds like an extra step with no benefit to me
05:13:13FromDiscord<Elegantbeef> No you do not do `setFilePos` in my case
05:13:43FromDiscord<voidwalker> but I do need to setFilePos.. I don't know any other way to write random ranges into a file if it's not already set to the needed length
05:13:46FromDiscord<Elegantbeef> I didnt read your code
05:13:46FromDiscord<Elegantbeef> Only your query
05:13:51FromDiscord<Elegantbeef> I see now each file is a different file size
05:14:26FromDiscord<voidwalker> yeah query was confusing, "empty file" of a given size. I discovered that I can create these sparse files by accident with setFilePos
06:23:17FromDiscord<voidwalker> Is it possible to get the position of an element in a sequence in filter/filterIt ? I need to filter by position
06:29:35FromDiscord<Arathanis> In reply to @voidwalker "Is it possible to": you can be cheeky and do this:
06:29:50*syl quit (Quit: C-x C-c)
06:30:39*blackbeard420_ joined #nim
06:30:40FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRA
06:30:55FromDiscord<Elegantbeef> If you're using `filterIt` and wanting an index you're using `filterIt` wrong
06:31:05*blackbeard420 quit (Ping timeout: 260 seconds)
06:31:10FromDiscord<Arathanis> granted you will get pairs out the other side, so you have to do even more processing
06:31:32FromDiscord<Arathanis> but beef is absolutely right, we are abusing filterIt doing this
06:31:46FromDiscord<Arathanis> and being wasteful to boot
06:32:07FromDiscord<voidwalker> I guess so, I just wanted a one liner, sigh
06:32:17FromDiscord<voidwalker> I should look up into those zero functional libs for nim
06:32:25FromDiscord<voidwalker> see if they have anything better
06:32:38FromDiscord<Arathanis> code golf is the root of all evil
06:32:50FromDiscord<Arathanis> unless you are in a golfing tournament.
06:33:06*syl joined #nim
06:33:11FromDiscord<voidwalker> no I am not, it is just a common enough operation that it deserves golfing
06:33:44FromDiscord<voidwalker> I just feel bad when opening a `for` : \
06:34:53FromDiscord<voidwalker> yeah the pairs way is the way to go now, all my code uses map filter etc in very inefficient ways, when I refactor it, I will start with zero functional anyway.
06:34:55FromDiscord<Arathanis> sent a long message, see http://ix.io/4vRB
06:35:17FromDiscord<Arathanis> (edit) "http://ix.io/4vRB" => "http://ix.io/4vRC"
06:35:29FromDiscord<Arathanis> sent a long message, see http://ix.io/4vRD
06:35:30FromDiscord<Arathanis> aww no more eval
06:35:39FromDiscord<Elegantbeef> Eval only works on a single line anywho
06:35:43FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRE
06:35:47FromDiscord<Arathanis> In reply to @Elegantbeef "Eval only works on": ohhhh
06:36:41FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRF
06:36:51FromDiscord<Elegantbeef> It's now a one line
06:37:05FromDiscord<Elegantbeef> And it's more useful cause you can reuse your code
06:37:13*PMunch joined #nim
06:38:08*azimut quit (Ping timeout: 240 seconds)
06:38:50FromDiscord<Arathanis> @voidwalker what is the positional condition you are filtering on?
06:39:14FromDiscord<voidwalker> well, something like `t.files.pairs().toSeq.filterIt(t.filesWanted[it[0]] == 1)`
06:39:23FromDiscord<voidwalker> if another seq on that position is 1/true
06:39:30FromDiscord<Arathanis> oh
06:39:34FromDiscord<Arathanis> use zip for this
06:39:42FromDiscord<Arathanis> just zip them together and collect the truthy ones
06:43:18FromDiscord<voidwalker> wouldn't that be the same as pairs ?
06:43:36FromDiscord<Arathanis> its more expressive
06:44:49FromDiscord<Elegantbeef> I'm always amazed at the fact there are not iterators for `openArray` in `sequtils`
06:45:28FromDiscord<Arathanis> In reply to @Elegantbeef "I'm always amazed at": and that its all for seq?
06:46:40FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRG
06:46:47FromDiscord<Elegantbeef> Cmon it's so simple
06:47:01FromDiscord<Arathanis> is this... not that? https://media.discordapp.net/attachments/371759389889003532/1107559743884628028/image.png
06:47:07FromDiscord<Elegantbeef> `proc`
06:47:12FromDiscord<Arathanis> omg its a proc
06:47:13FromDiscord<Elegantbeef> It yields a `seq`
06:47:15FromDiscord<Arathanis> ???????????
06:47:31FromDiscord<Elegantbeef> I mean sequtils is all about FP so it yields `seq`s so allocates like crazy
06:47:40FromDiscord<Elegantbeef> If you care about performance you use like 1 proc from it
06:48:20FromDiscord<Elegantbeef> I'm pretty happy about my slight change in the compiler to enable pluggable iterable operations
06:48:29FromDiscord<Elegantbeef> `for (i, x) in theVal.items.mapIt(it 2).group(2).enumerate():`
06:48:32FromDiscord<Elegantbeef> It's glorious
06:48:34FromDiscord<Elegantbeef> All 0 cost
06:49:08FromDiscord<Elegantbeef> https://github.com/beef331/slicerator/blob/itermacros/src/itermacros.nim#L45-L115 with a simple macro and templates we have `.` based operations for iterables
06:49:56FromDiscord<Arathanis> ohhh, so it lets you chain iterables with `.`?
06:50:04FromDiscord<Elegantbeef> Yep
06:50:07FromDiscord<Arathanis> that is pretty hot
06:50:16FromDiscord<Arathanis> what version is that change coming in?
06:50:30FromDiscord<voidwalker> nimskull 1.0 : D
06:50:37FromDiscord<Elegantbeef> The change technically allows `(iterator myIter(...): T = ...; myIter)` to work
06:50:42FromDiscord<Elegantbeef> Nah I do not contribute to Nimskull
06:50:52FromDiscord<Elegantbeef> Coming in 2.0 i'd guess
06:51:02FromDiscord<Elegantbeef> Not like the change makes sense to backport 😄
06:51:38FromDiscord<Arathanis> what is Nimskull supposed to be? and why?
06:51:42FromDiscord<Elegantbeef> This did make saem think of a cleaner solution for Nimskull so it'll probably land in Nimskull as `iterator name[T](i: iterable[T])`
06:52:14FromDiscord<Elegantbeef> It's a fork of Nim that intends to clean the compiler up and make it easier to contribute, codifying and solidifying the language
06:52:32*nanxiao joined #nim
06:52:41FromDiscord<voidwalker> is it that much of a mess ?
06:52:53FromDiscord<Arathanis> it says its going to be incompatible eventually, are they planning to maintain both?
06:52:58FromDiscord<Elegantbeef> The language doesnt have a formalised spec, it has a manual
06:53:02FromDiscord<Arathanis> or are they gonna drop one for the other?
06:53:07FromDiscord<Elegantbeef> It's a different language
06:53:13FromDiscord<Elegantbeef> So of course it's going to be incompatible
06:53:16PMunchThere are two different groups developing Nim and NimSkull
06:53:31FromDiscord<Arathanis> i can smell the culture wars from here 😎
06:53:41PMunchSo whether one or the other drops support is up to each group
06:54:01PMunchAnyways, what's stopping you from writing those iterators Elegantbeef ;)
06:54:13FromDiscord<Elegantbeef> What do you mean?
06:54:24FromDiscord<Elegantbeef> I did write them inside slicerator
06:54:52FromDiscord<Elegantbeef> Until my change there was no reason to use `iterable` cause it was not possible to add operations and chain them
07:01:19FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vRK
07:02:06FromDiscord<Arathanis> still trying to do it on a single line? lol
07:02:17FromDiscord<Elegantbeef> That's void for you
07:02:37FromDiscord<voidwalker> doesn't really matter, as I said, all the code uses shortcuts with no concern for performance at the moment
07:02:52FromDiscord<voidwalker> I am mostly interested in the algorithms, not their implementation
07:03:12FromDiscord<voidwalker> I will revisit every proc one day and make it better/faster, but not now : D
07:03:22FromDiscord<Arathanis> but why spend so much time trying to get it on one line when you could have just used the iterator approach and it would also be faster?
07:03:29FromDiscord<huantian> In reply to @voidwalker "blah so this is": man I have no idea what this line does lmao
07:03:59FromDiscord<voidwalker> it filters elements of a seq based on the value of their position in another seq
07:04:18FromDiscord<voidwalker> (edit) "it filters elements of a seq based on the value of their position in another seq ... " added "(t.files and t.filesWanted)"
07:04:59FromDiscord<voidwalker> In reply to @Arathanis "but why spend so": cause I don't want to mix good code with bad code : D
07:05:09FromDiscord<Arathanis> wild lol
07:05:28FromDiscord<Arathanis> i can respect carving your own path through the jungle
07:05:48FromDiscord<voidwalker> I'll wait for nim 2.0 I guess before optimizing all this functional procs
07:06:05FromDiscord<voidwalker> too many things can change until then
07:07:14FromDiscord<Arathanis> make yourself a nice reusable iterator that does this and then have a super clean one-liner
07:08:22FromDiscord<voidwalker> I believe I should not write custom code for such simple matters. I will wait for nim 2.0 and/or zero-functional lib
07:08:49FromDiscord<Arathanis> you are writing so much custom code to get it on one line, why not leverage the custom code to make it clean?
07:08:56FromDiscord<voidwalker> I am thinking of the project as a showcase of nim's features and style (eventually). Doesn't show well if I have to implement such trivial things
07:09:54FromDiscord<voidwalker> Also, refactoring/cleaning up/making things faster, is super rewarding : P
07:10:03FromDiscord<voidwalker> will save myself the satisfaction for the future
07:10:16FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRL
07:11:12FromDiscord<Arathanis> In reply to @voidwalker "I am thinking of": showing how easy and clean it is to add this kind of functionality is a good showcase of a languages functionalit
07:11:19FromDiscord<Arathanis> just dont miss the forest for the trees :p
07:11:34FromDiscord<Arathanis> (edit) "languages functionalit" => "language's functionality"
07:11:55FromDiscord<voidwalker> as I said, I will wait for nim 2.0, maybe I can do this then without extra code 🙂
07:12:35FromDiscord<voidwalker> For now I am more concerned about getting a clean interface and types
07:12:42FromDiscord<voidwalker> implementation is not important
07:13:08FromDiscord<voidwalker> Also I don't like to scroll much to find my procs : D
07:13:16FromDiscord<voidwalker> so one liners are ideal
07:18:46FromDiscord<voidwalker> is it me or the compiling is a bit zippier in nim-devel vs 1.6 ?
07:19:50FromDiscord<Arathanis> In reply to @voidwalker "Also I don't like": ahh i just F12 to definition cause im lazy
07:19:56FromDiscord<Arathanis> scrolling is for chumps 😤
07:20:28FromDiscord<voidwalker> Oh I didn't know about F12, thanks
07:20:32FromDiscord<Arathanis> np
07:20:40FromDiscord<Arathanis> hotkeys are good
08:00:06NimEventerNew thread by Araq: Malebogia, see https://forum.nim-lang.org/t/10198
08:16:33*nyeaa492842301 quit (Quit: Ping timeout (120 seconds))
08:16:48*nyeaa492842301 joined #nim
08:24:30*Notxor joined #nim
08:41:09*nanxiao quit (Quit: Client closed)
09:01:41*junaid_ joined #nim
09:23:09om3gahello! if I'm getting it right, for example we have strings:sec[string] with size of around 4gb. so by clearing all the seq like: strings = @[], will GC free all allocations in heap immidiately?
09:23:42om3gawhy I'm asking, seems gc not frees here, or I misunderstand something
09:24:27om3gaI use malloc, and tried both variants with alloc too. all the same with other gc's too
09:29:25FromDiscord<Elegantbeef> You might need a `runOrc` but yes ` = @[]` should free
09:29:40*PMunch quit (Quit: Leaving)
09:40:38om3gaElegantbeef so it should free immidiately righ after this operation?
09:41:22om3gawith orc is the same as with arc or orher gc's
10:05:12FromDiscord<Rika> It’s not guaranteed to be immediate unless you are using either ARC or ORC
10:12:29om3gadumpNumberOfInstances() - what a useful feature!
10:16:41om3ganow I see where all stuff lays
10:17:08*derpydoo quit (Quit: derpydoo)
10:31:49om3garight, gc not frees immidiately
10:39:51*junaid_ quit (Remote host closed the connection)
10:48:18*Notxor quit (Read error: Connection reset by peer)
10:48:48*antranigv_ joined #nim
10:49:29*antranigv quit (Ping timeout: 256 seconds)
11:13:54FromDiscord<Entikan> how do I `pow(int, 2)` do I really have to convert to a float?
11:14:21FromDiscord<dennisritchie> relax
11:14:41FromDiscord<Entikan> don't do it
11:14:54FromDiscord<Entikan> when you want to get to it
11:15:16FromDiscord<Rika> `int^2`?
11:16:59om3gaint is a type
11:17:03FromDiscord<Entikan> oh >.<
11:17:07FromDiscord<Entikan> thanks @Rika
11:17:15om3gawhat are you trying to do?
11:17:23FromDiscord<Rika> omega, i know, i am using their notation
11:17:37FromDiscord<Entikan> In reply to @om3ga "what are you trying": pythagoras
11:17:59*PMunch joined #nim
11:24:08Amun-Rahow about… x * x
11:27:33FromDiscord<Entikan> yeah that works too. But I also wanted to how to do powers in general.
11:27:41FromDiscord<Entikan> (edit) "yeah that works too. But I also wanted to ... how" added "know"
11:49:10NimEventerNew post on r/nim by qtless: Path Params Assignment, see https://reddit.com/r/nim/comments/13i5y1p/path_params_assignment/
11:55:45FromDiscord<gloopsies> I have a procedure that takes any type and does things based on type switch, is there a way to have a collection of different types that I can store data into and then call the template function on every element?
11:56:33PMunchNot really, the normal collections are homogeneous
11:57:02PMunchYou can give all your types the same ancestor and make them ref objects, then you can store them in a collection, but it's a bit cumbersome to get them back out
11:58:09PMunchThe alternative is to use case objects or create closures to put in the collection
12:01:31PMunchThat last thing would look a little something like this: https://play.nim-lang.org/#ix=4vSx
12:07:40*blackbeard420_ quit (Quit: ZNC 1.8.2 - https://znc.in)
12:07:53*blackbeard420 joined #nim
12:43:27*lucasta joined #nim
12:45:02FromDiscord<chmod222> Okay so, before I get too far into my weeds here, I'm looking to generate code from a big JSON file (5 MB for now). I could process it in a standard `macro` but because you have to crank up `maxLoopIterations` and it takes quite a few seconds, that isn't really fun. So went for importing `compiler/[ast, renderer]` and generating code at runtime with a dedicated codegen binary and then importing the generated code into the project that
12:45:32FromDiscord<chmod222> With that context, can I depend on renderer.`$` to generate correct code?
12:46:21FromDiscord<chmod222> It seems correct for now, but I don't want to find out somewhere in the middle that something is afoul
12:47:25FromDiscord<chmod222> That other alternative is manually string-formatting the nim code and that's even less fun
12:47:31PMunchWith repr I believe it should be correct
12:47:53PMunchThat said the way Futhark works is to consume JSON and create code
12:48:21FromDiscord<chmod222> Unfortunately, repr doesn't work at runtime with `NimNode` as generated by std/macro
12:48:27FromDiscord<chmod222> Only at compile time
12:48:45FromDiscord<chmod222> But it seems to use renderer.`$` at compile time
12:52:26PMunchOh I believe `repr` is mapped to renderer.`$`
12:52:55PMunchYou could use a faster JSON parser though
12:53:24PMunchI've been meaning to do that for Futhark
12:54:05PMunchCurrently for my Gtk/WebKit based markdowneditor it parses 12Mb of JSON and it does take a while
12:55:18PMunchBut it caches the result, so unless I'm changing anything it's pretty much instant
12:55:33PMunchYou can see how this is done in Futhark if you want to go down a similar route
12:55:43PMunchNot sure what you're doing so caching might not apply
12:56:11FromDiscord<chmod222> It's probably very cacheable, the file probably only changes every few months
12:56:27FromDiscord<chmod222> But can I cache straight from within a `macro` block?
12:57:01FromDiscord<chmod222> I'd prefer working within the std/macros ecosystem than needing to dig down into compiler internals
12:58:59FromDiscord<chmod222> If I could give the macro my json data and have it actually generate nim modules, that'd be even better
12:59:42FromDiscord<chmod222> You know, I didn't even consider that NimVM can write files
13:00:10FromDiscord<chmod222> I don't care about having to bump the VM limit if I only have to do it once every few months
13:03:48FromDiscord<chmod222> Yep, that works just fine. Should have thought about that from the start, thanks for pushing me in the right direction
13:10:15PMunchNo problem, just shared how I'm already doing it in Futhark :) If you found an even better solution I would've learned something as well
13:12:44FromDiscord<chmod222> And as an additional nuggest, `jsony` is efficient enough to not require bumping the VM limit for my file
13:13:58FromDiscord<chmod222> Still takes enough time to warrant caching
13:17:02FromDiscord<jmgomez> FYI NimForUE also uses repr and it works fine and it generates more than 1M LoC. it’s a two step process though, one for generating the metadata file which is also Nim (so it doesn’t have to be parsed) and another one for generating the actual Nim code. Since it’s split in modules it can also run in parallel
13:20:32PMunch@chmod222, how much faster is jsony over the native json library?
13:20:54PMunchAnd it's probably just because it's not recursive that you don't have to bump the VM limit
13:26:50FromDiscord<chmod222> Let me benchmark real fast
13:27:27FromDiscord<chmod222> jsony requires 7.27 seconds for parsing the source given via `staticRead`
13:27:38*antranigv_ is now known as antranigv
13:29:10FromDiscord<chmod222> std/json requires 10.40 seconds with bumped VM limit
13:29:20FromDiscord<chmod222> for read+unmarshal
13:30:10FromDiscord<chmod222> 5176730 of source data
13:30:24PMunchHmm, I'm guessing that the unmarshaling requires a substantial amount of time
13:30:31PMunchBut it's probably still faster
13:30:43PMunchJSONY that is
13:30:48FromDiscord<chmod222> jsony also unmarshals
13:30:54FromDiscord<chmod222> So the time is comparable
13:31:10PMunchOoh right..
13:31:18PMunchThat's why I didn't use it
13:31:53*rockcavera joined #nim
13:32:33FromDiscord<chmod222> I think that's the reason why it's faster and requires less VM time, std/json has the parse -\> unmarshal as a 2 step pipeline and jsony does it in one step
13:33:35FromDiscord<chmod222> My json is very simple but very much so unmarshalling into a couple of objects is fine fo me
13:34:53FromDiscord<gloopsies> In reply to @PMunch "You can give all": That could work if I have a field that marks the type
13:35:03FromDiscord<gloopsies> So I can cast to desired type
13:35:20FromDiscord<gloopsies> I think at least but that's how I'd do something similar in c
13:35:47FromDiscord<gloopsies> Have an array of struct pointers that all have first field as type then based on that cast to actual type
13:36:08PMunchThat's essentially what both the common ancestor and case object would do
13:36:33PMunchAnd the closure I guess
13:40:07*antranigv is now known as antranigv_
13:40:11*antranigv_ is now known as antranigv
13:43:04*antranigv is now known as antranigv_
13:43:34*antranigv_ is now known as antranigv
13:50:24*Notxor joined #nim
13:51:22FromDiscord<chmod222> `Error: Invalid node kind nnkConstSection for macros.$`
13:51:34FromDiscord<chmod222> Does `$` really not rnder consts or am I being obtuse?
13:52:28FromDiscord<chmod222> Ah yeah, I'm being obtuse
13:52:39FromDiscord<chmod222> Needs `repr`
13:56:21*progranner joined #nim
14:02:20PMunchYeah basically there are many ways to represent a NimNode so there is no default `$`
14:07:38FromDiscord<jtv> Pmunch, I never ported to Nim, but my lock-free data structures are here: https://github.com/viega/hatrack
14:08:43PMunchHmm, interesting
14:08:55FromDiscord<jtv> There are kind of TOO many options for hash tables, ended up doing a bunch of testing and would just pick one 🙂
14:10:31FromDiscord<jtv> Yeah, I haven't done anything multi-threaded in nim yet, and the model there is definitely something I'd need to drill into. If it were all just 'normal' garbage collected stuff, then some of the memory safeguards I have there would be unneeded, but I think w Arc they probably still are.
14:11:03FromDiscord<jtv> Anyway I have a board meeting tomorrow so am distracted, but if you're interested I can spend some time discussing after that
14:22:15FromDiscord<chmod222> Dang, `dirExists` works from within a macro but `createDir` does not
14:24:24FromDiscord<chmod222> I see futhark does `staticExec` for mkdir
14:24:25FromDiscord<chmod222> This hurts me on a deep level
14:38:31*antranigv is now known as antranigv_
14:39:34*antranigv_ is now known as antranigv
14:40:16*antranigv quit (Quit: ZNC 1.8.2 - https://znc.in)
14:40:36*antranigv joined #nim
15:02:45*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
15:15:08*progranner joined #nim
15:23:45*azimut joined #nim
15:25:18*def- quit (Quit: -)
15:26:07*def- joined #nim
15:53:54*xet7 quit (Remote host closed the connection)
16:33:54*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
16:36:05*progranner joined #nim
16:38:36*progranner quit (Client Quit)
16:38:38*dv^_^ quit (Quit: Ping timeout (120 seconds))
16:39:07*dv^_^ joined #nim
16:39:28*progranner joined #nim
17:18:51ehmryis there a way to compose objects together other than inheritence? I thought there was a feature where all the fields of an object could be added to another but maybe this was a different language
17:21:33*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
17:29:40*progranner joined #nim
17:51:04FromDiscord<demotomohiro> Another way is put objects in another object as fields.↵Or use macro to merge fields from existing objects and create a new object.
17:58:09FromDiscord<Ayy Lmao> I'm trying to make an audio plugin, and it involves making a dll that is hosted inside another program. The host calls different functions on two different threads, and one is a hard realtime thread. Is there a way to get Nim working in this case? I have been able to get it working with Odin, but every time I try to do anything involving a sequence with Nim I get random segfaults. I'm calling NimMain on entry, is there anything else spec
18:00:13FromDiscord<Ayy Lmao> I have no idea what Nim does behind the scenes when making refs, but the problem arises when the host spawns two instances of my program.
18:08:01FromDiscord<demotomohiro> Each two functions in one loaded dll called from two threads?↵Are you using `--mm:arc` or `--mm:orc`?
18:09:32FromDiscord<demotomohiro> And `--threads:on`?
18:12:09FromDiscord<Ayy Lmao> In reply to @demotomohiro "Each two functions in": There is one entry point which the host says is 'thread safe'. I call NimMain there. The host spawns instances of my plugin in a thread safe function, but then the host is allowed to call callbacks of each instance on two different threads that are managed by the host itself. I am using `--gc:arc`. If I use `--threads:on` the program immediately segfaults upon loading.
18:20:10FromDiscord<Chronos [She/Her]> Hey ElegantBeef, you here? I want to work on my MC server impl again but this time, using WASM, my issue though is that I'm kinda unsure how to actually implement it? Would you recommend sandboxing the game and what can be accessed? I'd also need different permission levels too if I want sandboxing, not sure how to implement it though
18:21:17FromDiscord<Chronos [She/Her]> Also I'm wondering on if I should have 'native' extensions too, instead of purely using a WASM module system, though I'd definitely prefer the WASM-only plugin system... Just a bit tricky
18:22:29FromDiscord<demotomohiro> sent a long message, see http://ix.io/4vTZ
18:23:50FromDiscord<Q-Master> {.threadvar.}'ll help IMO.
18:23:59FromDiscord<Ayy Lmao> In reply to @demotomohiro "https://nim-lang.org/docs/manual.html#threads > Nim": But wouldn't it only use its own garbage collected heap for threads that are spawned within Nim itself? The program doesn't know about the threads that the host spawned. I'm also not compiling with threads on at the moment.
18:24:49FromDiscord<Ayy Lmao> I need the host to spawn instances of my program that have shared data between the two threads the callbacks are called on
18:29:24FromDiscord<Ayy Lmao> I guess the question is, is it possible to use Nim in a multithreaded environment where Nim isn't the one in charge of the threads?
18:29:57FromDiscord<demotomohiro> If two functions use seq and try to allocate heap, Nim's memory allocater try to allocate heap for them.↵Maybe Nim's memory allocater is not thread safe and it get crash.↵If so, only one of two thread allocate/deallocate heap might fix it.
18:31:37FromDiscord<Ayy Lmao> Well you aren't supposed to even allocate on the realtime audio thread anyway, so I think if I allocate on the main thread only I might be ok. The only problem is I have no idea how to stop Nim from allocating in certain circumstances.
18:31:48FromDiscord<Ayy Lmao> Like for instance the crash I am getting happens when I try to sort a sequence.
18:45:09FromDiscord<demotomohiro> https://github.com/nim-lang/Nim/blob/f4a9b258c34a83efb74d9dea6853880e47f45b06/lib/pure/algorithm.nim#L412↵If you use this sort proc, it calls `newSeq`.
18:45:35FromDiscord<Ayy Lmao> Yeah that's where it segfaults.
18:46:25FromDiscord<Ayy Lmao> Is NimMain itself threadsafe with `--threads:on`? I'm wondering why I can't turn threads on without crashing the program.
18:52:50om3galocks
18:52:53om3gashared ram
18:52:59FromDiscord<chmod222> If an object has both `x: T` and `proc x(obj: T)`, is there a way to specify at call site which one you get? Or do I have to name one of them differently?
18:53:05om3gaI spent hours coding threads
18:53:17om3gait's very easy to ruin whole program
18:56:00PMunch@chmod222, yeah that bug me to..
18:56:23FromDiscord<Chronos [She/Her]> In reply to @Hourglass, When the Hour Strikes "Also I'm wondering on": @ElegantBeef Clearly Beef isn't omnipresent lmao
18:56:38*PMunch quit (Quit: leaving)
18:56:40FromDiscord<demotomohiro> In reply to @Ayy Lmao "Yeah that's where it": I think `NimMain` is supposed to be called only once, not called from each threads.
18:56:44om3gaAyy Lmao, sounds like you need to use locks
18:59:10FromDiscord<chmod222> It's not ideal, I guess I'll just name the internal fields "f\_x" and such, given that "x\_" is forbidden↵(<@709044657232936960_=50=4dunch=5b=49=52=43=5d>)
19:00:06FromDiscord<Ayy Lmao> In reply to @om3ga "Ayy Lmao, sounds like": I'm not at the point where I'm sharing data yet. And also locks are apparently bad for realtime audio.
19:00:48FromDiscord<chmod222> Locks are not the issue, lock contention is the issue
19:02:03om3gaAyy Lmao, if your code crashes during sort of the shared data in heap, the issue is more with concurency
19:03:30FromDiscord<Ayy Lmao> The data I am sorting is only being accessed from the audio thread though. When I do this same kind of logic in Odin it doesn't segfault.
19:03:55*krux02 joined #nim
19:04:20FromDiscord<Arathanis> How come `array[0..20, int]` is valid but `array[0..<20, int]` is not?
19:07:14FromDiscord<Ayy Lmao> The segfault specifically happens at the line `c.freeList = c.freeList.next` in `proc rawAlloc(a: var MemRegion, requestedSize: int): pointer` in `alloc.nim`
19:09:54om3gaAyy Lmao, add options --passC:"-O0 -g3 -fsanitize=thread" and --passL:"-O0 -g3 -fsanitize=thread"
19:10:07om3gathis will help you to debug
19:11:05om3gaif these options will not print any output about the error, use -fsanitize=address instead
19:12:55FromDiscord<Chronos [She/Her]> Anyone know what I'd call a module that handles serialisation and deserialisation? Trying to get a proper and clean structure
19:13:12FromDiscord<Chronos [She/Her]> for my module
19:13:29FromDiscord<Chronos [She/Her]> Everything is top-level and it's getting kinda cluttered
19:15:06om3gaI reduced ram usage from 21GB to 12gb, thanks for the awesome feature provided by dumpNumberOfInstances
19:17:49FromDiscord<auxym> In reply to @Hourglass, When the Hour Strikes "Anyone know what I'd": something like frosty or flatty?
19:17:53FromDiscord<Ayy Lmao> In reply to @om3ga "Ayy Lmao, add options": It seems to tell me `cannot find -ltsan`. Also, since this is a dll hosted in another program I don't get any output printed when it crashes. I've just been going by debug symbols.
19:19:00FromDiscord<Arathanis> In reply to @Hourglass, When the Hour Strikes "Anyone know what I'd": is it expected to be exported to a use or for internal use?
19:19:11FromDiscord<Arathanis> (edit) "use" => "user"
19:20:43om3gaAyy Lmao, yeah, you should have it installed, if you have linux you can install it. not sure about windows
19:21:38om3gaso you have shared lib compilation
19:21:56om3gathen your problem is more complicated
19:21:58FromDiscord<Ayy Lmao> I'll have to figure out how to install it. I'm on windows.
19:22:29om3gaI'm not sure if it works under windows, but should in wsl
19:30:33FromDiscord<Arathanis> Can someone explain the practical difference between alloc/dealloc and allocShared/deallocShared?
19:31:17FromDiscord<Arathanis> Threads dont seem to care one way or the other if I use pointer from one or the other
19:37:57FromDiscord<Elegantbeef> @Chronos [She/Her] No i'm monopresent
19:38:29FromDiscord<Elegantbeef> You'd use wasm modules for user space code and native wasm stuff for non user code
19:38:35FromDiscord<Elegantbeef> I do not really get the path of the query
19:38:35FromDiscord<michaelb.eth> In reply to @Arathanis "Can someone explain the": Not sure about Nim 2.0 RCs, but in 1.6 and earlier, allocShared can be important when you’re using the default `refc` gc
19:38:51FromDiscord<Elegantbeef> alloc/dealloc doesnt use locks, allocShared and deallocShared do
19:39:06FromDiscord<michaelb.eth> (edit) "In reply to @Arathanis "Can someone explain the": Not sure about Nim 2.0 RCs, but in 1.6 and earlier, allocShared can be important when you’re using the default `refc` gc ... " added "and you want to share some memory between threads"
19:39:56FromDiscord<Arathanis> so the shared versions should be used when allocating memory inside threads?
19:39:59FromDiscord<Elegantbeef> Atleast that's how it used t obe
19:40:11FromDiscord<Elegantbeef> With refc yea
19:40:17FromDiscord<Elegantbeef> With arc/orc depending what you're doing you do not need it
19:40:20FromDiscord<Arathanis> pfff, we orc now 😎
19:40:29FromDiscord<Arathanis> doesn't matter with orc im guessing?
19:40:51FromDiscord<Elegantbeef> Well refc doesnt have a shared heap
19:41:13FromDiscord<Elegantbeef> arc/orc do have a shared heap so you can transfer ownership of graphs assuming you disarm the destructors properly
19:41:57FromDiscord<Arathanis> In reply to @Elegantbeef "arc/orc do have a": whew, i wish i understood this more. have an example to point to?
19:42:15FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "You'd use wasm modules": Native WASM stuff?
19:42:27FromDiscord<Elegantbeef> Look at the forum there are an abundant amount of threading related posts recently
19:42:31FromDiscord<Elegantbeef> Host functions
19:42:54FromDiscord<Chronos [She/Her]> In reply to @Arathanis "is it expected to": I figured out the names but it was so I could group them in a folder and export them
19:43:15FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Host functions": Ah
19:44:13FromDiscord<Chronos [She/Her]> Now I need to design this in a way that C can also use the API cleanly
19:44:34FromDiscord<Chronos [She/Her]> All I'll need is to make a C library or something with a struct like my Nim type, right?
19:44:56FromDiscord<Elegantbeef> You need to have accurate ABI yes
19:47:31FromDiscord<Chronos [She/Her]> Alr nice
19:48:37FromDiscord<Chronos [She/Her]> Hm... Should my `Packet` object be a ref object or a normal object...
19:48:55FromDiscord<Chronos [She/Her]> Meh I'll change it as needed
19:50:24*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
19:50:25FromDiscord<Elegantbeef> Probably neither
19:50:42FromDiscord<Elegantbeef> Assuming you're still wanting to do shit from the plugins
19:55:07FromDiscord<Chronos [She/Her]> Oh this is just a Nim library, I've decided to have permission levels which decide what functions a WASM env has, so the highest WASM env will have WASI (for networking as an example...if that'll even work within WASM)
19:56:04FromDiscord<Elegantbeef> Yea I'd not do any of that 😄
19:56:15FromDiscord<Chronos [She/Her]> Why not?
19:56:27FromDiscord<Elegantbeef> A plugin should be simple and not do anything lowlevel
19:57:00FromDiscord<Elegantbeef> If you want to have a packet fire on a specific ID subscribe a procedure that gets a `cstring` and works on that
19:57:13FromDiscord<Chronos [She/Her]> The idea was to allow networking to be swapped in and out though, because implementing every version would get big, no?
19:57:25FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "If you want to": Okay wait
19:58:19FromDiscord<Chronos [She/Her]> So the server should have a basic event handler and socket server, and then plugins should have an API to subscribe to events?
19:59:04FromDiscord<Chronos [She/Her]> So the plugin itself never sees the TCP server directly, besides sending the data that the server needs to create a packet and send it?
19:59:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vUm
19:59:29FromDiscord<Elegantbeef> Then if you want to send a packet it'd be like `sendPacket(PacketId, cstring)`
19:59:31*progranner joined #nim
19:59:59FromDiscord<Elegantbeef> Yea I don't think that having the network details shown to the plugin really benefit you
20:00:02FromDiscord<Chronos [She/Her]> `cstring`? So it's compatible with C?
20:00:10FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Yea I don't think": Yeah that makes sense
20:00:10FromDiscord<Elegantbeef> Do you really want to expose an entire TCP stack to each plugin
20:00:25FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "Do you really want": Hm... Yeah not really lol
20:00:30FromDiscord<Elegantbeef> I mean it's a cstring cause wasm and host are different data
20:00:34FromDiscord<Chronos [She/Her]> That'd get bulky fast
20:00:41FromDiscord<Elegantbeef> You need to copy to some interop type
20:00:50FromDiscord<Elegantbeef> a cstring + len or just cstring is easy to do
20:00:59FromDiscord<Chronos [She/Her]> In reply to @Elegantbeef "I mean it's a": But how about the padding? Would that be solved by just making it packed?
20:01:07FromDiscord<Chronos [She/Her]> (The data type)
20:01:17FromDiscord<Elegantbeef> You cannot pass a Nim string to a wasm function cause a Nim string is 64bit on modern CPUs but a wasm Nim string is 32bit
20:01:27FromDiscord<Elegantbeef> Yes I generally pack my wasm data to make it easier to reason
20:01:37FromDiscord<Elegantbeef> Whether it's good for performance is another thing, but it's good for ABI
20:01:59FromDiscord<Chronos [She/Her]> Makes sense, thanks kb!
20:02:57FromDiscord<Chronos [She/Her]> Oh wait does this also mean the server needs to parse packets into the Nim objects? Or could I just pass that as a cstring or something and then handle that on the WASM side too
20:03:17FromDiscord<Elegantbeef> I mean the host needs to parse the id and len
20:03:26FromDiscord<Elegantbeef> Each packet should start with `id, len`
20:03:36FromDiscord<Chronos [She/Her]> Yeah it does
20:03:41FromDiscord<Elegantbeef> the rest is just send it to wasm to handle
20:03:49FromDiscord<Chronos [She/Her]> Sweet, thanks!
20:04:30FromDiscord<Elegantbeef> No clue how this works with the minecraft networking stack, but this is atleast what i'd do if I really wanted a pluggable server
20:05:06FromDiscord<Chronos [She/Her]> Probably should be fine aha
20:05:40FromDiscord<Elegantbeef> The slightly nice part is that you can have a set of builtin IDs and user defined ones, though the user defined ones are a bit questionable
20:06:21FromDiscord<Elegantbeef> I'd probably use a uint16 for the id and use the MSB as a flag to indicate if it's a custom or builtin
20:06:47FromDiscord<Elegantbeef> If it's a custom the packet would look like `(id, nameLen, nameData, packetid, packetLen, packetData)`
20:06:50FromDiscord<Chronos [She/Her]> Minecraft only uses a single byte for IDs
20:07:15FromDiscord<Elegantbeef> Ah shame
20:07:59FromDiscord<Chronos [She/Her]> Yeah aha, there are plugin channels though, Minecraft's default client can do jack with them, but mods are able to read them
20:15:21FromDiscord<Chronos [She/Her]> How much of `system.nim` and the `orc` GC actually rely on libc for Linux?
20:17:17FromDiscord<Elegantbeef> Atleast 1
20:17:33*tiorock joined #nim
20:17:33*tiorock quit (Changing host)
20:17:33*tiorock joined #nim
20:17:33*rockcavera is now known as Guest2557
20:17:33*Guest2557 quit (Killed (copper.libera.chat (Nickname regained by services)))
20:17:33*tiorock is now known as rockcavera
20:19:08FromDiscord<Chronos [She/Her]> Hm
20:19:35FromDiscord<Chronos [She/Her]> Eh I should be finee
20:19:37FromDiscord<Elegantbeef> You're asking a question that no one has an answer to
20:19:57FromDiscord<Chronos [She/Her]> Yeah makes sense
20:20:13ehmryChronos: not that much
20:20:29ehmryfloat to decimal formating comes to mind
20:21:21FromDiscord<Chronos [She/Her]> Ah, thanks ehmry! For the answer and proving Beef wrong haha
20:21:31FromDiscord<Elegantbeef> Lol
20:21:41ehmryI've run nim without a libc a few times, it's not crazy but its a bunch of patches that aren't getting merged anytime soon
20:22:20FromDiscord<Elegantbeef> This does remind me I need to get something setup for building with an older glibc
20:24:02ehmryhttps://github.com/nim-lang/Nim/pull/19536
20:40:07FromDiscord<wick3dr0se> Coming from too much bash magic.. I can't figure out why this won't work. I'm trying to print white text, wait 100ms, print red and repeat it 5x in the middle of the screen. I just don't get why everything in the nested loops only executes at once after all the sleep time adds up ~1 second in this case
20:40:26FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vUu
20:40:41FromDiscord<Elegantbeef> `stdout.flushFile` after line 4 might help
20:42:56FromDiscord<wick3dr0se> That did it
20:42:59FromDiscord<Chronos [She/Her]> https://github.com/Nimberite-Development/ModernNet :)
20:43:34FromDiscord<Chronos [She/Her]> Packet parsing isn't actually implemented yet but that is enough to actually implement your own packet handling
20:43:42FromDiscord<Chronos [She/Her]> Maybe the name is a bit misleading though?
20:43:56FromDiscord<Chronos [She/Her]> Don't know what else to call it tho, the name fits very well imo
20:44:26FromDiscord<Piko> sent a code paste, see https://play.nim-lang.org/#ix=4vUv
20:44:37FromDiscord<Elegantbeef> `Vec3`
20:44:52FromDiscord<Elegantbeef> `vec3` is a generic procedure that likey says "Expected generic parameters" or "Ambiguousu symbol"
20:46:01FromDiscord<Piko> Vec3 with vmath says: Error: attempting to call routine: 'Vec3'↵and with glm says: Error: cannot instantiate 'Vec3[T: VectorElementType]' inside of type definition: 'returns_a_vec3'; Maybe generic arguments are missing?
20:46:29FromDiscord<Elegantbeef> Is it `Vec3f` in vmath
20:46:29FromDiscord<Elegantbeef> I forget
20:47:13FromDiscord<Elegantbeef> Nope `Vec3` is an alias
20:47:24FromDiscord<Elegantbeef> `nim -v`?
20:47:38FromDiscord<Piko> in glm it works with Vec3f as type and returning vec3f( ... )
20:47:58FromDiscord<Piko> with vmath it doesn't, I was trying using DVec2 earlier
20:48:19FromDiscord<Elegantbeef> You also likely want `vec3(1.0f, 2.0f, 3.0f)`
20:48:19FromDiscord<Piko> Nim Compiler Version 1.6.12 [Linux: amd64]
20:48:30FromDiscord<Elegantbeef> Or just `vec3(1.0f, 2.0, 3.0)` probably works
20:50:24FromDiscord<Piko> ok so nim is case insentive except when declaring types that have the same name as their constructors?
20:50:41FromDiscord<Elegantbeef> Nim isnt case insensitive
20:50:49FromDiscord<Elegantbeef> Nim is style insensitive
20:50:58*Mister_Magister joined #nim
20:50:58FromDiscord<Elegantbeef> Which means the first character is sensitive and `_` is removed
20:51:26FromDiscord<Piko> I see
21:16:10*krux02 quit (Remote host closed the connection)
21:21:17*Jjp137 quit (Read error: Connection reset by peer)
21:21:58*Jjp137 joined #nim
21:25:22*Jjp137_ joined #nim
21:26:00FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vUE
21:26:21FromDiscord<wick3dr0se> I didn't like nesting it inside another for loop
21:27:31*casaca quit (Ping timeout: 240 seconds)
21:27:31*noeontheend quit (Ping timeout: 240 seconds)
21:28:01*mronetwo quit (Ping timeout: 240 seconds)
21:29:33*Jjp137 quit (Read error: Connection reset by peer)
21:29:33*Jjp137_ quit (Client Quit)
21:30:43*Jjp137 joined #nim
21:31:14*mronetwo joined #nim
21:35:41FromDiscord<chmod222> Given `proc someProc(...) {.myFunPragma.}`, is there some way to tell nim that `myFunPragma` does not exist in that module but in whatever module ultimately imports the module that contains `proc someProc(...) {.myFunPragma.}`?
21:35:46FromDiscord<chmod222> Late-binding macros, so to say
21:36:07FromDiscord<Elegantbeef> Nope
21:36:17FromDiscord<Elegantbeef> What are you trying to actually do?
21:37:12FromDiscord<chmod222> Generating a whole bunch of prototypes that merely say "I exist as a function and have this protoype, but the body is a stub to be generated in a macro that depends on state I cannot know yet"
21:37:42FromDiscord<Elegantbeef> I'd say your entire design is wrong and you just want generics
21:39:32FromDiscord<chmod222> The problem is that the entire thing becomes a shared library which gets called through an entry point, from where I get a large-ish structure containing functions like `invoke_ptr_constructor(int typeid)` which returns further pointers, so at the point where my method is stubbed that function pointer, let alone the implementation that exists in the host program does not exist
21:39:42*Jjp137 quit (Quit: Leaving)
21:40:08*casaca joined #nim
21:40:26FromDiscord<chmod222> So I generate `proc constructor(_: typedesc[MyAutogeneratedType]): MyAutogeneratedType {.ctor(4).}` which at the point it's supposed to be expanded has the necessary context to know where the large-ish struct from C has been stored
21:41:24FromDiscord<ranok (Jacob Torrey)> Hi, I'm trying to find documentation about what is defined during compilation, specifically per target. I want to import re if I'm not compiling for JS, and jsre if I am
21:41:32*Jjp137 joined #nim
21:41:42FromDiscord<ranok (Jacob Torrey)> Thus far I have some ugly command line defines, but I was hoping there's something better
21:41:49FromDiscord<chmod222> `when defined(js): ... else: ...`
21:41:53FromDiscord<chmod222> Is the simplest method
21:42:01FromDiscord<ranok (Jacob Torrey)> ok, so nim js will define js?
21:42:06FromDiscord<chmod222> ype
21:42:14FromDiscord<ranok (Jacob Torrey)> ok, that's excellent, thanks
21:42:22FromDiscord<ranok (Jacob Torrey)> is c defined for the default nim c?
21:42:31FromDiscord<chmod222> It will also define `nodejs` if you happen to `nim js --run`
21:42:40*noeontheend joined #nim
21:43:17FromDiscord<Elegantbeef> chmod without a more real world example I can only say you're likely thinking of the problem wrong
21:43:48FromDiscord<chmod222> Well, that is the real world example in a nutshell, I'm generating bindings for GDExtension
21:44:08FromDiscord<Elegantbeef> I mean a code example
21:44:09FromDiscord<Elegantbeef> Words tend to fail me and the problem
21:44:20FromDiscord<chmod222> RIght, okay
21:49:16FromDiscord<chmod222> sent a long message, see http://ix.io/4vUH
21:50:10FromDiscord<Elegantbeef> Right I've looked at GDExtensions briefly
21:51:19FromDiscord<Elegantbeef> Does each type have it's own interface pointer?
21:51:23FromDiscord<chmod222> I could probably just `include`, rather than `import` the entire autogen code
21:51:30FromDiscord<chmod222> But I'd like to stay inside the module system
21:51:36FromDiscord<chmod222> No, it's one globally shared
21:51:45FromDiscord<Elegantbeef> So why does `gd_method` not know it?
21:52:14FromDiscord<jmgomez> Kinda orthogonal, but isnt Godot written in C++? Can you take adv of it somehow?
21:52:30FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vUK
21:52:48FromDiscord<Elegantbeef> I mean it's written in C++ but why would you attempt to shoehorn Nim into it when you can just use gdextensions
21:53:24FromDiscord<chmod222> It is, and there's also a kind-of reference GDExtension implementation for C++, but if I can do "natively" without dealing with C++, I'd prefer that↵(@jmgomez)
21:54:11FromDiscord<chmod222> The API is simple enough, just a lot of it
21:55:14FromDiscord<chmod222> Well my intention was to have the entire autogenerated code its own module and have the hand written interface glue/helpers just import and re-export the autogenerated code
21:55:19FromDiscord<chmod222> It seems cleaner that way
21:55:38FromDiscord<Elegantbeef> Regardless why can you not just expose the pointer?
21:55:54FromDiscord<Elegantbeef> Do not export it from the high level API and there you go
21:56:02FromDiscord<chmod222> I don't think there's anything stopping me
21:56:31FromDiscord<Elegantbeef> You then can set the pointer when you need to inside your entry procedure
21:56:48FromDiscord<Elegantbeef> Then you just use the pointer inside any calls you make with your macro
21:56:51FromDiscord<Elegantbeef> Eh voila
21:57:10FromDiscord<jmgomez> Dont know anything about them, or Godot. I was just wondering because it feels like you will be able to do more as the engine is written in C++. For instance, many plugins use UE reflection system but there isnt a single one (including Blueprint and probably Verse) than can compete with the NUE integration just because of it. But it may be that UE is quite different from Godot from an Arch point of view
21:57:21FromDiscord<jmgomez> and they dont use inheritance etc.
21:57:39FromDiscord<Elegantbeef> Well the GDExtension is practically what gdscript really is
21:57:52FromDiscord<chmod222> GDExtension are hooked pretty far into the core engine code, that's why it replaces GDNative
21:57:56FromDiscord<Elegantbeef> GDscript is just a slightly ergonomic wrapping over the GDExtension API
21:57:59FromDiscord<chmod222> It can do a lot
21:58:18FromDiscord<Elegantbeef> I don't know if it's implemented that way, but it's practically all it is
21:58:33FromDiscord<jmgomez> I see. So people dont use C++ at all? In UE you can do full games in Blueprint but you cant access all the Engine features from them
21:58:37FromDiscord<Elegantbeef> Nice Nimble fails to build my project due to an compiler error, but freestanding Nim works fine
21:58:48FromDiscord<Elegantbeef> C++ in godot is used for plugins/lowlevel code
21:58:55FromDiscord<Elegantbeef> gdscript is the go to for most sane people
21:58:57FromDiscord<huantian> In reply to @Elegantbeef "Nice Nimble fails to": skill issue
21:59:11FromDiscord<huantian> In reply to @Elegantbeef "gdscript is the go": honestly with godot 4 I'd say C# looks more appealing than gdscript
21:59:17FromDiscord<Elegantbeef> Anything gdscript can do you can do in C++ and vice versa aside from level stuff
21:59:21FromDiscord<Elegantbeef> Never say C# is appealing
21:59:31FromDiscord<Elegantbeef> Thanks
22:00:18FromDiscord<huantian> hey I only speak my honest opinions 🙃
22:00:57FromDiscord<Elegantbeef> Better to be thought a fool than open your mouth and prove it
22:01:27FromDiscord<chmod222> C# just feels wrong to me, I cannot put my finger onto why
22:01:32FromDiscord<huantian> meh I'd rather be able to leverage the C# ecosystem than use weak python
22:01:40FromDiscord<chmod222> It seems to hit all kinds of design decisions that disagree with me
22:01:48FromDiscord<Elegantbeef> I'd rather just use Nim huan
22:02:12FromDiscord<jmgomez> chmod is your plugin in github or something?
22:02:33FromDiscord<chmod222> Nope, but if I end up being happy with it, it will be
22:02:48FromDiscord<chmod222> Right now it's just an excercise in how far I can push the metaprogramming
22:03:16FromDiscord<huantian> yeah I mean I would prefer Nim, I often end up thinking that "this would be so much easier/better/cleaner in Nim" when I write C#↵but it always has felt good enough so I would still prefer it over gdscript 🤷‍♂️
22:03:42FromDiscord<Elegantbeef> Nice I've now got it to stop compiling with Nim.... wait
22:04:33FromDiscord<jmgomez> In reply to @chmod222 "Right now it's just": are you building a dsl?
22:04:46FromDiscord<chmod222> That is the intent
22:05:38FromDiscord<chmod222> Mostly I wanted an excuse to work with Godot for a while because it seems fun
22:05:50*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
22:06:06FromDiscord<chmod222> If I feel like my design approach is clean and works, it'll end up on github somewhere
22:06:59FromDiscord<jmgomez> let me know if it does, I dont know godot but it's good to see this kind of stuff in Nim. Good luck with the project
22:08:51FromDiscord<Elegantbeef> I know my biggest complaint with the gdnative stuff was how obnoxious it was to use
22:09:08FromDiscord<Elegantbeef> No auto compiling, no way of making a Nim file from inside the editor
22:10:06FromDiscord<huantian> I don't think godot 4 solves the latter iirc
22:10:31FromDiscord<Elegantbeef> I think you can technically make engine plugins to solve it
22:10:32FromDiscord<chmod222> GDExtension is also limited in some ways, i.e. if you change your code you pretty much have to restart the editor if you require the changes to be visible in-editor
22:10:50FromDiscord<jmgomez> @geekrelief screenshared some months ago briefly how it worked in godot3 and it felt quite bad TBH
22:10:59FromDiscord<chmod222> But I believe all native code interfaces that depend on shared library loading suffer from this
22:11:02FromDiscord<jmgomez> the prev nim bindings I mean
22:11:29FromDiscord<Elegantbeef> that's not really that true
22:11:41FromDiscord<Elegantbeef> The editor can unload the libraries and reload them
22:11:56FromDiscord<Elegantbeef> Especially since the editor doesnt run much of the actual logic in godot's case
22:12:13FromDiscord<jmgomez> yeah, that would be quite a painful workflow
22:12:28FromDiscord<jmgomez> ideally you should be able to change the editor from NimScript 😛
22:12:39FromDiscord<Elegantbeef> Also geek did have hot code reload working
22:13:32FromDiscord<chmod222> I just tested my prototype by hitting F5 in Godot to actually build and run the project, which would just load a fresh copy of my extension for the running scene
22:15:00*alice quit (Killed (lithium.libera.chat (Nickname regained by services)))
22:15:01*alice joined #nim
22:15:22FromDiscord<ranok (Jacob Torrey)> Ok, now encodings.nim fails to compile with JS as a target
22:15:38FromDiscord<chmod222> copyMem?
22:16:27FromDiscord<chmod222> Some modules unfortunately don't like the JS backend, I've had to do some hacking around that in the new checksums algorithms
22:17:34FromDiscord<ranok (Jacob Torrey)> no
22:17:51FromDiscord<ranok (Jacob Torrey)> it gets further when I define a target (-d\:linux)
22:18:03FromDiscord<ranok (Jacob Torrey)> then it gives me\: encodings.nim(472, 14) Error\: cstring doesn't support `[]=` operator
22:19:53*Notxor quit (Remote host closed the connection)
22:21:24FromDiscord<ranok (Jacob Torrey)> Look related to this\: https://github.com/nim-lang/Nim/issues/14157
22:22:19*progranner joined #nim
22:42:40*progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…)
22:43:08*progranner joined #nim
22:45:40*progranner quit (Client Quit)
22:53:05FromDiscord<Chronos [She/Her]> Wait how would I make my plugin system not consume copious amounts of RAM
22:56:43*NimBot joined #nim
23:00:32FromDiscord<Elegantbeef> Give them 64k of stack and call it a day
23:01:13FromDiscord<Chronos [She/Her]> Would that even be enough?
23:01:31FromDiscord<Chronos [She/Her]> ...tho tbf, I could probably have a way to increase it in the config if that's even needed?
23:01:44FromDiscord<Elegantbeef> That's plenty that's more ram than most computers had access to in the 80s
23:02:14FromDiscord<Chronos [She/Her]> Would it be good enough for like, 100 or 1000 items in a sequence with multiple string data types?
23:02:57FromDiscord<Elegantbeef> Stack size != heapsize
23:04:18FromDiscord<Chronos [She/Her]> What's the heap?
23:04:35FromDiscord<Chronos [She/Her]> Also does wasm3 separate the 2?
23:06:55FromDiscord<Chronos [She/Her]> I roughly know what a heap is from java but not much
23:10:25FromDiscord<wick3dr0se> Why does std/terminal not include a proc to turn off echoing to the terminal such as the `stty -echo` command does. The proc getch() is written with the termios library which is all that would be required to write an echoOff/echoOn proc
23:10:32FromDiscord<wick3dr0se> (edit) "does." => "does?"
23:10:54FromDiscord<wick3dr0se> (edit) "Why does std/terminal ... not" added "library"
23:42:29*lucasta quit (Remote host closed the connection)