00:15:41 | * | rockcavera joined #nim |
01:42:03 | FromDiscord | <voidwalker> is there some "paths" module so that I can get a distinct path type ? seq[string] just doesn't feel right |
01:42:17 | FromDiscord | <voidwalker> (edit) "is there some "paths" module so that I can get a distinct ... path" added "filesystem" |
01:43:24 | FromDiscord | <huantian> unfortunately I don't think we have like a python pathlib equivalent |
01:43:53 | FromDiscord | <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:05 | FromDiscord | <voidwalker> I found this, but it seems a bit under developed: https://github.com/achesak/nim-pythonpathlib/blob/master/pythonpathlib.nim |
01:48:20 | FromDiscord | <Elegantbeef> Devel has static typed paths |
01:48:59 | FromDiscord | <Elegantbeef> https://nim-lang.github.io/Nim/paths.html if using devel |
01:49:31 | FromDiscord | <huantian> dang I guess i have to start using devel now |
01:54:05 | * | nanxiao joined #nim |
02:01:06 | FromDiscord | <voidwalker> blah, nim arch pkg 2+ months outdated now. let's see if aur package compiles |
02:01:14 | FromDiscord | <voidwalker> (edit) "blah, nim arch pkg 2+ months outdated now. let's see if aur ... package" added "-git" |
02:01:41 | FromDiscord | <Elegantbeef> One day people will learn gitnim/choosenim are the way to install Nim if you want to swap between versions |
02:08:41 | FromDiscord | <voidwalker> Hint: Binary 'nim' isn't in your PATH. Ensure that '/home/sgm/.nimble/bin' is in your PATH. |
02:08:46 | FromDiscord | <voidwalker> why doesn't it do paths as well |
02:09:25 | FromDiscord | <huantian> huh? |
02:09:32 | FromDiscord | <voidwalker> `choosenim devel` |
02:09:56 | FromDiscord | <Elegantbeef> Did you not add `.nimble/bin` to your path? |
02:13:12 | FromDiscord | <voidwalker> oh I guess there's not any universal way to add to PATH |
02:13:19 | FromDiscord | <voidwalker> (edit) "any" => "one" |
02:13:31 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vQQ |
02:13:31 | FromDiscord | <Elegantbeef> Nope depending on shell and desired way of doing it's fun |
02:14:15 | FromDiscord | <Elegantbeef> `nvim ~/.config/fish/config.fish` add `fish_addpath ~/.nimble/bin` |
02:14:42 | FromDiscord | <Elegantbeef> Fish users unite |
02:15:10 | FromDiscord | <voidwalker> i really don't care for shells, it's just what cachyOS has as default, and it works |
02:15:11 | FromDiscord | <Rika> You like swimming? |
02:15:32 | FromDiscord | <Elegantbeef> I really just like it's out of the box auto complete |
02:15:36 | FromDiscord | <Elegantbeef> It's top notch |
02:20:20 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vQR |
02:20:54 | FromDiscord | <voidwalker> fish_add_path |
02:22:52 | FromDiscord | <voidwalker> well, project compiles on devel fine. I guess I didn't do anything too fancy so far |
02:23:04 | FromDiscord | <Elegantbeef> Right my bad, set you up for failure |
02:23:32 | FromDiscord | <voidwalker> funny I am switching to devel for damn paths |
02:24:08 | FromDiscord | <Elegantbeef> The fun part is there is nothing develly about them |
02:24:27 | FromDiscord | <Elegantbeef> If the stdlib wasnt attached to the compiler you could use it in stable |
02:24:32 | FromDiscord | <voidwalker> feels like a super late addition.. how come they didn't realise sooner to make this ? |
02:24:51 | FromDiscord | <Elegantbeef> Cause 0.x already had string paths |
02:24:58 | FromDiscord | <Elegantbeef> So it had to wait until a 2.0 to replace |
02:25:27 | * | lumo_e joined #nim |
02:26:18 | FromDiscord | <Elegantbeef> After the 1.0 release we're now in "No breaking changes" land |
02:26:27 | FromDiscord | <Elegantbeef> Which means breaking changes need to wait until major releases |
02:27:12 | FromDiscord | <voidwalker> lots of things left to break |
02:30:41 | FromDiscord | <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:00 | FromDiscord | <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:48 | FromDiscord | <Elegantbeef> `string(MyPath)` |
03:34:21 | FromDiscord | <voidwalker> oh ok, wonder why there isn't a $ |
03:34:52 | FromDiscord | <turtlebasket> Is there any documentation on how to use nim without a C stdlib (i.e. using `gcc -freestanding`)? |
03:37:37 | FromDiscord | <demotomohiro> I tried that long time ago:↵https://internet-of-tomohiro.netlify.app/nim/nim4k.en.html |
03:39:56 | FromDiscord | <turtlebasket> hmm.. issue is that the generated C source including `string.h` despite my not using the `string` type |
03:40:11 | FromDiscord | <Elegantbeef> I mean Nim's string doesnt come from `string.h` anyway |
03:40:32 | FromDiscord | <turtlebasket> wait what↵then I wonder why it's even there to begin with 😵💫 |
03:40:52 | FromDiscord | <Elegantbeef> Cause it has Cstring operations |
03:41:06 | FromDiscord | <Elegantbeef> You best bet is likely to write your own nimbase.h |
03:41:11 | FromDiscord | <voidwalker> are they going to change all the path operating procs, like file procs, to use Path instead of string ? |
03:41:18 | FromDiscord | <Elegantbeef> They already have |
03:41:40 | FromDiscord | <voidwalker> [1] proc newFileStream(filename: string; mode: FileMode = fmRead; bufSize: int = -1): owned |
03:42:22 | FromDiscord | <Elegantbeef> I guess PR time for you? 😄 |
03:42:36 | FromDiscord | <Elegantbeef> Add a new overload that takes in a `Path` |
03:44:15 | * | nanxiao quit (Quit: Client closed) |
03:44:21 | FromDiscord | <voidwalker> [1] proc openAsync(filename: string; mode = fmRead): AsyncFile |
03:44:51 | FromDiscord | <Elegantbeef> io/os were replaced with the statically typed versions |
03:45:05 | FromDiscord | <Elegantbeef> Everything else still uses strings, so i'd suggest open a PR if it bothers you enough |
03:49:04 | FromDiscord | <voidwalker> what is the best practice concerning path separators and portable code ? |
03:49:35 | FromDiscord | <Elegantbeef> use `/` or `joinPath` |
03:50:00 | FromDiscord | <voidwalker> I remember in free pascal there was some const that was automatically set to the correct char depending on platform |
03:50:16 | FromDiscord | <Elegantbeef> That's what nim does aswell |
03:50:55 | FromDiscord | <voidwalker> so If I have a `it.path.split("/").mapIt` |
03:51:21 | FromDiscord | <voidwalker> there's no split to path components in std/paths as I can see |
03:52:02 | FromDiscord | <Elegantbeef> `splitPath` `parentDir` |
03:52:08 | FromDiscord | <Elegantbeef> `parentDirs` |
03:54:32 | FromDiscord | <voidwalker> parentDirs won't work, only gives the parent dirs, not all elements |
03:56:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRa |
03:57:21 | FromDiscord | <voidwalker> well, I will just use string split, as it's raw data anyway, not actually to be used as a Path |
03:57:38 | FromDiscord | <voidwalker> so there's no magic keyword for cross platform path delimitator? |
03:57:46 | FromDiscord | <voidwalker> if I want to use it for string manipulation |
03:57:50 | FromDiscord | <Elegantbeef> I said there was a constant |
03:58:04 | FromDiscord | <voidwalker> which one ? |
03:58:10 | FromDiscord | <Elegantbeef> `DirSep` |
03:58:22 | FromDiscord | <Elegantbeef> https://nim-lang.github.io/Nim/osseps.html declared in this odd module |
04:13:49 | FromDiscord | <voidwalker> ah lol, and strutils split has `char` sep, while join only has string |
04:14:14 | FromDiscord | <voidwalker> $DirSep it is : D |
04:15:30 | FromDiscord | <demotomohiro> MS Windows uses both '\' and '/' as path separaters.↵os module aware that. |
04:15:43 | FromDiscord | <demotomohiro> both '\\' and '/' |
04:19:13 | * | lumo_e quit (Quit: Quit) |
05:03:20 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vRl |
05:06:05 | FromDiscord | <Elegantbeef> Use cpFile instead of writing each one i'd say |
05:07:08 | * | rockcavera quit (Remote host closed the connection) |
05:08:07 | FromDiscord | <voidwalker> https://nim-lang.github.io/Nim/nimscript.html#cpFile%2Cstring%2Cstring ? |
05:08:32 | FromDiscord | <Elegantbeef> nope that's nimscript |
05:08:37 | FromDiscord | <Elegantbeef> it's copyFile from os i guess |
05:09:23 | FromDiscord | <voidwalker> how do you copy a file that does not exist to begin with ? |
05:09:36 | FromDiscord | <Elegantbeef> Write a file once to tmp then copy it from there |
05:10:16 | FromDiscord | <voidwalker> so basically one extra step.. for what ? |
05:10:41 | FromDiscord | <Elegantbeef> You arent writing a file each time you're letting the OS do it's thing |
05:11:00 | FromDiscord | <voidwalker> oh, it's non blocking |
05:12:50 | FromDiscord | <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:01 | FromDiscord | <voidwalker> sounds like an extra step with no benefit to me |
05:13:13 | FromDiscord | <Elegantbeef> No you do not do `setFilePos` in my case |
05:13:43 | FromDiscord | <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:46 | FromDiscord | <Elegantbeef> I didnt read your code |
05:13:46 | FromDiscord | <Elegantbeef> Only your query |
05:13:51 | FromDiscord | <Elegantbeef> I see now each file is a different file size |
05:14:26 | FromDiscord | <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:17 | FromDiscord | <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:35 | FromDiscord | <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:40 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRA |
06:30:55 | FromDiscord | <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:10 | FromDiscord | <Arathanis> granted you will get pairs out the other side, so you have to do even more processing |
06:31:32 | FromDiscord | <Arathanis> but beef is absolutely right, we are abusing filterIt doing this |
06:31:46 | FromDiscord | <Arathanis> and being wasteful to boot |
06:32:07 | FromDiscord | <voidwalker> I guess so, I just wanted a one liner, sigh |
06:32:17 | FromDiscord | <voidwalker> I should look up into those zero functional libs for nim |
06:32:25 | FromDiscord | <voidwalker> see if they have anything better |
06:32:38 | FromDiscord | <Arathanis> code golf is the root of all evil |
06:32:50 | FromDiscord | <Arathanis> unless you are in a golfing tournament. |
06:33:06 | * | syl joined #nim |
06:33:11 | FromDiscord | <voidwalker> no I am not, it is just a common enough operation that it deserves golfing |
06:33:44 | FromDiscord | <voidwalker> I just feel bad when opening a `for` : \ |
06:34:53 | FromDiscord | <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:55 | FromDiscord | <Arathanis> sent a long message, see http://ix.io/4vRB |
06:35:17 | FromDiscord | <Arathanis> (edit) "http://ix.io/4vRB" => "http://ix.io/4vRC" |
06:35:29 | FromDiscord | <Arathanis> sent a long message, see http://ix.io/4vRD |
06:35:30 | FromDiscord | <Arathanis> aww no more eval |
06:35:39 | FromDiscord | <Elegantbeef> Eval only works on a single line anywho |
06:35:43 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRE |
06:35:47 | FromDiscord | <Arathanis> In reply to @Elegantbeef "Eval only works on": ohhhh |
06:36:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRF |
06:36:51 | FromDiscord | <Elegantbeef> It's now a one line |
06:37:05 | FromDiscord | <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:50 | FromDiscord | <Arathanis> @voidwalker what is the positional condition you are filtering on? |
06:39:14 | FromDiscord | <voidwalker> well, something like `t.files.pairs().toSeq.filterIt(t.filesWanted[it[0]] == 1)` |
06:39:23 | FromDiscord | <voidwalker> if another seq on that position is 1/true |
06:39:30 | FromDiscord | <Arathanis> oh |
06:39:34 | FromDiscord | <Arathanis> use zip for this |
06:39:42 | FromDiscord | <Arathanis> just zip them together and collect the truthy ones |
06:43:18 | FromDiscord | <voidwalker> wouldn't that be the same as pairs ? |
06:43:36 | FromDiscord | <Arathanis> its more expressive |
06:44:49 | FromDiscord | <Elegantbeef> I'm always amazed at the fact there are not iterators for `openArray` in `sequtils` |
06:45:28 | FromDiscord | <Arathanis> In reply to @Elegantbeef "I'm always amazed at": and that its all for seq? |
06:46:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vRG |
06:46:47 | FromDiscord | <Elegantbeef> Cmon it's so simple |
06:47:01 | FromDiscord | <Arathanis> is this... not that? https://media.discordapp.net/attachments/371759389889003532/1107559743884628028/image.png |
06:47:07 | FromDiscord | <Elegantbeef> `proc` |
06:47:12 | FromDiscord | <Arathanis> omg its a proc |
06:47:13 | FromDiscord | <Elegantbeef> It yields a `seq` |
06:47:15 | FromDiscord | <Arathanis> ??????????? |
06:47:31 | FromDiscord | <Elegantbeef> I mean sequtils is all about FP so it yields `seq`s so allocates like crazy |
06:47:40 | FromDiscord | <Elegantbeef> If you care about performance you use like 1 proc from it |
06:48:20 | FromDiscord | <Elegantbeef> I'm pretty happy about my slight change in the compiler to enable pluggable iterable operations |
06:48:29 | FromDiscord | <Elegantbeef> `for (i, x) in theVal.items.mapIt(it 2).group(2).enumerate():` |
06:48:32 | FromDiscord | <Elegantbeef> It's glorious |
06:48:34 | FromDiscord | <Elegantbeef> All 0 cost |
06:49:08 | FromDiscord | <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:56 | FromDiscord | <Arathanis> ohhh, so it lets you chain iterables with `.`? |
06:50:04 | FromDiscord | <Elegantbeef> Yep |
06:50:07 | FromDiscord | <Arathanis> that is pretty hot |
06:50:16 | FromDiscord | <Arathanis> what version is that change coming in? |
06:50:30 | FromDiscord | <voidwalker> nimskull 1.0 : D |
06:50:37 | FromDiscord | <Elegantbeef> The change technically allows `(iterator myIter(...): T = ...; myIter)` to work |
06:50:42 | FromDiscord | <Elegantbeef> Nah I do not contribute to Nimskull |
06:50:52 | FromDiscord | <Elegantbeef> Coming in 2.0 i'd guess |
06:51:02 | FromDiscord | <Elegantbeef> Not like the change makes sense to backport 😄 |
06:51:38 | FromDiscord | <Arathanis> what is Nimskull supposed to be? and why? |
06:51:42 | FromDiscord | <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:14 | FromDiscord | <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:41 | FromDiscord | <voidwalker> is it that much of a mess ? |
06:52:53 | FromDiscord | <Arathanis> it says its going to be incompatible eventually, are they planning to maintain both? |
06:52:58 | FromDiscord | <Elegantbeef> The language doesnt have a formalised spec, it has a manual |
06:53:02 | FromDiscord | <Arathanis> or are they gonna drop one for the other? |
06:53:07 | FromDiscord | <Elegantbeef> It's a different language |
06:53:13 | FromDiscord | <Elegantbeef> So of course it's going to be incompatible |
06:53:16 | PMunch | There are two different groups developing Nim and NimSkull |
06:53:31 | FromDiscord | <Arathanis> i can smell the culture wars from here 😎 |
06:53:41 | PMunch | So whether one or the other drops support is up to each group |
06:54:01 | PMunch | Anyways, what's stopping you from writing those iterators Elegantbeef ;) |
06:54:13 | FromDiscord | <Elegantbeef> What do you mean? |
06:54:24 | FromDiscord | <Elegantbeef> I did write them inside slicerator |
06:54:52 | FromDiscord | <Elegantbeef> Until my change there was no reason to use `iterable` cause it was not possible to add operations and chain them |
07:01:19 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4vRK |
07:02:06 | FromDiscord | <Arathanis> still trying to do it on a single line? lol |
07:02:17 | FromDiscord | <Elegantbeef> That's void for you |
07:02:37 | FromDiscord | <voidwalker> doesn't really matter, as I said, all the code uses shortcuts with no concern for performance at the moment |
07:02:52 | FromDiscord | <voidwalker> I am mostly interested in the algorithms, not their implementation |
07:03:12 | FromDiscord | <voidwalker> I will revisit every proc one day and make it better/faster, but not now : D |
07:03:22 | FromDiscord | <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:29 | FromDiscord | <huantian> In reply to @voidwalker "blah so this is": man I have no idea what this line does lmao |
07:03:59 | FromDiscord | <voidwalker> it filters elements of a seq based on the value of their position in another seq |
07:04:18 | FromDiscord | <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:59 | FromDiscord | <voidwalker> In reply to @Arathanis "but why spend so": cause I don't want to mix good code with bad code : D |
07:05:09 | FromDiscord | <Arathanis> wild lol |
07:05:28 | FromDiscord | <Arathanis> i can respect carving your own path through the jungle |
07:05:48 | FromDiscord | <voidwalker> I'll wait for nim 2.0 I guess before optimizing all this functional procs |
07:06:05 | FromDiscord | <voidwalker> too many things can change until then |
07:07:14 | FromDiscord | <Arathanis> make yourself a nice reusable iterator that does this and then have a super clean one-liner |
07:08:22 | FromDiscord | <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:49 | FromDiscord | <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:56 | FromDiscord | <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:54 | FromDiscord | <voidwalker> Also, refactoring/cleaning up/making things faster, is super rewarding : P |
07:10:03 | FromDiscord | <voidwalker> will save myself the satisfaction for the future |
07:10:16 | FromDiscord | <Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4vRL |
07:11:12 | FromDiscord | <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:19 | FromDiscord | <Arathanis> just dont miss the forest for the trees :p |
07:11:34 | FromDiscord | <Arathanis> (edit) "languages functionalit" => "language's functionality" |
07:11:55 | FromDiscord | <voidwalker> as I said, I will wait for nim 2.0, maybe I can do this then without extra code 🙂 |
07:12:35 | FromDiscord | <voidwalker> For now I am more concerned about getting a clean interface and types |
07:12:42 | FromDiscord | <voidwalker> implementation is not important |
07:13:08 | FromDiscord | <voidwalker> Also I don't like to scroll much to find my procs : D |
07:13:16 | FromDiscord | <voidwalker> so one liners are ideal |
07:18:46 | FromDiscord | <voidwalker> is it me or the compiling is a bit zippier in nim-devel vs 1.6 ? |
07:19:50 | FromDiscord | <Arathanis> In reply to @voidwalker "Also I don't like": ahh i just F12 to definition cause im lazy |
07:19:56 | FromDiscord | <Arathanis> scrolling is for chumps 😤 |
07:20:28 | FromDiscord | <voidwalker> Oh I didn't know about F12, thanks |
07:20:32 | FromDiscord | <Arathanis> np |
07:20:40 | FromDiscord | <Arathanis> hotkeys are good |
08:00:06 | NimEventer | New 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:09 | om3ga | hello! 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:42 | om3ga | why I'm asking, seems gc not frees here, or I misunderstand something |
09:24:27 | om3ga | I use malloc, and tried both variants with alloc too. all the same with other gc's too |
09:29:25 | FromDiscord | <Elegantbeef> You might need a `runOrc` but yes ` = @[]` should free |
09:29:40 | * | PMunch quit (Quit: Leaving) |
09:40:38 | om3ga | Elegantbeef so it should free immidiately righ after this operation? |
09:41:22 | om3ga | with orc is the same as with arc or orher gc's |
10:05:12 | FromDiscord | <Rika> It’s not guaranteed to be immediate unless you are using either ARC or ORC |
10:12:29 | om3ga | dumpNumberOfInstances() - what a useful feature! |
10:16:41 | om3ga | now I see where all stuff lays |
10:17:08 | * | derpydoo quit (Quit: derpydoo) |
10:31:49 | om3ga | right, 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:54 | FromDiscord | <Entikan> how do I `pow(int, 2)` do I really have to convert to a float? |
11:14:21 | FromDiscord | <dennisritchie> relax |
11:14:41 | FromDiscord | <Entikan> don't do it |
11:14:54 | FromDiscord | <Entikan> when you want to get to it |
11:15:16 | FromDiscord | <Rika> `int^2`? |
11:16:59 | om3ga | int is a type |
11:17:03 | FromDiscord | <Entikan> oh >.< |
11:17:07 | FromDiscord | <Entikan> thanks @Rika |
11:17:15 | om3ga | what are you trying to do? |
11:17:23 | FromDiscord | <Rika> omega, i know, i am using their notation |
11:17:37 | FromDiscord | <Entikan> In reply to @om3ga "what are you trying": pythagoras |
11:17:59 | * | PMunch joined #nim |
11:24:08 | Amun-Ra | how about… x * x |
11:27:33 | FromDiscord | <Entikan> yeah that works too. But I also wanted to how to do powers in general. |
11:27:41 | FromDiscord | <Entikan> (edit) "yeah that works too. But I also wanted to ... how" added "know" |
11:49:10 | NimEventer | New post on r/nim by qtless: Path Params Assignment, see https://reddit.com/r/nim/comments/13i5y1p/path_params_assignment/ |
11:55:45 | FromDiscord | <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:33 | PMunch | Not really, the normal collections are homogeneous |
11:57:02 | PMunch | You 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:09 | PMunch | The alternative is to use case objects or create closures to put in the collection |
12:01:31 | PMunch | That 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:02 | FromDiscord | <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:32 | FromDiscord | <chmod222> With that context, can I depend on renderer.`$` to generate correct code? |
12:46:21 | FromDiscord | <chmod222> It seems correct for now, but I don't want to find out somewhere in the middle that something is afoul |
12:47:25 | FromDiscord | <chmod222> That other alternative is manually string-formatting the nim code and that's even less fun |
12:47:31 | PMunch | With repr I believe it should be correct |
12:47:53 | PMunch | That said the way Futhark works is to consume JSON and create code |
12:48:21 | FromDiscord | <chmod222> Unfortunately, repr doesn't work at runtime with `NimNode` as generated by std/macro |
12:48:27 | FromDiscord | <chmod222> Only at compile time |
12:48:45 | FromDiscord | <chmod222> But it seems to use renderer.`$` at compile time |
12:52:26 | PMunch | Oh I believe `repr` is mapped to renderer.`$` |
12:52:55 | PMunch | You could use a faster JSON parser though |
12:53:24 | PMunch | I've been meaning to do that for Futhark |
12:54:05 | PMunch | Currently for my Gtk/WebKit based markdowneditor it parses 12Mb of JSON and it does take a while |
12:55:18 | PMunch | But it caches the result, so unless I'm changing anything it's pretty much instant |
12:55:33 | PMunch | You can see how this is done in Futhark if you want to go down a similar route |
12:55:43 | PMunch | Not sure what you're doing so caching might not apply |
12:56:11 | FromDiscord | <chmod222> It's probably very cacheable, the file probably only changes every few months |
12:56:27 | FromDiscord | <chmod222> But can I cache straight from within a `macro` block? |
12:57:01 | FromDiscord | <chmod222> I'd prefer working within the std/macros ecosystem than needing to dig down into compiler internals |
12:58:59 | FromDiscord | <chmod222> If I could give the macro my json data and have it actually generate nim modules, that'd be even better |
12:59:42 | FromDiscord | <chmod222> You know, I didn't even consider that NimVM can write files |
13:00:10 | FromDiscord | <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:48 | FromDiscord | <chmod222> Yep, that works just fine. Should have thought about that from the start, thanks for pushing me in the right direction |
13:10:15 | PMunch | No 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:44 | FromDiscord | <chmod222> And as an additional nuggest, `jsony` is efficient enough to not require bumping the VM limit for my file |
13:13:58 | FromDiscord | <chmod222> Still takes enough time to warrant caching |
13:17:02 | FromDiscord | <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:32 | PMunch | @chmod222, how much faster is jsony over the native json library? |
13:20:54 | PMunch | And it's probably just because it's not recursive that you don't have to bump the VM limit |
13:26:50 | FromDiscord | <chmod222> Let me benchmark real fast |
13:27:27 | FromDiscord | <chmod222> jsony requires 7.27 seconds for parsing the source given via `staticRead` |
13:27:38 | * | antranigv_ is now known as antranigv |
13:29:10 | FromDiscord | <chmod222> std/json requires 10.40 seconds with bumped VM limit |
13:29:20 | FromDiscord | <chmod222> for read+unmarshal |
13:30:10 | FromDiscord | <chmod222> 5176730 of source data |
13:30:24 | PMunch | Hmm, I'm guessing that the unmarshaling requires a substantial amount of time |
13:30:31 | PMunch | But it's probably still faster |
13:30:43 | PMunch | JSONY that is |
13:30:48 | FromDiscord | <chmod222> jsony also unmarshals |
13:30:54 | FromDiscord | <chmod222> So the time is comparable |
13:31:10 | PMunch | Ooh right.. |
13:31:18 | PMunch | That's why I didn't use it |
13:31:53 | * | rockcavera joined #nim |
13:32:33 | FromDiscord | <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:35 | FromDiscord | <chmod222> My json is very simple but very much so unmarshalling into a couple of objects is fine fo me |
13:34:53 | FromDiscord | <gloopsies> In reply to @PMunch "You can give all": That could work if I have a field that marks the type |
13:35:03 | FromDiscord | <gloopsies> So I can cast to desired type |
13:35:20 | FromDiscord | <gloopsies> I think at least but that's how I'd do something similar in c |
13:35:47 | FromDiscord | <gloopsies> Have an array of struct pointers that all have first field as type then based on that cast to actual type |
13:36:08 | PMunch | That's essentially what both the common ancestor and case object would do |
13:36:33 | PMunch | And 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:22 | FromDiscord | <chmod222> `Error: Invalid node kind nnkConstSection for macros.$` |
13:51:34 | FromDiscord | <chmod222> Does `$` really not rnder consts or am I being obtuse? |
13:52:28 | FromDiscord | <chmod222> Ah yeah, I'm being obtuse |
13:52:39 | FromDiscord | <chmod222> Needs `repr` |
13:56:21 | * | progranner joined #nim |
14:02:20 | PMunch | Yeah basically there are many ways to represent a NimNode so there is no default `$` |
14:07:38 | FromDiscord | <jtv> Pmunch, I never ported to Nim, but my lock-free data structures are here: https://github.com/viega/hatrack |
14:08:43 | PMunch | Hmm, interesting |
14:08:55 | FromDiscord | <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:31 | FromDiscord | <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:03 | FromDiscord | <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:15 | FromDiscord | <chmod222> Dang, `dirExists` works from within a macro but `createDir` does not |
14:24:24 | FromDiscord | <chmod222> I see futhark does `staticExec` for mkdir |
14:24:25 | FromDiscord | <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:51 | ehmry | is 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:04 | FromDiscord | <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:09 | FromDiscord | <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:13 | FromDiscord | <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:01 | FromDiscord | <demotomohiro> Each two functions in one loaded dll called from two threads?↵Are you using `--mm:arc` or `--mm:orc`? |
18:09:32 | FromDiscord | <demotomohiro> And `--threads:on`? |
18:12:09 | FromDiscord | <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:10 | FromDiscord | <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:17 | FromDiscord | <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:29 | FromDiscord | <demotomohiro> sent a long message, see http://ix.io/4vTZ |
18:23:50 | FromDiscord | <Q-Master> {.threadvar.}'ll help IMO. |
18:23:59 | FromDiscord | <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:49 | FromDiscord | <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:24 | FromDiscord | <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:57 | FromDiscord | <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:37 | FromDiscord | <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:48 | FromDiscord | <Ayy Lmao> Like for instance the crash I am getting happens when I try to sort a sequence. |
18:45:09 | FromDiscord | <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:35 | FromDiscord | <Ayy Lmao> Yeah that's where it segfaults. |
18:46:25 | FromDiscord | <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:50 | om3ga | locks |
18:52:53 | om3ga | shared ram |
18:52:59 | FromDiscord | <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:05 | om3ga | I spent hours coding threads |
18:53:17 | om3ga | it's very easy to ruin whole program |
18:56:00 | PMunch | @chmod222, yeah that bug me to.. |
18:56:23 | FromDiscord | <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:40 | FromDiscord | <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:44 | om3ga | Ayy Lmao, sounds like you need to use locks |
18:59:10 | FromDiscord | <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:06 | FromDiscord | <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:48 | FromDiscord | <chmod222> Locks are not the issue, lock contention is the issue |
19:02:03 | om3ga | Ayy Lmao, if your code crashes during sort of the shared data in heap, the issue is more with concurency |
19:03:30 | FromDiscord | <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:20 | FromDiscord | <Arathanis> How come `array[0..20, int]` is valid but `array[0..<20, int]` is not? |
19:07:14 | FromDiscord | <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:54 | om3ga | Ayy Lmao, add options --passC:"-O0 -g3 -fsanitize=thread" and --passL:"-O0 -g3 -fsanitize=thread" |
19:10:07 | om3ga | this will help you to debug |
19:11:05 | om3ga | if these options will not print any output about the error, use -fsanitize=address instead |
19:12:55 | FromDiscord | <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:12 | FromDiscord | <Chronos [She/Her]> for my module |
19:13:29 | FromDiscord | <Chronos [She/Her]> Everything is top-level and it's getting kinda cluttered |
19:15:06 | om3ga | I reduced ram usage from 21GB to 12gb, thanks for the awesome feature provided by dumpNumberOfInstances |
19:17:49 | FromDiscord | <auxym> In reply to @Hourglass, When the Hour Strikes "Anyone know what I'd": something like frosty or flatty? |
19:17:53 | FromDiscord | <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:00 | FromDiscord | <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:11 | FromDiscord | <Arathanis> (edit) "use" => "user" |
19:20:43 | om3ga | Ayy Lmao, yeah, you should have it installed, if you have linux you can install it. not sure about windows |
19:21:38 | om3ga | so you have shared lib compilation |
19:21:56 | om3ga | then your problem is more complicated |
19:21:58 | FromDiscord | <Ayy Lmao> I'll have to figure out how to install it. I'm on windows. |
19:22:29 | om3ga | I'm not sure if it works under windows, but should in wsl |
19:30:33 | FromDiscord | <Arathanis> Can someone explain the practical difference between alloc/dealloc and allocShared/deallocShared? |
19:31:17 | FromDiscord | <Arathanis> Threads dont seem to care one way or the other if I use pointer from one or the other |
19:37:57 | FromDiscord | <Elegantbeef> @Chronos [She/Her] No i'm monopresent |
19:38:29 | FromDiscord | <Elegantbeef> You'd use wasm modules for user space code and native wasm stuff for non user code |
19:38:35 | FromDiscord | <Elegantbeef> I do not really get the path of the query |
19:38:35 | FromDiscord | <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:51 | FromDiscord | <Elegantbeef> alloc/dealloc doesnt use locks, allocShared and deallocShared do |
19:39:06 | FromDiscord | <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:56 | FromDiscord | <Arathanis> so the shared versions should be used when allocating memory inside threads? |
19:39:59 | FromDiscord | <Elegantbeef> Atleast that's how it used t obe |
19:40:11 | FromDiscord | <Elegantbeef> With refc yea |
19:40:17 | FromDiscord | <Elegantbeef> With arc/orc depending what you're doing you do not need it |
19:40:20 | FromDiscord | <Arathanis> pfff, we orc now 😎 |
19:40:29 | FromDiscord | <Arathanis> doesn't matter with orc im guessing? |
19:40:51 | FromDiscord | <Elegantbeef> Well refc doesnt have a shared heap |
19:41:13 | FromDiscord | <Elegantbeef> arc/orc do have a shared heap so you can transfer ownership of graphs assuming you disarm the destructors properly |
19:41:57 | FromDiscord | <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:15 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "You'd use wasm modules": Native WASM stuff? |
19:42:27 | FromDiscord | <Elegantbeef> Look at the forum there are an abundant amount of threading related posts recently |
19:42:31 | FromDiscord | <Elegantbeef> Host functions |
19:42:54 | FromDiscord | <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:15 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Host functions": Ah |
19:44:13 | FromDiscord | <Chronos [She/Her]> Now I need to design this in a way that C can also use the API cleanly |
19:44:34 | FromDiscord | <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:56 | FromDiscord | <Elegantbeef> You need to have accurate ABI yes |
19:47:31 | FromDiscord | <Chronos [She/Her]> Alr nice |
19:48:37 | FromDiscord | <Chronos [She/Her]> Hm... Should my `Packet` object be a ref object or a normal object... |
19:48:55 | FromDiscord | <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:25 | FromDiscord | <Elegantbeef> Probably neither |
19:50:42 | FromDiscord | <Elegantbeef> Assuming you're still wanting to do shit from the plugins |
19:55:07 | FromDiscord | <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:04 | FromDiscord | <Elegantbeef> Yea I'd not do any of that 😄 |
19:56:15 | FromDiscord | <Chronos [She/Her]> Why not? |
19:56:27 | FromDiscord | <Elegantbeef> A plugin should be simple and not do anything lowlevel |
19:57:00 | FromDiscord | <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:13 | FromDiscord | <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:25 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "If you want to": Okay wait |
19:58:19 | FromDiscord | <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:04 | FromDiscord | <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:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vUm |
19:59:29 | FromDiscord | <Elegantbeef> Then if you want to send a packet it'd be like `sendPacket(PacketId, cstring)` |
19:59:31 | * | progranner joined #nim |
19:59:59 | FromDiscord | <Elegantbeef> Yea I don't think that having the network details shown to the plugin really benefit you |
20:00:02 | FromDiscord | <Chronos [She/Her]> `cstring`? So it's compatible with C? |
20:00:10 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Yea I don't think": Yeah that makes sense |
20:00:10 | FromDiscord | <Elegantbeef> Do you really want to expose an entire TCP stack to each plugin |
20:00:25 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Do you really want": Hm... Yeah not really lol |
20:00:30 | FromDiscord | <Elegantbeef> I mean it's a cstring cause wasm and host are different data |
20:00:34 | FromDiscord | <Chronos [She/Her]> That'd get bulky fast |
20:00:41 | FromDiscord | <Elegantbeef> You need to copy to some interop type |
20:00:50 | FromDiscord | <Elegantbeef> a cstring + len or just cstring is easy to do |
20:00:59 | FromDiscord | <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:07 | FromDiscord | <Chronos [She/Her]> (The data type) |
20:01:17 | FromDiscord | <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:27 | FromDiscord | <Elegantbeef> Yes I generally pack my wasm data to make it easier to reason |
20:01:37 | FromDiscord | <Elegantbeef> Whether it's good for performance is another thing, but it's good for ABI |
20:01:59 | FromDiscord | <Chronos [She/Her]> Makes sense, thanks kb! |
20:02:57 | FromDiscord | <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:17 | FromDiscord | <Elegantbeef> I mean the host needs to parse the id and len |
20:03:26 | FromDiscord | <Elegantbeef> Each packet should start with `id, len` |
20:03:36 | FromDiscord | <Chronos [She/Her]> Yeah it does |
20:03:41 | FromDiscord | <Elegantbeef> the rest is just send it to wasm to handle |
20:03:49 | FromDiscord | <Chronos [She/Her]> Sweet, thanks! |
20:04:30 | FromDiscord | <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:06 | FromDiscord | <Chronos [She/Her]> Probably should be fine aha |
20:05:40 | FromDiscord | <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:21 | FromDiscord | <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:47 | FromDiscord | <Elegantbeef> If it's a custom the packet would look like `(id, nameLen, nameData, packetid, packetLen, packetData)` |
20:06:50 | FromDiscord | <Chronos [She/Her]> Minecraft only uses a single byte for IDs |
20:07:15 | FromDiscord | <Elegantbeef> Ah shame |
20:07:59 | FromDiscord | <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:21 | FromDiscord | <Chronos [She/Her]> How much of `system.nim` and the `orc` GC actually rely on libc for Linux? |
20:17:17 | FromDiscord | <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:08 | FromDiscord | <Chronos [She/Her]> Hm |
20:19:35 | FromDiscord | <Chronos [She/Her]> Eh I should be finee |
20:19:37 | FromDiscord | <Elegantbeef> You're asking a question that no one has an answer to |
20:19:57 | FromDiscord | <Chronos [She/Her]> Yeah makes sense |
20:20:13 | ehmry | Chronos: not that much |
20:20:29 | ehmry | float to decimal formating comes to mind |
20:21:21 | FromDiscord | <Chronos [She/Her]> Ah, thanks ehmry! For the answer and proving Beef wrong haha |
20:21:31 | FromDiscord | <Elegantbeef> Lol |
20:21:41 | ehmry | I'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:20 | FromDiscord | <Elegantbeef> This does remind me I need to get something setup for building with an older glibc |
20:24:02 | ehmry | https://github.com/nim-lang/Nim/pull/19536 |
20:40:07 | FromDiscord | <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:26 | FromDiscord | <wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vUu |
20:40:41 | FromDiscord | <Elegantbeef> `stdout.flushFile` after line 4 might help |
20:42:56 | FromDiscord | <wick3dr0se> That did it |
20:42:59 | FromDiscord | <Chronos [She/Her]> https://github.com/Nimberite-Development/ModernNet :) |
20:43:34 | FromDiscord | <Chronos [She/Her]> Packet parsing isn't actually implemented yet but that is enough to actually implement your own packet handling |
20:43:42 | FromDiscord | <Chronos [She/Her]> Maybe the name is a bit misleading though? |
20:43:56 | FromDiscord | <Chronos [She/Her]> Don't know what else to call it tho, the name fits very well imo |
20:44:26 | FromDiscord | <Piko> sent a code paste, see https://play.nim-lang.org/#ix=4vUv |
20:44:37 | FromDiscord | <Elegantbeef> `Vec3` |
20:44:52 | FromDiscord | <Elegantbeef> `vec3` is a generic procedure that likey says "Expected generic parameters" or "Ambiguousu symbol" |
20:46:01 | FromDiscord | <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:29 | FromDiscord | <Elegantbeef> Is it `Vec3f` in vmath |
20:46:29 | FromDiscord | <Elegantbeef> I forget |
20:47:13 | FromDiscord | <Elegantbeef> Nope `Vec3` is an alias |
20:47:24 | FromDiscord | <Elegantbeef> `nim -v`? |
20:47:38 | FromDiscord | <Piko> in glm it works with Vec3f as type and returning vec3f( ... ) |
20:47:58 | FromDiscord | <Piko> with vmath it doesn't, I was trying using DVec2 earlier |
20:48:19 | FromDiscord | <Elegantbeef> You also likely want `vec3(1.0f, 2.0f, 3.0f)` |
20:48:19 | FromDiscord | <Piko> Nim Compiler Version 1.6.12 [Linux: amd64] |
20:48:30 | FromDiscord | <Elegantbeef> Or just `vec3(1.0f, 2.0, 3.0)` probably works |
20:50:24 | FromDiscord | <Piko> ok so nim is case insentive except when declaring types that have the same name as their constructors? |
20:50:41 | FromDiscord | <Elegantbeef> Nim isnt case insensitive |
20:50:49 | FromDiscord | <Elegantbeef> Nim is style insensitive |
20:50:58 | * | Mister_Magister joined #nim |
20:50:58 | FromDiscord | <Elegantbeef> Which means the first character is sensitive and `_` is removed |
20:51:26 | FromDiscord | <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:00 | FromDiscord | <wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4vUE |
21:26:21 | FromDiscord | <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:41 | FromDiscord | <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:46 | FromDiscord | <chmod222> Late-binding macros, so to say |
21:36:07 | FromDiscord | <Elegantbeef> Nope |
21:36:17 | FromDiscord | <Elegantbeef> What are you trying to actually do? |
21:37:12 | FromDiscord | <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:42 | FromDiscord | <Elegantbeef> I'd say your entire design is wrong and you just want generics |
21:39:32 | FromDiscord | <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:26 | FromDiscord | <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:24 | FromDiscord | <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:42 | FromDiscord | <ranok (Jacob Torrey)> Thus far I have some ugly command line defines, but I was hoping there's something better |
21:41:49 | FromDiscord | <chmod222> `when defined(js): ... else: ...` |
21:41:53 | FromDiscord | <chmod222> Is the simplest method |
21:42:01 | FromDiscord | <ranok (Jacob Torrey)> ok, so nim js will define js? |
21:42:06 | FromDiscord | <chmod222> ype |
21:42:14 | FromDiscord | <ranok (Jacob Torrey)> ok, that's excellent, thanks |
21:42:22 | FromDiscord | <ranok (Jacob Torrey)> is c defined for the default nim c? |
21:42:31 | FromDiscord | <chmod222> It will also define `nodejs` if you happen to `nim js --run` |
21:42:40 | * | noeontheend joined #nim |
21:43:17 | FromDiscord | <Elegantbeef> chmod without a more real world example I can only say you're likely thinking of the problem wrong |
21:43:48 | FromDiscord | <chmod222> Well, that is the real world example in a nutshell, I'm generating bindings for GDExtension |
21:44:08 | FromDiscord | <Elegantbeef> I mean a code example |
21:44:09 | FromDiscord | <Elegantbeef> Words tend to fail me and the problem |
21:44:20 | FromDiscord | <chmod222> RIght, okay |
21:49:16 | FromDiscord | <chmod222> sent a long message, see http://ix.io/4vUH |
21:50:10 | FromDiscord | <Elegantbeef> Right I've looked at GDExtensions briefly |
21:51:19 | FromDiscord | <Elegantbeef> Does each type have it's own interface pointer? |
21:51:23 | FromDiscord | <chmod222> I could probably just `include`, rather than `import` the entire autogen code |
21:51:30 | FromDiscord | <chmod222> But I'd like to stay inside the module system |
21:51:36 | FromDiscord | <chmod222> No, it's one globally shared |
21:51:45 | FromDiscord | <Elegantbeef> So why does `gd_method` not know it? |
21:52:14 | FromDiscord | <jmgomez> Kinda orthogonal, but isnt Godot written in C++? Can you take adv of it somehow? |
21:52:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4vUK |
21:52:48 | FromDiscord | <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:24 | FromDiscord | <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:11 | FromDiscord | <chmod222> The API is simple enough, just a lot of it |
21:55:14 | FromDiscord | <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:19 | FromDiscord | <chmod222> It seems cleaner that way |
21:55:38 | FromDiscord | <Elegantbeef> Regardless why can you not just expose the pointer? |
21:55:54 | FromDiscord | <Elegantbeef> Do not export it from the high level API and there you go |
21:56:02 | FromDiscord | <chmod222> I don't think there's anything stopping me |
21:56:31 | FromDiscord | <Elegantbeef> You then can set the pointer when you need to inside your entry procedure |
21:56:48 | FromDiscord | <Elegantbeef> Then you just use the pointer inside any calls you make with your macro |
21:56:51 | FromDiscord | <Elegantbeef> Eh voila |
21:57:10 | FromDiscord | <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:21 | FromDiscord | <jmgomez> and they dont use inheritance etc. |
21:57:39 | FromDiscord | <Elegantbeef> Well the GDExtension is practically what gdscript really is |
21:57:52 | FromDiscord | <chmod222> GDExtension are hooked pretty far into the core engine code, that's why it replaces GDNative |
21:57:56 | FromDiscord | <Elegantbeef> GDscript is just a slightly ergonomic wrapping over the GDExtension API |
21:57:59 | FromDiscord | <chmod222> It can do a lot |
21:58:18 | FromDiscord | <Elegantbeef> I don't know if it's implemented that way, but it's practically all it is |
21:58:33 | FromDiscord | <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:37 | FromDiscord | <Elegantbeef> Nice Nimble fails to build my project due to an compiler error, but freestanding Nim works fine |
21:58:48 | FromDiscord | <Elegantbeef> C++ in godot is used for plugins/lowlevel code |
21:58:55 | FromDiscord | <Elegantbeef> gdscript is the go to for most sane people |
21:58:57 | FromDiscord | <huantian> In reply to @Elegantbeef "Nice Nimble fails to": skill issue |
21:59:11 | FromDiscord | <huantian> In reply to @Elegantbeef "gdscript is the go": honestly with godot 4 I'd say C# looks more appealing than gdscript |
21:59:17 | FromDiscord | <Elegantbeef> Anything gdscript can do you can do in C++ and vice versa aside from level stuff |
21:59:21 | FromDiscord | <Elegantbeef> Never say C# is appealing |
21:59:31 | FromDiscord | <Elegantbeef> Thanks |
22:00:18 | FromDiscord | <huantian> hey I only speak my honest opinions 🙃 |
22:00:57 | FromDiscord | <Elegantbeef> Better to be thought a fool than open your mouth and prove it |
22:01:27 | FromDiscord | <chmod222> C# just feels wrong to me, I cannot put my finger onto why |
22:01:32 | FromDiscord | <huantian> meh I'd rather be able to leverage the C# ecosystem than use weak python |
22:01:40 | FromDiscord | <chmod222> It seems to hit all kinds of design decisions that disagree with me |
22:01:48 | FromDiscord | <Elegantbeef> I'd rather just use Nim huan |
22:02:12 | FromDiscord | <jmgomez> chmod is your plugin in github or something? |
22:02:33 | FromDiscord | <chmod222> Nope, but if I end up being happy with it, it will be |
22:02:48 | FromDiscord | <chmod222> Right now it's just an excercise in how far I can push the metaprogramming |
22:03:16 | FromDiscord | <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:42 | FromDiscord | <Elegantbeef> Nice I've now got it to stop compiling with Nim.... wait |
22:04:33 | FromDiscord | <jmgomez> In reply to @chmod222 "Right now it's just": are you building a dsl? |
22:04:46 | FromDiscord | <chmod222> That is the intent |
22:05:38 | FromDiscord | <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:06 | FromDiscord | <chmod222> If I feel like my design approach is clean and works, it'll end up on github somewhere |
22:06:59 | FromDiscord | <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:51 | FromDiscord | <Elegantbeef> I know my biggest complaint with the gdnative stuff was how obnoxious it was to use |
22:09:08 | FromDiscord | <Elegantbeef> No auto compiling, no way of making a Nim file from inside the editor |
22:10:06 | FromDiscord | <huantian> I don't think godot 4 solves the latter iirc |
22:10:31 | FromDiscord | <Elegantbeef> I think you can technically make engine plugins to solve it |
22:10:32 | FromDiscord | <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:50 | FromDiscord | <jmgomez> @geekrelief screenshared some months ago briefly how it worked in godot3 and it felt quite bad TBH |
22:10:59 | FromDiscord | <chmod222> But I believe all native code interfaces that depend on shared library loading suffer from this |
22:11:02 | FromDiscord | <jmgomez> the prev nim bindings I mean |
22:11:29 | FromDiscord | <Elegantbeef> that's not really that true |
22:11:41 | FromDiscord | <Elegantbeef> The editor can unload the libraries and reload them |
22:11:56 | FromDiscord | <Elegantbeef> Especially since the editor doesnt run much of the actual logic in godot's case |
22:12:13 | FromDiscord | <jmgomez> yeah, that would be quite a painful workflow |
22:12:28 | FromDiscord | <jmgomez> ideally you should be able to change the editor from NimScript 😛 |
22:12:39 | FromDiscord | <Elegantbeef> Also geek did have hot code reload working |
22:13:32 | FromDiscord | <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:22 | FromDiscord | <ranok (Jacob Torrey)> Ok, now encodings.nim fails to compile with JS as a target |
22:15:38 | FromDiscord | <chmod222> copyMem? |
22:16:27 | FromDiscord | <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:34 | FromDiscord | <ranok (Jacob Torrey)> no |
22:17:51 | FromDiscord | <ranok (Jacob Torrey)> it gets further when I define a target (-d\:linux) |
22:18:03 | FromDiscord | <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:24 | FromDiscord | <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:05 | FromDiscord | <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:32 | FromDiscord | <Elegantbeef> Give them 64k of stack and call it a day |
23:01:13 | FromDiscord | <Chronos [She/Her]> Would that even be enough? |
23:01:31 | FromDiscord | <Chronos [She/Her]> ...tho tbf, I could probably have a way to increase it in the config if that's even needed? |
23:01:44 | FromDiscord | <Elegantbeef> That's plenty that's more ram than most computers had access to in the 80s |
23:02:14 | FromDiscord | <Chronos [She/Her]> Would it be good enough for like, 100 or 1000 items in a sequence with multiple string data types? |
23:02:57 | FromDiscord | <Elegantbeef> Stack size != heapsize |
23:04:18 | FromDiscord | <Chronos [She/Her]> What's the heap? |
23:04:35 | FromDiscord | <Chronos [She/Her]> Also does wasm3 separate the 2? |
23:06:55 | FromDiscord | <Chronos [She/Her]> I roughly know what a heap is from java but not much |
23:10:25 | FromDiscord | <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:32 | FromDiscord | <wick3dr0se> (edit) "does." => "does?" |
23:10:54 | FromDiscord | <wick3dr0se> (edit) "Why does std/terminal ... not" added "library" |
23:42:29 | * | lucasta quit (Remote host closed the connection) |