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:52 | FromDiscord | <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:17 | FromDiscord | <Elegantbeef> write a json hook for that object then do something special for that field |
01:22:21 | FromDiscord | <huantian> would I then have to implement the rest of the parsing myself? |
01:22:38 | FromDiscord | <huantian> or is there a way to borrow it |
01:23:07 | FromDiscord | <Elegantbeef> You can just call the hook manually, or atleast should be able to |
01:24:07 | FromDiscord | <huantian> then it turns into a recursive function since the overload matches the more specific hook that I'm definig |
01:24:16 | FromDiscord | <huantian> at least that's what I think it does |
01:25:26 | FromDiscord | <Elegantbeef> What's your code? |
01:26:32 | FromDiscord | <huantian> sent a code paste, see https://play.nim-lang.org/#ix=3R7Z |
01:26:55 | FromDiscord | <Elegantbeef> Well yea who said to call this object's proc?! |
01:27:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R80 |
01:29:53 | FromDiscord | <huantian> ah that makes a lot more sense |
01:30:06 | FromDiscord | <huantian> thanks 🙏 |
01:30:24 | FromDiscord | <Elegantbeef> Personally i'd say to make a distinct type for the field |
01:30:32 | FromDiscord | <Elegantbeef> This way you dont need your own hook for the object |
01:32:12 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R81 |
01:57:11 | FromDiscord | <kalbhairab> Can we include units of measure in nim |
01:57:25 | FromDiscord | <Rika> sure why not |
01:57:32 | FromDiscord | <Rika> what do you mean exactly though |
01:57:44 | FromDiscord | <kalbhairab> See fsharp |
01:57:50 | FromDiscord | <kalbhairab> Units of measure |
01:57:51 | FromDiscord | <Elegantbeef> https://github.com/SciNim/Measuremancer#other-distinct-data-types |
01:58:26 | FromDiscord | <Rika> does it have nonunicode ops too? |
01:58:37 | FromDiscord | <Elegantbeef> Sorry it's unchained https://github.com/SciNim/Unchained |
01:59:31 | FromDiscord | <ynfle> Great and mind boggling implementation |
01:59:36 | FromDiscord | <Rika> mind boggling? |
01:59:37 | FromDiscord | <ynfle> (edit) "Great ... and" added "library" |
01:59:58 | FromDiscord | <ynfle> Have you taken a look at the implementation? |
02:00:01 | FromDiscord | <kalbhairab> Very great than fsharp |
02:04:00 | FromDiscord | <kalbhairab> Strformat should be core library |
02:04:33 | FromDiscord | <Rika> ? it is part of the stdlib |
02:04:43 | FromDiscord | <Elegantbeef> I think they mean it should be auto imported |
02:04:53 | FromDiscord | <Elegantbeef> Which i say, you can always add that to your project config, or your global config |
02:05:02 | FromDiscord | <Elegantbeef> The latter is going to be more error prone |
02:05:11 | FromDiscord | <kalbhairab> Yes |
02:05:19 | FromDiscord | <kalbhairab> I am saying that |
02:05:26 | FromDiscord | <kalbhairab> Auto imported |
02:05:42 | FromDiscord | <Elegantbeef> The core nim devs presently think the system library is to big, so it's going to get smaller in time |
02:05:54 | FromDiscord | <Elegantbeef> Modules exist and should be used |
02:06:04 | FromDiscord | <kalbhairab> "{person.name} is " |
02:06:07 | FromDiscord | <Elegantbeef> Just cause it's easier to auto import doesnt mean it should be |
02:06:14 | FromDiscord | <kalbhairab> Ohh |
02:06:17 | FromDiscord | <kalbhairab> Why |
02:06:50 | FromDiscord | <Elegantbeef> Cause it pollutes the namespace, and it fails to follow proper module conventions |
02:07:01 | FromDiscord | <Elegantbeef> You the modules you need, all modules available |
02:07:03 | FromDiscord | <Rika> it doesnt really pollute the namespace here |
02:07:08 | FromDiscord | <Elegantbeef> not all modules available\ |
02:07:19 | FromDiscord | <Elegantbeef> I'm talking about generally |
02:08:59 | FromDiscord | <kalbhairab> Ohh |
02:10:25 | FromDiscord | <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:45 | FromDiscord | <kalbhairab> Ohh |
02:11:41 | FromDiscord | <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:19 | FromDiscord | <kalbhairab> I am not expert in programming |
02:12:30 | FromDiscord | <kalbhairab> I am civil engineer |
02:12:49 | FromDiscord | <kalbhairab> I think there should be design for syntax |
02:13:01 | FromDiscord | <Elegantbeef> I'm not an expert either |
02:13:07 | FromDiscord | <Elegantbeef> I'm a self taught numpty |
02:13:24 | FromDiscord | <kalbhairab> Ohh |
02:13:26 | FromDiscord | <kalbhairab> Same |
02:13:29 | FromDiscord | <kalbhairab> 😃 |
02:15:22 | FromDiscord | <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:38 | FromDiscord | <kalbhairab> I elegantbeef and rika can we talk in off topic? |
02:15:49 | FromDiscord | <Elegantbeef> There's a chance we could |
02:15:59 | FromDiscord | <Rika> why? |
02:16:03 | FromDiscord | <Elegantbeef> Presently this is still nim related |
02:16:10 | FromDiscord | <kalbhairab> Ohh |
02:16:19 | FromDiscord | <Elegantbeef> You like those three letter |
02:16:22 | FromDiscord | <Elegantbeef> letters\ |
02:16:37 | FromDiscord | <kalbhairab> Once i got kicked from flutter so 😃 |
02:16:56 | FromDiscord | <kalbhairab> I have posted one pic to 3 chat rooms |
02:17:08 | FromDiscord | <kalbhairab> They kicked without warning |
02:18:03 | FromDiscord | <kalbhairab> In reply to @Elegantbeef "You like those three": ??? |
02:18:36 | FromDiscord | <Elegantbeef> Ohh |
02:18:47 | FromDiscord | <kalbhairab> Haha |
02:19:07 | FromDiscord | <kalbhairab> Is there any graphics library for nim? |
02:19:12 | FromDiscord | <Rika> a lot |
02:19:28 | FromDiscord | <kalbhairab> Thats bcz of fb chat |
02:41:53 | * | ltriant_ quit (Ping timeout: 252 seconds) |
02:47:57 | FromDiscord | <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:00 | FromDiscord | <huantian> sent a code paste, see https://paste.rs/Am5 |
03:10:49 | FromDiscord | <huantian> I suppose the distinct method is the best |
03:11:48 | FromDiscord | <Elegantbeef> Well call the jsony method instead of `parseHook` |
03:14:44 | * | arkurious quit (Quit: Leaving) |
03:15:15 | FromDiscord | <Elegantbeef> Ah I guess nevermind |
03:15:58 | FromDiscord | <huantian> I could just copy paste a bunch of stuff :P |
03:54:12 | FromDiscord | <retkid> There’s not enough audio libraries |
03:54:42 | FromDiscord | <retkid> Well there’s none |
03:54:58 | FromDiscord | <Elegantbeef> There are audio libraries |
03:55:21 | FromDiscord | <retkid> Not on the awesome list |
03:55:39 | FromDiscord | <retkid> Omni is less of an audio manipulation library and more of a sound library |
03:55:42 | FromDiscord | <Elegantbeef> https://nimble.directory/search?query=audio |
03:56:43 | FromDiscord | <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:09 | FromDiscord | <Elegantbeef> https://github.com/jiro4989/wave also seems to exist |
04:01:25 | FromDiscord | <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:32 | FromDiscord | <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:54 | FromDiscord | <Elegantbeef> No clue |
04:12:01 | FromDiscord | <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:40 | FromDiscord | <retkid> In reply to @congusbongus "isn't amplitude just data": yes |
05:04:48 | FromDiscord | <retkid> but you cant get the data |
05:04:50 | FromDiscord | <retkid> so fuck it?\ |
05:04:52 | FromDiscord | <retkid> (edit) "it?\" => "it?" |
05:05:08 | FromDiscord | <retkid> its literally just the 16 bit value / 2^16 |
05:33:56 | * | girvo joined #nim |
05:37:24 | FromDiscord | <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:31 | NimEventer | New 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:21 | FromDiscord | <sOkam!> sent a long message, see http://ix.io/3R8F |
06:09:58 | FromDiscord | <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:18 | FromDiscord | <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:44 | FromDiscord | <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:28 | FromDiscord | <demotomohiro> If you use only a few functions/types in large C code, write binding manually that only import what you use. |
06:45:48 | FromDiscord | <Elegantbeef> I think nimterop and futhark require the user have libclang on their pc or similar |
06:55:37 | FromDiscord | <geekrelief> In reply to @Elegantbeef "I think nimterop and": Nimterop only requires gcc. Futhark needs libclang |
06:56:17 | FromDiscord | <Elegantbeef> Ah my bad |
07:04:33 | FromDiscord | <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:57 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> Someone clearly talking about the quake engine |
07:07:18 | FromDiscord | <sOkam!> yep |
07:07:41 | FromDiscord | <Elegantbeef> Well then the best thing to do is wrap what you need as you need it |
07:08:03 | FromDiscord | <Elegantbeef> So use c2nim + hand wrapped stuff |
07:08:28 | FromDiscord | <sOkam!> i see |
07:08:31 | FromDiscord | <Elegantbeef> I think things like nimterop/futhark would be more annoying for something like this, i could be wrong though |
07:08:58 | FromDiscord | <sOkam!> should I use nimline/cinterop as the projects suggest, just to get the code up and compiling? |
07:09:11 | FromDiscord | <sOkam!> or just straight to c2nim+manual? |
07:12:03 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> I havent used them ever so no clue how effective they are for large apis like this |
07:12:46 | FromDiscord | <sOkam!> kk |
07:15:13 | FromDiscord | <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:37 | FromDiscord | <sOkam!> nimterop is more akin to futhark? or are cinterop and nimterop the same type of tool? |
07:15:45 | FromDiscord | <Elegantbeef> I never have heard of cinterop before |
07:15:54 | FromDiscord | <sOkam!> https://github.com/n0bra1n3r/cinterop |
07:16:39 | FromDiscord | <sOkam!> this paragraph was the source of my questions, basically https://media.discordapp.net/attachments/371759389889003532/948478930548064266/unknown.png |
07:17:45 | FromDiscord | <sOkam!> the other one of my doubts was this: https://github.com/sinkingsugar/nimline |
07:18:35 | FromDiscord | <sOkam!> but you guys were sending me to wrappers/bindings, so not sure if these tools could change the answer |
07:19:31 | FromDiscord | <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:44 | FromDiscord | <Elegantbeef> The latter is better if you actually plan on using the code, as it's concrete |
07:21:59 | FromDiscord | <sOkam!> is there any specific benefit to c2nim vs futhark/nimterop? |
07:23:59 | FromDiscord | <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:09 | FromDiscord | <sOkam!> not sure i follow, sry me dummie 😔 ↵what do you mean by "concrete"? |
07:26:20 | FromDiscord | <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:09 | FromDiscord | <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:37 | FromDiscord | <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:58 | FromDiscord | <sOkam!> (edit) removed "any of" |
07:31:27 | FromDiscord | <Elegantbeef> Compare https://gitlab.com/define-private-public/stb_image-Nim to the futhark example |
07:31:38 | FromDiscord | <sOkam!> 👌 |
07:31:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3R8P |
07:31:55 | FromDiscord | <Elegantbeef> God damn i'm tired |
07:32:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/OVL |
07:33:26 | FromDiscord | <Elegantbeef> There are benefits with futhark in that it regenerates, so library changes that are breaking will be caught |
07:34:11 | PMunch | That'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:51 | FromDiscord | <Elegantbeef> Surprised pmunch hasnt said "Yea i just wrapped the quake 3 engine in 30 second with futhark" |
07:35:04 | PMunch | But yeah, automatically catching changes in the underlying library so you don't end up chasing obscure bugs in some wrapper |
07:35:31 | PMunch | @Elegantbeef, haha, maybe when I add the next version with better folder support :) |
07:35:32 | FromDiscord | <Elegantbeef> I mean I just learned but Nim can do some amount of API assurances |
07:35:33 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R8S |
07:36:52 | FromDiscord | <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:57 | FromDiscord | <Elegantbeef> There is a `--checkAbi` flag apparently |
07:37:14 | FromDiscord | <Elegantbeef> Yea i mean you can just pester pmunch until you get your bindings |
07:37:23 | FromDiscord | <sOkam!> the community version i'm will be using is supported, but nothing out of the rare bugfix |
07:37:29 | FromDiscord | <Elegantbeef> Either pester him to make them or for help 😛 |
07:38:16 | FromDiscord | <sOkam!> In reply to @PMunch "<@145405730571288577>, haha, maybe when": 🙏 🥺 🙏 |
07:41:42 | FromDiscord | <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:06 | PMunch | Hard to tell without having ever looked at the sources for q3 engine |
07:42:15 | PMunch | But if it's pretty standard C code then you should be fine |
07:42:23 | FromDiscord | <sOkam!> what does futhark currently have issues with? |
07:42:38 | PMunch | Mostly macros that the user is supposed to use |
07:42:48 | PMunch | It handles macros used by the library just fine |
07:43:08 | FromDiscord | <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:17 | PMunch | But if they define macros that the user is supposed to use it starts to struggle because those aren't really typed |
07:43:20 | PMunch | Do you have a link? |
07:43:24 | FromDiscord | <sOkam!> ye |
07:43:52 | FromDiscord | <sOkam!> This is the one that we use nowadays for mods↵https://github.com/ec-/Quake3e |
07:45:23 | PMunch | From the two files I've opened it seems like it should be fine |
07:45:32 | FromDiscord | <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:02 | FromDiscord | <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:32 | PMunch | Not apart from the sample code and the various wrappers I've helped people write in the issues |
07:46:45 | FromDiscord | <sOkam!> 👌 |
07:47:11 | PMunch | But 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:44 | FromDiscord | <sOkam!> yeah, someone recommended me that before |
07:47:58 | PMunch | Might've been me :P |
07:48:11 | FromDiscord | <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:42 | FromDiscord | <sOkam!> i have a list of .h files that i generated, but what do i do with that? |
07:48:58 | PMunch | That you generated? |
07:49:05 | FromDiscord | <sOkam!> yeah with find or ls |
07:49:09 | FromDiscord | <sOkam!> or similar, dont remember |
07:49:14 | PMunch | Uhm, don't do that |
07:49:20 | FromDiscord | <sOkam!> see? |
07:49:21 | FromDiscord | <sOkam!> 😄 |
07:50:30 | PMunch | Download 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:58 | FromDiscord | <sOkam!> this is what that aforementioned list looks like https://media.discordapp.net/attachments/371759389889003532/948487816957009920/unknown.png |
07:54:54 | PMunch | Why have you only copied those things out? |
07:55:03 | PMunch | They must depend on some other files as well? |
07:55:29 | FromDiscord | <sOkam!> because, like i said, i have no clue how to get the .h file list |
07:55:37 | FromDiscord | <sOkam!> other than by bash scripting |
07:56:05 | PMunch | You don't need a list though? |
07:56:58 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R8Z |
07:57:21 | FromDiscord | <Elegantbeef> You treat `importc` like the `#include` in C |
07:57:27 | FromDiscord | <Elegantbeef> So you importC the header files you want |
07:57:38 | PMunch | Exactly |
07:57:54 | FromDiscord | <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:17 | FromDiscord | <sOkam!> im so lost 😔 |
07:58:26 | * | Guest2979 joined #nim |
07:58:30 | PMunch | Do you have a minimal sample in C? |
07:58:32 | FromDiscord | <sOkam!> i don't think im understanding the methodology |
07:59:01 | FromDiscord | <sOkam!> In reply to @PMunch "Do you have a": wdym? of q3 engine? |
07:59:14 | PMunch | Of a game which uses it |
07:59:34 | FromDiscord | <sOkam!> q3 games are ingrained in the engine. not sure how i would do that, and make it compile |
07:59:39 | PMunch | Doesn't have to do anything, like the "hello world" of using it |
08:00:13 | FromDiscord | <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:41 | FromDiscord | <sOkam!> only a handful of people actually understand the architecture enough to dissect it in such a way |
08:01:21 | PMunch | Then it's not really a library is it? |
08:01:41 | FromDiscord | <sOkam!> which is my point, its an engine not really an api or library |
08:01:50 | FromDiscord | <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:53 | FromDiscord | <sOkam!> so don't know how to approach the issue |
08:03:25 | FromDiscord | <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:44 | nrds | <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:51 | nrds | <Prestige99> Curious if anyone else is having this issue |
08:04:58 | FromDiscord | <Elegantbeef> Well you get to generate C code using Nim then include it in your C file and call it |
08:05:01 | FromDiscord | <Elegantbeef> Did anti virus get involved prestige? |
08:05:05 | FromDiscord | <Elegantbeef> Did they restart? |
08:05:06 | FromDiscord | <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:18 | FromDiscord | <Elegantbeef> Windows path is a funky beast |
08:05:29 | nrds | <Prestige99> Yeah antivirus complained but he told it to continue |
08:05:32 | nrds | <Prestige99> the install, I mean |
08:05:32 | FromDiscord | <Elegantbeef> Well that'd be one way of doing it |
08:08:02 | FromDiscord | <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:24 | FromDiscord | <Elegantbeef> It's never going to be a "Nim engine" |
08:08:45 | FromDiscord | <Elegantbeef> It's 23 years of C, if you want a Nim engine, write it in Nim 😛 |
08:09:07 | FromDiscord | <sOkam!> i would, but it wouldn't be the same |
08:10:06 | FromDiscord | <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:32 | FromDiscord | <sOkam!> (edit) "feel" => "feels" | "feelsgood enough ... 😦↵i" added "compared to id3" |
08:10:48 | FromDiscord | <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:46 | FromDiscord | <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:01 | FromDiscord | <sOkam!> i know its not an easy task |
08:12:14 | FromDiscord | <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:01 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=3R99 |
08:25:34 | FromDiscord | <Elegantbeef> With what pmunch said you just include `one.h` and `two.h` |
08:25:38 | FromDiscord | <sOkam!> (edit) "https://play.nim-lang.org/#ix=3R99" => "https://play.nim-lang.org/#ix=3R9a" |
08:25:45 | FromDiscord | <Elegantbeef> Now if he's a liar that's bad |
08:26:16 | FromDiscord | <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:35 | FromDiscord | <sOkam!> basically, this function https://github.com/ec-/Quake3e/blob/65db7c877cb37e37315b6bfbf52c1f3066376436/code/win32/win_main.c#L740 |
08:30:01 | FromDiscord | <sOkam!> how does futhark do its thing in the background?↵does it manage the C compiler automatically or smth? |
08:38:22 | nrds | <Prestige99> Elegantbeef do you know how to link dlls on windows by chance? |
08:38:49 | nrds | <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:58 | FromDiscord | <Elegantbeef> The same as on linux |
08:42:08 | nrds | <Prestige99> Okay how do you do that? :P |
08:42:20 | PMunch | Sorry I was in a meeting |
08:42:33 | FromDiscord | <Elegantbeef> Download the dev files then import the file with dynlib |
08:42:48 | FromDiscord | <Elegantbeef> If static linking also having the static library and linking it with command line arguments |
08:43:59 | PMunch | sOkam, 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:21 | FromDiscord | <Elegantbeef> Does it recurse down includes? |
08:45:30 | PMunch | Yes |
08:45:53 | FromDiscord | <demotomohiro> If you use dll with https://docs.microsoft.com/en-us/troubleshoot/windows-client/deployment/dynamic-link-library#types-of-dlls |
08:45:57 | PMunch | Well 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:38 | PMunch | This 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:02 | PMunch | So For this you could say that you wanted `one.h` and everything it imports which lives in `Quake32/code` |
08:47:20 | FromDiscord | <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:48 | PMunch | The 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:25 | PMunch | So with the above sample you pasted sOkam it would look something like this in Nim: https://play.nim-lang.org/#ix=3R9h |
08:48:53 | PMunch | And 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:29 | nrds | <Prestige99> Elegantbeef any guides on that? |
08:52:38 | nrds | <Prestige99> I don't know how any of this linking business works |
08:52:57 | FromDiscord | <abdu> How is Nim for C's #define preprocessor eg.↵#define foo 99 |
08:53:34 | PMunch | @abdu, not sure what you mean |
08:53:37 | FromDiscord | <demotomohiro> `const Foo = 99` |
08:53:51 | PMunch | In Nim you would do it like @demotomohiro said, with a compile-time constant |
08:56:00 | FromDiscord | <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:03 | PMunch | You 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:34 | PMunch | Prestige, do you just need to link a DLL into your program? |
08:58:00 | nrds | <Prestige99> Uh well now we're trying to do static linking |
08:58:07 | nrds | <Prestige99> have the .lib files |
08:58:28 | FromDiscord | <demotomohiro> On windows, .dll is not a file linked to executable file. Link .lib file with --passL:"foo.lib". |
08:58:49 | nrds | <Prestige99> do we need dynlibOverride for that? |
09:00:23 | PMunch | Nah I think that is just to stop procedures marked with `{.dynlib.}` from being imported from a dynamic library |
09:00:52 | PMunch | Like if you wanted to use the standard library ssl implementation but static link it |
09:01:06 | nrds | <Prestige99> hmm okay |
09:01:50 | FromDiscord | <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:13 | PMunch | It depends |
09:03:29 | PMunch | It handles all the macros that just live inside the library just fine |
09:04:05 | PMunch | And it should handle most static values just fine |
09:04:29 | PMunch | But macros which are intended to be called like a procedure is a bit worse |
09:04:58 | FromDiscord | <sOkam!> In reply to @PMunch "But macros which are": there\ are procedures, yep |
09:05:07 | FromDiscord | <sOkam!> (edit) "there\" => "there" | "yep" => "yep. quite a few" |
09:05:09 | PMunch | Which you are supposed to call? |
09:05:56 | FromDiscord | <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:22 | FromDiscord | <sOkam!> unless they are behind some other functions and can be avoided, which I don't know yet |
09:06:30 | FromDiscord | <sOkam!> are they fine if they are called from C code only? |
09:07:38 | FromDiscord | <abdu> In reply to @demotomohiro "If you want macro": solved! thanks |
09:08:39 | PMunch | sOkam, yeah they're fine as long as they are behind C code |
09:09:10 | PMunch | The 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:13 | nrds | <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:32 | nrds | <Prestige99> It's using the dynlib pragma, don't know what I'm missing here |
09:16:55 | nrds | <Prestige99> using --passL:path/to/my.lib |
09:18:02 | PMunch | Shouldn't that be `--passL:"-Lpath/to/library -lmy"`? |
09:18:22 | PMunch | --passL only sends things to the linker |
09:18:22 | nrds | <Prestige99> I have no idea |
09:18:49 | PMunch | On Linux at least -L is used to pass a folder to search for libraries |
09:19:07 | PMunch | And -l to link to an actual library (but I think dynlib should handle that automatically) |
09:19:08 | FromDiscord | <demotomohiro> `GPU_TRANSLATE` is a symbol in your static lib? Or it is in other library? |
09:19:34 | nrds | <Prestige99> It should be in the static lib afaik |
09:19:44 | PMunch | So you would need `--passL:"-Lpath/to/lib"` in order to pass the folder that Nim will go looking for that library |
09:20:00 | PMunch | But since it uses dynlib you probably need to use dynlibOverride |
09:20:45 | nrds | <Prestige99> I thought that's what clibdir was for |
09:21:41 | * | Gustavo6046 quit (Quit: Leaving) |
09:21:43 | nrds | <Prestige99> I got it to build using absolute paths, but the binary does nothing. Weird |
09:21:51 | PMunch | Oh, never seen that before, but yeah I guess that does the same thing |
09:23:20 | FromDiscord | <demotomohiro> Do you got error like `path/to/my.lib was not found`? |
09:23:53 | nrds | <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:14 | nrds | <Prestige99> after statically linking using absolute paths, I had to put the dll's next to the executable for it to run |
09:33:19 | nrds | <Prestige99> so the static libs aren't actually static? |
09:33:39 | PMunch | No that just sounds like you dynamically linked them |
09:34:26 | nrds | <Prestige99> I'm using dynlibOverrideAll so I don't think so..? |
09:34:37 | nrds | <Prestige99> Unless that doesn't do what I think it does |
09:35:15 | PMunch | Well it's not very static if you need the files to be there is it? |
09:35:33 | nrds | <Prestige99> Yeah that's my point |
09:36:01 | nrds | <Prestige99> maybe the .lib file is just a loader for the dll |
09:36:28 | nrds | <Prestige99> SDL2.lib is only 171kb but the .dll is 2179kb, seems weird |
09:37:24 | FromDiscord | <demotomohiro> File size depends on compiler options. |
09:38:00 | FromDiscord | <demotomohiro> Maybe your .lib was not built correctly? |
09:38:14 | nrds | <Prestige99> I got it from the sdl website so, hopefully it's correct |
09:38:58 | PMunch | Why do you want to static link it anyways? |
09:39:20 | nrds | <Prestige99> Easier to ship binaries |
09:40:06 | FromDiscord | <demotomohiro> Did you read SDL2 manual? It should tells which library you need to link. Maybe you need to link other library. |
09:42:18 | FromDiscord | <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:55 | nrds | <Prestige99> idk about that |
09:48:54 | nrds | <Prestige99> Well I've been working on this for too long, will try getting it working again another day |
09:55:32 | NimEventer | New thread by Drkameleon: C/C++-wrapping Windows/VCC-related issues again, see https://forum.nim-lang.org/t/8969 |
10:04:41 | FromDiscord | <MaskDuck> hi |
10:07:03 | FromDiscord | <demotomohiro> hi |
10:07:31 | FromDiscord | <Rika> hi |
10:09:23 | FromDiscord | <MaskDuck> nim looks cooler than python ig |
10:09:31 | FromDiscord | <MaskDuck> i right now only code using python |
10:09:36 | FromDiscord | <MaskDuck> and wanting to learn another language |
10:09:42 | FromDiscord | <MaskDuck> (edit) "i right now only code using python ... " added "(proficient)" |
10:10:24 | FromDiscord | <MaskDuck> maybe ill learn nim |
10:10:43 | FromDiscord | <MaskDuck> btw i think nim structure looks like a command line™️ |
10:11:34 | PMunch | Like a command line? |
10:11:51 | FromDiscord | <Rika> Good to hear that you like it |
10:12:07 | PMunch | Prestige, 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:29 | nrds | <Prestige99> Yeah that's fine |
10:12:40 | FromDiscord | <Rika> Is SDL2 GPL and not lesser? |
10:12:57 | FromDiscord | <MaskDuck> yup |
10:13:08 | PMunch | Ah it might be LGPL, I just found some references to it when I searched for static linking things earlier |
10:13:18 | PMunch | And it's not that hard to ship a couple extra dlls |
10:13:38 | FromDiscord | <Rika> It’s zlib license |
10:13:50 | PMunch | How 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:35 | FromDiscord | <Rika> Semi-static hahaha |
10:15:00 | FromDiscord | <Rika> I can imagine AV would hate that though |
10:15:09 | FromDiscord | <demotomohiro> Nim has command invocation syntax and many proc/func/template/macro can be called like command line. |
10:15:13 | FromDiscord | <demotomohiro> https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax |
10:15:19 | FromDiscord | <MaskDuck> ho |
10:15:21 | FromDiscord | <MaskDuck> how can i |
10:15:24 | FromDiscord | <MaskDuck> install nim |
10:15:29 | FromDiscord | <MaskDuck> using source distributor |
10:15:36 | FromDiscord | <MaskDuck> i can find the build.sh file |
10:16:04 | FromDiscord | <MaskDuck> cant |
10:17:12 | FromDiscord | <demotomohiro> Here is how to build from source: https://github.com/nim-lang/nim#compiling |
10:19:02 | FromDiscord | <demotomohiro> There are build_all.sh for Linux/Mac and build_all.bat for Windows. |
10:21:11 | PMunch | Source distributor? |
10:21:18 | PMunch | I recommend you do it through choosenim |
10:21:36 | PMunch | That way you're sure it's installed correctly, and that you can easily upgrade to future versions |
10:23:06 | FromDiscord | <MaskDuck> aic thanks |
10:23:15 | FromDiscord | <MaskDuck> In reply to @PMunch "I recommend you do": i tried choosenim |
10:23:23 | FromDiscord | <MaskDuck> but it is too slow |
10:24:07 | PMunch | Too slow? |
10:24:14 | FromDiscord | <MaskDuck> do we neeed any dependacies |
10:24:28 | PMunch | It literally just downloads a tarball and extracts it |
10:24:33 | PMunch | How can that be too slow? |
10:24:49 | FromDiscord | <MaskDuck> it is faster now |
10:24:50 | PMunch | As for dependencies you need a C compiler, but not much else |
10:24:55 | FromDiscord | <MaskDuck> ok i installed thanks guys |
10:25:04 | FromDiscord | <MaskDuck> now |
10:25:09 | FromDiscord | <MaskDuck> if i wanna write hello world |
10:25:15 | FromDiscord | <MaskDuck> `echo "Hello World"`? |
10:26:11 | PMunch | Yup |
10:26:13 | FromDiscord | <demotomohiro> yes. Then save it to file hello.nim and `nim c -r hello.nim` |
10:26:41 | FromDiscord | <MaskDuck> ah thanks ya |
10:27:05 | FromDiscord | <MaskDuck (MaskDuck)> tysm |
10:27:19 | PMunch | I mean technically you don't even need to save it to a file: nim --eval:'echo "hello world"' |
10:27:28 | FromDiscord | <MaskDuck> lmao |
10:27:49 | FromDiscord | <MaskDuck> https://media.discordapp.net/attachments/371759389889003532/948527038267011072/unknown.png |
10:28:06 | PMunch | Well you didn't install it properly then |
10:28:15 | PMunch | You need to make sure that the Nim binary is in your path |
10:28:28 | PMunch | Ad do you have `nim` repeated twice, or is that just your shell? |
10:29:11 | PMunch | I think choosenim asks you if you want it to add it to your path for you |
10:30:00 | FromDiscord | <MaskDuck> In reply to @PMunch "I think choosenim asks": well |
10:30:05 | FromDiscord | <MaskDuck> it doesnt add it into the path |
10:30:16 | FromDiscord | <MaskDuck> and the nim folder is something contain the `hello.nim` file |
10:30:57 | FromDiscord | <MaskDuck> In reply to @PMunch "I think choosenim asks": well it doesnt |
10:31:57 | FromDiscord | <Rika> In reply to @MaskDuck "well it doesnt": It does, otherwise it’s somehow broken |
10:32:15 | FromDiscord | <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:24 | PMunch | You shouldn't put your project files in the Nim compiler folder |
10:33:30 | PMunch | I mean you can, but you shouldn't |
10:34:16 | PMunch | Either 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:30 | PMunch | Simply update your PATH variable to include that folder |
10:34:49 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…) |
10:34:54 | PMunch | Of 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:31 | FromDiscord | <Rika> Or symlink into a bin folder you already have in your path lol |
10:36:10 | PMunch | That would probably cause Nim to fail to find the standard library though wouldn't it? |
10:37:19 | FromDiscord | <Rika> Dunno never used it |
10:37:37 | FromDiscord | <Rika> If so then that should be fixed |
10:38:09 | PMunch | Oh well, time for lunch |
10:38:10 | * | PMunch quit (Quit: leaving) |
10:42:58 | FromDiscord | <demotomohiro> Running nim with absolute path worked. |
10:51:14 | * | ltriant joined #nim |
10:52:34 | nrds | <Prestige99> Is there a way to have a template return a bool, but also allow the user to pass in a body? |
10:52:56 | FromDiscord | <Rika> Templates don’t really “return” |
10:53:42 | nrds | <Prestige99> yeah |
10:53:50 | nrds | <Prestige99> But do you know what I mean? |
10:53:53 | FromDiscord | <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:00 | FromDiscord | <demotomohiro> `template foo(body: untyped): bool = body; true`? |
10:54:16 | nrds | <Prestige99> yeah |
10:54:17 | FromDiscord | <Rika> ^Pretty much the same as what I mean except with a block too |
10:55:09 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3R9H |
10:55:28 | FromDiscord | <demotomohiro> true without '?' |
10:55:53 | nrds | <Prestige99> so I'm trying to do something like https://play.nim-lang.org/#ix=3R9I |
10:55:56 | nrds | <Prestige99> if that makes sense |
10:56:40 | nrds | <Prestige99> I think I'm too tired, lol |
10:58:40 | FromDiscord | <demotomohiro> It works without block: https://play.nim-lang.org/#ix=3R9K |
10:59:09 | FromDiscord | <Rika> Of course it does, I just wrap with a block for sanitation |
10:59:28 | nrds | <Prestige99> So I can't use it in an if statement though? |
10:59:29 | FromDiscord | <Rika> Even if there’s no real benefit to that since it’s sanitary either way when used in that case |
11:05:45 | nrds | <Prestige99> Any ideas? |
11:10:02 | FromDiscord | <demotomohiro> https://play.nim-lang.org/#ix=3R9M |
11:10:43 | * | xaltsc joined #nim |
11:12:55 | nrds | <Prestige99> hm doesn't work well for multiline does it? |
11:14:44 | FromDiscord | <demotomohiro> https://play.nim-lang.org/#ix=3R9N |
11:15:22 | nrds | <Prestige99> hmm |
11:15:38 | FromDiscord | <demotomohiro> It seems using `foo` with if statement requires `(block:...)`. |
11:15:46 | nrds | <Prestige99> interesting |
11:17:00 | * | ltriant quit (Ping timeout: 240 seconds) |
11:26:50 | FromDiscord | <whisperdev> How can I get sha256 from a file? |
11:33:20 | FromDiscord | <demotomohiro> Probaby `let content = readFile("myfile")` and pass it to `update` proc in nimcrypto/sha2. |
11:33:31 | FromDiscord | <demotomohiro> https://github.com/cheatfate/nimcrypto |
11:35:09 | * | jjido joined #nim |
11:37:03 | FromDiscord | <whisperdev> Thanks. Found some old code for nimSHA2 on forum that also works! |
11:37:46 | FromDiscord | <demotomohiro> !eval import osproc; echo execCmd "sha256sum /usercode/in.nim" |
11:37:49 | NimBot | Compile failed: 7555e94d3c86083b5d6df92f38fb0a6c411170b6f6c9fe9d03ddf8bc63d3d0d5 /usercode/in.nim↵0 |
11:38:39 | FromDiscord | <haoliang> sent a code paste, see https://play.nim-lang.org/#ix=3R9R |
11:38:55 | FromDiscord | <demotomohiro> It say compile failed but output is correct? |
11:39:56 | FromDiscord | <demotomohiro> sent a code paste, see https://paste.rs/U2P |
11:40:36 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=3R9W |
11:41:24 | * | PMunch joined #nim |
11:41:34 | FromDiscord | <demotomohiro> In reply to @haoliang "i was wondering how": https://play.nim-lang.org/#ix=3R9X |
11:42:18 | FromDiscord | <demotomohiro> It is same to how to write Nim code in github issue or Readme.md. |
11:42:27 | FromDiscord | <Sense> sent a code paste, see https://paste.rs/Gdo |
11:42:55 | FromDiscord | <Sense> It's pretty simple but uh... I would like to see how it will look like in Nim code self. |
11:43:06 | FromDiscord | <haoliang> In reply to @demotomohiro "https://play.nim-lang.org/#ix=3R9X": thanks! |
11:48:32 | PMunch | @Sense, it would look a little something like this: http://ix.io/3R9Z/nim |
11:50:43 | FromDiscord | <demotomohiro> https://play.nim-lang.org/#ix=3Ra0 |
11:51:13 | FromDiscord | <demotomohiro> "Write a number: " prints without "\n", isn't it? |
11:51:39 | PMunch | Ah okay, fair enough |
11:51:41 | FromDiscord | <demotomohiro> Maybe my code is wrong. I don't know much about Pascal. |
11:52:22 | * | jmdaemon quit (Ping timeout: 260 seconds) |
12:04:58 | FromDiscord | <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:19 | FromDiscord | <Michal Maršálek> (edit) "yeah" => "each" |
12:05:26 | PMunch | Probably just to have shorter names |
12:05:39 | FromDiscord | <Michal Maršálek> (edit) "in" => "on" |
12:05:39 | PMunch | rune is a fairly common name for a unicode character |
12:06:01 | * | supakeen quit (Quit: WeeChat 3.4) |
12:06:12 | PMunch | By 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:16 | FromDiscord | <Rika> I’ve heard of runes before Nim as well |
12:06:30 | * | supakeen joined #nim |
12:06:53 | FromDiscord | <Rika> What is the difference between a “character” that you say and a code point |
12:07:03 | PMunch | And to print out each unicode character you would probably do `for c in myStr.runes: echo c` |
12:07:12 | FromDiscord | <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:24 | PMunch | It's a nice short word :) |
12:07:56 | PMunch | @Rika, I guess things like zero-width joiners are their own code points but not a printable character |
12:08:02 | FromDiscord | <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:09 | PMunch | Exactly |
12:08:19 | FromDiscord | <Michal Maršálek> Like a letter and an accent |
12:08:29 | FromDiscord | <Rika> Denormalise then I guess |
12:08:38 | FromDiscord | <Michal Maršálek> Two codepoints combined to a single character. |
12:08:39 | FromDiscord | <Rika> Doesn’t work for all I guess |
12:08:51 | FromDiscord | <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:11 | PMunch | @ajusa, for the Nim forum? |
12:09:22 | PMunch | Or do you mean the playground |
12:10:03 | FromDiscord | <ajusa> Playground, my bad |
12:21:11 | PMunch | Well, it's a feature I built ages ago that has never really been used |
12:21:50 | PMunch | The 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:28 | FromDiscord | <deeuu> sent a long message, see http://ix.io/3Rab |
12:23:57 | * | ltriant joined #nim |
12:23:59 | PMunch | It doesn't really seem to work at the moment though |
12:24:04 | FromDiscord | <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:46 | PMunch | @deeuu, maybe try execCmdEx: https://nim-lang.org/docs/osproc.html#execCmdEx%2Cstring%2Cset%5BProcessOption%5D%2CStringTableRef%2Cstring%2Cstring |
12:26:06 | FromDiscord | <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:04 | PMunch | Yeah I think it's time to axe that feature |
12:27:46 | PMunch | I've actually been looking at reimplementing the playground with HTMX myself |
12:28:00 | FromDiscord | <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:38 | PMunch | I started rewriting the front-end to be more contributor-friendly but I got lost in writing my own CSS library :P |
12:29:10 | PMunch | readLines likely reads until the stream returns atEnd |
12:29:39 | * | ltriant quit (Ping timeout: 256 seconds) |
12:30:57 | PMunch | Ah no, it actualy runs until p.peekExitCode != -1 |
12:31:04 | PMunch | That's weird |
12:31:28 | FromDiscord | <abdu> How identifier naming?↵it's so narrow with insensitive letter-case execpt the first !↵please share tour best tips! |
12:31:49 | PMunch | @abdu, do you want to know how people name things? |
12:32:08 | FromDiscord | <Rika> Types are capitalised and variables are not |
12:32:16 | PMunch | Do you normally have myVar, myvar, and my_var point to different variables? |
12:32:17 | FromDiscord | <Rika> Pretty much the general consensus at least |
12:32:24 | PMunch | If so remind me to never read your code :P |
12:32:55 | PMunch | Yeah, types start with a capital letter, variables are snakeCase |
12:32:59 | * | jjido joined #nim |
12:33:25 | FromDiscord | <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:37 | FromDiscord | <Rika> In reply to @PMunch "Yeah, types start with": snakeThatSwallowedAFewElephantsCase |
12:35:11 | PMunch | Haha, I meant camelCase :P |
12:35:51 | PMunch | @ajusa, send me a link? Send me a PR instead |
12:37:34 | FromDiscord | <deeuu> sent a long message, see https://paste.rs/7tp |
12:38:50 | PMunch | That is unfortunate |
12:39:16 | PMunch | I thought negative numbers where just treated as unsigned uint8s |
12:45:15 | FromDiscord | <hmmm> boiz is there something automatic to escape a windows path string to double the slashes |
12:45:20 | FromDiscord | <deeuu> Yeah thought so. Note that this issue only appears to arise on Windows |
12:46:30 | FromDiscord | <Rika> In reply to @hmmm "boiz is there something": ? why would you need this? |
12:46:45 | FromDiscord | <Rika> when you get user input it's already "escaped" |
12:47:14 | FromDiscord | <hmmm> apparently in pythonland they use something like os.path.join |
12:47:16 | FromDiscord | <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:37 | FromDiscord | <Rika> oh you mean you have a group of strings that represent folders? |
12:47:44 | PMunch | @hmmm, it sounds like you're looking for `/` |
12:47:48 | FromDiscord | <Rika> yes |
12:47:51 | FromDiscord | <Rika> in os |
12:48:04 | PMunch | https://nim-lang.org/docs/os.html#%2F%2Cstring%2Cstring |
12:48:23 | FromDiscord | <abdu> https://forum.nim-lang.org/t/8967#58573↵How do you think,↵"my frustration that Nim is slower than Python " |
12:48:38 | FromDiscord | <hmmm> hmm I'll try it, see if it works |
12:48:42 | PMunch | @deeuu, aah Windows probably derps with the error codes |
12:48:48 | PMunch | Because it's Windows I guess |
12:48:57 | FromDiscord | <deeuu> Fair |
12:49:12 | FromDiscord | <Rika> isnt bigint specifically mentioning that its not optimised |
12:49:19 | PMunch | Yup |
12:50:18 | PMunch | bigint 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:24 | FromDiscord | <Rika> lol |
12:51:56 | PMunch | But 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:28 | PMunch | If you find a similarly optimised Nim library Nim is likely to be faster again because of faster startups |
12:54:00 | PMunch | Hmm, 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:19 | PMunch | What would be the best way to implement something similar in Nim that can be Ctrl+C'ed with proper shutdown code? |
12:54:45 | PMunch | I guess just use setControlCHook.. |
13:01:31 | FromDiscord | <hmmm> solved with r"<path>" |
13:01:36 | FromDiscord | <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:01 | FromDiscord | <deeuu> sent a code paste, see https://paste.rs/3Lm |
13:35:34 | FromDiscord | <deeuu> (edit) "https://play.nim-lang.org/#ix=3Ray" => "https://paste.rs/kM8" |
13:49:18 | * | ltriant joined #nim |
13:51:22 | PMunch | @deeuu, that would probably be a good idea |
13:51:35 | PMunch | Please 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:11 | FromDiscord | <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:01 | PMunch | @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:06 | PMunch | Probably want setLen though |
15:26:15 | PMunch | To 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:58 | ehmry | can I read asynchronously from io.stdin or do I need to read from an extra thread? |
16:00:22 | FromDiscord | <abdu> What's "reset arr to completely reset it" supposed to mean to be different to `arr.setLen(0)` ? |
16:05:36 | FromDiscord | <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:19 | FromDiscord | <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:16 | FromDiscord | <Waldecir Santos> Just fond on the docs there is an `as` let me try it |
16:59:57 | FromDiscord | <Waldecir Santos> It worked \o/ |
17:30:14 | * | vicfred quit (Quit: Leaving) |
17:38:58 | FromDiscord | <whisperdev> Does anyone use Nim with Svelte? |
17:39:27 | FromDiscord | <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:35 | FromDiscord | <planetis> There are react bindings |
17:50:44 | * | jjido joined #nim |
17:59:18 | FromDiscord | <-|-> 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:14 | FromDiscord | <Phil> Okay I have this faint feeling that std/logging is just hopelessly not working whatsoever |
18:44:25 | FromDiscord | <Goat> sent a code paste, see https://play.nim-lang.org/#ix=3Rcg |
18:44:26 | FromDiscord | <Phil> Time to try out a library |
18:44:46 | FromDiscord | <Phil> .... that is valid syntax? |
18:44:59 | FromDiscord | <Goat> Its for a macro I have, so yes |
18:45:11 | FromDiscord | <Phil> Oh, macro, nevermind I'll shut up, not my area |
18:45:34 | FromDiscord | <Phil> Sidenote, if anyone here got std/logging to properly work for them, I'd love to get some pointer |
18:45:35 | FromDiscord | <Phil> (edit) "pointer" => "pointers" |
18:53:53 | FromDiscord | <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:49 | FromDiscord | <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:28 | FromDiscord | <Phil> So apparently jsony and chronicles really don't like each other |
19:11:07 | FromDiscord | <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:20 | shadow0133 | Is there a way to turn `seq[Future[Foo]]` into `Future[seq[Foo]]`? |
19:18:48 | FromDiscord | <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:51 | FromDiscord | <exelotl> sent a long message, see http://ix.io/3Rco |
19:29:45 | FromDiscord | <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:32 | FromDiscord | <Phil> (edit) "module," => "module (controllers.nim by virtue of otherModule being imported there while it also exports chronicles)," |
19:31:38 | FromDiscord | <Phil> sent a long message, see http://ix.io/3Rcp |
19:33:16 | FromDiscord | <dom96> weird, but implies a problem in jsony or the json_serialization package |
19:33:48 | FromDiscord | <Phil> I'm... not sure whom to give a github issue for that one |
19:34:16 | FromDiscord | <dom96> you could try modifying the code it points to and see if you can resolve the problem |
19:34:59 | FromDiscord | <Phil> Can do, but first I feel like there's something fundamental about nims import rules I don't get here |
19:35:30 | FromDiscord | <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:31 | FromDiscord | <Phil> when jsony.nim calls "toJson", that proc is defined within that module or a module it imports |
19:35:49 | FromDiscord | <Phil> jsony.nim never imports chronicles |
19:36:33 | FromDiscord | <Phil> So due to generics it's able for a proc from "downstream" to cause ambiguity issues "upstream"? |
19:36:58 | FromDiscord | <dom96> I'm not 100% sure but I think so |
19:37:21 | FromDiscord | <-|-> In reply to @exelotl "There's lots of ways": Do you have a single <name>.nimble file for the whole project? |
19:40:23 | shadow0133 | Can you `map` the Future? |
19:40:52 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=3Rcq |
19:41:08 | FromDiscord | <dom96> In reply to @shadow0133 "Can you `map` the": there is no async map so no, but you can easily write one |
19:41:17 | FromDiscord | <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:00 | FromDiscord | <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:57 | FromDiscord | <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:23 | shadow0133 | how to construct ready Future? |
19:55:24 | FromDiscord | <dom96> In reply to @Isofruit "dom? can you just": you can throw multiple |
19:55:31 | FromDiscord | <dom96> In reply to @shadow0133 "how to construct ready": `newFuture` |
19:57:04 | shadow0133 | but with value? something like `ready(T): Future[T]` |
19:57:54 | FromDiscord | <dom96> newFuture + complete |
19:58:01 | FromDiscord | <dom96> you can't construct a completed future |
20:02:32 | FromDiscord | <-|-> 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:44 | shadow0133 | How to iterate over `seq[T]` such that it returns `T`, not `lent T`? |
20:26:38 | nrds | <Prestige99> maybe using mitems? |
20:27:14 | nrds | <Prestige99> https://nim-lang.org/docs/iterators.html#mitems.i%2CopenArray%5BT%5D |
20:34:11 | FromDiscord | <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:09 | FromDiscord | <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:46 | shadow0133 | so, mitems doesn't work, but `for (_, x) in seq.pairs` does ¯\_(ツ)_/¯ |
20:44:05 | FromDiscord | <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:06 | shadow0133 | hmm, 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:11 | FromDiscord | <Skaruts> how do I add something to the beginning of a sequence? |
21:10:33 | FromDiscord | <Skaruts> at index 0 |
21:15:42 | * | ltriant joined #nim |
21:19:54 | FromDiscord | <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:18 | FromDiscord | <Phil> In reply to @dom96 "you can throw multiple": Thanks for the info! |
21:21:56 | FromDiscord | <Skaruts> @exelotl Ah! I had only found `insert` in sequtils. Thanks. |
21:22:00 | nrds | <Prestige99> Is there a way to do something like this? https://play.nim-lang.org/#ix=3RcS |
21:22:10 | nrds | <Prestige99> Maybe need to write some sort of macro |
21:22:36 | FromDiscord | <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:48 | FromDiscord | <b4mbus> sent a code paste, see https://play.nim-lang.org/#ix=3RcT |
21:24:26 | FromDiscord | <b4mbus> (edit) "https://play.nim-lang.org/#ix=3RcT" => "https://play.nim-lang.org/#ix=3RcU" |
21:33:20 | FromDiscord | <exelotl> In reply to @b4mbus "How do I achieve": Like this: https://play.nim-lang.org/#ix=3RcW |
21:34:00 | FromDiscord | <b4mbus> oh, so Nim doesnt have a concept of a pure virtual function/pure method |
21:34:15 | FromDiscord | <b4mbus> thanks a lot |
21:35:59 | FromDiscord | <exelotl> yeah I think it doesn't |
21:39:15 | FromDiscord | <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:17 | FromDiscord | <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:25 | FromDiscord | <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:28 | FromDiscord | <Elegantbeef> It removes runtime type information on objects that are inheritable↵(@kbsec) |
22:49:08 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#types-cast-uncheckedassign i think this works↵(@zidsal) |
22:52:03 | FromDiscord | <ATwenty0ne> sent a code paste, see https://paste.rs/Xuk |
22:52:25 | FromDiscord | <ATwenty0ne> sent a code paste, see https://play.nim-lang.org/#ix=3Rd4 |
22:52:43 | FromDiscord | <ATwenty0ne> (edit) "https://play.nim-lang.org/#ix=3Rd4" => "https://play.nim-lang.org/#ix=3Rd5" |
22:53:00 | FromDiscord | <Elegantbeef> that offsets the ptr of `x` by w so in nim i'd be `int (cstrLen(x[w].addr))` |
22:53:28 | FromDiscord | <Elegantbeef> or you could just do `cstrlen(x) - w` |
22:53:46 | FromDiscord | <Elegantbeef> Actually i'm wrong arent i |
22:53:49 | FromDiscord | <demotomohiro> In reply to @kbsec "What exactly does `{.pure.}`": https://play.nim-lang.org/#ix=3Rd6 |
22:54:09 | FromDiscord | <Elegantbeef> it's offsetting the char\ by `w` so it'd be `cast[ptr UncheckedArray[cstring]](x)[w]` |
22:58:00 | FromDiscord | <Elegantbeef> that's still not right God C can be awful |
22:58:05 | FromDiscord | <demotomohiro> I think `strSize = x.len - w`. |
22:58:13 | FromDiscord | <ATwenty0ne> lol yea this one is a head scratcher |
22:58:23 | FromDiscord | <Elegantbeef> No `w` is a pointer |
22:58:27 | FromDiscord | <Elegantbeef> I mean x is a pointer |
22:58:30 | FromDiscord | <Elegantbeef> `x + w` offsets the pointer by w bytes |
22:59:27 | FromDiscord | <Elegantbeef> so the best thing to do i guess is manual arithmetic `cstrlen(cast[cstring](cast[int](x) + w)))` |
22:59:54 | FromDiscord | <zidsal> Thanks @ElegantBeef |
23:00:23 | FromDiscord | <Elegantbeef> That should work twentyone, sorry for the 30 wrong answers 😛 |
23:00:39 | FromDiscord | <ATwenty0ne> lol its ok, I appreciate you helping, thanks! |
23:01:37 | FromDiscord | <Elegantbeef> I fully blame C's inanity |
23:01:57 | FromDiscord | <Elegantbeef> Also are you interoping with C or writing pure Nim? |
23:04:25 | FromDiscord | <ATwenty0ne> interoping |
23:06:11 | * | girvo joined #nim |
23:16:24 | * | acidsys quit (Excess Flood) |
23:17:01 | * | acidsys joined #nim |
23:35:35 | girvo | Hi all :) |
23:36:20 | FromDiscord | <Elegantbeef> Hello |
23:36:40 | girvo | Anyone 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:47 | girvo | Theres gotta be a better way I'm missing |
23:36:55 | FromDiscord | <Elegantbeef> Cdecls cannot have captures |
23:37:12 | FromDiscord | <Elegantbeef> Closures are incompatible with cdecl due to the environment carried with them |
23:37:18 | girvo | Yeah figured as much |
23:37:36 | FromDiscord | <Elegantbeef> What's your callback and what's your code trying to do? |
23:37:45 | girvo | One tick I'll grab the definitions in a pastebin for ya |
23:39:45 | girvo | https://pastebin.com/j9trbgGQ |
23:40:20 | girvo | `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:47 | FromDiscord | <Elegantbeef> Can you store `cb` on the object that's passed to the procedure? |
23:40:58 | girvo | I can actually |
23:41:05 | girvo | Oh! |
23:41:08 | girvo | I see :D |
23:41:08 | FromDiscord | <Elegantbeef> so like could you do `cast[MyObject](a1).cb()` |
23:41:10 | * | jmdaemon joined #nim |
23:41:15 | FromDiscord | <Elegantbeef> well `ptr MyObject` |
23:41:16 | girvo | Yeah I should be able to. I'll give it a shot |
23:41:35 | FromDiscord | <Elegantbeef> Your `pointer` is your closure environment somewhat |
23:42:15 | girvo | Yep that's exactly how FreeRTOS uses it |
23:43:25 | girvo | Hah she compiles at least |
23:43:35 | girvo | Lets see if it runs or blows my tiny stack. Embedded is fun |
23:43:45 | FromDiscord | <System64 ~ Flandre Scarlet> https://nimble.directory/pkg/dimscord↵Does it support the latest Discord API features? |
23:46:21 | FromDiscord | <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:50 | girvo | Ohhh that's a good idea too |
23:48:28 | girvo | I plan on doing my best to make working with FreeRTOS in ESP32 as nice as possible in Nim land lol |
23:48:43 | FromDiscord | <Elegantbeef> Then that macro sounds pretty nice 🙂 |
23:48:44 | girvo | Because doing it in straight C is painful at best |
23:49:58 | girvo | Interesting, 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:49 | girvo | Hahaha yeah |
23:51:14 | girvo | I gotta brush up on scoping in Nim with ARC nowadays |
23:52:31 | girvo | https://pastebin.com/aqqMUXgd that's the main.nim app code |
23:52:53 | girvo | https://pastebin.com/qqy97X0P |
23:52:59 | girvo | xTaskCreate wrapper |
23:53:25 | girvo | Despite the while true: in the cb proc, it amusingly runs once then `=destroy` is called |
23:53:36 | girvo | Because I'm definitely misunderstanding how one should approach this ;) |
23:54:24 | FromDiscord | <Elegantbeef> At the end of `appMain` it'll destroy `task` |
23:54:38 | nrds | <Prestige99> Is there a non-reentrant lock in the stdlib? |
23:56:02 | girvo | Yeah. 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:19 | girvo | Hah yeah. A simple white true: triggers the FreeRTOS task watchdog |
23:57:30 | girvo | Time to go look at some documentation I think |
23:58:05 | girvo | I suppose I could skip the RAII-like destructor and just make it an explicit delete proc on the task object for now |