<< 02-03-2022 >>

00:00:18*jmdaemon joined #nim
00:04:48*noeontheend joined #nim
00:21:18*Gustavo6046_ joined #nim
00:21:34*Gustavo6046 quit (Remote host closed the connection)
00:21:58*noeontheend quit (Ping timeout: 250 seconds)
00:22:30*Gustavo6046_ quit (Remote host closed the connection)
00:22:41*Gustavo6046 joined #nim
00:30:20*vicfred quit (Quit: Leaving)
00:32:12*Gustavo6046 quit (Ping timeout: 240 seconds)
00:35:07*Gustavo6046 joined #nim
01:13:52FromDiscord<huantian> When using jsony to parse json into an object, is there a way to do something special with a certain field of that one specific type
01:15:17FromDiscord<Elegantbeef> write a json hook for that object then do something special for that field
01:22:21FromDiscord<huantian> would I then have to implement the rest of the parsing myself?
01:22:38FromDiscord<huantian> or is there a way to borrow it
01:23:07FromDiscord<Elegantbeef> You can just call the hook manually, or atleast should be able to
01:24:07FromDiscord<huantian> then it turns into a recursive function since the overload matches the more specific hook that I'm definig
01:24:16FromDiscord<huantian> at least that's what I think it does
01:25:26FromDiscord<Elegantbeef> What's your code?
01:26:32FromDiscord<huantian> sent a code paste, see https://play.nim-lang.org/#ix=3R7Z
01:26:55FromDiscord<Elegantbeef> Well yea who said to call this object's proc?!
01:27:56FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R80
01:29:53FromDiscord<huantian> ah that makes a lot more sense
01:30:06FromDiscord<huantian> thanks 🙏
01:30:24FromDiscord<Elegantbeef> Personally i'd say to make a distinct type for the field
01:30:32FromDiscord<Elegantbeef> This way you dont need your own hook for the object
01:32:12FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R81
01:57:11FromDiscord<kalbhairab> Can we include units of measure in nim
01:57:25FromDiscord<Rika> sure why not
01:57:32FromDiscord<Rika> what do you mean exactly though
01:57:44FromDiscord<kalbhairab> See fsharp
01:57:50FromDiscord<kalbhairab> Units of measure
01:57:51FromDiscord<Elegantbeef> https://github.com/SciNim/Measuremancer#other-distinct-data-types
01:58:26FromDiscord<Rika> does it have nonunicode ops too?
01:58:37FromDiscord<Elegantbeef> Sorry it's unchained https://github.com/SciNim/Unchained
01:59:31FromDiscord<ynfle> Great and mind boggling implementation
01:59:36FromDiscord<Rika> mind boggling?
01:59:37FromDiscord<ynfle> (edit) "Great ... and" added "library"
01:59:58FromDiscord<ynfle> Have you taken a look at the implementation?
02:00:01FromDiscord<kalbhairab> Very great than fsharp
02:04:00FromDiscord<kalbhairab> Strformat should be core library
02:04:33FromDiscord<Rika> ? it is part of the stdlib
02:04:43FromDiscord<Elegantbeef> I think they mean it should be auto imported
02:04:53FromDiscord<Elegantbeef> Which i say, you can always add that to your project config, or your global config
02:05:02FromDiscord<Elegantbeef> The latter is going to be more error prone
02:05:11FromDiscord<kalbhairab> Yes
02:05:19FromDiscord<kalbhairab> I am saying that
02:05:26FromDiscord<kalbhairab> Auto imported
02:05:42FromDiscord<Elegantbeef> The core nim devs presently think the system library is to big, so it's going to get smaller in time
02:05:54FromDiscord<Elegantbeef> Modules exist and should be used
02:06:04FromDiscord<kalbhairab> "{person.name} is "
02:06:07FromDiscord<Elegantbeef> Just cause it's easier to auto import doesnt mean it should be
02:06:14FromDiscord<kalbhairab> Ohh
02:06:17FromDiscord<kalbhairab> Why
02:06:50FromDiscord<Elegantbeef> Cause it pollutes the namespace, and it fails to follow proper module conventions
02:07:01FromDiscord<Elegantbeef> You the modules you need, all modules available
02:07:03FromDiscord<Rika> it doesnt really pollute the namespace here
02:07:08FromDiscord<Elegantbeef> not all modules available\
02:07:19FromDiscord<Elegantbeef> I'm talking about generally
02:08:59FromDiscord<kalbhairab> Ohh
02:10:25FromDiscord<Elegantbeef> Atleast it's my view that a nim with no imports should pretty much just have the builtins and basic operations for them
02:10:45FromDiscord<kalbhairab> Ohh
02:11:41FromDiscord<Elegantbeef> I do say it does pollute the namespace rika, say you dont like nim's `fmt` for whatever reason so implement your own, you now get told "ambigious call for `fmt`" when you try to invoke your own
02:12:19FromDiscord<kalbhairab> I am not expert in programming
02:12:30FromDiscord<kalbhairab> I am civil engineer
02:12:49FromDiscord<kalbhairab> I think there should be design for syntax
02:13:01FromDiscord<Elegantbeef> I'm not an expert either
02:13:07FromDiscord<Elegantbeef> I'm a self taught numpty
02:13:24FromDiscord<kalbhairab> Ohh
02:13:26FromDiscord<kalbhairab> Same
02:13:29FromDiscord<kalbhairab> 😃
02:15:22FromDiscord<Rika> In reply to @Elegantbeef "I do say it": i said really, it does but it is a rare case that you would want to do such
02:15:38FromDiscord<kalbhairab> I elegantbeef and rika can we talk in off topic?
02:15:49FromDiscord<Elegantbeef> There's a chance we could
02:15:59FromDiscord<Rika> why?
02:16:03FromDiscord<Elegantbeef> Presently this is still nim related
02:16:10FromDiscord<kalbhairab> Ohh
02:16:19FromDiscord<Elegantbeef> You like those three letter
02:16:22FromDiscord<Elegantbeef> letters\
02:16:37FromDiscord<kalbhairab> Once i got kicked from flutter so 😃
02:16:56FromDiscord<kalbhairab> I have posted one pic to 3 chat rooms
02:17:08FromDiscord<kalbhairab> They kicked without warning
02:18:03FromDiscord<kalbhairab> In reply to @Elegantbeef "You like those three": ???
02:18:36FromDiscord<Elegantbeef> Ohh
02:18:47FromDiscord<kalbhairab> Haha
02:19:07FromDiscord<kalbhairab> Is there any graphics library for nim?
02:19:12FromDiscord<Rika> a lot
02:19:28FromDiscord<kalbhairab> Thats bcz of fb chat
02:41:53*ltriant_ quit (Ping timeout: 252 seconds)
02:47:57FromDiscord<demotomohiro> https://github.com/xflywind/awesome-nim#image
02:52:08*krux02 quit (Remote host closed the connection)
02:53:01*neurocyte0917090 quit (Ping timeout: 256 seconds)
03:04:44*rockcavera joined #nim
03:04:44*rockcavera quit (Changing host)
03:04:44*rockcavera joined #nim
03:07:00FromDiscord<huantian> sent a code paste, see https://paste.rs/Am5
03:10:49FromDiscord<huantian> I suppose the distinct method is the best
03:11:48FromDiscord<Elegantbeef> Well call the jsony method instead of `parseHook`
03:14:44*arkurious quit (Quit: Leaving)
03:15:15FromDiscord<Elegantbeef> Ah I guess nevermind
03:15:58FromDiscord<huantian> I could just copy paste a bunch of stuff :P
03:54:12FromDiscord<retkid> There’s not enough audio libraries
03:54:42FromDiscord<retkid> Well there’s none
03:54:58FromDiscord<Elegantbeef> There are audio libraries
03:55:21FromDiscord<retkid> Not on the awesome list
03:55:39FromDiscord<retkid> Omni is less of an audio manipulation library and more of a sound library
03:55:42FromDiscord<Elegantbeef> https://nimble.directory/search?query=audio
03:56:43FromDiscord<retkid> Well I couldn’t really find a library which allowed me to get the amplitude of a wav file over time but I didn’t look too hard
03:59:09FromDiscord<Elegantbeef> https://github.com/jiro4989/wave also seems to exist
04:01:25FromDiscord<retkid> It’s really cool he gave the docs for the pcm format I couldn’t find it 😭
04:06:01*supakeen quit (Quit: WeeChat 3.4)
04:06:32*supakeen joined #nim
04:06:32FromDiscord<retkid> In reply to @Elegantbeef "https://github.com/jiro4989/wave also seems to": cant find anything on the audio itself only getting data from it?
04:06:45*ltriant joined #nim
04:07:54FromDiscord<Elegantbeef> No clue
04:12:01FromDiscord<congusbongus> isn't amplitude just data / max amplitude
04:24:54*wyrd quit (Quit: leaving)
04:28:21*wyrd joined #nim
04:50:34*rockcavera quit (Remote host closed the connection)
05:04:40FromDiscord<retkid> In reply to @congusbongus "isn't amplitude just data": yes
05:04:48FromDiscord<retkid> but you cant get the data
05:04:50FromDiscord<retkid> so fuck it?\
05:04:52FromDiscord<retkid> (edit) "it?\" => "it?"
05:05:08FromDiscord<retkid> its literally just the 16 bit value / 2^16
05:33:56*girvo joined #nim
05:37:24FromDiscord<demotomohiro> How about to convert it to float and multiply some value and convert back to uint16?
05:51:16*vicfred joined #nim
05:52:39*slowButPresent quit (Quit: leaving)
05:54:31NimEventerNew thread by Pyautogui: Replit featured us in their newsletter this week!, see https://forum.nim-lang.org/t/8968
06:06:42*ltriant quit (Ping timeout: 272 seconds)
06:07:21FromDiscord<sOkam!> sent a long message, see http://ix.io/3R8F
06:09:58FromDiscord<Elegantbeef> It's mostly just what do you prefer the most, use whichever tool you like
06:36:17*wyrd quit (Remote host closed the connection)
06:36:32*wyrd joined #nim
06:37:18FromDiscord<sOkam!> i have no preference, i would need to learn any of them from 0↵is the end result the exact same, though?
06:41:44FromDiscord<sOkam!> like, if cimterop was inspired by nimline... but they are different projects... why are they different and why would one decide on one over the other?↵that type of question is what I don't know how to answer, so don't know how/what to choose
06:42:28FromDiscord<demotomohiro> If you use only a few functions/types in large C code, write binding manually that only import what you use.
06:45:48FromDiscord<Elegantbeef> I think nimterop and futhark require the user have libclang on their pc or similar
06:55:37FromDiscord<geekrelief> In reply to @Elegantbeef "I think nimterop and": Nimterop only requires gcc. Futhark needs libclang
06:56:17FromDiscord<Elegantbeef> Ah my bad
07:04:33FromDiscord<geekrelief> In reply to @sOkam! "I'm having a really": If the API is small, just bind it manually as demotomohiro suggests. Quite a few people have used Futhark with success, but the libclang requirement might be annoying on Windows. I forked nimterop and use it for The Machinery. It works well enough for me, but probably has a steeper learning curve than Futhark.
07:05:57FromDiscord<sOkam!> In reply to @geekrelief "If the API is": it is no small project, and it has no api. the games are hooked straight into the engine. its not like the current theme of lib-ified engines with clean and nice apis
07:06:43FromDiscord<Elegantbeef> Someone clearly talking about the quake engine
07:07:18FromDiscord<sOkam!> yep
07:07:41FromDiscord<Elegantbeef> Well then the best thing to do is wrap what you need as you need it
07:08:03FromDiscord<Elegantbeef> So use c2nim + hand wrapped stuff
07:08:28FromDiscord<sOkam!> i see
07:08:31FromDiscord<Elegantbeef> I think things like nimterop/futhark would be more annoying for something like this, i could be wrong though
07:08:58FromDiscord<sOkam!> should I use nimline/cinterop as the projects suggest, just to get the code up and compiling?
07:09:11FromDiscord<sOkam!> or just straight to c2nim+manual?
07:12:03FromDiscord<Elegantbeef> I dont know what to say there's a lot of code spread out, so wrapping it all automated or manually is going to be a hassle, I guess futhark/nimterop might be able to give you the C api directly in Nim, no clue really
07:12:13FromDiscord<Elegantbeef> I havent used them ever so no clue how effective they are for large apis like this
07:12:46FromDiscord<sOkam!> kk
07:15:13FromDiscord<sOkam!> also, dunno if we were talking about the same thing↵you guys say nimterop, but i was thinking of Cinterop↵dunno how much difference there is between them
07:15:37FromDiscord<sOkam!> nimterop is more akin to futhark? or are cinterop and nimterop the same type of tool?
07:15:45FromDiscord<Elegantbeef> I never have heard of cinterop before
07:15:54FromDiscord<sOkam!> https://github.com/n0bra1n3r/cinterop
07:16:39FromDiscord<sOkam!> this paragraph was the source of my questions, basically https://media.discordapp.net/attachments/371759389889003532/948478930548064266/unknown.png
07:17:45FromDiscord<sOkam!> the other one of my doubts was this: https://github.com/sinkingsugar/nimline
07:18:35FromDiscord<sOkam!> but you guys were sending me to wrappers/bindings, so not sure if these tools could change the answer
07:19:31FromDiscord<Elegantbeef> Well you're going to need to wrap the API, nimline does it in a sort of dynamic way where it just assumes code is valid, the other method is to emit the Nimcode from the C code like Futhark/Nimterop/C2nim do
07:20:44FromDiscord<Elegantbeef> The latter is better if you actually plan on using the code, as it's concrete
07:21:59FromDiscord<sOkam!> is there any specific benefit to c2nim vs futhark/nimterop?
07:23:59FromDiscord<Elegantbeef> The generated code is what people use, instead of the methods of generating the code, so it's a bit more concrete
07:24:50*PMunch joined #nim
07:25:09FromDiscord<sOkam!> not sure i follow, sry me dummie 😔 ↵what do you mean by "concrete"?
07:26:20FromDiscord<Elegantbeef> With C2Nim your share your nim files that are actual `importc`'d types/procs, with futhark/nimterop you share files that run over the C code and emit the bindings and your share the wrapping templates/procedures
07:30:09FromDiscord<sOkam!> do you have an example of a project made with c2nim, and one with either of the others?↵maybe ill understand what you mean by seeing the code compared
07:30:37FromDiscord<sOkam!> i get the feeling that i understand it the idea in such a superficial level, that i wont be able to actually use any of them 😔
07:30:58FromDiscord<sOkam!> (edit) removed "any of"
07:31:27FromDiscord<Elegantbeef> Compare https://gitlab.com/define-private-public/stb_image-Nim to the futhark example
07:31:38FromDiscord<sOkam!> 👌
07:31:48FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R8P
07:31:55FromDiscord<Elegantbeef> God damn i'm tired
07:32:18FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/OVL
07:33:26FromDiscord<Elegantbeef> There are benefits with futhark in that it regenerates, so library changes that are breaking will be caught
07:34:11PMunchThat's pretty much why I wrote Futhark. Well that and having something which actually just works without hours/days of hair pulling frustration
07:34:35*jjido joined #nim
07:34:51FromDiscord<Elegantbeef> Surprised pmunch hasnt said "Yea i just wrapped the quake 3 engine in 30 second with futhark"
07:35:04PMunchBut yeah, automatically catching changes in the underlying library so you don't end up chasing obscure bugs in some wrapper
07:35:31PMunch@Elegantbeef, haha, maybe when I add the next version with better folder support :)
07:35:32FromDiscord<Elegantbeef> I mean I just learned but Nim can do some amount of API assurances
07:35:33FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R8S
07:36:52FromDiscord<sOkam!> In reply to @Elegantbeef "There are benefits with": this engine is quite stagnant, though. not sure how much adaptation/regeneration I'll ever need
07:36:57FromDiscord<Elegantbeef> There is a `--checkAbi` flag apparently
07:37:14FromDiscord<Elegantbeef> Yea i mean you can just pester pmunch until you get your bindings
07:37:23FromDiscord<sOkam!> the community version i'm will be using is supported, but nothing out of the rare bugfix
07:37:29FromDiscord<Elegantbeef> Either pester him to make them or for help 😛
07:38:16FromDiscord<sOkam!> In reply to @PMunch "<@145405730571288577>, haha, maybe when": 🙏 🥺 🙏
07:41:42FromDiscord<sOkam!> In reply to @PMunch "That's pretty much why": do you think futhark might have issues with something when dealing with q3 engine?
07:42:06PMunchHard to tell without having ever looked at the sources for q3 engine
07:42:15PMunchBut if it's pretty standard C code then you should be fine
07:42:23FromDiscord<sOkam!> what does futhark currently have issues with?
07:42:38PMunchMostly macros that the user is supposed to use
07:42:48PMunchIt handles macros used by the library just fine
07:43:08FromDiscord<sOkam!> its ansi C '89, coded in 1999 by tons of carmack-ian weirdness. dunno how standard or non-standard that will be 🤔
07:43:17PMunchBut if they define macros that the user is supposed to use it starts to struggle because those aren't really typed
07:43:20PMunchDo you have a link?
07:43:24FromDiscord<sOkam!> ye
07:43:52FromDiscord<sOkam!> This is the one that we use nowadays for mods↵https://github.com/ec-/Quake3e
07:45:23PMunchFrom the two files I've opened it seems like it should be fine
07:45:32FromDiscord<sOkam!> that project has no gamecode. you can see the gamecode specific things in this other engine inside cgame/game/q3_ui : https://github.com/ioquake/ioq3
07:46:02FromDiscord<sOkam!> In reply to @PMunch "From the two files": kk. any tuts written for futhark? i literally haven't used it yet because i have no clue where to start
07:46:32PMunchNot apart from the sample code and the various wrappers I've helped people write in the issues
07:46:45FromDiscord<sOkam!> 👌
07:47:11PMunchBut it's pretty simple, you just give it a block of things to import from C, and then you sit back and enjoy your wrapper
07:47:44FromDiscord<sOkam!> yeah, someone recommended me that before
07:47:58PMunchMight've been me :P
07:48:11FromDiscord<sOkam!> I don't know how to go about that, though. like, i know its probably dummie not being able to understand that, but i cant grasp how
07:48:42FromDiscord<sOkam!> i have a list of .h files that i generated, but what do i do with that?
07:48:58PMunchThat you generated?
07:49:05FromDiscord<sOkam!> yeah with find or ls
07:49:09FromDiscord<sOkam!> or similar, dont remember
07:49:14PMunchUhm, don't do that
07:49:20FromDiscord<sOkam!> see?
07:49:21FromDiscord<sOkam!> 😄
07:50:30PMunchDownload the Quake library from GitHub, then have an `importc` block which tells futhark where to find clang standard libraries and the libraries you just cloned (the two first lines of the stb example) then just list all the .h files you want to import the same way you would do it in C
07:51:58FromDiscord<sOkam!> this is what that aforementioned list looks like https://media.discordapp.net/attachments/371759389889003532/948487816957009920/unknown.png
07:54:54PMunchWhy have you only copied those things out?
07:55:03PMunchThey must depend on some other files as well?
07:55:29FromDiscord<sOkam!> because, like i said, i have no clue how to get the .h file list
07:55:37FromDiscord<sOkam!> other than by bash scripting
07:56:05PMunchYou don't need a list though?
07:56:58FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R8Z
07:57:21FromDiscord<Elegantbeef> You treat `importc` like the `#include` in C
07:57:27FromDiscord<Elegantbeef> So you importC the header files you want
07:57:38PMunchExactly
07:57:54FromDiscord<Elegantbeef> So you might want to importC all the files of a folder together so you can expose them as a Nim module
07:58:17FromDiscord<sOkam!> im so lost 😔
07:58:26*Guest2979 joined #nim
07:58:30PMunchDo you have a minimal sample in C?
07:58:32FromDiscord<sOkam!> i don't think im understanding the methodology
07:59:01FromDiscord<sOkam!> In reply to @PMunch "Do you have a": wdym? of q3 engine?
07:59:14PMunchOf a game which uses it
07:59:34FromDiscord<sOkam!> q3 games are ingrained in the engine. not sure how i would do that, and make it compile
07:59:39PMunchDoesn't have to do anything, like the "hello world" of using it
08:00:13FromDiscord<sOkam!> the engine is so hairy, that we all start by modding the original game directly. i dont think such a minimal example exists
08:00:41FromDiscord<sOkam!> only a handful of people actually understand the architecture enough to dissect it in such a way
08:01:21PMunchThen it's not really a library is it?
08:01:41FromDiscord<sOkam!> which is my point, its an engine not really an api or library
08:01:50FromDiscord<Elegantbeef> It's not a library it's C code so it's going to be 'fun' to make Nim work with it
08:01:53FromDiscord<sOkam!> so don't know how to approach the issue
08:03:25FromDiscord<sOkam!> its like, if you have firefox already coded, and you want to start using firefox code from nim (or any fully fledged app that's not lib-ified)
08:04:07*Guest2979 quit (Ping timeout: 256 seconds)
08:04:30*girvo quit (Ping timeout: 272 seconds)
08:04:44nrds<Prestige99> Anyone here using windows? My friend installed nim from the site and ran the "finish.exe" to add nim to his path but it seems to not have worked
08:04:51nrds<Prestige99> Curious if anyone else is having this issue
08:04:58FromDiscord<Elegantbeef> Well you get to generate C code using Nim then include it in your C file and call it
08:05:01FromDiscord<Elegantbeef> Did anti virus get involved prestige?
08:05:05FromDiscord<Elegantbeef> Did they restart?
08:05:06FromDiscord<sOkam!> from what I know about the engine, the "only wrap those things you need" actually means "wrap and rewrite the whole main loop in a new nim main loop function", and start from there
08:05:18FromDiscord<Elegantbeef> Windows path is a funky beast
08:05:29nrds<Prestige99> Yeah antivirus complained but he told it to continue
08:05:32nrds<Prestige99> the install, I mean
08:05:32FromDiscord<Elegantbeef> Well that'd be one way of doing it
08:08:02FromDiscord<sOkam!> In reply to @Elegantbeef "Well you get to": that's another approach I thought about, but that wouldn't really be a nim engine eventually.↵it would still be C that uses code auto-generated from nim compiling as C code instead of as binary
08:08:24FromDiscord<Elegantbeef> It's never going to be a "Nim engine"
08:08:45FromDiscord<Elegantbeef> It's 23 years of C, if you want a Nim engine, write it in Nim 😛
08:09:07FromDiscord<sOkam!> i would, but it wouldn't be the same
08:10:06FromDiscord<sOkam!> for some freaky weird reason i dont understand, not even id2 / id4 feel good enough 😦↵i tried all engines, and nothing is close. definitely not the modern ones with gjk/bvh
08:10:32FromDiscord<sOkam!> (edit) "feel" => "feels" | "feelsgood enough ... 😦↵i" added "compared to id3"
08:10:48FromDiscord<Elegantbeef> Well make an engine that feels the same, it'll probably be less of a pain than trying to make this work nicelyt
08:11:46FromDiscord<sOkam!> aware of how many people have said that? 25y, tens of games, hundreds of programmers, none achieved what it was achieved with id3. not even the same guys with their very next engine (id4)
08:12:01FromDiscord<sOkam!> i know its not an easy task
08:12:14FromDiscord<sOkam!> just trying to understand how, that's all. even if its hard
08:20:57*krux02 joined #nim
08:23:19*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
08:25:01FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R99
08:25:34FromDiscord<Elegantbeef> With what pmunch said you just include `one.h` and `two.h`
08:25:38FromDiscord<sOkam!> (edit) "https://play.nim-lang.org/#ix=3R99" => "https://play.nim-lang.org/#ix=3R9a"
08:25:45FromDiscord<Elegantbeef> Now if he's a liar that's bad
08:26:16FromDiscord<sOkam!> Ok, so then I would only need to manage the main loop and the functions that it calls
08:26:33*jjido joined #nim
08:28:35FromDiscord<sOkam!> basically, this function https://github.com/ec-/Quake3e/blob/65db7c877cb37e37315b6bfbf52c1f3066376436/code/win32/win_main.c#L740
08:30:01FromDiscord<sOkam!> how does futhark do its thing in the background?↵does it manage the C compiler automatically or smth?
08:38:22nrds<Prestige99> Elegantbeef do you know how to link dlls on windows by chance?
08:38:49nrds<Prestige99> Trying to get my sdl project to compile on windows but have been running into issues, I think it's not finding the files
08:38:58FromDiscord<Elegantbeef> The same as on linux
08:42:08nrds<Prestige99> Okay how do you do that? :P
08:42:20PMunchSorry I was in a meeting
08:42:33FromDiscord<Elegantbeef> Download the dev files then import the file with dynlib
08:42:48FromDiscord<Elegantbeef> If static linking also having the static library and linking it with command line arguments
08:43:59PMunchsOkam, so basically what Futhark does is that it loads the header files you specified with libclang, then it asks Clang to list out everything which is defined in those headers. It then converts those definitions to Nim, and tells it to grab it from the C sources. So in Nim you just import the C header files, Futhark converts them to Nim definitions, and when you call them in Nim it will call the C functions for you.
08:44:21FromDiscord<Elegantbeef> Does it recurse down includes?
08:45:30PMunchYes
08:45:53FromDiscord<demotomohiro> If you use dll with https://docs.microsoft.com/en-us/troubleshoot/windows-client/deployment/dynamic-link-library#types-of-dlls
08:45:57PMunchWell it recurses down the includes to get the definitions it needs, but it only exports the definitions for the files you've specified
08:46:38PMunchThis is what I was talking about with the folder import thing. I want to add a flag which makes it so that it will add all the definitions in a given folder automatically
08:47:02PMunchSo For this you could say that you wanted `one.h` and everything it imports which lives in `Quake32/code`
08:47:20FromDiscord<demotomohiro> If you use dll with Load-time dynamic linking, you need to add .lib file to linker. That is bit different from Linux. If you use dll as Run-time dynamic linking, you don't need to link .lib or .dll files at link time.
08:47:48PMunchThe reason I've done it like this is because otherwise it will go all the way to the top of the C definitions and start pulling in the C definition for an integer and things like that
08:48:25PMunchSo with the above sample you pasted sOkam it would look something like this in Nim: https://play.nim-lang.org/#ix=3R9h
08:48:53PMunchAnd in myMethod you could call procedures from one.h and two.h and access their types just as if it was written in C
08:52:29nrds<Prestige99> Elegantbeef any guides on that?
08:52:38nrds<Prestige99> I don't know how any of this linking business works
08:52:57FromDiscord<abdu> How is Nim for C's #define preprocessor eg.↵#define foo 99
08:53:34PMunch@abdu, not sure what you mean
08:53:37FromDiscord<demotomohiro> `const Foo = 99`
08:53:51PMunchIn Nim you would do it like @demotomohiro said, with a compile-time constant
08:56:00FromDiscord<demotomohiro> If you want macro like `#define min(x, y) ((x) < (y) ? (x): (y))`, `template min(x, y: untyped): untyped = if x < y: x else: y`.
08:56:03PMunchYou could use `{.emit: ["#define ", somename, " ", something].}` or maybe even `let foo {.codegenDecl: "#define $2 $1".} = 99` to put such defines into Nim code
08:56:34PMunchPrestige, do you just need to link a DLL into your program?
08:58:00nrds<Prestige99> Uh well now we're trying to do static linking
08:58:07nrds<Prestige99> have the .lib files
08:58:28FromDiscord<demotomohiro> On windows, .dll is not a file linked to executable file. Link .lib file with --passL:"foo.lib".
08:58:49nrds<Prestige99> do we need dynlibOverride for that?
09:00:23PMunchNah I think that is just to stop procedures marked with `{.dynlib.}` from being imported from a dynamic library
09:00:52PMunchLike if you wanted to use the standard library ssl implementation but static link it
09:01:06nrds<Prestige99> hmm okay
09:01:50FromDiscord<sOkam!> PMunch, you mentioned something about macros earlier. Q3 engine has quite a lot of them↵what happens in futhark with macros? does it handle them properly?
09:03:13PMunchIt depends
09:03:29PMunchIt handles all the macros that just live inside the library just fine
09:04:05PMunchAnd it should handle most static values just fine
09:04:29PMunchBut macros which are intended to be called like a procedure is a bit worse
09:04:58FromDiscord<sOkam!> In reply to @PMunch "But macros which are": there\ are procedures, yep
09:05:07FromDiscord<sOkam!> (edit) "there\" => "there" | "yep" => "yep. quite a few"
09:05:09PMunchWhich you are supposed to call?
09:05:56FromDiscord<sOkam!> hmmm, don't have an answer to that yet. maybe the C code does, but you'd call them if you write in the engine in C, yep
09:06:22FromDiscord<sOkam!> unless they are behind some other functions and can be avoided, which I don't know yet
09:06:30FromDiscord<sOkam!> are they fine if they are called from C code only?
09:07:38FromDiscord<abdu> In reply to @demotomohiro "If you want macro": solved! thanks
09:08:39PMunchsOkam, yeah they're fine as long as they are behind C code
09:09:10PMunchThe problem is that clang can't figure out the signature of such a macro, because it doesn't really have one, so I can't convert it into anything useful in Nim
09:16:13nrds<Prestige99> So I'm having an issue getting this lib statically linked, "undefined reference to GPU_TRANSLATE" and any other functions that are used. Here https://github.com/Vladar4/sdl2_nim/blob/master/sdl2_nim/sdl_gpu.nim#L1703
09:16:32nrds<Prestige99> It's using the dynlib pragma, don't know what I'm missing here
09:16:55nrds<Prestige99> using --passL:path/to/my.lib
09:18:02PMunchShouldn't that be `--passL:"-Lpath/to/library -lmy"`?
09:18:22PMunch--passL only sends things to the linker
09:18:22nrds<Prestige99> I have no idea
09:18:49PMunchOn Linux at least -L is used to pass a folder to search for libraries
09:19:07PMunchAnd -l to link to an actual library (but I think dynlib should handle that automatically)
09:19:08FromDiscord<demotomohiro> `GPU_TRANSLATE` is a symbol in your static lib? Or it is in other library?
09:19:34nrds<Prestige99> It should be in the static lib afaik
09:19:44PMunchSo you would need `--passL:"-Lpath/to/lib"` in order to pass the folder that Nim will go looking for that library
09:20:00PMunchBut since it uses dynlib you probably need to use dynlibOverride
09:20:45nrds<Prestige99> I thought that's what clibdir was for
09:21:41*Gustavo6046 quit (Quit: Leaving)
09:21:43nrds<Prestige99> I got it to build using absolute paths, but the binary does nothing. Weird
09:21:51PMunchOh, never seen that before, but yeah I guess that does the same thing
09:23:20FromDiscord<demotomohiro> Do you got error like `path/to/my.lib was not found`?
09:23:53nrds<Prestige99> Can't get either of those to work for some reason - the error is "undefined reference to GPU_TRANSLATE" etc
09:26:06*xaltsc quit (Read error: Connection reset by peer)
09:33:14nrds<Prestige99> after statically linking using absolute paths, I had to put the dll's next to the executable for it to run
09:33:19nrds<Prestige99> so the static libs aren't actually static?
09:33:39PMunchNo that just sounds like you dynamically linked them
09:34:26nrds<Prestige99> I'm using dynlibOverrideAll so I don't think so..?
09:34:37nrds<Prestige99> Unless that doesn't do what I think it does
09:35:15PMunchWell it's not very static if you need the files to be there is it?
09:35:33nrds<Prestige99> Yeah that's my point
09:36:01nrds<Prestige99> maybe the .lib file is just a loader for the dll
09:36:28nrds<Prestige99> SDL2.lib is only 171kb but the .dll is 2179kb, seems weird
09:37:24FromDiscord<demotomohiro> File size depends on compiler options.
09:38:00FromDiscord<demotomohiro> Maybe your .lib was not built correctly?
09:38:14nrds<Prestige99> I got it from the sdl website so, hopefully it's correct
09:38:58PMunchWhy do you want to static link it anyways?
09:39:20nrds<Prestige99> Easier to ship binaries
09:40:06FromDiscord<demotomohiro> Did you read SDL2 manual? It should tells which library you need to link. Maybe you need to link other library.
09:42:18FromDiscord<demotomohiro> Maybe, C compiler that built .lib file and C compiler your Nim uses are different and .lib file is not compatible with your C compiler
09:42:55nrds<Prestige99> idk about that
09:48:54nrds<Prestige99> Well I've been working on this for too long, will try getting it working again another day
09:55:32NimEventerNew thread by Drkameleon: C/C++-wrapping Windows/VCC-related issues again, see https://forum.nim-lang.org/t/8969
10:04:41FromDiscord<MaskDuck> hi
10:07:03FromDiscord<demotomohiro> hi
10:07:31FromDiscord<Rika> hi
10:09:23FromDiscord<MaskDuck> nim looks cooler than python ig
10:09:31FromDiscord<MaskDuck> i right now only code using python
10:09:36FromDiscord<MaskDuck> and wanting to learn another language
10:09:42FromDiscord<MaskDuck> (edit) "i right now only code using python ... " added "(proficient)"
10:10:24FromDiscord<MaskDuck> maybe ill learn nim
10:10:43FromDiscord<MaskDuck> btw i think nim structure looks like a command line™️
10:11:34PMunchLike a command line?
10:11:51FromDiscord<Rika> Good to hear that you like it
10:12:07PMunchPrestige, just take into account that you probably need to GPL license whatever it is you're doing if you want to static link against SDL2
10:12:29nrds<Prestige99> Yeah that's fine
10:12:40FromDiscord<Rika> Is SDL2 GPL and not lesser?
10:12:57FromDiscord<MaskDuck> yup
10:13:08PMunchAh it might be LGPL, I just found some references to it when I searched for static linking things earlier
10:13:18PMunchAnd it's not that hard to ship a couple extra dlls
10:13:38FromDiscord<Rika> It’s zlib license
10:13:50PMunchHow does that work, if you write a program which has staticRead the DLLs during compile-time and if the libraries don't exists it spits them out before loading them?
10:14:35FromDiscord<Rika> Semi-static hahaha
10:15:00FromDiscord<Rika> I can imagine AV would hate that though
10:15:09FromDiscord<demotomohiro> Nim has command invocation syntax and many proc/func/template/macro can be called like command line.
10:15:13FromDiscord<demotomohiro> https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax
10:15:19FromDiscord<MaskDuck> ho
10:15:21FromDiscord<MaskDuck> how can i
10:15:24FromDiscord<MaskDuck> install nim
10:15:29FromDiscord<MaskDuck> using source distributor
10:15:36FromDiscord<MaskDuck> i can find the build.sh file
10:16:04FromDiscord<MaskDuck> cant
10:17:12FromDiscord<demotomohiro> Here is how to build from source: https://github.com/nim-lang/nim#compiling
10:19:02FromDiscord<demotomohiro> There are build_all.sh for Linux/Mac and build_all.bat for Windows.
10:21:11PMunchSource distributor?
10:21:18PMunchI recommend you do it through choosenim
10:21:36PMunchThat way you're sure it's installed correctly, and that you can easily upgrade to future versions
10:23:06FromDiscord<MaskDuck> aic thanks
10:23:15FromDiscord<MaskDuck> In reply to @PMunch "I recommend you do": i tried choosenim
10:23:23FromDiscord<MaskDuck> but it is too slow
10:24:07PMunchToo slow?
10:24:14FromDiscord<MaskDuck> do we neeed any dependacies
10:24:28PMunchIt literally just downloads a tarball and extracts it
10:24:33PMunchHow can that be too slow?
10:24:49FromDiscord<MaskDuck> it is faster now
10:24:50PMunchAs for dependencies you need a C compiler, but not much else
10:24:55FromDiscord<MaskDuck> ok i installed thanks guys
10:25:04FromDiscord<MaskDuck> now
10:25:09FromDiscord<MaskDuck> if i wanna write hello world
10:25:15FromDiscord<MaskDuck> `echo "Hello World"`?
10:26:11PMunchYup
10:26:13FromDiscord<demotomohiro> yes. Then save it to file hello.nim and `nim c -r hello.nim`
10:26:41FromDiscord<MaskDuck> ah thanks ya
10:27:05FromDiscord<MaskDuck (MaskDuck)> tysm
10:27:19PMunchI mean technically you don't even need to save it to a file: nim --eval:'echo "hello world"'
10:27:28FromDiscord<MaskDuck> lmao
10:27:49FromDiscord<MaskDuck> https://media.discordapp.net/attachments/371759389889003532/948527038267011072/unknown.png
10:28:06PMunchWell you didn't install it properly then
10:28:15PMunchYou need to make sure that the Nim binary is in your path
10:28:28PMunchAd do you have `nim` repeated twice, or is that just your shell?
10:29:11PMunchI think choosenim asks you if you want it to add it to your path for you
10:30:00FromDiscord<MaskDuck> In reply to @PMunch "I think choosenim asks": well
10:30:05FromDiscord<MaskDuck> it doesnt add it into the path
10:30:16FromDiscord<MaskDuck> and the nim folder is something contain the `hello.nim` file
10:30:57FromDiscord<MaskDuck> In reply to @PMunch "I think choosenim asks": well it doesnt
10:31:57FromDiscord<Rika> In reply to @MaskDuck "well it doesnt": It does, otherwise it’s somehow broken
10:32:15FromDiscord<Rika> In reply to @MaskDuck "it doesnt add it": It can’t add it for you, you have to do that yourself in this case
10:33:24PMunchYou shouldn't put your project files in the Nim compiler folder
10:33:30PMunchI mean you can, but you shouldn't
10:34:16PMunchEither way it's just a matter of getting your shell to find the Nim binary. If you have built the Nim binary from sources it should be enough to add the `bin` folder in the Nim sources you've got to your path
10:34:30PMunchSimply update your PATH variable to include that folder
10:34:49*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
10:34:54PMunchOf course if you don't want to do that you could pass the full path to the compiler when you want to invoke it
10:35:31FromDiscord<Rika> Or symlink into a bin folder you already have in your path lol
10:36:10PMunchThat would probably cause Nim to fail to find the standard library though wouldn't it?
10:37:19FromDiscord<Rika> Dunno never used it
10:37:37FromDiscord<Rika> If so then that should be fixed
10:38:09PMunchOh well, time for lunch
10:38:10*PMunch quit (Quit: leaving)
10:42:58FromDiscord<demotomohiro> Running nim with absolute path worked.
10:51:14*ltriant joined #nim
10:52:34nrds<Prestige99> Is there a way to have a template return a bool, but also allow the user to pass in a body?
10:52:56FromDiscord<Rika> Templates don’t really “return”
10:53:42nrds<Prestige99> yeah
10:53:50nrds<Prestige99> But do you know what I mean?
10:53:53FromDiscord<Rika> Make a template with a block inside, put the passes body in the block, then after the body at the end of a block do an “explicit value return”
10:54:00FromDiscord<demotomohiro> `template foo(body: untyped): bool = body; true`?
10:54:16nrds<Prestige99> yeah
10:54:17FromDiscord<Rika> ^Pretty much the same as what I mean except with a block too
10:55:09FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3R9H
10:55:28FromDiscord<demotomohiro> true without '?'
10:55:53nrds<Prestige99> so I'm trying to do something like https://play.nim-lang.org/#ix=3R9I
10:55:56nrds<Prestige99> if that makes sense
10:56:40nrds<Prestige99> I think I'm too tired, lol
10:58:40FromDiscord<demotomohiro> It works without block: https://play.nim-lang.org/#ix=3R9K
10:59:09FromDiscord<Rika> Of course it does, I just wrap with a block for sanitation
10:59:28nrds<Prestige99> So I can't use it in an if statement though?
10:59:29FromDiscord<Rika> Even if there’s no real benefit to that since it’s sanitary either way when used in that case
11:05:45nrds<Prestige99> Any ideas?
11:10:02FromDiscord<demotomohiro> https://play.nim-lang.org/#ix=3R9M
11:10:43*xaltsc joined #nim
11:12:55nrds<Prestige99> hm doesn't work well for multiline does it?
11:14:44FromDiscord<demotomohiro> https://play.nim-lang.org/#ix=3R9N
11:15:22nrds<Prestige99> hmm
11:15:38FromDiscord<demotomohiro> It seems using `foo` with if statement requires `(block:...)`.
11:15:46nrds<Prestige99> interesting
11:17:00*ltriant quit (Ping timeout: 240 seconds)
11:26:50FromDiscord<whisperdev> How can I get sha256 from a file?
11:33:20FromDiscord<demotomohiro> Probaby `let content = readFile("myfile")` and pass it to `update` proc in nimcrypto/sha2.
11:33:31FromDiscord<demotomohiro> https://github.com/cheatfate/nimcrypto
11:35:09*jjido joined #nim
11:37:03FromDiscord<whisperdev> Thanks. Found some old code for nimSHA2 on forum that also works!
11:37:46FromDiscord<demotomohiro> !eval import osproc; echo execCmd "sha256sum /usercode/in.nim"
11:37:49NimBotCompile failed: 7555e94d3c86083b5d6df92f38fb0a6c411170b6f6c9fe9d03ddf8bc63d3d0d5 /usercode/in.nim↵0
11:38:39FromDiscord<haoliang> sent a code paste, see https://play.nim-lang.org/#ix=3R9R
11:38:55FromDiscord<demotomohiro> It say compile failed but output is correct?
11:39:56FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/U2P
11:40:36FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3R9W
11:41:24*PMunch joined #nim
11:41:34FromDiscord<demotomohiro> In reply to @haoliang "i was wondering how": https://play.nim-lang.org/#ix=3R9X
11:42:18FromDiscord<demotomohiro> It is same to how to write Nim code in github issue or Readme.md.
11:42:27FromDiscord<Sense> sent a code paste, see https://paste.rs/Gdo
11:42:55FromDiscord<Sense> It's pretty simple but uh... I would like to see how it will look like in Nim code self.
11:43:06FromDiscord<haoliang> In reply to @demotomohiro "https://play.nim-lang.org/#ix=3R9X": thanks!
11:48:32PMunch@Sense, it would look a little something like this: http://ix.io/3R9Z/nim
11:50:43FromDiscord<demotomohiro> https://play.nim-lang.org/#ix=3Ra0
11:51:13FromDiscord<demotomohiro> "Write a number: " prints without "\n", isn't it?
11:51:39PMunchAh okay, fair enough
11:51:41FromDiscord<demotomohiro> Maybe my code is wrong. I don't know much about Pascal.
11:52:22*jmdaemon quit (Ping timeout: 260 seconds)
12:04:58FromDiscord<Michal Maršálek> What is the Nim way to work with unicode characters? Like if I wanted to print yeah character of the given string in its own line? As far as I can tell, std/unicode only has support for runes. Related question: why does std/unicode deviate from the unicode terminology (rune = code point, character = grapheme cluster)?
12:05:19FromDiscord<Michal Maršálek> (edit) "yeah" => "each"
12:05:26PMunchProbably just to have shorter names
12:05:39FromDiscord<Michal Maršálek> (edit) "in" => "on"
12:05:39PMunchrune is a fairly common name for a unicode character
12:06:01*supakeen quit (Quit: WeeChat 3.4)
12:06:12PMunchBy the way, try to edit your messages as little as possible. Each edit you makes gets sent as a separate message to IRC, which is a bit annoying
12:06:16FromDiscord<Rika> I’ve heard of runes before Nim as well
12:06:30*supakeen joined #nim
12:06:53FromDiscord<Rika> What is the difference between a “character” that you say and a code point
12:07:03PMunchAnd to print out each unicode character you would probably do `for c in myStr.runes: echo c`
12:07:12FromDiscord<Michal Maršálek> In reply to @PMunch "rune is a fairly": I neber heard it but I see that golang uses that word too.
12:07:24PMunchIt's a nice short word :)
12:07:56PMunch@Rika, I guess things like zero-width joiners are their own code points but not a printable character
12:08:02FromDiscord<Michal Maršálek> In reply to @Rika "What is the difference": What users usually perceive as one character can be one or multiple codepoints.
12:08:09PMunchExactly
12:08:19FromDiscord<Michal Maršálek> Like a letter and an accent
12:08:29FromDiscord<Rika> Denormalise then I guess
12:08:38FromDiscord<Michal Maršálek> Two codepoints combined to a single character.
12:08:39FromDiscord<Rika> Doesn’t work for all I guess
12:08:51FromDiscord<ajusa> PMunch this is bordering on #offtopic but could you explain what the tour endpoint does for the Nim forums? I was planning on migrating it to HTMX this week in a fork using the existing stack with Nimja as the templating engine.
12:09:11PMunch@ajusa, for the Nim forum?
12:09:22PMunchOr do you mean the playground
12:10:03FromDiscord<ajusa> Playground, my bad
12:21:11PMunchWell, it's a feature I built ages ago that has never really been used
12:21:50PMunchThe idea was that people would be able to write their own "tours" in a subset of HTML and the playground would then display them similar to how "A tour of Go" is done
12:22:28FromDiscord<deeuu> sent a long message, see http://ix.io/3Rab
12:23:57*ltriant joined #nim
12:23:59PMunchIt doesn't really seem to work at the moment though
12:24:04FromDiscord<deeuu> And for context I'm executing a Python application on Windows, which fails with an exit code of -1, thus leaving me in a pickle
12:25:04*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
12:25:46PMunch@deeuu, maybe try execCmdEx: https://nim-lang.org/docs/osproc.html#execCmdEx%2Cstring%2Cset%5BProcessOption%5D%2CStringTableRef%2Cstring%2Cstring
12:26:06FromDiscord<ajusa> PMunch would it be fine if I took it out for now then? It would simplify the changes I'd be making, plus to make it work with HTMX changes would be needed anyway. Do you have any issues with what I'm proposing so far? If not, I can start coding
12:27:04PMunchYeah I think it's time to axe that feature
12:27:46PMunchI've actually been looking at reimplementing the playground with HTMX myself
12:28:00FromDiscord<deeuu> In reply to @PMunch "<@746663152459972669>, maybe try execCmdEx:": Yeah I'll try that, thanks. I was more thinking is it correct that `readLines` iterates until `p.peekExitCode != -1` (which in my example never occurs).
12:28:38PMunchI started rewriting the front-end to be more contributor-friendly but I got lost in writing my own CSS library :P
12:29:10PMunchreadLines likely reads until the stream returns atEnd
12:29:39*ltriant quit (Ping timeout: 256 seconds)
12:30:57PMunchAh no, it actualy runs until p.peekExitCode != -1
12:31:04PMunchThat's weird
12:31:28FromDiscord<abdu> How identifier naming?↵it's so narrow with insensitive letter-case execpt the first !↵please share tour best tips!
12:31:49PMunch@abdu, do you want to know how people name things?
12:32:08FromDiscord<Rika> Types are capitalised and variables are not
12:32:16PMunchDo you normally have myVar, myvar, and my_var point to different variables?
12:32:17FromDiscord<Rika> Pretty much the general consensus at least
12:32:24PMunchIf so remind me to never read your code :P
12:32:55PMunchYeah, types start with a capital letter, variables are snakeCase
12:32:59*jjido joined #nim
12:33:25FromDiscord<ajusa> In that case I'll send you a link once I have stuff working, with the intention of merging it back eventually. I'm not planning on touching the CSS, just removing Karax and replacing it with HTMX
12:34:37FromDiscord<Rika> In reply to @PMunch "Yeah, types start with": snakeThatSwallowedAFewElephantsCase
12:35:11PMunchHaha, I meant camelCase :P
12:35:51PMunch@ajusa, send me a link? Send me a PR instead
12:37:34FromDiscord<deeuu> sent a long message, see https://paste.rs/7tp
12:38:50PMunchThat is unfortunate
12:39:16PMunchI thought negative numbers where just treated as unsigned uint8s
12:45:15FromDiscord<hmmm> boiz is there something automatic to escape a windows path string to double the slashes
12:45:20FromDiscord<deeuu> Yeah thought so. Note that this issue only appears to arise on Windows
12:46:30FromDiscord<Rika> In reply to @hmmm "boiz is there something": ? why would you need this?
12:46:45FromDiscord<Rika> when you get user input it's already "escaped"
12:47:14FromDiscord<hmmm> apparently in pythonland they use something like os.path.join
12:47:16FromDiscord<Rika> so like if the user types "a\b" you receive "in code", "a\\b" or a, then \ as a char, then b
12:47:37FromDiscord<Rika> oh you mean you have a group of strings that represent folders?
12:47:44PMunch@hmmm, it sounds like you're looking for `/`
12:47:48FromDiscord<Rika> yes
12:47:51FromDiscord<Rika> in os
12:48:04PMunchhttps://nim-lang.org/docs/os.html#%2F%2Cstring%2Cstring
12:48:23FromDiscord<abdu> https://forum.nim-lang.org/t/8967#58573↵How do you think,↵"my frustration that Nim is slower than Python "
12:48:38FromDiscord<hmmm> hmm I'll try it, see if it works
12:48:42PMunch@deeuu, aah Windows probably derps with the error codes
12:48:48PMunchBecause it's Windows I guess
12:48:57FromDiscord<deeuu> Fair
12:49:12FromDiscord<Rika> isnt bigint specifically mentioning that its not optimised
12:49:19PMunchYup
12:50:18PMunchbigint specifically says that it is not fast. Nim is faster than Python, but some Python libraries are written in highly optimised C code and just shimmied in which I guess is what's going on here. If you use a library which is actually optimised for speed you will get more speed (who'da thunk?)
12:51:24FromDiscord<Rika> lol
12:51:56PMunchBut yeah, if you don't write Python code which essentially boils down to calling out to a C library that does all the work Nim will be faster
12:52:28PMunchIf you find a similarly optimised Nim library Nim is likely to be faster again because of faster startups
12:54:00PMunchHmm, I'm porting some C code to Nim, it adds a signal handler for SIGINT which just sets an atomic int and then the main loop is looking for that atomic int and stops if it is 0. Then it has cleanup after the loop
12:54:19PMunchWhat would be the best way to implement something similar in Nim that can be Ctrl+C'ed with proper shutdown code?
12:54:45PMunchI guess just use setControlCHook..
13:01:31FromDiscord<hmmm> solved with r"<path>"
13:01:36FromDiscord<hmmm> handy stuff!
13:25:22*slowButPresent joined #nim
13:28:56*rockcavera joined #nim
13:28:56*rockcavera quit (Changing host)
13:28:56*rockcavera joined #nim
13:34:01FromDiscord<deeuu> sent a code paste, see https://paste.rs/3Lm
13:35:34FromDiscord<deeuu> (edit) "https://play.nim-lang.org/#ix=3Ray" => "https://paste.rs/kM8"
13:49:18*ltriant joined #nim
13:51:22PMunch@deeuu, that would probably be a good idea
13:51:35PMunchPlease create a PR to the Nim repository with this fix
13:55:27*ltriant quit (Ping timeout: 256 seconds)
14:36:44*ltriant joined #nim
14:39:53*arkurious joined #nim
14:41:17*ltriant quit (Ping timeout: 240 seconds)
15:08:19*ltriant joined #nim
15:13:05*ltriant quit (Ping timeout: 256 seconds)
15:17:11FromDiscord<abdu> How to reset over again↵`arr = newSeqOfCap[ int ](99)`↵after so many push i.e. arr.add( ) so as if start the very first push again on completely empt array?
15:26:01PMunch@abdu, `arr.setLen(0)` if you want to keep the internally allocated buffer, or you can use `reset arr` to completely reset it.
15:26:06PMunchProbably want setLen though
15:26:15PMunchTo avoid extra allocations
15:26:16*PMunch quit (Quit: Leaving)
15:39:53*ltriant joined #nim
15:39:54*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
15:44:46*ltriant quit (Ping timeout: 260 seconds)
15:53:21*neurocyte0917090 joined #nim
15:57:58ehmrycan I read asynchronously from io.stdin or do I need to read from an extra thread?
16:00:22FromDiscord<abdu> What's "reset arr to completely reset it" supposed to mean to be different to `arr.setLen(0)` ?
16:05:36FromDiscord<Rika> In reply to @abdu "What's "reset arr to": Reset will reallocate the buffer, which is an internal aspect that you don’t really notice aside from performance and memory usage
16:11:29*ltriant joined #nim
16:16:13*ltriant quit (Ping timeout: 240 seconds)
16:22:02*LyndsySimon quit (Ping timeout: 240 seconds)
16:23:09*LyndsySimon joined #nim
16:35:13*gsalazar joined #nim
16:56:19FromDiscord<Waldecir Santos> I've 2 modules/files with the same name but they live in different folders and I'm having a redefinition error, how should I import ? does nim have a `as` command like python ?
16:58:16FromDiscord<Waldecir Santos> Just fond on the docs there is an `as` let me try it
16:59:57FromDiscord<Waldecir Santos> It worked \o/
17:30:14*vicfred quit (Quit: Leaving)
17:38:58FromDiscord<whisperdev> Does anyone use Nim with Svelte?
17:39:27FromDiscord<whisperdev> I was going to go with Karax but there is not that many projects out there to look at and I am kinda dumb
17:43:35FromDiscord<planetis> There are react bindings
17:50:44*jjido joined #nim
17:59:18FromDiscord<-|-> Henlo, everyone↵I'm relatively new to Nim and working on a project that has a client, server, and some common components. Can I have some advice on what might be the best and most painless way to organize it, as far as directory structure and package management goes?
18:14:25*tinytoast is now known as tinystoat
18:18:40*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
18:19:51*rockcavera quit (Remote host closed the connection)
18:31:01*ltriant joined #nim
18:37:48*ltriant quit (Ping timeout: 240 seconds)
18:44:14FromDiscord<Phil> Okay I have this faint feeling that std/logging is just hopelessly not working whatsoever
18:44:25FromDiscord<Goat> sent a code paste, see https://play.nim-lang.org/#ix=3Rcg
18:44:26FromDiscord<Phil> Time to try out a library
18:44:46FromDiscord<Phil> .... that is valid syntax?
18:44:59FromDiscord<Goat> Its for a macro I have, so yes
18:45:11FromDiscord<Phil> Oh, macro, nevermind I'll shut up, not my area
18:45:34FromDiscord<Phil> Sidenote, if anyone here got std/logging to properly work for them, I'd love to get some pointer
18:45:35FromDiscord<Phil> (edit) "pointer" => "pointers"
18:53:53FromDiscord<ajusa> In reply to @Goat "Which syntax is better?": like as someone who might be using this macro? I'd probably prefer the second to be honest. Is this a novel/story decision DSL?
18:55:49FromDiscord<Goat> Its a DSL that randomly rolls on a table, displays the flavor text of the choice and increases the two skills associated with it. I'm using it for a character generator https://media.discordapp.net/attachments/371759389889003532/948654878090203196/unknown.png
19:09:28FromDiscord<Phil> So apparently jsony and chronicles really don't like each other
19:11:07FromDiscord<Phil> (edit) "So apparently jsony and chronicles really don't like each other ... " added "since both make "toJson" procs available and partial imports on chronicles don't really alleviate the issue when you try to use it in a template"
19:15:51*shadow0133 joined #nim
19:17:20shadow0133Is there a way to turn `seq[Future[Foo]]` into `Future[seq[Foo]]`?
19:18:48FromDiscord<dom96> You can use `all` (https://nim-lang.org/docs/asyncfutures.html#all%2Cvarargs%5BFuture%5BT%5D%5D)` and then call .read() on each of the futures
19:28:51FromDiscord<exelotl> sent a long message, see http://ix.io/3Rco
19:29:45FromDiscord<Phil> I'm not sure how to get out of this hell I find myself in, anyone with ideas?↵The "ambiguous call" strangely happens within jsony. And merely because both of them are imported within the same module, which is just beyond strange for me. https://media.discordapp.net/attachments/371759389889003532/948663418074828850/unknown.png
19:30:32FromDiscord<Phil> (edit) "module," => "module (controllers.nim by virtue of otherModule being imported there while it also exports chronicles),"
19:31:38FromDiscord<Phil> sent a long message, see http://ix.io/3Rcp
19:33:16FromDiscord<dom96> weird, but implies a problem in jsony or the json_serialization package
19:33:48FromDiscord<Phil> I'm... not sure whom to give a github issue for that one
19:34:16FromDiscord<dom96> you could try modifying the code it points to and see if you can resolve the problem
19:34:59FromDiscord<Phil> Can do, but first I feel like there's something fundamental about nims import rules I don't get here
19:35:30FromDiscord<dom96> I don't think this is so much about Nim's import rules as much as it is about Nim's late binding generics
19:35:31FromDiscord<Phil> when jsony.nim calls "toJson", that proc is defined within that module or a module it imports
19:35:49FromDiscord<Phil> jsony.nim never imports chronicles
19:36:33FromDiscord<Phil> So due to generics it's able for a proc from "downstream" to cause ambiguity issues "upstream"?
19:36:58FromDiscord<dom96> I'm not 100% sure but I think so
19:37:21FromDiscord<-|-> In reply to @exelotl "There's lots of ways": Do you have a single <name>.nimble file for the whole project?
19:40:23shadow0133Can you `map` the Future?
19:40:52FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3Rcq
19:41:08FromDiscord<dom96> In reply to @shadow0133 "Can you `map` the": there is no async map so no, but you can easily write one
19:41:17FromDiscord<exelotl> In reply to @-|- "Do you have a": I'm not using Nimble but if you are (which is probably a more conventional approach tbh) then you could have a single .nimble and single source directory, and the .nimble can have 2 binary targets in it, no problem
19:42:00FromDiscord<dom96> In reply to @exelotl "I'm not using Nimble": yep, for my game I have a single nimble file with many different tasks. For example "backend", "server", "android" to build for different targets
19:48:52*jjido joined #nim
19:49:09*cornfeedhobo joined #nim
19:51:57FromDiscord<Phil> dom? can you just throw multiple -d compiler flags behind one another or can you only specify -d once and have to throw multiple values in some strange syntax into it at once?
19:52:23shadow0133how to construct ready Future?
19:55:24FromDiscord<dom96> In reply to @Isofruit "dom? can you just": you can throw multiple
19:55:31FromDiscord<dom96> In reply to @shadow0133 "how to construct ready": `newFuture`
19:57:04shadow0133but with value? something like `ready(T): Future[T]`
19:57:54FromDiscord<dom96> newFuture + complete
19:58:01FromDiscord<dom96> you can't construct a completed future
20:02:32FromDiscord<-|-> In reply to @exelotl "I'm not using Nimble": Thanks for the advice. I think I see how I want to do it now.
20:25:44shadow0133How to iterate over `seq[T]` such that it returns `T`, not `lent T`?
20:26:38nrds<Prestige99> maybe using mitems?
20:27:14nrds<Prestige99> https://nim-lang.org/docs/iterators.html#mitems.i%2CopenArray%5BT%5D
20:34:11FromDiscord<sOkam!> Is this the same concept as the (deprecated) nimgen way of translating code? https://media.discordapp.net/attachments/371759389889003532/948679637750411264/unknown.png
20:36:09FromDiscord<sOkam!> Basically trying to understand if nimterop still has support for code translation in some way, or if I should stay to raw c2nim or nimgen for that
20:36:46shadow0133so, mitems doesn't work, but `for (_, x) in seq.pairs` does ¯\_(ツ)_/¯
20:44:05FromDiscord<sOkam!> nvm i think this answered it https://media.discordapp.net/attachments/371759389889003532/948682127438913566/unknown.png
20:53:23*cornfeedhobo quit (Ping timeout: 272 seconds)
20:55:06shadow0133hmm, it doesn't work for now, but thanks for help @dom96 and @Prestige
20:57:58*Gustavo6046 joined #nim
20:59:27*shadow0133 quit (Quit: Client closed)
21:02:48*Gustavo6046 quit (Client Quit)
21:03:14*Gustavo6046 joined #nim
21:09:09*cornfeedhobo joined #nim
21:10:11FromDiscord<Skaruts> how do I add something to the beginning of a sequence?
21:10:33FromDiscord<Skaruts> at index 0
21:15:42*ltriant joined #nim
21:19:54FromDiscord<exelotl> In reply to @Skaruts "how do I add": https://nim-lang.org/docs/system.html#insert%2Cseq%5BT%5D%2CsinkT
21:20:13*ltriant quit (Ping timeout: 240 seconds)
21:21:18FromDiscord<Phil> In reply to @dom96 "you can throw multiple": Thanks for the info!
21:21:56FromDiscord<Skaruts> @exelotl Ah! I had only found `insert` in sequtils. Thanks.
21:22:00nrds<Prestige99> Is there a way to do something like this? https://play.nim-lang.org/#ix=3RcS
21:22:10nrds<Prestige99> Maybe need to write some sort of macro
21:22:36FromDiscord<b4mbus> How do I achieve something similiar to this C++ code but in Nim? Someone pointed me to `method`s but Im incredibely confused how they work and how I should use them
21:22:48FromDiscord<b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3RcT
21:24:26FromDiscord<b4mbus> (edit) "https://play.nim-lang.org/#ix=3RcT" => "https://play.nim-lang.org/#ix=3RcU"
21:33:20FromDiscord<exelotl> In reply to @b4mbus "How do I achieve": Like this: https://play.nim-lang.org/#ix=3RcW
21:34:00FromDiscord<b4mbus> oh, so Nim doesnt have a concept of a pure virtual function/pure method
21:34:15FromDiscord<b4mbus> thanks a lot
21:35:59FromDiscord<exelotl> yeah I think it doesn't
21:39:15FromDiscord<Rika> Not without external libraries
21:42:15*wyrd quit (Ping timeout: 240 seconds)
21:47:08*rockcavera joined #nim
21:47:08*rockcavera quit (Changing host)
21:47:08*rockcavera joined #nim
21:47:10*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
21:49:15*wyrd joined #nim
22:11:51*gsalazar quit (Ping timeout: 256 seconds)
22:19:35*sagax joined #nim
22:22:23*ltriant joined #nim
22:24:19*cornfeedhobo quit (Ping timeout: 256 seconds)
22:33:17FromDiscord<kbsec> What exactly does `{.pure.}` pragma do? I have a small demo here https://play.nim-lang.org/#ix=3Rd1 where I would expect the runtime identifier for the attribute in the object defined with `{.pure.}` for each field to be ommited, but it would seem the object is the same w/ or w/out the pragma ?
22:35:25FromDiscord<zidsal> Quick question, I have a seq of a variant type e.g JsonNode and I know for a fact they are all JInt. Is there a way I can tell the compiler I know what the kind is without manually checking the enum value?
22:43:12*cornfeedhobo joined #nim
22:48:28FromDiscord<Elegantbeef> It removes runtime type information on objects that are inheritable↵(@kbsec)
22:49:08FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#types-cast-uncheckedassign i think this works↵(@zidsal)
22:52:03FromDiscord<ATwenty0ne> sent a code paste, see https://paste.rs/Xuk
22:52:25FromDiscord<ATwenty0ne> sent a code paste, see https://play.nim-lang.org/#ix=3Rd4
22:52:43FromDiscord<ATwenty0ne> (edit) "https://play.nim-lang.org/#ix=3Rd4" => "https://play.nim-lang.org/#ix=3Rd5"
22:53:00FromDiscord<Elegantbeef> that offsets the ptr of `x` by w so in nim i'd be `int (cstrLen(x[w].addr))`
22:53:28FromDiscord<Elegantbeef> or you could just do `cstrlen(x) - w`
22:53:46FromDiscord<Elegantbeef> Actually i'm wrong arent i
22:53:49FromDiscord<demotomohiro> In reply to @kbsec "What exactly does `{.pure.}`": https://play.nim-lang.org/#ix=3Rd6
22:54:09FromDiscord<Elegantbeef> it's offsetting the char\ by `w` so it'd be `cast[ptr UncheckedArray[cstring]](x)[w]`
22:58:00FromDiscord<Elegantbeef> that's still not right God C can be awful
22:58:05FromDiscord<demotomohiro> I think `strSize = x.len - w`.
22:58:13FromDiscord<ATwenty0ne> lol yea this one is a head scratcher
22:58:23FromDiscord<Elegantbeef> No `w` is a pointer
22:58:27FromDiscord<Elegantbeef> I mean x is a pointer
22:58:30FromDiscord<Elegantbeef> `x + w` offsets the pointer by w bytes
22:59:27FromDiscord<Elegantbeef> so the best thing to do i guess is manual arithmetic `cstrlen(cast[cstring](cast[int](x) + w)))`
22:59:54FromDiscord<zidsal> Thanks @ElegantBeef
23:00:23FromDiscord<Elegantbeef> That should work twentyone, sorry for the 30 wrong answers 😛
23:00:39FromDiscord<ATwenty0ne> lol its ok, I appreciate you helping, thanks!
23:01:37FromDiscord<Elegantbeef> I fully blame C's inanity
23:01:57FromDiscord<Elegantbeef> Also are you interoping with C or writing pure Nim?
23:04:25FromDiscord<ATwenty0ne> interoping
23:06:11*girvo joined #nim
23:16:24*acidsys quit (Excess Flood)
23:17:01*acidsys joined #nim
23:35:35girvoHi all :)
23:36:20FromDiscord<Elegantbeef> Hello
23:36:40girvoAnyone have a good example for Nim-ified wrappers of C libraries that take callbacks? I'm having issues passing procs to a {.cdecl.} wrapper, as trying to call a proc declared outside of it is an illegal capture
23:36:47girvoTheres gotta be a better way I'm missing
23:36:55FromDiscord<Elegantbeef> Cdecls cannot have captures
23:37:12FromDiscord<Elegantbeef> Closures are incompatible with cdecl due to the environment carried with them
23:37:18girvoYeah figured as much
23:37:36FromDiscord<Elegantbeef> What's your callback and what's your code trying to do?
23:37:45girvoOne tick I'll grab the definitions in a pastebin for ya
23:39:45girvohttps://pastebin.com/j9trbgGQ
23:40:20girvo`var t = newTask(sendAT, "sendAT", (16384 * 3).SzBytes)` is what I wanted to achieve lol where sendAt is just a regular void proc
23:40:47FromDiscord<Elegantbeef> Can you store `cb` on the object that's passed to the procedure?
23:40:58girvoI can actually
23:41:05girvoOh!
23:41:08girvoI see :D
23:41:08FromDiscord<Elegantbeef> so like could you do `cast[MyObject](a1).cb()`
23:41:10*jmdaemon joined #nim
23:41:15FromDiscord<Elegantbeef> well `ptr MyObject`
23:41:16girvoYeah I should be able to. I'll give it a shot
23:41:35FromDiscord<Elegantbeef> Your `pointer` is your closure environment somewhat
23:42:15girvoYep that's exactly how FreeRTOS uses it
23:43:25girvoHah she compiles at least
23:43:35girvoLets see if it runs or blows my tiny stack. Embedded is fun
23:43:45FromDiscord<System64 ~ Flandre Scarlet> https://nimble.directory/pkg/dimscord↵Does it support the latest Discord API features?
23:46:21FromDiscord<Elegantbeef> You could make a macro like `proc doThing(a1: Task) {.rtosProc.}` which emits a `let a1 = cast[ptr Task](a1)` and adds `cdecl` to the procedure to make it a bit cleaner but ymmv 🙂
23:47:50girvoOhhh that's a good idea too
23:48:28girvoI plan on doing my best to make working with FreeRTOS in ESP32 as nice as possible in Nim land lol
23:48:43FromDiscord<Elegantbeef> Then that macro sounds pretty nice 🙂
23:48:44girvoBecause doing it in straight C is painful at best
23:49:58girvoInteresting, it created the task! and it ran! once lol. I gotta have a look at what it's doing, likely my destructor/scoping causing it to delete itself I reckon
23:50:49girvoHahaha yeah
23:51:14girvoI gotta brush up on scoping in Nim with ARC nowadays
23:52:31girvohttps://pastebin.com/aqqMUXgd that's the main.nim app code
23:52:53girvohttps://pastebin.com/qqy97X0P
23:52:59girvoxTaskCreate wrapper
23:53:25girvoDespite the while true: in the cb proc, it amusingly runs once then `=destroy` is called
23:53:36girvoBecause I'm definitely misunderstanding how one should approach this ;)
23:54:24FromDiscord<Elegantbeef> At the end of `appMain` it'll destroy `task`
23:54:38nrds<Prestige99> Is there a non-reentrant lock in the stdlib?
23:56:02girvoYeah. I gotta look into FreeRTOS and work out how the "main thread" stuff works. I could put a while true in app_main as well, though I remember FreeRTOS saying not to?
23:57:19girvoHah yeah. A simple white true: triggers the FreeRTOS task watchdog
23:57:30girvoTime to go look at some documentation I think
23:58:05girvoI suppose I could skip the RAII-like destructor and just make it an explicit delete proc on the task object for now