00:52:40 | * | nisstyre quit (Server closed connection) |
00:53:01 | * | nisstyre joined #nim |
01:10:05 | * | moonlit joined #nim |
01:12:23 | * | flouer joined #nim |
01:12:37 | * | moonlit quit (Client Quit) |
01:12:53 | * | flouer quit (Client Quit) |
01:13:11 | * | flouer joined #nim |
01:13:17 | * | flouer_ joined #nim |
01:13:31 | * | flouer quit (Client Quit) |
01:21:44 | FromDiscord | <millymox> In reply to @jmgomez "It is": So you’d say it’s worth learning a framework like happyX and making websites in it? |
01:26:28 | * | redj quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
01:30:22 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4yWy |
01:30:50 | FromDiscord | <Andreas> (edit) "https://play.nim-lang.org/#ix=4yWy" => "https://play.nim-lang.org/#ix=4yWz" |
01:31:14 | FromDiscord | <Elegantbeef> The first could if it was a static int, and used `when` |
01:31:21 | FromDiscord | <Andreas> (edit) "https://play.nim-lang.org/#ix=4yWz" => "https://play.nim-lang.org/#ix=4yWA" |
01:32:05 | FromDiscord | <Elegantbeef> Would suggest the macro i mentioned 😄 |
01:34:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/ZMLrD |
01:36:45 | FromDiscord | <Elegantbeef> But yea that's just a fancy `when i == 8:... elif i == 16: ...` |
01:40:52 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4yWB |
01:41:09 | FromDiscord | <Elegantbeef> Of course not |
01:42:05 | FromDiscord | <Andreas> In reply to @Elegantbeef "Of course not": so i'm demanding the impossible thing, here ? sry is that true ? |
01:42:22 | FromDiscord | <Elegantbeef> Nim is statically type what you're asking for is runtime typing |
01:43:31 | FromDiscord | <Elegantbeef> This stuff is hard cause it's just the antithesis of how most compiled languages work |
01:45:28 | FromDiscord | <Elegantbeef> The type of thing you want is done using a tagged union generally |
01:46:08 | FromDiscord | <Andreas> In reply to @Elegantbeef "Nim is statically type": not quite - fair enough `flow-typing` would help - but thats not what i need. The compiler accepts the concept and i can use 2-4 similar types 'cos they all fit into the concept. The catch-22 is the init, since i can't cast a concept i need to make sure the compiler is happy with the types - and thats the case - but i can't init them ? |
01:46:26 | FromDiscord | <Elegantbeef> I don't even know what you mean |
01:46:33 | FromDiscord | <Elegantbeef> flow-typing isnt expanding type information |
01:47:33 | FromDiscord | <Andreas> In reply to @Elegantbeef "flow-typing isnt expanding type": flow-typing is a runtime-thing - i don't get that far :(() |
01:47:43 | FromDiscord | <Elegantbeef> Flow typing isnt a runtime thing afaik |
01:48:05 | FromDiscord | <Elegantbeef> Flow typing is using static logic to reduce the possible type state |
01:48:16 | FromDiscord | <Elegantbeef> IE checking if a tagged union is of X type |
01:48:22 | FromDiscord | <Elegantbeef> You then know inside that body that it is that type |
01:48:58 | FromDiscord | <Elegantbeef> Flow typing only really works when your types are all pointers like in Java |
01:49:05 | FromDiscord | <Andreas> sure it is - it gives a hint to the runtime, that a the shape of the type has a and b and so one can use it. but nim checks anything at compile-time and in my case the compiler is happy... |
01:49:09 | FromDiscord | <Elegantbeef> Otherwise it's pointless |
01:49:15 | FromDiscord | <Elegantbeef> It's not even a hint |
01:49:24 | FromDiscord | <Elegantbeef> It narrows the type inside of the if statement to a specific type |
01:49:54 | FromDiscord | <Elegantbeef> Regardless though it's unrelated to this problem 😄 |
01:50:04 | FromDiscord | <Elegantbeef> You want to be able to do `myType(size).init()` |
01:50:16 | FromDiscord | <Elegantbeef> The way you do that is to make a tagged union of your type |
01:50:21 | FromDiscord | <Andreas> In reply to @Elegantbeef "It narrows the type": correct, one can do interfaces this way - but its not compile-time-checksd AFAIK |
01:50:26 | FromDiscord | <Elegantbeef> Then have an `init` that takes an init and init's the branch |
01:50:41 | FromDiscord | <Elegantbeef> I mean it's not compile time checked, but it narrows at compile time |
01:51:21 | FromDiscord | <Elegantbeef> The check is still done at runtime cause it has to be, but in Nim you just do `when X is T` and get the same sorta logic without the runtime check cause it has generics 😄 |
01:52:06 | FromDiscord | <Elegantbeef> Flow typing is mostly only sensible when all types can be upcasted to a `Object` or similar like C#/Java do afaict |
01:52:19 | FromDiscord | <Elegantbeef> Not to say Nim's inheritance couldnt use it, but yea |
01:52:35 | FromDiscord | <Elegantbeef> Or Nim's variants couldnt |
01:52:51 | FromDiscord | <Elegantbeef> It's neither here nor there cause it doesnt solve your problem |
01:53:02 | FromDiscord | <Andreas> the simple truth is : my type has one field that varies in size. All the rest is identical - thats why i can't do a variant-type |
01:53:58 | FromDiscord | <Elegantbeef> Why cant you |
01:54:06 | FromDiscord | <Elegantbeef> That field would be an objectvariant |
01:54:20 | FromDiscord | <Elegantbeef> Can you share some of your code? |
01:54:41 | FromDiscord | <Elegantbeef> You seem to have 4 states for that object, so it seems like a fine usage of an object variant |
01:55:54 | FromDiscord | <Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4yWC |
01:56:16 | FromDiscord | <Andreas> (edit) "https://play.nim-lang.org/#ix=4yWC" => "https://play.nim-lang.org/#ix=4yWD" |
01:56:23 | FromDiscord | <Elegantbeef> Right so why cant you use an object variant? |
01:57:18 | FromDiscord | <Andreas> what would the discriminator be ? |
01:57:55 | FromDiscord | <Andreas> (edit) "what would the discriminator be ? ... " added "A additional field, `typesize`" |
01:58:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4yWE |
01:58:57 | FromDiscord | <Elegantbeef> sure if you want you could use an enum and that information |
01:59:27 | FromDiscord | <Elegantbeef> `case size: 0u8..64u8` |
01:59:33 | FromDiscord | <Elegantbeef> Is also valid |
02:52:50 | * | arkanoid quit (Server closed connection) |
02:54:24 | * | arkanoid joined #nim |
04:08:44 | FromDiscord | <user2m> I'm trying to learn how to wrap c libraries with nim (and I also know very little about c) are there any small c libraries that would be easy to wrap? |
04:15:48 | FromDiscord | <millymox> nimcaptcha is coming along 😄 https://media.discordapp.net/attachments/371759389889003532/1122017203080937542/Screenshot_2023-06-23_at_10.15.35_PM.png |
04:31:38 | NimEventer | New Nimble package! mvb - Minimum viable bindings for OpenCV, see https://github.com/tapsterbot/mvb-opencv |
04:46:45 | FromDiscord | <demotomohiro> In reply to @user2m "I'm trying to learn": I wrote C library tutorial for Nimmer:↵https://internet-of-tomohiro.netlify.app/nim/clibrary.en.html↵It contains simple C code. |
04:51:34 | FromDiscord | <spotlightkid> In my experience, the best way to learn programming is to program something that you actually need, so I would pick a library, which helps you with doing something you want to use Nim for.↵(@user2m) |
04:59:23 | FromDiscord | <user2m> In reply to @demotomohiro "I wrote C library": great thank you! |
05:00:01 | FromDiscord | <user2m> In reply to @spotlightkid "In my experience, the": yes I was looking to work with ImageMagick, but that proved a little to difficult at this time |
05:03:08 | FromDiscord | <elamandeep> I'm trying to use choosenim https://media.discordapp.net/attachments/371759389889003532/1122029114359021598/image.png |
05:03:32 | FromDiscord | <elamandeep> (edit) "choosenim" => "choosenim. But unable to use it. need help?" |
05:03:41 | FromDiscord | <elamandeep> (edit) "help?" => "help" |
05:04:34 | FromDiscord | <michaelb.eth> In reply to @millymox "nimcaptcha is coming along": Nim isn't C, consider dropping the prefixes and postfixes |
05:05:31 | FromDiscord | <michaelb.eth> prefix: `stuff_` |
05:06:13 | FromDiscord | <michaelb.eth> before `task`, maintaining diff re: v2 and v3 |
05:06:39 | FromDiscord | <michaelb.eth> postfix: `_proxyless` |
05:07:14 | FromDiscord | <michaelb.eth> In reply to @elamandeep "I'm trying to use": how did you install Nim? |
05:07:42 | FromDiscord | <elamandeep> In reply to @michaelb.eth "how did you install": i downloaded zip of choosenim |
05:08:00 | FromDiscord | <michaelb.eth> sure, np, took another look and realized you'reon Windows |
05:08:09 | FromDiscord | <elamandeep> yes |
05:09:01 | FromDiscord | <bungfro> sent a long message, see http://ix.io/4yX4 |
05:10:29 | FromDiscord | <michaelb.eth> apologies, but when I download/install/use Nim on Windows, I don't use `cmd.exe`, so my advice could be off, but I'm wondering if you missed a step adding a choosenim path to the global Windows environment |
05:10:45 | FromDiscord | <michaelb.eth> In reply to @elamandeep "i downloaded zip of": apologies, but when I download/install/use Nim on Windows, I don't use `cmd.exe`, so my advice could be off, but I'm wondering if you missed a step adding a choosenim path to the global Windows environment |
05:11:04 | FromDiscord | <elamandeep> In reply to @michaelb.eth "apologies, but when I": ok |
05:11:12 | FromDiscord | <elamandeep> i have git bash |
05:11:25 | FromDiscord | <elamandeep> and i generally use gitbash |
05:11:41 | FromDiscord | <elamandeep> (edit) "gitbash" => "git bash" |
05:13:02 | FromDiscord | <Elegantbeef> bungfro object variants |
05:13:04 | FromDiscord | <michaelb.eth> In reply to @elamandeep "i have git bash": git bash is good stuff, but!! it's a somewhat lobotomized MSYS2 installation, so if you're already using git bash, I recommend switching to using a normal MSYS2 installation, with the UCRT64 environment (currently the default anyway) being the way to go:↵https://www.msys2.org/ |
05:13:34 | FromDiscord | <michaelb.eth> (edit) "environment" => "shell/environment" |
05:14:13 | FromDiscord | <elamandeep> i will try that but i'm just trying nim |
05:14:17 | FromDiscord | <michaelb.eth> form within an MSYS2 shell, you can install the compiler toolchain, git, etc., run curl/wget installer for choosenim, great stuff |
05:14:33 | FromDiscord | <elamandeep> (edit) "but i'm just trying nim" => "later" |
05:14:39 | FromDiscord | <michaelb.eth> In reply to @elamandeep "i will try that": I understand |
05:14:50 | FromDiscord | <bungfro> In reply to @Elegantbeef "bungfro object variants": Could you give an example? |
05:15:09 | FromDiscord | <elamandeep> if i do so many things i will be confused how to fix it😅 |
05:15:13 | FromDiscord | <Elegantbeef> Look at the official manual/tutorial |
05:15:16 | FromDiscord | <elamandeep> (edit) "it😅" => "it😅." |
05:15:36 | FromDiscord | <elamandeep> it's path issue right? |
05:15:38 | FromDiscord | <michaelb.eth> In reply to @elamandeep "if i do so": I understand, completely |
05:15:44 | FromDiscord | <michaelb.eth> In reply to @elamandeep "it's path issue right?": yes |
05:16:01 | FromDiscord | <elamandeep> what path should i give?😅 |
05:16:08 | FromDiscord | <elamandeep> i tried to add |
05:18:42 | FromDiscord | <elamandeep> @michaelb.eth still getting same error |
05:18:53 | FromDiscord | <elamandeep> (edit) "@michaelb.eth still getting same error ... " added "even after setting path" |
05:18:54 | FromDiscord | <michaelb.eth> how did you try to add it? |
05:19:31 | FromDiscord | <elamandeep> https://media.discordapp.net/attachments/371759389889003532/1122033238769156186/image.png |
05:19:38 | FromDiscord | <elamandeep> see this |
05:20:04 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yX6 |
05:21:14 | FromDiscord | <elamandeep> In reply to @michaelb.eth "I haven't used git": https://media.discordapp.net/attachments/371759389889003532/1122033671214485556/image.png |
05:21:20 | FromDiscord | <elamandeep> see this |
05:22:01 | FromDiscord | <michaelb.eth> hmm, okay, that's different than how it works with MSYS2; but nevermind that |
05:22:19 | FromDiscord | <michaelb.eth> ah! |
05:23:44 | FromDiscord | <michaelb.eth> In reply to @elamandeep "": Un your screenshot above, you aren't modifying the global path. You should delete the Variable nim you created and modify the Value for Variable Path |
05:23:45 | FromDiscord | <bungfro> sent a long message, see http://ix.io/4yX7 |
05:23:54 | FromDiscord | <michaelb.eth> (edit) "Un" => "In" |
05:24:10 | FromDiscord | <elamandeep> ok |
05:26:28 | FromDiscord | <millymox> In reply to @michaelb.eth "Nim isn't C, consider": Thanks |
05:27:06 | FromDiscord | <elamandeep> In reply to @michaelb.eth "In your screenshot above,": hey my file path is right |
05:27:19 | FromDiscord | <millymox> In reply to @michaelb.eth "Nim isn't C, consider": What do I name some like recap enterprise |
05:28:19 | FromDiscord | <elamandeep> @michaelb.eth `c/choosenim-0.8.4/bin |
05:28:23 | FromDiscord | <elamandeep> (edit) "`c/choosenim-0.8.4/bin" => "`c/choosenim-0.8.4/bin`" |
05:28:39 | FromDiscord | <elamandeep> (edit) "" => "This is my file path" |
05:29:43 | FromDiscord | <michaelb.eth> _starts to shrink away in terror and sleepiness_ |
05:30:54 | FromDiscord | <michaelb.eth> sent a code paste, see https://paste.rs/bmAdi |
05:31:19 | FromDiscord | <michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4yXa" => "https://play.nim-lang.org/#ix=4yX9" |
05:32:42 | FromDiscord | <elamandeep> https://media.discordapp.net/attachments/371759389889003532/1122036559454146560/image.png |
05:33:03 | FromDiscord | <elamandeep> I GOT PATH OF IMBLE |
05:33:18 | FromDiscord | <michaelb.eth> In reply to @michaelb.eth "In your screenshot above,": I could have given bad advice there, given my inexperience with the canonical way of installing Nim on Windows; so just disclosing that I may have incorrectly assumed you didn't understand how to modify the global Windows `Path` variable |
05:34:23 | FromDiscord | <michaelb.eth> In reply to @elamandeep "": can you copy/paste that instead of a screenshot |
05:34:28 | FromDiscord | <michaelb.eth> (edit) "screenshot" => "screenshot?" |
05:35:13 | FromDiscord | <elamandeep> sent a code paste, see https://play.nim-lang.org/#ix=4yXb |
05:36:01 | FromDiscord | <elamandeep> `c/Users/ASUS/.nimble/bin` this one |
05:38:31 | FromDiscord | <elamandeep> i have tried anything on OS level. But soon i will migrate to linux |
05:38:39 | FromDiscord | <elamandeep> (edit) "i have ... tried" added "never" |
05:38:59 | FromDiscord | <elamandeep> (edit) "linux" => "linux😅" |
05:39:31 | FromDiscord | <michaelb.eth> At one point in history there was a Windows OS limit on the number of characters in global env var `Path`. I haven't encountered that limit in awhile (I don't really use Windows), but it was a realy thing and maybe it's playing a role here. |
05:40:14 | FromDiscord | <michaelb.eth> (edit) "realy" => "real" |
05:40:38 | FromDiscord | <elamandeep> then what to do |
05:41:47 | FromDiscord | <elamandeep> (edit) "do" => "do?" |
05:44:17 | * | ntat joined #nim |
05:44:41 | FromDiscord | <michaelb.eth> In reply to @millymox "What do I name": separate modules? |
05:46:23 | FromDiscord | <millymox> In reply to @michaelb.eth "separate modules?": I’m confused lmao, Aren’t they already? |
05:46:46 | FromDiscord | <millymox> Why do I have to make a seperate module to rename it something else? |
05:48:27 | FromDiscord | <michaelb.eth> well the core noun/concept seems to be `task` |
05:49:04 | FromDiscord | <michaelb.eth> keep in mind that Nim is very liberal re: allowing you to override proc/func `task` |
05:49:42 | FromDiscord | <michaelb.eth> so consider breaking up `task`-related procs/func/etc into different modules with different library entrypoints |
05:50:49 | FromDiscord | <millymox> So, like, recaptcha(client, site_key, site_url, version)? |
05:54:09 | FromDiscord | <Elegantbeef> Right then you can do `myModule.recaptcha` |
05:54:20 | FromDiscord | <elamandeep> @michaelb.eth windows installer will work? https://media.discordapp.net/attachments/371759389889003532/1122042000678596628/image.png |
05:54:32 | FromDiscord | <michaelb.eth> sure, maybe something like that, give it a shot! remember you can define enum types, distinct types, and so on, which can be a help for writing overloads of the underlying `task()` |
05:55:36 | FromDiscord | <millymox> In reply to @Elegantbeef "Right then you can": Okay got it! |
05:55:50 | FromDiscord | <michaelb.eth> In reply to @elamandeep "<@383034029135364096> windows installer will": I don't know, and I'm sorry I can't help answer that question at the moment: I don't have a physical or virtual Windows machine handy to experiment with. |
05:55:54 | FromDiscord | <millymox> In reply to @michaelb.eth "sure, maybe something like": Thanks I will give a try, haven’t tried any of these things in nim lmao still so new |
05:56:45 | FromDiscord | <elamandeep> In reply to @michaelb.eth "I don't know, and": after installing windows installer. This i got https://media.discordapp.net/attachments/371759389889003532/1122042608869453865/image.png |
05:57:05 | FromDiscord | <Elegantbeef> You havent finished installing |
05:57:17 | FromDiscord | <Elegantbeef> One day people will not use windows and that'll e a good day |
05:57:18 | FromDiscord | <michaelb.eth> In reply to @elamandeep "after installing windows installer.": looks... promising, press Y |
06:08:46 | FromDiscord | <michaelb.eth> In reply to @Elegantbeef "One day people will": likely to be just a few milliseconds before the 🎺 blows |
06:11:03 | FromDiscord | <elamandeep> In reply to @michaelb.eth "likely to be just": installed successfully https://media.discordapp.net/attachments/371759389889003532/1122046210384080977/image.png |
06:11:16 | FromDiscord | <elamandeep> windows is not for programmer |
06:11:26 | FromDiscord | <elamandeep> (edit) "programmer" => "programmer😞" |
06:14:22 | FromDiscord | <elamandeep> @michaelb.eth how to see location of nim? |
07:06:35 | FromDiscord | <rakgew> @michaelb.eth \: in your terminal on linux you could ask via `which nim` on win it would be `where nim` - if it is in your PATH that is. |
07:24:03 | * | derpydoo quit (Ping timeout: 250 seconds) |
07:26:32 | * | azimut quit (Ping timeout: 240 seconds) |
07:36:50 | NimEventer | New thread by noah: Thoughts on a backend target for bun?, see https://forum.nim-lang.org/t/10297 |
07:42:09 | * | ntat quit (Quit: Leaving) |
08:53:18 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yXI |
08:56:17 | FromDiscord | <Elegantbeef> It strips type information for inheritiance |
08:56:20 | FromDiscord | <Elegantbeef> It's copy fields only |
09:34:29 | FromDiscord | <toma400> sent a code paste, see https://play.nim-lang.org/#ix=4yXV |
09:37:29 | * | mad_toothbrush joined #nim |
09:48:40 | FromDiscord | <Elegantbeef> Stop using regex is the answer |
09:48:40 | FromDiscord | <Elegantbeef> `if l notin Letters + {'_'}:` |
09:55:01 | FromDiscord | <toma400> In reply to @Elegantbeef "`if l notin Letters": Thank you a ton, that worked ❤️ |
09:56:02 | FromDiscord | <Elegantbeef> It's also much faster |
09:56:02 | FromDiscord | <Elegantbeef> regex is awful never reach for it unless you're actually searching |
10:01:25 | FromDiscord | <odexine> “Actually searching”? |
10:01:54 | FromDiscord | <Elegantbeef> Searching a string for a complex pattern that you cannot define beforehand in logic |
10:01:59 | FromDiscord | <Elegantbeef> User facing generally |
10:33:14 | FromDiscord | <Andreas> sent a long message, see http://ix.io/4yY9 |
10:34:38 | FromDiscord | <Andreas> (edit) "http://ix.io/4yY9" => "http://ix.io/4yYa" |
11:46:36 | * | mad_toothbrush quit (Ping timeout: 260 seconds) |
12:25:01 | * | ntat joined #nim |
12:41:19 | * | azimut joined #nim |
12:56:30 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yYF |
12:57:16 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#ix=4yYF" => "https://play.nim-lang.org/#ix=4yYG" |
12:57:21 | FromDiscord | <heysokam> (edit) "https://play.nim-lang.org/#ix=4yYG" => "https://play.nim-lang.org/#ix=4yYH" |
12:58:30 | FromDiscord | <graveflo> you should not need to de-reference |
13:00:51 | FromDiscord | <heysokam> kk ty |
13:18:17 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yYN |
13:22:29 | FromDiscord | <heysokam> In reply to @demotomohiro "How pure pragma work": i see. well explained, thenks!↵is there any practical usage of this feature? |
13:22:55 | FromDiscord | <heysokam> (edit) "usage of" => "application for" |
13:31:29 | FromDiscord | <demotomohiro> Wrapping types in C/C++ library. |
14:02:04 | FromDiscord | <bungfro> In reply to @bungfro ""attempt to redefine: 'channel'"": Bump |
14:03:00 | FromDiscord | <odexine> In reply to @bungfro ""attempt to redefine: 'channel'"": you cannot use the same field name inside object variants |
15:00:49 | FromDiscord | <bungfro> In reply to @odexine "you cannot use the": My original question was how to allow the 'channel' to be one of two types. Is there another way? |
15:00:58 | FromDiscord | <bungfro> (edit) "In reply to @odexine "you cannot use the": My original question was how to allow the 'channel' ... to" added "field" |
15:02:03 | FromDiscord | <odexine> inheritance can be (ab)used to do that, in a way |
15:02:41 | FromDiscord | <bungfro> How? |
15:11:51 | FromDiscord | <bungfro> In reply to @odexine "inheritance can be (ab)used": Would you happen to know how? |
15:11:59 | FromDiscord | <odexine> not really |
15:20:32 | * | azimut quit (Remote host closed the connection) |
15:21:21 | * | PMunch joined #nim |
15:23:54 | * | azimut joined #nim |
15:24:58 | FromDiscord | <millymox> execution of an external compiler program 'clang -c -w -ferror-limit=3 -I/Users/mox/.choosenim/toolchains/nim-1.6.12/lib -I/Users/mox/Desktop/Projects/nim/hello_world -o /Users/mox/.cache/nim/main_d/@m..@s..@s..@[email protected]@[email protected]@slib@[email protected] /Users/mox/.cache/nim/main_d/@m..@s..@s..@[email protected]@[email protected]@slib@[email protected]' failed with exit code 1 |
15:25:04 | FromDiscord | <millymox> https://media.discordapp.net/attachments/371759389889003532/1122185630877749258/Screenshot_2023-06-24_at_9.25.01_AM.png |
15:35:44 | * | azimut quit (Ping timeout: 240 seconds) |
15:44:45 | FromDiscord | <heysokam> Does someone have an example on how to wrap a cpp library with `importcpp`?↵I have wrapped a C one, but wondering how classes and methods are wrapped when they come from cpp instead |
15:45:22 | PMunch | If you have a look at Nim for UE I believe that's the biggest C++ wrapped Nim project |
15:45:24 | FromDiscord | <treeform> In reply to @millymox "Okay great thank you,": It's just my and my friend Guzba. I am just huge Nim fan and a very productive programmer. |
15:45:42 | FromDiscord | <heysokam> In reply to @PMunch "If you have a": good idea ✍️ |
15:46:44 | FromDiscord | <millymox> In reply to @treeform "It's just my and": Well all respect to you my friend the things you've made are great |
15:46:58 | FromDiscord | <heysokam> or not such a good idea. its hella complicated |
15:47:26 | FromDiscord | <heysokam> @pmunch can you think of any alternative that's not so overthetopcomplex? |
15:47:46 | PMunch | Haha, I was afraid that it was a bit complicated |
15:48:07 | PMunch | Not sure really, so many C++ libraries have a C header/interface so it's not all that common to wrap C++ |
15:49:23 | FromDiscord | <heysokam> @jmgomez any tips on wrapping a cpp library?↵i have exp wrapping a C one, but wondering about the specifics for cpp |
15:49:26 | PMunch | Oh by the way user2m, if you're still around you might want to have a look at Futhark for wrapping C libraries. Sure you won't actually learn how to wrap a C library, but unless you want to contribute to the tool you don't really have to know |
15:50:02 | PMunch | Maybe hook up with arkanoid, they're working on adding C++ to Futhark so they've looked into it recently :) |
15:50:47 | FromDiscord | <michaelb.eth> In reply to @millymox "execution of an external": I think you're missing `importc` or something like that, though I could be wrong |
15:51:00 | FromDiscord | <michaelb.eth> iow, I'm not sure you can just supply `header` |
15:51:14 | FromDiscord | <treeform> In reply to @nnsee "as a test, i": I wanted to update 'print' to be thread-safe. I had created 'print' before it was on the -y library name train, so I decided to rename 'print' to 'pretty' and modify everything about it. However, I don't want the code of people who are currently using 'print' to break. Therefore, 'pretty' is the new 'print' with all the thread-safety and API changes. |
15:52:05 | FromDiscord | <treeform> In reply to @graveflo "https://github.com/treeform/jsony https://nim-lang.": I am also working on `taggy` for XML, but it's not ready yet. |
15:52:14 | FromDiscord | <michaelb.eth> In reply to @heysokam "Does someone have an": there's a video of a presentation that one of the participants here gave at a conference |
15:52:19 | FromDiscord | <michaelb.eth> I'll find the link |
15:52:28 | FromDiscord | <michaelb.eth> it looks at some basics of wrapping |
15:52:41 | FromDiscord | <nnsee> In reply to @treeform "I wanted to update": well, pretty causes GC issues for me so 😅 |
15:52:48 | FromDiscord | <millymox> In reply to @michaelb.eth "I think you're missing": hm okay, im trying to learn how to wrap C libraries |
15:53:11 | FromDiscord | <nnsee> still need to work on a minimal repro case for that |
15:53:40 | FromDiscord | <heysokam> In reply to @millymox "": yeah you need `importc: "theSymbolName", header: "blablabla.h"` |
15:54:05 | FromDiscord | <heysokam> also probably need `cdecl` most likely |
15:54:27 | FromDiscord | <nnsee> In reply to @treeform "I wanted to update": but, if you like investigating, this is the commit just before replacing pretty with print, and has the GC issues https://git.dog/xx/fastcube/src/commit/18f333fa995288a6a97d25cec750f08fc6daed38 |
15:54:45 | PMunch | @millymox, have you checked out my article on the subject? |
15:54:55 | PMunch | https://peterme.net/wrapping-c-libraries-in-nim.html |
15:55:01 | FromDiscord | <michaelb.eth> In reply to @heysokam "Does someone have an": in the later parts of the video deech explores c++ interop, might be helpful for getting started: https://www.youtube.com/watch?v=d2VRuZo2pdA |
15:55:11 | FromDiscord | <heysokam> ty |
15:55:29 | FromDiscord | <treeform> In reply to @millymox "Well all respect to": Thanks! We also made some vids: https://www.youtube.com/channel/UC1r0r_fciKYgF5cqC6rwdgw and there is a list of all of our libs that we currently support: https://github.com/treeform/hobby |
15:55:39 | FromDiscord | <millymox> In reply to @heysokam "yeah you need `importc:": Alright got it |
15:55:52 | FromDiscord | <millymox> In reply to @PMunch "<@1004399071848583228>, have you checked": No i have not will do now thank you!, Will this work on macos? |
15:56:04 | PMunch | @millymox, sure, why wouldn't it? |
15:56:20 | FromDiscord | <millymox> In reply to @PMunch "<@1004399071848583228>, sure, why wouldn't": curious |
15:56:39 | PMunch | It should work on anything Clang can compile |
15:57:59 | FromDiscord | <michaelb.eth> the only thing that might come up on macos is if you installed some C lib with brew or macports and the tool put it in a place that won't collide with version of the same library that Apple ships with macOS or Xcode |
15:58:09 | FromDiscord | <michaelb.eth> brew calls that "keg only" |
15:58:40 | FromDiscord | <heysokam> ugg, ok i will just use futhark for the C interface. what a mess 😔 |
15:58:43 | FromDiscord | <michaelb.eth> in any case, for those you'd need to use `--passL` and/or `--passC` with the nim compiler to point it to the directory where the headers and libs are |
15:59:00 | FromDiscord | <millymox> In reply to @michaelb.eth "the only thing that": hmmmm |
15:59:34 | FromDiscord | <michaelb.eth> brew is good about telling you what flags you need (I'm less experienced with macports, but it probably does also) |
16:00:36 | FromDiscord | <heysokam> @millymox both https://github.com/heysokam/wgpu and https://github.com/heysokam/nglfw have mac support in them, and they are C wrappers, if you need to have some reference |
16:01:18 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yZE |
16:01:49 | FromDiscord | <heysokam> @millymox better links to the relevant files, sorry:↵https://github.com/heysokam/wgpu/blob/master/src/wgpu/compile.nim↵https://github.com/heysokam/nglfw/blob/master/src/nglfw/compile.nim |
16:02:20 | FromDiscord | <millymox> In reply to @heysokam "<@1004399071848583228> better links to": Thanks a lot i will take a look |
16:02:50 | FromDiscord | <heysokam> basically, you have to write a tiny compiler configuration in the nim file, for whatever requirements the C library has |
16:03:45 | FromDiscord | <heysokam> if you link statically, the setup is more complex, because it builds the code too↵but if you link dynamically, its much simpler, like you can see here with nimassimp https://github.com/beef331/nimassimp/blob/ccdf8aa1483493dc47e19216baa8a9f2d33e9421/src/assimp.nim#L25-L30 |
16:08:51 | FromDiscord | <treeform> In reply to @heysokam "basically, you have to": Do you think it would be hard to make windy work with webGPU? |
16:12:14 | FromDiscord | <heysokam> In reply to @treeform "Do you think it": you just need to provide a way to create a native surface. no idea how that's done 🤷♂️ |
16:13:01 | FromDiscord | <heysokam> @treeform https://github.com/gfx-rs/wgpu-native/blob/6f95ce3fc1cd8829f23401e98967112f00f940c2/examples/triangle/main.c#L147-L232 |
16:19:09 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4yZJ |
16:19:18 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4yZJ |
16:19:39 | FromDiscord | <user2m> sent a code paste, see https://play.nim-lang.org/#ix=4yZK |
16:24:03 | PMunch | Replace expr with untyped I believe |
16:24:39 | FromDiscord | <heysokam> @pmunch what was the option for futhark to output prettier output? |
16:24:58 | PMunch | Hmm, let me have a look in the docs |
16:25:13 | PMunch | nodeclguards is the one |
16:26:11 | FromDiscord | <heysokam> kk ty |
16:26:17 | FromDiscord | <heysokam> couldn't find it searching on disc |
16:26:19 | FromDiscord | <treeform> In reply to @heysokam "<@107140179025735680> https://github.com/gfx-rs/wgp": Wow that does not look that hard. |
16:26:43 | FromDiscord | <heysokam> In reply to @treeform "Wow that does not": yeah definitely not. its all that wants, native surface and the rest is handled by the api |
16:26:55 | PMunch | @heysokam, try searching the Futhark README for readability :) |
16:27:20 | FromDiscord | <heysokam> ahhh readability was the key to search for. i tried a few things but couldn't find anything relevant. zenks |
16:27:42 | PMunch | No problem, if you have another keyword I could throw in there I'll consider it |
16:28:08 | FromDiscord | <heysokam> `pretty` is one |
16:28:10 | NimEventer | New post on r/nim by 4runninglife: How do you convert a Datamancer dataframe to a CSV?, see https://reddit.com/r/nim/comments/14hx569/how_do_you_convert_a_datamancer_dataframe_to_a_csv/ |
16:28:33 | FromDiscord | <heysokam> `pretty`, `prettier output` or similar, thats what i was searching for |
16:28:58 | PMunch | Ah right, sounds like a good one to add |
16:29:07 | FromDiscord | <heysokam> can the defines be declared inside the .nim file, or only at compile time? |
16:29:27 | PMunch | They are standard Nim `-d:` defines |
16:29:38 | FromDiscord | <heysokam> so only on compile i guess |
16:29:38 | PMunch | So you can define them anywhere those can be defined |
16:29:59 | PMunch | Well Futhark only does work on compile-time, so setting it at runtime wouldn't do much.. |
16:30:12 | FromDiscord | <spotlightkid> Wouldn't `smelly` be a better name? 😛 I don't touch XMl unless I have too.↵(@treeform) |
16:30:26 | FromDiscord | <heysokam> lul |
16:39:35 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yZS |
16:39:42 | FromDiscord | <treeform> In reply to @spotlightkid "Wouldn't `smelly` be a": Great idea! I don't like XML. |
16:41:41 | PMunch | @heysokam, of course |
16:42:01 | PMunch | Read the section on import paths |
16:42:48 | PMunch | Basically the definition isn't found in any of your defined `path` elements |
16:44:14 | PMunch | So Futhark doesn't generate anything for it. But in order to make the wrappers work in creates these "opaque type" definitions so that pointers to elements can still work |
16:47:13 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yZV |
16:47:28 | FromDiscord | <heysokam> go to definition gets me nowhere, it must be coming from cpp |
16:49:11 | FromDiscord | <pmunch> Quite possibly. Do you need access to the data in that object? |
16:49:18 | FromDiscord | <heysokam> yep |
16:49:31 | FromDiscord | <heysokam> its not an opaque, it contains everything needed |
16:49:39 | FromDiscord | <heysokam> (edit) "its not an opaque, it contains everything needed ... " added "for working with the output data" |
16:49:44 | FromDiscord | <pmunch> Hmm, then it should be available from C as well |
16:49:59 | FromDiscord | <heysokam> yeah, but i dont know how to get it from futhark |
16:50:40 | FromDiscord | <pmunch> It should just be about giving it the right path. And potentially pass some switches if the library requires it |
16:50:46 | FromDiscord | <heysokam> also, how do renames work? im saying `rename aiScene, SceneTest` and its not changing anything 🤔 |
16:51:14 | FromDiscord | <pmunch> It's name is structaiscene |
16:51:24 | FromDiscord | <pmunch> (edit) "It's" => "Its" |
16:51:34 | FromDiscord | <heysokam> oh the original is the resulting nim name? |
16:52:14 | FromDiscord | <heysokam> nope, still nothing |
16:52:34 | FromDiscord | <heysokam> are they quoted or unquoted? the docs just says "<thing>" and its not clear |
16:52:46 | FromDiscord | <heysokam> (edit) ""<thing>"" => "`<thing>`" |
16:53:41 | FromDiscord | <pmunch> Sorry I have to run to the store and cook dinner. Won't be back for a while.. Try looking at some other wrapped library |
16:56:00 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yZX |
17:07:20 | * | azimut joined #nim |
17:47:13 | * | rapcavera joined #nim |
17:50:17 | * | koltrast quit (Server closed connection) |
17:50:36 | * | koltrast joined #nim |
17:52:46 | FromDiscord | <Elegantbeef> @Andreas\: no problem I tend to have that effect on people |
18:29:07 | * | rapcavera quit (Quit: windows sucks bad) |
18:57:40 | FromDiscord | <mratsim> In reply to @treeform "Great idea! I don't": Who does? |
18:58:33 | * | Guest45 joined #nim |
18:58:33 | * | Guest45 quit (Client Quit) |
19:01:00 | FromDiscord | <treeform> I am sure there are XML fans, why is it everywhere! |
19:29:50 | FromDiscord | <bungfro> In reply to @bungfro "My original question was": Anyone know how this would be done? I don't really see anything on the docs. |
19:34:36 | FromDiscord | <michaelb.eth> In reply to @bungfro "Anyone know how this": you want two different object types that have a field of the same name but different types? |
19:34:41 | FromDiscord | <Elegantbeef> I think people are accidently using html as a serialisation format!↵(@treeform) |
19:37:02 | FromDiscord | <graveflo> In reply to @bungfro "Anyone know how this": type variant, generic object or inheritance |
19:37:25 | FromDiscord | <Elegantbeef> Nim is statically typed, branched types require branched logic |
19:37:32 | FromDiscord | <Elegantbeef> Also grave nice PR 😄 |
19:37:41 | FromDiscord | <graveflo> I'm trying LOL |
19:37:47 | FromDiscord | <graveflo> its still broken af |
19:38:17 | FromDiscord | <bungfro> In reply to @michaelb.eth "you want two different": Yeah, so I have↵↵Object:↵ field: Type1 or Type2 |
19:38:26 | FromDiscord | <Elegantbeef> That doesnt work |
19:38:33 | FromDiscord | <Elegantbeef> `Type1 or Type2` is a generic constraint |
19:38:36 | FromDiscord | <Elegantbeef> use an object variant |
19:38:48 | FromDiscord | <Elegantbeef> or https://github.com/alaviss/union |
19:39:21 | FromDiscord | <bungfro> I don't actually use `or` I just want it to be able to be either one of the types. I'll look at the link you sent. |
19:39:47 | FromDiscord | <Elegantbeef> Well I've told you to use an object variant there is no way in a statically typed language like Nim to have a field refer to two types |
19:40:29 | FromDiscord | <Elegantbeef> Even in those pesky Rust style 'adt's you need to have deliminted logic |
19:40:35 | FromDiscord | <Elegantbeef> delimited\ |
19:41:01 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4z0w |
19:41:22 | FromDiscord | <Elegantbeef> accidental colon |
19:41:37 | FromDiscord | <michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4z0w" => "https://play.nim-lang.org/#ix=4z0y" |
19:43:43 | FromDiscord | <Elegantbeef> Man vcpkg is silly, I was all happy cause it lists a bunch of different platforms that it has assimp for, but it doesnt cross compile to any of them ... so it does nothing useful for someone using linux |
20:02:42 | FromDiscord | <millymox> sent a code paste, see https://play.nim-lang.org/#ix=4z0G |
20:04:44 | FromDiscord | <Elegantbeef> Time to use a generic |
20:05:03 | FromDiscord | <millymox> enlighten me Elegantbeef |
20:06:01 | FromDiscord | <Elegantbeef> Hard to say I just said use a generic |
20:06:29 | FromDiscord | <Elegantbeef> You're providing code that is convoluted |
20:10:16 | FromDiscord | <graveflo> design problems are not easily advisable without knowing the intentions of a project. People can give you tools but you have to use them. Here is a tool that is probably not the best one but its so general that I can say it will work in this case despite it's ill fit. Make `Task` a new root object with the `inheritable` pragma and then make two sub classes of `Task` inheriting from it. Then you can use the root object you created to have a da |
20:22:49 | FromDiscord | <heysokam> silly question: `ptr ptr SomeType` is a legal type, right? |
20:22:58 | FromDiscord | <Elegantbeef> Of course |
20:23:04 | FromDiscord | <heysokam> kk ty |
20:23:08 | FromDiscord | <Elegantbeef> Generally pointless as you likely want `var ptr T` |
20:23:24 | FromDiscord | <heysokam> its an element of a struct |
20:23:45 | FromDiscord | <Elegantbeef> Right the rare case it's not pointless |
20:24:34 | * | ntat quit (Quit: Leaving) |
20:36:08 | PMunch | @heysokam, hmm, a visibility attribute inside a struct? |
20:44:11 | FromDiscord | <heysokam> idk, i wrapped it all manually. i was wasting time. took the preexisting implementation and did a manual pass adding what was missing, and checking what was there 🤷♂️ |
20:44:59 | PMunch | Hmm, looking at assimp I'm not sure if it is even valid C.. |
20:45:00 | FromDiscord | <heysokam> the idea was to save time with futhark, but i was debugging issues that i didn't need to, so manual/tedious work ended up being more reliable |
20:45:25 | FromDiscord | <heysokam> yeah, the C api is a bit of a mess |
20:45:28 | PMunch | For a one shot thing, sure. But good look repeating it if they come out with another version.. |
20:45:50 | PMunch | They seem to add a `__declspec(dllexport)` to a struct.. |
20:45:54 | FromDiscord | <heysokam> i couldn't even rename things, so... |
20:46:32 | FromDiscord | <heysokam> i figure there must be a way, but seeing that i couldn't even do the basics like that, i just went the manual way |
20:46:34 | PMunch | That is weird |
20:47:06 | FromDiscord | <heysokam> it has worked well for other stuff, but seems like it crashes a lot with this lib for some reason |
20:56:20 | PMunch | Hmm, I figured out the naming issue |
20:57:22 | PMunch | It had to be `struct_aiscene` |
20:57:29 | FromDiscord | <yandall> Hi guys, quick question. Is possible to define an object like this? |
20:58:37 | FromDiscord | <yandall> sent a code paste, see https://play.nim-lang.org/#ix=4z0M |
20:59:11 | PMunch | Not inline like that |
20:59:19 | PMunch | You could of course use a tuple |
20:59:23 | PMunch | But an object needs a name |
21:00:41 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4z0O |
21:01:56 | FromDiscord | <yandall> Thanks |
21:04:51 | PMunch | @heysokam, do you have the code for your Futhark attempt? |
21:05:10 | PMunch | I'd like to see what's going on |
21:15:26 | FromDiscord | <heysokam> i deleted it 😔 |
21:15:41 | FromDiscord | <heysokam> but it was mostly like the example |
21:16:03 | FromDiscord | <heysokam> i was importing cimport.h... and when i added scene.h it crashed |
21:16:20 | PMunch | cimport.h? |
21:20:20 | FromDiscord | <heysokam> yeah, from assimp |
21:21:00 | FromDiscord | <heysokam> https://github.com/assimp/assimp/tree/master/include/assimp |
21:21:03 | PMunch | Ah, yes now I got the issue |
21:21:23 | FromDiscord | <heysokam> aka: https://github.com/assimp/assimp/blob/master/include/assimp/cimport.h |
21:29:20 | * | beholders_eye quit (Quit: WeeChat 3.6) |
21:32:55 | PMunch | Okay, try Futhark HEAD, it should work now |
21:34:43 | PMunch | Spits out this definition for aiscene: http://ix.io/4z0X |
21:34:48 | PMunch | @heysokam ^ |
21:38:15 | FromDiscord | <heysokam> its almost done. will try if they happen to make some release that breaks everything or something |
21:38:32 | FromDiscord | <heysokam> or for the next lib that I need to wrap |
21:38:58 | PMunch | http://ix.io/4z0Z <- Just in case you want to try it out |
21:40:37 | FromDiscord | <heysokam> zenks 🙂 |
22:15:03 | * | xaltsc joined #nim |
22:19:33 | * | PMunch quit (Quit: leaving) |
22:28:43 | * | xet7 joined #nim |
22:43:05 | FromDiscord | <takko_the_boss> "Ass Imp" is what I opened this chat to. Amazing. |
23:07:06 | FromDiscord | <bungfro> sent a code paste, see https://play.nim-lang.org/#ix=4z1e |
23:07:27 | FromDiscord | <bungfro> Theres a bunch more that spammed the console, that's just the first one. |
23:07:38 | FromDiscord | <Elegantbeef> read the error |
23:07:53 | FromDiscord | <Elegantbeef> "mismatch at position 1" that means you gave it a `Embed` but it wanted `string` |
23:11:17 | FromDiscord | <bungfro> sent a code paste, see https://play.nim-lang.org/#ix=4z1g |
23:12:42 | FromDiscord | <Elegantbeef> do you not have `std/json` imported? |
23:13:48 | FromDiscord | <bungfro> I do |
23:14:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4z1j |
23:15:51 | FromDiscord | <bungfro> Same error |
23:15:59 | FromDiscord | <Elegantbeef> Well read the error |
23:18:25 | FromDiscord | <Elegantbeef> The condescension is due to you not sharing the error |
23:23:24 | FromDiscord | <bungfro> It's the same error that I sent the first time |
23:23:32 | FromDiscord | <Elegantbeef> It clearly isnt |
23:24:35 | FromDiscord | <Elegantbeef> `formatstr, a: string): string` is from strutils |
23:28:17 | FromDiscord | <bungfro> sent a code paste, see https://play.nim-lang.org/#ix=4z1m |
23:28:47 | FromDiscord | <Andreas> sent a long message, see http://ix.io/4z1n |
23:35:49 | FromDiscord | <Elegantbeef> What is the type of `embed` |
23:38:59 | FromDiscord | <bungfro> sent a code paste, see https://play.nim-lang.org/#ix=4z1s |
23:39:21 | FromDiscord | <Elegantbeef> Doesnt that mean you should use `%` |
23:40:57 | FromDiscord | <bungfro> Tried that already, doesn't work. Brings back the exact same error. |
23:42:47 | termer | How would you make a const array of uint8? |
23:42:49 | * | derpydoo joined #nim |
23:43:10 | FromDiscord | <Elegantbeef> \`const a = [0u8, 2, 3, 4, 5, 6, 7, ...] |
23:43:17 | termer | oh, I have to cast the first one |
23:43:21 | termer | const pixmapX: array[1, uint8] = [0] |
23:43:23 | termer | I was doing this |
23:46:46 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4z1u |
23:47:31 | FromDiscord | <heysokam> c2nim said `ptr ptr`, but the original wrapper im using as reference used `ptr UncheckedArray[ptr ]` |
23:47:59 | FromDiscord | <demotomohiro> It depends on whats `mskeleton` means. |
23:48:31 | FromDiscord | <heysokam> it believe its a pointer to an array of skeleton data |
23:50:29 | FromDiscord | <demotomohiro> Then, `ptr ptr UnckeckedArray[Skeleton]`. |
23:51:17 | FromDiscord | <heysokam> the rest of the lib that was mapped before says `ptr UncheckedArray[ptr ...]`... why ptr ptr array? 🤔 |
23:52:21 | FromDiscord | <heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4z1w |
23:52:37 | FromDiscord | <heysokam> im just confused because c2nim said ptr ptr, but don't really understand the difference |
23:58:52 | FromDiscord | <demotomohiro> `SomeType pdata;` in C can be `ptr Sometype` or `ptr UnckeckeArray[SomeType]` become `SomeType pdata;` can points to single value or array. |