<< 10-05-2021 >>

00:13:27*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
00:13:47*njoseph joined #nim
00:33:57FromDiscord<treeform> Oh sorry you are using benchy with a bug, please update
00:34:18FromDiscord<treeform> Benchy code gets optimized away in this version
00:35:11FromDiscord<ElegantBeef> Ah yea that better
00:36:53FromDiscord<treeform> I forgot to try lto
00:37:09FromDiscord<treeform> I'll try it when I get back
00:37:19FromDiscord<ElegantBeef> `.xyz` is around 1.5 times faster and `[]=` is about .4ms faster
00:37:42FromDiscord<treeform> Ok
00:37:51FromDiscord<ElegantBeef> So yea arr is still slower
00:38:07FromDiscord<treeform> But obj.arr is not
00:38:26FromDiscord<treeform> Why having array wrapped in an object makes it faster?
00:38:51FromDiscord<ElegantBeef> time to comment out alll the tests and profile that single case
00:39:07FromDiscord<treeform> Should nim always wrap array in structs?
00:40:27FromDiscord<treeform> Post you runtimes
00:40:28FromDiscord<ElegantBeef> I dont see how it's any different since it's still allocated the same, or atleast should be
00:40:38FromDiscord<ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/841112458515972146/unknown.png
00:41:27FromDiscord<treeform> On mine the objarr is always faster
00:41:32FromDiscord<treeform> Or the same
00:42:17FromDiscord<ElegantBeef> I assume in some cases the casts i do are more easily optimized so some are better
00:49:33FromDiscord<ElegantBeef> So just found a weird behaviour doing all 4 tests in a single file results in it taking 8 ms, doing it alone results in 1.2ms
00:51:24FromDiscord<ElegantBeef> Seems that is actually mostly to do with the gc
00:55:26*oddp quit (Quit: Quit)
00:55:54FromDiscord<ElegantBeef> And now i'm hitting ` stack smashing detected : terminated`
01:35:04FromDiscord<treeform> Oh
01:35:17FromDiscord<treeform> I did not try separate files
01:39:13FromDiscord<ElegantBeef> Oh i didnt use seperate files i was talking about in order
01:39:36FromDiscord<ElegantBeef> Like test 1 had 4 go, test 2 had only 1
01:39:59FromDiscord<ElegantBeef> When ran all together they're consistent but doing the slow ones alone seems to be different
01:51:54*Tanger joined #nim
02:03:30*vicfred_ joined #nim
02:05:51*vicfred quit (Ping timeout: 252 seconds)
02:09:09*wasted_youth2 quit (Ping timeout: 245 seconds)
02:09:52*vicfred_ quit (Quit: Leaving)
02:10:47*wasted_youth2 joined #nim
03:00:57*thomasross quit (Ping timeout: 260 seconds)
03:04:01*krux02 quit (Remote host closed the connection)
03:28:42ForumUpdaterBotNew thread by Halloleo: How to catch DOM exception in Nim code?, see https://forum.nim-lang.org/t/7958
03:46:58*NimBot joined #nim
04:49:46*letto quit (Quit: Konversation terminated!)
04:50:26*letto joined #nim
05:08:07*vicfred joined #nim
05:12:54*narimiran joined #nim
05:33:32*a_chou joined #nim
05:33:35*a_chou quit (Remote host closed the connection)
05:41:34*nekits07 quit (Ping timeout: 268 seconds)
06:13:01ForumUpdaterBotNew thread by Pietroppeter: Visualizing Garbage Collector Algorithms (2014), see https://forum.nim-lang.org/t/7959
06:18:20*voltist quit (Quit: The Lounge - https://thelounge.chat)
06:21:24*voltist joined #nim
06:27:21ForumUpdaterBotNew Nimble package! owoifynim - Turning your worst nightmare into a Nim package. This is a Nim port of mohan-cao's owoify-js, which will help you turn any string into nonsensical babyspeak similar to LeafySweet's infamous Chrome extension., see https://github.com/deadshot465/owoifynim
06:47:06ForumUpdaterBotNew thread by Halloleo: Can I create a string stream from its own data?, see https://forum.nim-lang.org/t/7960
07:00:53*PMunch joined #nim
07:23:35*wasted_youth2 quit (Quit: Leaving)
07:34:45FromDiscord<Nisha's alt> Is it possible to compile a Nim file/project with a default pragma?
07:35:04FromDiscord<Nisha's alt> So for example, adding `{.exportc.}` to everything for use in C
07:35:09FromDiscord<Nisha's alt> Probably not lol
07:35:59FromDiscord<ElegantBeef> you can make a file that is just `{.push exportc.}` then do `--include:exporter.nim`
07:36:06FromDiscord<ElegantBeef> but no clue if that'll work propeprly
07:36:08FromDiscord<ElegantBeef> (edit) "propeprly" => "properly"
07:38:05FromDiscord<Nisha's alt> Oh okay
07:38:21FromDiscord<Nisha's alt> Is there also a way to use Nim types in C? :P
07:39:13FromDiscord<Nisha's alt> And my final question is!- How do i compile an entire Nim project to a .so file or a .h file if it'd possible :p
07:39:30FromDiscord<Nisha's alt> (Nim types as in stuff like Int, or Str)
07:39:31FromDiscord<haxscramper> Depends on what you mean by "use in C". nim compiles to C, so you can use everything, technically
07:40:10FromDiscord<Nisha's alt> Well, i wanna use the Nim string type in C (mainly being able to access and be able to read the value)
07:40:26FromDiscord<Nisha's alt> And using cstring isn't an option here
07:42:36FromDiscord<haxscramper> In reply to @Hitoshi Shinsou|πŸ’»β­ "And my final question": https://github.com/haxscramper/hack/blob/master/testing/nim/c_interop/nim_clib/build.sh to header file and compile C app with this library
07:42:43FromDiscord<DumbMahreeo> In reply to @DumbMahreeo "Yes, sorry for not": @Rika how did you achieve that?
07:43:41FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3mmW
07:43:41FromDiscord<haxscramper> I think
07:43:53FromDiscord<haxscramper> But it is different for new runtime etc.,
07:44:33FromDiscord<haxscramper> So you can't really work with it, unless you are willing to wrap everything in some sort of macro metaprogramming to check for which string implementation is used
07:45:29FromDiscord<haxscramper> In reply to @haxscramper "nim's `string` representation in": See `stdlib_system_nim.c(pp)` in compilation cache, it has all built-in types compiled
07:45:44FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3mmX
07:46:00FromDiscord<haxscramper> But again - this is an implementation detail
07:46:02FromDiscord<Rika> In reply to @DumbMahreeo "<@!259277943275126785> how did you": i dont use lsp xd
07:46:12FromDiscord<haxscramper> No guarantees about the structure, availability etc.
07:46:43FromDiscord<haxscramper> In reply to @Hitoshi Shinsou|πŸ’»β­ "And using cstring isn't": btw, why can't you use `cstring` in the first place?
07:46:58FromDiscord<Nisha's alt> In reply to @haxscramper "https://github.com/haxscramper/hack/blob/master/tes": Thanks!
07:47:07FromDiscord<Nisha's alt> In reply to @haxscramper "So you can't really": Ah okay
07:48:11FromDiscord<Nisha's alt> In reply to @haxscramper "See `stdlib_system_nim.c(pp)` in compilation": Ah alright
07:48:48FromDiscord<Nisha's alt> In reply to @haxscramper "btw, why can't you": Pre-existing lib and it would take too much time changing all the Nim types to the C types
07:51:01FromDiscord<haxscramper> Can't you just `exportc` wrappers for working with nim `string` too?
07:51:19FromDiscord<Nisha's alt> Wdym?
07:51:36FromDiscord<haxscramper> you need to work with nim string at `C` side, correct?
07:51:51FromDiscord<haxscramper> then write functions for working with nim string and `exportc` them
07:52:19FromDiscord<haxscramper> like `proc nim_strcmp(a, b: string): bool {.exportc.} = a == b`
07:52:23FromDiscord<haxscramper> And use it in C code
07:52:46FromDiscord<Nisha's alt> Oh okay!
07:52:47FromDiscord<haxscramper> boilerplate, yes, but I don't think there is any other sane way of doing so
07:52:52FromDiscord<Nisha's alt> That actually makes sense lol
07:53:54FromDiscord<haxscramper> You lose some things like `[]` access for characters, and have to add disambiguation prefix for exportc-ed functions to avoid name clashes on C side
07:53:59FromDiscord<Nisha's alt> sent a code paste, see https://play.nim-lang.org/#ix=3mmZ
07:54:14FromDiscord<Nisha's alt> Ah okay
07:54:21FromDiscord<haxscramper> well, don't see why it shouldn't work
07:54:27FromDiscord<Nisha's alt> Thanks! Lol
07:59:50FromDiscord<haxscramper> Though I don't really know how this would work wrt. to garbage collector. Maybe you would have to manually manage nim strings
08:00:27FromDiscord<haxscramper> But simple example is working correctly
08:00:30FromDiscord<haxscramper> sent a code paste, see https://paste.rs/l50
08:04:10FromDiscord<demotomohiro> Using Nim string in C code sounds like "To boldly go where no man has gone before!"
08:05:10FromDiscord<haxscramper> tbh I would rather use nim strings than C ones
08:05:54FromDiscord<haxscramper> especially considering you can convert a lot of types to strings, and have cheap strlen etc., while in C you are left with `printf`
08:05:59FromDiscord<haxscramper> and `strlen`
08:06:04FromDiscord<Nisha's alt> Hm
08:08:26FromDiscord<Nisha's alt> Can i just like, replace every reference of `string` to `cstring` and `int` to `cint`? Lol
08:09:29FromDiscord<demotomohiro> sizeof(int) and sizeof(cint) can be different
08:09:38*MarderIII joined #nim
08:09:43FromDiscord<Nisha's alt> Oh?
08:10:01FromDiscord<demotomohiro> !eval echo int.sizeof, cint.sizeof
08:10:05NimBot84
08:10:11*spiderstew joined #nim
08:10:30FromDiscord<Nisha's alt> !eval echo int.sizeof
08:10:32NimBot8
08:10:36FromDiscord<Nisha's alt> !eval echo cint.sizeof
08:10:38NimBot4
08:10:47FromDiscord<Nisha's alt> Huh.
08:11:00FromDiscord<Nisha's alt> !eval echo cint8.sizeof
08:11:02NimBotCompile failed: /usercode/in.nim(1, 6) Error: undeclared identifier: 'cint8'
08:11:56Amun_RaNisha's alt: https://nim-lang.org/docs/system.html#clong
08:14:12FromDiscord<demotomohiro> In Nim, sizeof(int) is same to sizeof(pointer), but in C sizeof(int) can be 4 bytes even on 64bit cpu
08:14:36Amun_RaNim's c*types are only for non-fixed width (long/short/int/…) or implementation-defined C types
08:16:59FromDiscord<Nisha's alt> Oh okay!
08:17:28Amun_Raso it's just int8, uint8, etc.
08:19:42FromDiscord<Nisha's alt> Ah okay then
08:19:49FromDiscord<Nisha's alt> Is there a cfloat? Lol
08:19:56FromDiscord<Nisha's alt> !eval echo cfloat
08:19:56Amun_Rayes
08:19:57NimBotcfloat
08:20:03FromDiscord<Nisha's alt> Nice
08:20:22Amun_Ralook at that system.html for complete types reference
08:21:12FromDiscord<Nisha's alt> Alright then, thanks!
08:26:39FromDiscord<Nisha's alt> !eval echo cbool
08:26:41NimBotCompile failed: /usercode/in.nim(1, 6) Error: undeclared identifier: 'cbool'
08:26:45FromDiscord<Nisha's alt> Wait
08:26:58FromDiscord<Nisha's alt> Why tf am i not checking the docs lol
08:30:45FromDiscord<ElegantBeef> If you have a bool that isnt 1 byte, you're writing Java
08:32:30Amun_Ra_Bool can be larger than 1 byte according to C standard
08:33:04FromDiscord<demotomohiro> !eval bool.sizeof
08:33:06NimBotCompile failed: /usercode/in.nim(1, 5) Error: expression '1' is of type 'int' and has to be used (or discarded)
08:33:33FromDiscord<demotomohiro> !eval echo bool.sizeof
08:33:35NimBot1
08:33:43FromDiscord<Rika> it said in the error xd
08:33:55FromDiscord<Rika> `...expression '1' is...`
08:34:54FromDiscord<demotomohiro> I didn't read error
08:43:10*Tanger quit (Quit: Leaving)
08:44:39*krux02 joined #nim
08:53:49*aeverr quit (Quit: Konversation terminated!)
08:53:55FromDiscord<Nisha's alt> In reply to @ElegantBeef "If you have a": Lol
09:01:47FromDiscord<jtiai> Now since I've stared few hours a C code is there in nim something that would equal to `#define`. Templates maybe?
09:02:16FromDiscord<Rika> Not exactly but they’re close yes
09:02:29FromDiscord<Rika> In some cases you can just use const as well
09:02:47FromDiscord<haxscramper> `const a = 123`, `when a == 333: ....`
09:02:54*aeverr joined #nim
09:03:35FromDiscord<haxscramper> @Nisha's alt after some diffing it seems like `--header` is deprecated and https://github.com/nim-lang/Nim/commit/279df834bae8b6972af6cbcbdd57c1d53e1df9c7
09:03:46FromDiscord<haxscramper> and I'm not sure what is the other way
09:03:48FromDiscord<ElegantBeef> And if you're after macros, we have type safe macros
09:04:28FromDiscord<ElegantBeef> Yea it's odd that it doesnt anymore, would be nice if it was possible
09:04:46*Vladar joined #nim
09:04:59FromDiscord<haxscramper> In reply to @haxscramper "and I'm not sure": https://forum.nim-lang.org/t/5809 says ↡`> "Also and more importantly, --header is unsupported, write your header files manually or extract them via a 3rd party tool."`
09:05:09FromDiscord<haxscramper> but anyway
09:05:12FromDiscord<haxscramper> it works for now
09:05:18FromDiscord<jtiai> How macros do differ from templates?
09:05:28FromDiscord<jtiai> All examples I have seen looks very complex.
09:05:30FromDiscord<ElegantBeef> macros can do introspection and generate AST directly
09:05:37FromDiscord<ElegantBeef> templates are basic code subsitution
09:06:39FromDiscord<haxscramper> most importantly macros can execute arbitrary logic
09:06:54FromDiscord<haxscramper> arbitary code
09:06:57FromDiscord<Nisha's alt> Ah okay
09:07:46FromDiscord<jtiai> Wonder what is practical use case for macro...
09:08:24FromDiscord<ElegantBeef> Wanting to make a DSL, or do something that requires introspection
09:08:45FromDiscord<ElegantBeef> https://github.com/beef331/constructor here is a whole list of them if you want to see some more simple ones
09:09:19FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3mno
09:09:23FromDiscord<haxscramper> boilerplate reduction
09:09:36FromDiscord<haxscramper> complex type introspection is also possible with macros
09:09:45FromDiscord<ElegantBeef> Dont write code a lot, have a macro write code for you
09:09:52FromDiscord<haxscramper> writing custom serializers
09:10:14FromDiscord<ElegantBeef> Aslong as it's not changing the syntax, you can probably implement what you want in a macro
09:10:46FromDiscord<ElegantBeef> Still a little sad after learning term rewritting macros are after semantic checking, cannot add object unpacking with them πŸ˜„
09:11:09FromDiscord<haxscramper> In reply to @jtiai "Wonder what is practical": https://github.com/mratsim/photon-jit/blob/747ae2db3698e1b814e78fded175d08a778fada9/photon_jit/x86_64/x86_64_op_generator.nim#L14
09:11:13FromDiscord<haxscramper> might be interesting for you
09:15:27FromDiscord<jtiai> Now given that familiar assembler stuff I was able to understand part of it. So yes I could write my Z80 emulator with macros as well but I'll I use more straightforward approach first to make sure it even works.
09:26:42Oddmongerstring are immutable, even when adressed with a pointer ?
09:27:00PMunchOddmonger, strings aren't immutable..
09:27:38Oddmongeryes my bas, i was testing from a nimscript
09:28:15Oddmongerwith nimscript, this one : https://play.nim-lang.org/#ix=3mnw prints Β« bug mug Β»
09:28:24Oddmongerand not Β« mug mug Β» as expected
09:29:11Oddmongerbut i've read somewhere that nim script had issues with pointers (in fact, it's read-only ptr, a new concept :ΓΎ )
09:29:36FromDiscord<ElegantBeef> Not really a new concept, we have `lent` in the language πŸ˜›
09:32:44Oddmongerhttps://nim-lang.org/docs/destructors.html#lent-type seems intricate (for me)
09:33:32Oddmongeri will learn it next year, when i'm graduated for current newb session
09:35:33Oddmongersink and lent seem to be nim concept (i didn't found a broader explaination on g**gle)
09:37:18Oddmongerbut wait … i remember to have seen Β« sink Β» in Β« programming in lua Β»
09:38:03FromDiscord<haxscramper> I think `sink` is C++ `rvalue`
09:38:09FromDiscord<haxscramper> `&&` references
09:39:51Oddmonger&& ? really ? (boolean and ?)
09:40:02Oddmongeri know & for reference
09:41:13FromDiscord<haxscramper> https://en.cppreference.com/w/cpp/language/reference
09:45:20Oddmongerok it's new to C++11 . I know it's not the place, but i don't understand the difference between a pointer and a simple ref (&) when declaring lvalue (i've used references only in functions parameters, for avoiding the horrible ** )
10:05:29*vicfred quit (Ping timeout: 246 seconds)
10:08:45FromDiscord<Nisha's alt> Has someone written an MC server in Nim yet? Lol
10:18:34FromDiscord<jtiai> In reply to @Hitoshi Shinsou|πŸ’»β­ "Has someone written an": You probably would be the first... πŸ˜„
10:26:56FromDiscord<Nisha's alt> That'd be SO cool-
10:27:01FromDiscord<Nisha's alt> But too much effort lol
10:27:12FromDiscord<Nisha's alt> I'll definitely attempt it once 1.17 comes out, but no promises lol
10:30:54PMunchWait, a complete Nim re-implementation of the Minecraft server. Or simply the front-end bit?
10:37:22FromDiscord<Rika> Likely the former
10:39:30FromDiscord<Nisha's alt> Depends what you mean lol
10:40:56FromDiscord<Nisha's alt> PMunch (unless you're already talking lol)
10:41:25PMunchWhat do you mean by server
10:41:58FromDiscord<Nisha's alt> Like the server software lol
10:42:11PMunchI mean the Minecraft server is quite complex isn't it? Keeping track of all the mobs, block states, and players. You'd basically need to recreate all the rules of the game to write a new server
10:42:35FromDiscord<Nisha's alt> Fair lol
10:42:43PMunchBut on top of that is the interface where you can type commands, manage players, etc. which is a lot easier I'd imagine
10:42:45FromDiscord<Nisha's alt> But I'm looking for more of a minimal implementation
10:43:06FromDiscord<Nisha's alt> That provides the basic functionality like joining and disconnecting from the server lol
10:43:21FromDiscord<Rika> but then is it really minecraft
10:44:02PMunchI think either I'm misunderstanding what you want to do, or you have no idea what a Minecraft server is :P
10:44:30FromDiscord<Rika> or maybe nisha has no idea what a minecraft server is
10:44:33FromDiscord<Rika> oh
10:44:35FromDiscord<Rika> misread
10:44:43FromDiscord<Rika> i thought you said "i have no..."
10:46:06FromDiscord<Nisha's alt> Basically something like https://github.com/Minestom/Minestom but in Nim :p
10:46:31FromDiscord<Nisha's alt> I need the core functionality so i can expand upon it
10:51:35PMunchOh, you actually want to create the whole thing
10:58:09PMunchHmm, looking at Minestom to try and get an idea of how much is done server side in Minecraft
10:58:28PMunchThey have like a goals system for the AI
10:58:43PMunchBut it's not obvious to me if this is a Minecraft concept or a Minestom one
11:01:46FromDiscord<Nisha's alt> In reply to @PMunch "Hmm, looking at Minestom": Alright then, thanks!
11:02:32*hyiltiz quit (Ping timeout: 246 seconds)
11:02:34PMunchHuh?
11:02:49FromDiscord<Rika> maybe misunderstanding
11:04:03FromDiscord<rb3> sent a code paste, see https://paste.rs/ypb
11:04:43FromDiscord<rb3> Like C++ `::thing` or Dlang's `.thing`?
11:04:43FromDiscord<Yardanico> you shadow the global `thing` with this code
11:04:49FromDiscord<Yardanico> in your proc
11:04:50PMunchI think you can do `<module name>.thing`
11:04:56FromDiscord<Yardanico> oh, that might work
11:05:54PMunchYup, it works: https://play.nim-lang.org/#ix=3mnR
11:06:04FromDiscord<rb3> Ah, so let's say a template called in `stuff` that wants to refer to `thing` will need to know the name of the module it expands in?
11:06:28PMunch(The playground stores the Nim code in a file in.nim, so the module name is `in` which turns out to be a keyword, hence the backticks)
11:06:59PMunchYou could use instantiationInfo to get that
11:07:28FromDiscord<rb3> Got it, thanks PMunch. I might make a utility template for this
11:08:36*hyiltiz joined #nim
11:08:36*hyiltiz quit (Changing host)
11:08:37*hyiltiz joined #nim
11:14:59PMunchHmm, not as easy as I thought..
11:15:12PMunchhttps://play.nim-lang.org/#ix=3mnU
11:15:17PMunchNot quite sure why that doesn't work
11:17:21PMunchThis works though: https://play.nim-lang.org/#ix=3mnW
11:18:03*MarderIII quit (Quit: Leaving)
11:18:32FromDiscord<rb3> Ah nice, thanks for this PMunch. Couldn't get mine to work haha
11:33:16FromDiscord<willyboar> can i switch off all outputs when building?
11:34:22FromDiscord<haxscramper> you mean `nimble build` or regular `nim c`?
11:34:44FromDiscord<willyboar> regular nim c or nim js
11:34:57FromDiscord<haxscramper> `--verbosity:0 --hints:off`
11:36:12FromDiscord<willyboar> Thank you @haxscramper
11:45:27FromDiscord<no name fits> Have any of you guys implemented float compare? If yes, can i see?
11:45:45FromDiscord<no name fits> Because i have it working, but my algorithm is so ugly and makes me cry
11:47:37FromDiscord<no name fits> Here is my ugly https://play.nim-lang.org/#ix=3lYR
11:54:07*xet7 quit (Remote host closed the connection)
11:56:07*xet7 joined #nim
11:56:42FromDiscord<Vindaar> @no name fits there is `almostEqual` in the stdlib nowadays: https://nim-lang.github.io/Nim/math.html#almostEqual%2CT%2CT%2CNatural
11:57:21FromDiscord<Vindaar> aside from that I have one that predates the stdlib one here: https://github.com/Vindaar/ggplotnim/blob/master/src/ggplotnim/dataframe/value.nim#L327-L342
12:02:46FromDiscord<no name fits> No way
12:02:51FromDiscord<no name fits> I feel so dumb
12:03:06FromDiscord<no name fits> I could've sworn i looked through the docs
12:04:21FromDiscord<no name fits> Thanks
12:08:30giacowhat's the best way to understand how nim work under the hood and understand better what's happening (find answers on my own) without asking to community? I know there might not be a general answer, but I've not found a "troubleshoot manual" or general tip&tricks when things goes wrong
12:10:35FromDiscord<no name fits> Do you mean the compilation? There is the manual that goes through it step-by-step
12:10:40FromDiscord<no name fits> If that's what you mean?
12:12:18FromDiscord<haxscramper> https://gitlab.com/pmetras/nim0 https://nim-lang.org/docs/intern.html and source code itself
12:12:59FromDiscord<haxscramper> `Nim0` is not exactly related, but since nim is a wirth language it might have some similarities, and the project itself is much smaller
12:13:29FromDiscord<haxscramper> But source code for nim compiler itself is a best reference of course
12:15:14giacono name fits, is there a compilation step-by-step into the manual? I might have missed it
12:15:47giacothanks!
12:27:59FromDiscord<no name fits> Compiler user guide: <https://nim-lang.org/docs/nimc.html>↡Internal docs: <https://nim-lang.org/docs/intern.html>↡Lang manual: <https://nim-lang.org/docs/manual.html>
12:28:24FromDiscord<no name fits> I find the lang manual to be plenty for me
13:01:30FromGitter<dilawar> Is there a way to integrate nim with cmake. I am compiling a C library using cmake and would be cool if I can integrate nim flow into CMake. I can write custom targets but would love to avoid it.
13:11:47FromDiscord<no name fits> something-something `add_custom_command` add nim as a command, run nim as a shell command from CMake
13:12:36FromDiscord<no name fits> You could also do it the other way around, and make Nim execute the CMake
13:12:52FromDiscord<no name fits> But i have no idea how that would work
13:20:45Oddmongeri see : proc `<%`(x, y: int8): bool {...} , and i understand i can use it as : Β« a <% b Β»
13:21:33Oddmongerand so it is, but how can this be possible ? I know the syntax: proc fx(a,b) which can be called like this : a.fx(b)
13:22:10Oddmongerso, <% could be called like this: a.<% (b)
13:22:47Oddmongerbut i don't understand how the working Β« a <% b Β» is possible with the proc definition (or may be a template under the hood ?)
13:25:42FromDiscord<Rika> certain characters in a proc name will make that proc operator-like
13:27:34leorize[m]it's in the manual, compositions of "operator" characters will enable a proc to be called like an operator
13:28:39Oddmongerahhh i was thinking `` was only for using reserved characters, thank you
13:29:00Oddmongervery interesting feature
13:29:20FromGitter<haxscramper> @dilawar I had to do something like that and ended up writing `FindNIM.cmake`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=609935304d0065337e643173]
13:29:31leorize[m]you can use backticks with anything, but there aren't many reasons to do so when you don't have to :p
13:30:28FromGitter<haxscramper> And the cmake file itself (for building nim application that uses bullet C++ library): ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=609935740845c416dcd58ca4]
13:37:12FromDiscord<carpal> hi, is there a way to move specific operations from the cpu to the gpu in nim?
13:37:55Oddmongerthere are bindings for opencl in nimble
13:39:28FromGitter<dilawar> Thanks @haxscramper. Really helpful.
14:04:32FromDiscord<hamidb80> just why??!?! https://media.discordapp.net/attachments/371759389889003532/841314765288898640/unknown.png
14:08:59FromDiscord<hamidb80> https://play.nim-lang.org/#ix=3moL
14:11:41FromDiscord<no name fits> Because a seq is a linked-list if I remember?
14:12:06FromDiscord<haxscramper> Seq is not a linked list
14:12:11FromDiscord<no name fits> I was wrong
14:12:29FromDiscord<Rika> lmao
14:12:30FromDiscord<hamidb80> i pass the same var to those procs
14:12:40FromDiscord<hamidb80> (edit) "the" => ""the" | "var" => "var""
14:12:55FromDiscord<no name fits> In reply to @Rika "lmao": it do be like that sometimes
14:14:01FromDiscord<no name fits> But if I recall they're allocated on the heap regardless of mutability
14:14:22FromDiscord<no name fits> (I better not have that wrong)
14:14:36FromDiscord<no name fits> And heap is slow
14:15:13FromDiscord<haxscramper> It does not matter where it allocated because it the same var
14:15:20FromDiscord<haxscramper> But you iterate in different order
14:15:23FromDiscord<no name fits> Oh right
14:15:35FromDiscord<Rika> lmao.repeat(2)
14:16:02FromDiscord<no name fits> In reply to @Rika "lmao.repeat(2)": One day I'll say something correct... One day
14:18:04*Jesin quit (Ping timeout: 252 seconds)
14:20:18FromDiscord<haxscramper> it looks like `seq` compiles to additional level of indirection https://media.discordapp.net/attachments/371759389889003532/841318733221724170/unknown.png
14:20:45FromDiscord<haxscramper> `s[x]` for openarray vs `(s)->data[x]` for seq
14:21:03FromDiscord<haxscramper> which is strange
14:21:31FromDiscord<haxscramper> Because `openarray` as a parameter is supposed to be an implicit generic IIRC
14:23:21FromDiscord<haxscramper> Now I'm also curious what is going on here
14:28:06FromDiscord<Rika> In reply to @no name fits "One day I'll say": you just did... or did you?
14:35:49FromDiscord<no name fits> In reply to @haxscramper "Now I'm also curious": https://xkcd.com/356/
14:46:40FromGitter<bung87> how to seek file cross platform?
15:02:02FromDiscord<hamidb80> In reply to @haxscramper "Because `openarray` as a": i don't understand anything, but if you could fix it, it's ok πŸ˜„
15:03:03FromDiscord<hamidb80> (edit) "ok" => "fine"
15:06:16FromDiscord<haxscramper> I don't think I can fix this
15:07:02FromDiscord<hamidb80> In reply to @haxscramper "it looks like `seq`": try to compile with `-d:release`
15:07:17FromDiscord<haxscramper> no changes
15:07:41FromDiscord<haxscramper> and it is not related to release/debug node in any way
15:11:41*PMunch quit (Quit: leaving)
15:41:01*fredrikhr joined #nim
15:42:37*xace quit (Ping timeout: 252 seconds)
15:49:08narimiranNimConf 2021 registration deadline is this Sunday! For more details, see: https://forum.nim-lang.org/t/7863
15:59:36FromDiscord<dom96> Keep reminding us. I think it's easy to miss these deadlines πŸ™‚
15:59:46FromDiscord<dom96> Still not sure whether to submit a talk or not
16:06:57FromDiscord<treeform> In reply to @narimiran "NimConf 2021 registration deadline": I missed it, but I could do another talk.
16:07:08narimiran@dom96 is this the part when we say to you "of course, you should submit it"?
16:07:08FromDiscord<treeform> Thanks registered
16:17:35*Jesin joined #nim
16:20:38*tane joined #nim
16:23:30*whitefly joined #nim
16:29:41*narimiran quit (Ping timeout: 240 seconds)
17:19:13FromDiscord<hamidb80> In reply to @haxscramper "and it is not": can we implement something like `openArray` with `concept`s?
17:20:24FromDiscord<haxscramper> Yes, `Indexable[T]` with requirements for existence of items, [] and len should give your the same API
17:20:50FromDiscord<haxscramper> Technically, thought I don't know what state concepts currently are in
17:25:54FromDiscord<Rika> New style concepts are partially implemented
17:35:04Oddmongerwhat are the rules for user defined operators ?
17:35:53Oddmonger`%%` is ok, `%b%` isn't
17:36:14Oddmongerit seems [a-zA-Z] is forbidden
17:39:20FromDiscord<konsumlamm> ye, only symbols
17:44:35Oddmongermaybe i could try ascii art then :)
17:49:55ForumUpdaterBotNew post on r/nim by h234sd: Invisible DB Driver / ORM without a single cool feature [experiment], see https://reddit.com/r/nim/comments/n9bb7a/invisible_db_driver_orm_without_a_single_cool/
17:51:26Oddmongerdo you think it's abusing of nim -> template %[T]( a:T,b:T) :T = a mod b
17:55:34*vicfred joined #nim
17:56:25FromDiscord<haxscramper> if you want you can write own `%`, but I would advise to just use `mod` instead
17:57:06Oddmongerok , i think i stick to mod then
17:57:29Oddmongeryou know how it is, when you find a new shining toy, you want to use it everywhere
17:57:51Oddmongerthinking i have not even began to play with AST and real macros…
18:02:46FromDiscord<hamidb80> me too
18:06:25FromDiscord<Varriount> Did we have a Skrylar here at some point?
18:13:43FromDiscord<Vindaar> @Varriount yep, we did (or still do?)
18:32:00FromDiscord<arnetheduck> @Varriount https://github.com/nim-lang/Nim/issues/17855#issuecomment-837047221 - ↡> it's understood that some people prefer to use result - this warning is not for them (it can be disabled by default).
18:37:17ForumUpdaterBotNew thread by LeFF: VSCode extension?, see https://forum.nim-lang.org/t/7961
18:44:13*Jesin quit (Ping timeout: 240 seconds)
19:16:45*narimiran joined #nim
19:26:00*wasted_youth2 joined #nim
19:26:11FromDiscord<brainproxy> If I have a nim `string` that contains multi-byte utf-8 characters like πŸ₯³ , what is the correct way to have ncurses print it to the screen. If
19:26:32FromDiscord<brainproxy> (edit) "If I have a nim `string` that contains multi-byte utf-8 characters like πŸ₯³ , what is the correct way to have ncurses print it to the screen. If ... " added "I naively do `printw(mystring)` then I get garbage in the terminal"
19:26:40FromDiscord<brainproxy> (edit) "screen." => "screen?"
19:26:43FromDiscord<ElegantBeef> It depends on if the font + terminal emulator supports it
19:28:25FromDiscord<ElegantBeef> For instance top is gnome terminal and bottom is kitty https://media.discordapp.net/attachments/371759389889003532/841396276662894632/unknown.png
19:28:49FromDiscord<brainproxy> https://media.discordapp.net/attachments/371759389889003532/841396375391830080/unknown.png
19:28:56FromDiscord<brainproxy> good point re: font + terminal
19:29:13FromDiscord<brainproxy> mine is iTerm2 on macOS
19:29:55FromDiscord<ElegantBeef> All nim does it output the string, it's up to whatever renders it to get it right
19:31:08FromDiscord<brainproxy> in this pic, I have my nim+ncurses program running and I input πŸ™ƒ https://media.discordapp.net/attachments/371759389889003532/841396955727921182/unknown.png
19:31:16FromDiscord<brainproxy> (edit) "pic," => "screeenshot,"
19:31:41FromDiscord<brainproxy> however, in the logfile for the program, I see the nim code does have the expected string, it's not garbled in the log
19:34:34FromDiscord<ElegantBeef> Hmm seems ncurses has a ncursesw version which supports wide characters
19:35:41FromDiscord<brainproxy> sent a code paste, see https://play.nim-lang.org/#ix=3mqP
19:36:32FromDiscord<brainproxy> ah wait, actually maybe it's linking to one that ships with the OS and I need to be more explicit to use the one installed with `brew`
19:37:02FromDiscord<brainproxy> yep
19:37:07FromDiscord<ElegantBeef> you can try `--passL:lncursesw` but idk if that'd work
19:37:34*rockcavera joined #nim
19:38:00FromDiscord<ElegantBeef> Oh it's looking for `libncurses.dylib` on mac
19:40:30FromDiscord<ElegantBeef> But yea cannot help much more πŸ˜„
19:50:31FromDiscord<Varriount> Anyone know how one would implement something like https://docs.python.org/3/library/functools.html#functools.lru_cache in Nim?
19:52:18FromDiscord<Varriount> @Vindaar Hah, because I just noticed that he and I "crossed paths" in a non-Nim issue a while ago: https://github.com/pyinvoke/invoke/issues/752
19:52:37FromDiscord<Varriount> (edit) "he" => "they"
19:53:42FromDiscord<checkersai> Is it possible to unpack arrays in a similar manner to tuples? I figure it should be possible since the length of arrays is known at compile time
19:54:02FromDiscord<ElegantBeef> I mean each function you add that to would have a table and it'd add to at the end of a calculation it'd check before the calculation
19:54:07FromDiscord<ElegantBeef> Yes there are macros that do it
19:54:13FromDiscord<ElegantBeef> (edit) "it" => "it, hell there are macros that unpack seqs"
19:54:15FromDiscord<checkersai> For example: `var (a,b,c) = [1,2,3]`
19:54:22FromDiscord<brainproxy> sent a code paste, see https://play.nim-lang.org/#ix=3mqQ
19:54:52FromDiscord<ElegantBeef> You cannot change that behaviour checker, but there are macros that allow `(a, b, c) := [1, 2, 3]`
19:55:34FromDiscord<brainproxy> however, even though now I'm (statically) linked to the correct ncurses lib, I still get garbage output
19:56:39FromDiscord<ElegantBeef> @checkersai https://hlaaftana.github.io/assigns/assigns.html#examples
19:57:14FromDiscord<checkersai> Sweet, thanks
19:57:51FromDiscord<checkersai> Also, I'm guessing it's then possible to convert an array type into a tuple type with macros?
19:58:03FromDiscord<ElegantBeef> if you can write the code manuall, you can do it in macros
19:58:09FromDiscord<ElegantBeef> (edit) "manuall," => "manually,"
19:59:32FromDiscord<checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3mqS
19:59:43FromDiscord<checkersai> And I would prefer that it return a tuple so that I can unpack it
20:01:29*kenran joined #nim
20:02:49FromDiscord<ElegantBeef> In reply to @Varriount "Anyone know how one": And yea doesnt seem too complicated with an ordered table, same restriction that all parameters would have to be hashable
20:04:55FromDiscord<ElegantBeef> I might throw together an implementation later, but idk
20:07:45FromDiscord<exelotl> is there a one liner to map over a fixed length array?
20:08:06FromDiscord<ElegantBeef> you mean map over an array and return an array?
20:08:10FromDiscord<exelotl> yeah
20:08:14FromDiscord<Varriount> @ElegantBeef I'm not too puzzled on how to implement a cache, but rather how to easily wrap a function without performance loss.
20:08:23FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3mqX
20:09:03FromDiscord<ElegantBeef> Well do it in a block expr and convert it to an array after πŸ˜›
20:10:36FromDiscord<exelotl> that's a 5 liner ;_;
20:10:48FromDiscord<ElegantBeef> Make a new array `mapIt`
20:11:46*narimiran quit (Ping timeout: 240 seconds)
20:12:12FromDiscord<ElegantBeef> The only way i can see the logic/cache be done is to insert a table check, if it has the key return the value, otherwise do the calculation and if the table is equal to max size remove the first element from the ordered table and insert the new one
20:14:36FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=3mqY
20:20:28FromDiscord<Varriount> In reply to @ElegantBeef "The only way i": Are you replying to me, or exelotl?
20:22:02FromDiscord<exelotl> probably you x)
20:22:27FromDiscord<exelotl> except for the "mapit" thing
20:34:11FromDiscord<Varriount> sent a long message, see http://ix.io/3mr4
20:43:19*Jesin joined #nim
20:44:20*Vladar quit (Quit: Leaving)
20:53:03leorize[m]I don't see how decorators free you from writing a macro
20:56:36*fredrikhr quit (Ping timeout: 260 seconds)
21:12:05FromDiscord<ElegantBeef> I was replying to you
21:12:30FromDiscord<Varriount> In reply to @leorize "I don't see how": They wouldn't, I guess. I guess I just wish there was an easy, frictionless, suitable equivalent in Nim
21:13:53FromDiscord<ElegantBeef> Yea i dont see the issue with pragmas as decorators, it's the same thing to me
21:14:27FromDiscord<ElegantBeef> Some amount of code will replace the proc definition or appended to it
21:16:55*thomasross joined #nim
21:18:19*ronny joined #nim
21:18:34ronnyhi
21:18:56FromDiscord<ElegantBeef> In the case of the cache, it can be a gensym'd name and you can write `clearCache()` and insert the code in the macro to clear it
21:19:27FromDiscord<ElegantBeef> That means the only way to mutate the cache is by calling that, or with the emitted code
21:19:29FromDiscord<ElegantBeef> Hello ronny
21:20:24ronnyim looking for away to have nim declare c structs in a very particular manner, as i'd like to export tem to cpython and hpy in a nice manner
21:20:39FromDiscord<ElegantBeef> `{.exportc.}`?
21:20:41ronnyas far as i can tell of hand, the python integrations for num lack that side
21:21:21ronnyproblem is they need to include stucts from a c header, and i think im m issing the detail here
21:23:00FromDiscord<Varriount> In reply to @ronny "as far as i": In what particular way? Exported name, bit size...?
21:23:11FromDiscord<Varriount> @ronny
21:24:03ronnystructurally what i'd like to do is declare cpython and hpy extension types/methods so specific header structs have to be included, and static data has to be put into the c level
21:26:20*xet7 quit (Remote host closed the connection)
21:27:16ronnyso i'd really like to find any docs on doing something like that, so far i havent, and the python integrations that exist simply dont manage that part as far as i can tell
21:30:22ronnyCurrent what i think i need to be able to integrate hpy/cpython is something like being able to make the resulting c code invoke extra macros, and declare c types in a specific way,
21:30:22ronnyin addition, also it might be nice to have a new kind of type thats "pythongc" instead of ref (and invokes the backends gc helpers/helper macros automatically)
21:30:23*xet7 joined #nim
21:32:00*tane quit (Quit: Leaving)
21:33:09FromDiscord<ElegantBeef> You could use the nim destructors to call the "backend"'s destructors for the object i imagine, though i dont know what you're after for the first part
21:35:14ronnyi want to make tools to declare python classes/methods in nim and have nim shed out c that integrates as well as possible wit the python ecosystem (which would inlclude using the python memory allocation/gc api(
21:35:16FromDiscord<ElegantBeef> Also you can look at https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-codegendecl-pragma for the "declaring structs in a specific way" but without an example i'm uncertain
21:35:52*kenran quit (Quit: leaving)
21:38:23ronnybasically i want to be able to emmit stuff like https://docs.python.org/3/extending/newtypes_tutorial.html#the-basics
21:43:17FromDiscord<ElegantBeef> I'm uncertain if that's possible, so i'll shush
22:31:58FromDiscord<Varriount> It's possible
22:33:59FromDiscord<Varriount> ronny: I'm not 100% clear on how using Python's allocator would work, but you can definitely interface with Python and create types. I think there is at least 1 nimble package that does that.
22:34:56FromDiscord<ElegantBeef> Also i couldnt help myself and implemented the cached procedure calling
22:41:48FromDiscord<ElegantBeef> On the off chance someone is curious on what it looks like https://play.nim-lang.org/#ix=3mrA
23:00:45*xace joined #nim
23:09:13FromGitter<ynfle> @ElegantBeeft, That's really cool! I've have been looking for something like that in nim! Python has lru_cache
23:09:25FromGitter<ynfle> *ElegantBeef
23:09:53FromDiscord<ElegantBeef> Yea that's where it came from, varriount was talking about python's so felt like emulating it
23:12:30FromGitter<ynfle> ```code paste, see link``` ⏎ ⏎ Can someone make sense of this error? [https://gitter.im/nim-lang/Nim?at=6099bddd93ac573bba9720b6]
23:13:41FromDiscord<ElegantBeef> If you're not using `int128` it's probably a compiler error
23:19:35FromGitter<ynfle> https://play.nim-lang.org/#ix=3mrG Here's the code if it makes a difference. I tried doing some interesting overload. Not sure if it's allowed
23:27:01FromDiscord<ElegantBeef> I dont feel like going through each to test which causes the issue πŸ˜„
23:27:19FromGitter<ynfle> You think its a test?
23:29:22FromDiscord<ElegantBeef> Well it's a function call to one of them, and i cannot be arsed to reason which one
23:29:48FromDiscord<ElegantBeef> So if you could minify it to just each function being called that'd be great πŸ˜›
23:48:19FromDiscord<zetashift> sent a code paste, see https://play.nim-lang.org/#ix=3mrN
23:48:21FromDiscord<zetashift> How would I mark f as `noSideEffect`?
23:50:28FromDiscord<checkersai> In reply to @zetashift "How would I mark": To my knowledge you'd have to write `f: proc(s:string): Either {.noSideEffect.}`
23:51:20FromDiscord<checkersai> Because there's no syntax sugar for `func` types and `func` isn't allowed in type descriptions
23:51:50FromDiscord<zetashift> ah that breaks all my existing func signatures
23:52:30FromDiscord<ElegantBeef> I believe that is right and i think there is an RFC or PR out in the wild to allow it
23:52:42FromDiscord<zetashift> I could use a cast pragma to override it and use sugar/funcs
23:52:44FromDiscord<checkersai> It's annoying and I tried to work on that issue but I quickly got lost because I haven't worked on the compiler before
23:52:48FromDiscord<clyybber> In reply to @ElegantBeef "I believe that is": RFC but no PR afaik
23:53:12FromDiscord<checkersai> https://github.com/nim-lang/Nim/issues/11518
23:54:10FromDiscord<checkersai> It'd be super cool if someone actually fixed this
23:54:25FromDiscord<clyybber> I'll take a look tomorrow
23:56:08FromDiscord<ElegantBeef> Oh clyybber you taking orders? πŸ˜›
23:56:19FromDiscord<zetashift> Could `->` even be "overloaded" for func types?
23:56:28FromDiscord<ElegantBeef> ~~Looks at the implict + explict generics failing to compile~~
23:57:32FromDiscord<checkersai> In reply to @zetashift "Could `->` even be": You could write a custom macro
23:58:03FromDiscord<ElegantBeef> I had to try the cache stuff on fib(50) https://media.discordapp.net/attachments/371759389889003532/841464129508081694/unknown.png
23:59:31FromDiscord<zetashift> In reply to @checkersai "You could write a": ah I see
23:59:39FromDiscord<checkersai> I tried to get sugar for func types merged a while back but got rejected, but you can still adapt the code
23:59:39FromDiscord<checkersai> https://github.com/nim-lang/Nim/pull/13948/files