00:18:02 | * | wallabra_ joined #nim |
00:20:24 | * | wallabra quit (Ping timeout: 268 seconds) |
00:20:25 | * | wallabra_ is now known as wallabra |
00:40:19 | * | wallabra_ joined #nim |
00:40:58 | * | wallabra quit (Ping timeout: 256 seconds) |
00:41:49 | * | wallabra_ is now known as wallabra |
01:21:52 | FromDiscord | <voidwalker> https://github.com/z-------------/nim-bencode/blob/master/src/bencodepkg/types.nim#L15 - how do I declare a ref var of that type ? :\ |
01:22:35 | FromDiscord | <albassort> x = new type |
01:23:40 | FromDiscord | <voidwalker> oh so new makes it implicitly ref. ok. any other syntax without new, using the ref keyword? |
01:28:58 | FromDiscord | <b1rdf00d> Like this? `let w = (ref Vec2)(x: 1.0, y: 0.0)` |
01:30:58 | FromDiscord | <voidwalker> hm nope that doesn't work for me. ` let tDict = (ref BencodeObj)(BencodeObj(kind:bkDict))` type mismatch: got 'BencodeObj' for 'BencodeObj(kind: bkDict)' but expected 'ref BencodeObj' |
01:32:11 | FromDiscord | <Elegantbeef> drop the `BenCodeObj` |
01:32:18 | FromDiscord | <Elegantbeef> it's `(ref BenCodeObj)(kind: ...)` |
01:34:54 | FromDiscord | <voidwalker> oh ok, that makes sense. |
01:35:20 | * | wallabra quit (Ping timeout: 260 seconds) |
01:35:26 | FromDiscord | <voidwalker> The author of this lib recently changed the object to value from ref.. and I have to rewrite my code if I want to use it as such. |
01:35:37 | FromDiscord | <voidwalker> https://github.com/z-------------/nim-bencode/commit/86f8fd266e0f377c5fad908c30c67aec32d86881 - what do you think is more suitable for a librafy, ref or value ? |
01:35:50 | FromDiscord | <voidwalker> (edit) "https://github.com/z-------------/nim-bencode/commit/86f8fd266e0f377c5fad908c30c67aec32d86881 - what do you think is more suitable for ... alibrary," added "such" | "librafy," => "library," |
01:36:03 | FromDiscord | <Elegantbeef> There is no single answer |
01:36:23 | FromDiscord | <Elegantbeef> You use `ref` for reference semantics |
01:36:29 | FromDiscord | <Elegantbeef> If you dont need reference semantics you use value |
01:36:29 | FromDiscord | <albassort> In reply to @Elegantbeef "it's `(ref BenCodeObj)(kind: ...)`": didn't know about this snyta |
01:36:32 | FromDiscord | <albassort> (edit) "snyta" => "snytax" |
01:36:37 | FromDiscord | <voidwalker> I guess if it's value, you can always make a ref to it. |
01:39:23 | FromDiscord | <b1rdf00d> Yeah I'd say if it doesn't need to be `ref` then value makes more sense as a default |
02:10:31 | NimEventer | New thread by demotomohiro: Can wasMoved be overloaded?, see https://forum.nim-lang.org/t/9694 |
03:15:59 | FromDiscord | <Tuatarian> I'm curious why this doesn't compile? |
03:16:19 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hLa |
03:16:22 | FromDiscord | <Tuatarian> I tried to do what beef said, but this doesn't seem to work |
03:18:05 | FromDiscord | <Tuatarian> so creating an `apply` template for `HvNum` makes that work, but `HvVal` is still broken |
03:20:34 | FromDiscord | <Elegantbeef> No else branch |
03:21:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hLb |
03:21:37 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hLc |
03:22:14 | FromDiscord | <πτ (pi man)> what I'm seing is that HvNum has no field `val` |
03:22:23 | FromDiscord | <Tuatarian> this is exhaustive right? |
03:22:29 | FromDiscord | <πτ (pi man)> (edit) "what I'm seing is that HvNum has no field `val` ... " added "(`v.nVal.val`)" |
03:22:35 | FromDiscord | <πτ (pi man)> (edit) "HvNum" => "`HvNum`" |
03:22:39 | FromDiscord | <Elegantbeef> Yes `else` is exhaustive |
03:22:42 | FromDiscord | <Elegantbeef> I mean case 😄 |
03:22:46 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hLe |
03:23:02 | FromDiscord | <πτ (pi man)> shouldn't that `when` be `if`? |
03:23:45 | FromDiscord | <Tuatarian> it can't be right? |
03:23:51 | FromDiscord | <Tuatarian> since it's a template/comptime |
03:24:03 | FromDiscord | <πτ (pi man)> you did it on `apply` |
03:24:10 | FromDiscord | <Elegantbeef> Again this doesnt work tuatara |
03:24:17 | FromDiscord | <Tuatarian> I'm extremely confused |
03:24:25 | FromDiscord | <Elegantbeef> All your code has to be typed the same |
03:24:36 | FromDiscord | <Elegantbeef> `h` is only known to be a `int` or `float` at runtime |
03:24:54 | FromDiscord | <πτ (pi man)> the template may be compile time, but `h.isInt` is only known at runtime |
03:25:13 | FromDiscord | <Tuatarian> I'm still really confused |
03:25:15 | FromDiscord | <πτ (pi man)> (unless `h` is a `const` I guess) |
03:25:27 | FromDiscord | <Tuatarian> if I change the `when` to be an `if` it gives a different set of compile errors |
03:25:39 | FromDiscord | <Elegantbeef> Of course |
03:25:41 | FromDiscord | <Tuatarian> again I think static typing related |
03:25:45 | FromDiscord | <Elegantbeef> You need the `if` |
03:25:49 | FromDiscord | <Elegantbeef> Cause it's runtime delimited |
03:26:07 | FromDiscord | <Tuatarian> I'm definitely not understanding this |
03:26:30 | FromDiscord | <Elegantbeef> An expression has a single return type |
03:26:36 | FromDiscord | <Tuatarian> so which variant of the type we're dealing with is not known until runtime |
03:26:39 | FromDiscord | <πτ (pi man)> in order to use `when` you have to know what the value is before you compile |
03:26:59 | FromDiscord | <πτ (pi man)> In reply to @iWonderAboutTuatara "so which variant of": not which variant, but what the value is |
03:27:06 | FromDiscord | <Tuatarian> yeah I'm aware I'm basically trying to cheat static typing here |
03:27:11 | FromDiscord | <πτ (pi man)> (edit) "In reply to @iWonderAboutTuatara "so which variant of": not which variant, but what the value is ... " added "(specifically of `isInt`)" |
03:27:31 | FromDiscord | <Tuatarian> but isn't this more or less necessary when working with a tagged union (unless you want to really laboriously check every little thing at runtime everywhere)? |
03:28:26 | FromDiscord | <πτ (pi man)> that's the catch with dynamic typing, everything is runtime |
03:28:51 | FromDiscord | <Tuatarian> yeah |
03:29:09 | FromDiscord | <Tuatarian> I'm aware I lose some comptime type safety here, but I'm trying to make code like this work |
03:29:22 | FromDiscord | <Tuatarian> avoid code like this |
03:29:34 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hLj |
03:30:11 | FromDiscord | <Tuatarian> I want to be able to just write something like `apply(a, b, func)` |
03:30:41 | FromDiscord | <Elegantbeef> You cannot do much to reduce the tedium |
03:32:05 | FromDiscord | <Elegantbeef> You can import `std/lenient` ops |
03:32:16 | FromDiscord | <Elegantbeef> and remove the silly `return` |
03:32:39 | FromDiscord | <Tuatarian> right, but I still need to know which ones of `fVal`, `iVal` etc exist |
03:33:04 | FromDiscord | <Tuatarian> so this could reduce the number of explicit conversions, but the messy part (the if statement) is still there |
03:33:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hLl |
03:33:07 | FromDiscord | <Tuatarian> yeah |
03:33:11 | FromDiscord | <Tuatarian> that's not that much better |
03:33:23 | FromDiscord | <Tuatarian> could I at least write a general `val` which grabs the value? |
03:33:28 | FromDiscord | <Elegantbeef> Nope |
03:33:35 | FromDiscord | <Tuatarian> that's unfortunate |
03:33:39 | FromDiscord | <Elegantbeef> That's dynamic typing |
03:33:42 | FromDiscord | <Elegantbeef> Nim is statically typed |
03:36:56 | FromDiscord | <πτ (pi man)> how do I get a section of a string defined by indices? |
03:36:59 | FromDiscord | <Tuatarian> I know, I am effectively trying to circumvent static typing here |
03:37:29 | FromDiscord | <Elegantbeef> `str[a..b]` or `str.toOpenArray(a, b)`↵(@πτ (pi man)) |
03:37:35 | FromDiscord | <Elegantbeef> You cannot circumvent it |
03:38:10 | FromDiscord | <πτ (pi man)> `a..b` :mood: imo this is ugly syntax but if it works it works I guess |
03:38:39 | FromDiscord | <Elegantbeef> It's ugly? |
03:39:04 | FromDiscord | <Elegantbeef> I mean you can always alias it |
03:39:33 | FromDiscord | <πτ (pi man)> I'd rather do `str.substr(a, b)` tbh |
03:39:45 | FromDiscord | <Elegantbeef> Meh |
03:40:02 | FromDiscord | <Elegantbeef> `str[a..^b]` and `str[a..b]` mirror `seq[T]` access aswell |
03:40:02 | FromDiscord | <πτ (pi man)> I'm not a fan of index operators |
03:40:18 | FromDiscord | <Elegantbeef> Well welcome to Nim |
03:40:23 | FromDiscord | <πτ (pi man)> same with `[^1]` i'd rather do `.end()` |
03:40:30 | FromDiscord | <πτ (pi man)> (edit) "`.end()`" => "`.last()`" |
03:40:32 | FromDiscord | <huantian> what if you need the second to last one |
03:40:37 | FromDiscord | <huantian> `.secondToLast()`? |
03:40:59 | FromDiscord | <πτ (pi man)> `list[list.size - 2]` |
03:41:22 | FromDiscord | <πτ (pi man)> I don't think I've ever needed to do that though tbh |
03:41:55 | FromDiscord | <Elegantbeef> Well it's relatively common |
03:44:38 | FromDiscord | <πτ (pi man)> sent a code paste, see https://play.nim-lang.org/#ix=4hLp |
03:45:16 | FromDiscord | <πτ (pi man)> I mean sure those index operators are useful, but idk, using `[]` to select multiple element just feels wrong |
03:45:23 | FromDiscord | <πτ (pi man)> (edit) "element" => "elements" |
03:46:00 | FromDiscord | <Elegantbeef> Well you're wrong! 😜 |
03:47:27 | FromDiscord | <πτ (pi man)> lol, I'm "wrong" with a lot of things |
03:47:46 | FromDiscord | <Elegantbeef> Doesnt C++ use `[]` for bitsets? |
03:48:19 | FromDiscord | <πτ (pi man)> wdym |
03:48:50 | FromDiscord | <πτ (pi man)> `std::vector<bool>` is stored as a bit array instead of a char array if that's what you mean |
03:49:05 | FromDiscord | <Elegantbeef> No |
03:49:13 | FromDiscord | <Elegantbeef> `std::bitset` uses `a[0] = true` |
03:49:15 | FromDiscord | <Elegantbeef> for instance |
03:50:41 | FromDiscord | <πτ (pi man)> that's still only accessing one bit at a time though |
03:53:07 | FromDiscord | <πτ (pi man)> though theoretically you could make something like `Foo subrange = customArrayClass[range(0, 16)];` |
03:54:12 | FromDiscord | <Rika> In reply to @πτ (pi man) "that's still only accessing": Think his point is that sets and arrays use the same syntax when they’re different concepts |
03:55:08 | FromDiscord | <πτ (pi man)> huh, is `a..b` inclusive on both ends? |
03:55:13 | FromDiscord | <huantian> yesh |
03:55:21 | FromDiscord | <πτ (pi man)> wha...... |
03:55:26 | FromDiscord | <huantian> `a..<b` is exclusive for b |
03:55:44 | FromDiscord | <πτ (pi man)> :BlobNotLikeThis: why does nothing ever make sense |
03:56:03 | FromDiscord | <Rika> Why wouldn’t .. be inclusive…? |
03:56:22 | FromDiscord | <πτ (pi man)> because ranges typically are exclusive for the last element |
03:56:44 | FromDiscord | <Rika> But that makes no sense if you don’t consider “common use” |
03:56:51 | FromDiscord | <πτ (pi man)> but that is common use? |
03:57:03 | FromDiscord | <huantian> I feel like when `..` is used for range it's usually inclusive on both sides |
03:57:28 | FromDiscord | <huantian> actually I can't think of anything else other than rust that uses `..` right now |
03:57:40 | FromDiscord | <πτ (pi man)> In reply to @huantian "actually I can't think": C# does |
03:57:44 | FromDiscord | <huantian> oh yeah |
03:57:50 | FromDiscord | <πτ (pi man)> but I don't use C# either |
03:58:13 | FromDiscord | <Elegantbeef> Isnt the `..` in math inclusive? |
03:58:25 | FromDiscord | <πτ (pi man)> I mostly use C and C++ and a bit of Java (1.8) |
03:58:30 | FromDiscord | <πτ (pi man)> In reply to @Elegantbeef "Isnt the `..` in": in math? |
03:58:58 | FromDiscord | <huantian> yeah when you use `...` in math it's inclusive |
03:59:36 | FromDiscord | <πτ (pi man)> you mean something like `1/2 + 1/4 + ... + 1/n`? |
04:00:31 | FromDiscord | <Rika> https://media.discordapp.net/attachments/371759389889003532/1049173396757413938/IMG_9894.png |
04:00:55 | FromDiscord | <Rika> Nim got the syntax from Pascal |
04:01:21 | FromDiscord | <Elegantbeef> And `..` in Nim is consistent across all types |
04:01:35 | FromDiscord | <Elegantbeef> For ranges, sets, slices it's inclusive |
04:02:06 | FromDiscord | <Tuatarian> if I'm trying to do something like this |
04:02:16 | FromDiscord | <Tuatarian> will this work as expected? |
04:02:16 | FromDiscord | <Tuatarian> sent a code paste, see https://play.nim-lang.org/#ix=4hLx |
04:02:25 | FromDiscord | <Tuatarian> since nim can't guarantee at comptime that `nVal` exists |
04:30:40 | FromDiscord | <demotomohiro> All return type must be same unless you use when statement. |
04:31:59 | * | jmdaemon joined #nim |
04:39:30 | * | arkurious quit (Quit: Leaving) |
04:52:48 | FromDiscord | <j-james> heyo - does anyone know where i could find a series of idiomatic, permissively-licensed code snippets? |
04:52:48 | FromDiscord | <j-james> o |
04:57:36 | madprops | stackoverflow? |
04:58:05 | madprops | ah im in #nim |
04:58:15 | FromDiscord | <Elegantbeef> Indeed |
04:58:26 | FromDiscord | <Elegantbeef> Best is to look at packages and use that MIT license 😄 |
04:58:47 | madprops | Mit is such a nice guy |
06:05:06 | * | ltriant quit (Ping timeout: 256 seconds) |
06:30:36 | FromDiscord | <Slava0135> In reply to @huantian "actually I can't think": Kotlin |
06:32:37 | * | ltriant joined #nim |
06:35:25 | FromDiscord | <Elegantbeef> no |
06:35:37 | FromDiscord | <Elegantbeef> Oh that was a quote |
06:35:38 | FromDiscord | <Elegantbeef> Shit |
06:35:53 | FromDiscord | <Elegantbeef> We only got 'kotlin' with 0 context here in matrix land |
06:38:36 | * | ltriant quit (Ping timeout: 264 seconds) |
06:42:25 | FromDiscord | <Rika> In reply to @Elegantbeef "*We only got 'kotlin'": Kotlin |
06:42:39 | FromDiscord | <Elegantbeef> Hey that reply worked |
06:57:22 | FromDiscord | <Cheeseinator> Is there a way to disable warnings for a file without it affecting other files that `include` said file? |
06:58:09 | FromDiscord | <Elegantbeef> You can turn specific warnings off for a block of code |
06:58:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hMg |
06:58:56 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/nimc.html#compiler-usage-list-of-warnings |
06:59:31 | FromDiscord | <Cheeseinator> I tried that and vscode still complained |
06:59:44 | FromDiscord | <Cheeseinator> ~~I probably shouldn't use vscode~~ |
07:23:30 | * | kenran joined #nim |
07:30:07 | * | kenran quit (Remote host closed the connection) |
07:31:54 | FromDiscord | <albassort> wit nimyaml |
07:31:57 | FromDiscord | <albassort> can i just parse yaml |
07:32:03 | FromDiscord | <albassort> i dont really want to make a type for this |
07:32:27 | FromDiscord | <albassort> (edit) "wit" => "with" |
07:33:02 | * | PMunch joined #nim |
07:34:33 | PMunch | Well this ain't great: https://forum.nim-lang.org/t/9685 |
07:35:31 | FromDiscord | <albassort> what is |
07:35:50 | FromDiscord | <albassort> ;what is great? nothing |
07:37:07 | FromDiscord | <Rika> https://nimyaml.org/api.html#the-document-object-model |
07:37:11 | FromDiscord | <albassort> i found it |
07:37:13 | FromDiscord | <albassort> sm |
07:37:14 | FromDiscord | <albassort> (edit) "sm" => "smh" |
07:37:18 | FromDiscord | <albassort> like 30s before |
07:37:32 | FromDiscord | <albassort> now to look for it in the test |
07:38:22 | FromDiscord | <Rika> https://nimyaml.org/api/dom.html#loadDom |
07:38:48 | FromDiscord | <Rika> says deprecated, replacement in docs |
07:39:03 | FromDiscord | <Rika> https://nimyaml.org/api/serialization.html#loadAs,string |
07:39:08 | FromDiscord | <albassort> yep |
07:39:31 | FromDiscord | <albassort> what |
07:39:37 | FromDiscord | <albassort> whatever i'll do tojson |
07:40:24 | FromDiscord | <Slava0135> does anyone know how can I configure VSCode plugin to use snake_case instead of camelCase? |
07:40:52 | FromDiscord | <Elegantbeef> You cannot |
07:42:32 | FromDiscord | <albassort> we stan camelCase here |
07:42:59 | FromDiscord | <albassort> whats up with this https://media.discordapp.net/attachments/371759389889003532/1049229385917534238/image.png |
07:43:02 | FromDiscord | <Elegantbeef> Well it's not too complicated to add to the saem extension |
07:43:06 | FromDiscord | <albassort> these guys taking up my memory |
07:43:23 | FromDiscord | <Elegantbeef> I did have a proof of concept, but it needed more work |
07:43:58 | FromDiscord | <Elegantbeef> What do you expect it to to use for a JS object equivlent |
07:44:00 | FromDiscord | <albassort> these json objets are pretty disgusting memory hogs huh |
07:45:01 | FromDiscord | <Elegantbeef> Well arbitrary representing a dynamically typed data type isnt the cheapest thing |
07:48:15 | FromDiscord | <albassort> on second thought i'll make the stinky object |
07:48:19 | FromDiscord | <albassort> though it might not work |
08:09:28 | FromDiscord | <untoreh> trying to use nimporter, getting "cannot dynamically load position-independent executable" |
08:13:49 | FromDiscord | <Slava0135> In reply to @albassort "we stan camelCase here": 💀 |
08:17:11 | Amun-Ra | Slava0135: that's not possible atm, vscode uses nimsuggest, nimsuggest does not support snake case :/ |
08:17:53 | FromDiscord | <Elegantbeef> Sure but vscode does process nimsuggest output |
08:18:01 | FromDiscord | <Elegantbeef> So you can always suggest symbols that are camel case |
08:18:29 | FromDiscord | <Elegantbeef> As i said i had a proof of concept working and it was relatively simple |
08:18:34 | Amun-Ra | hmm |
08:20:07 | FromDiscord | <Elegantbeef> Yea i think you can insert a "toSnakeCase" here https://github.com/saem/vscode-nim/blob/main/src/nimSuggest.nim#L91 |
08:44:43 | FromDiscord | <albassort> i dunno if we should encourage using casing which would make you an odd one out |
08:45:28 | FromDiscord | <Elegantbeef> Literally the entire point of style insensitivity |
08:46:04 | FromDiscord | <salt> i've been using camelCase on nim projects mostly because of ide, i wouldn't mind being able to snake_case again, but also when in rome |
08:47:23 | FromDiscord | <Elegantbeef> meanwhile style insensitivity exists |
08:50:23 | FromDiscord | <salt> the style insensitivity seems to be pretty polarizing when i show people nim |
08:51:02 | FromDiscord | <salt> i'm pretty neutral on it, but wonder what opinion is at large |
08:51:16 | FromDiscord | <Slava0135> ~~cool kids use rust and it's snake case~~ |
08:51:29 | FromDiscord | <salt> is rust snake_case too? |
08:51:34 | FromDiscord | <Elegantbeef> Nim programmers like it |
08:51:39 | FromDiscord | <Elegantbeef> People that dont use Nim dislike it |
08:52:05 | FromDiscord | <salt> i'm mostly just into whitespace |
08:52:22 | Amun-Ra | I prefer snake case, I use camel case in nim code, unfortunatelly |
08:54:03 | FromDiscord | <Slava0135> In reply to @Elegantbeef "Yea i think you": but will it also affect type names? |
08:54:51 | FromDiscord | <salt> shouldn't should it? just check first letter |
08:56:41 | FromDiscord | <Elegantbeef> Yes it could |
08:56:44 | FromDiscord | <Elegantbeef> It's all suggest symbols |
09:08:16 | FromDiscord | <Phil> In reply to @salt "i'm pretty neutral on": Pythonistas highly appreciate it whenever they touch any of my camelcase libs |
09:08:30 | FromDiscord | <Phil> ~~Not that they're actually used by anyone I don't think~~ |
09:10:33 | FromDiscord | <salt> there are a lot of python libs that are just bindings to c functions and they use the c naming conventions and it looks awful! Style insensitivity would be nice in those cases. |
09:11:07 | FromDiscord | <salt> looking at you `cv2` |
09:11:58 | FromDiscord | <albassort> In reply to @Slava0135 "~~cool kids use rust": uh not the place to shill rust |
09:12:05 | FromDiscord | <albassort> if we liked rust we would use rust |
09:13:04 | FromDiscord | <albassort> i really don't like it when languages don't have a consistent structure |
09:13:10 | FromDiscord | <albassort> (edit) "i really don't like it when languages don't have a consistent structure ... " added "and naming culture" |
09:13:17 | FromDiscord | <albassort> for example: C |
09:13:24 | FromDiscord | <albassort> GTK: https://media.discordapp.net/attachments/371759389889003532/1049252137479196713/image.png |
09:13:33 | FromDiscord | <albassort> X: https://media.discordapp.net/attachments/371759389889003532/1049252172388372500/image.png |
09:13:50 | FromDiscord | <albassort> :notLikeThis: |
09:14:24 | FromDiscord | <albassort> don't let this happen to nim |
09:14:27 | FromDiscord | <Slava0135> In reply to @albassort "i really don't like": goid thing about golang |
09:14:39 | FromDiscord | <Slava0135> (edit) "goid" => "good" |
09:14:46 | FromDiscord | <albassort> golang's naming structures are insane and should be shamed |
09:15:29 | FromDiscord | <Slava0135> but they are solid |
09:16:55 | PMunch | Hmm, does anyone know how conversion between WGS84 and EUM89 coordinates work? |
09:17:17 | FromDiscord | <albassort> i would love to help, but seeing as i have to google it, im sure, I cannot help you |
09:17:27 | FromDiscord | <albassort> as you are a smart fella and not a fart smella |
09:19:12 | PMunch | Haha, thanks for that imagery :P And I wouldn't ask if I could easily find it via google, the only thing I find there is online converters and instructions for how to do this in certain programs |
09:20:51 | FromDiscord | <albassort> In reply to @PMunch "Haha, thanks for that": why is why i didn't answer haha |
09:25:20 | FromDiscord | <planetis> I had a geodesy course in uni, don't remember much except they are all ellipsoids with different parameters. Book is at home so I cant fetch it either. |
09:35:49 | PMunch | I am curious how it's done, but I found another export with the coordinate system I needed :) |
09:40:40 | * | neceve quit (Ping timeout: 260 seconds) |
09:41:06 | FromDiscord | <planetis> I don't think conversion is something you would do often, each has an area where it's most accurate and you're supposed to pick the right one when measuring |
09:43:58 | FromDiscord | <planetis> Unless I am totally wrong and the tools do that conversion automatically |
09:50:05 | FromDiscord | <albassort> is there anyway to compile everything with --threads:on in vscode |
09:50:14 | FromDiscord | <albassort> i added it to the default compiler tags but i still need to make .nims |
10:18:09 | FromDiscord | <Yardanico> In reply to @albassort "i added it to": "i added it to the default compiler tags" how? |
10:18:26 | FromDiscord | <Yardanico> if you mean in the vscode settings, that only affects the nim command that runs when you press F6 |
10:18:34 | FromDiscord | <albassort> https://media.discordapp.net/attachments/371759389889003532/1049268537610469376/image.png |
10:18:38 | FromDiscord | <albassort> hmm |
10:18:39 | FromDiscord | <Yardanico> so if you want threads to be recognized by highlighting and stuff, you do need .nims or .nim.cfg |
10:18:41 | FromDiscord | <albassort> damn |
10:18:44 | FromDiscord | <albassort> i realized this now |
10:18:55 | FromDiscord | <albassort> sad |
10:19:09 | FromDiscord | <albassort> .nim.cfg where? |
10:19:13 | FromDiscord | <albassort> in my root? |
10:19:26 | FromDiscord | <Yardanico> depends on what you want it to affect |
10:19:33 | FromDiscord | <albassort> https://media.discordapp.net/attachments/371759389889003532/1049268780699766784/image.png |
10:19:39 | FromDiscord | <Yardanico> no |
10:19:46 | FromDiscord | <albassort> .-. |
10:20:04 | FromDiscord | <Yardanico> if you want it to affect your project, then you just place it near your main .nim file and name it `myfile.nim.cfg`. But again, you can as well use `.nims` for the same purpose, it's newer and is more extensible |
10:20:17 | FromDiscord | <albassort> annoying |
10:20:17 | FromDiscord | <Yardanico> so just create `myfile.nims` and add `switch("threads", "on")` to it, done |
10:20:21 | FromDiscord | <Yardanico> that's how you should do it properly anyway |
10:20:56 | FromDiscord | <albassort> i move my dependency structure so its no longer a problem |
10:21:02 | FromDiscord | <albassort> (edit) "move" => "moved" |
10:21:04 | FromDiscord | <albassort> :) |
11:07:00 | * | ltriant joined #nim |
11:11:54 | * | ltriant quit (Ping timeout: 260 seconds) |
11:36:11 | * | jmdaemon quit (Ping timeout: 264 seconds) |
12:08:47 | FromDiscord | <Jessa> sent a code paste, see https://play.nim-lang.org/#ix=4hNs |
12:09:36 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hNu |
12:10:04 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4hNu" => "https://play.nim-lang.org/#ix=4hNv" |
12:10:38 | * | dtomato4 quit (Quit: The Lounge - https://thelounge.chat) |
12:10:42 | FromDiscord | <albassort> i think you might be able to do something like |
12:10:51 | FromDiscord | <Jessa> ah, spaces |
12:11:05 | FromDiscord | <Jessa> i keep forgetting about spaces |
12:11:08 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hNw |
12:11:15 | FromDiscord | <albassort> i never tried that tho |
12:11:17 | FromDiscord | <albassort> might be wrong |
12:11:24 | FromDiscord | <Jessa> `a:seq[string] = @[]` works |
12:11:47 | FromDiscord | <Jessa> thank you |
12:11:58 | FromDiscord | <albassort> : |
12:12:02 | FromDiscord | <albassort> (edit) ":" => ":D" |
12:13:02 | * | ltriant joined #nim |
12:17:24 | * | ltriant quit (Ping timeout: 246 seconds) |
12:42:19 | FromDiscord | <emanresu3> sent a code paste, see https://play.nim-lang.org/#ix=4hNB |
12:45:03 | FromDiscord | <emanresu3> sent a code paste, see https://play.nim-lang.org/#ix=4hND |
12:46:21 | FromDiscord | <Generic> it doesn't work for arrays |
12:46:27 | FromDiscord | <Generic> your code only works for array literals |
12:46:59 | FromDiscord | <Generic> what you need to do is generate code which indexes the array or seq |
12:47:00 | * | ltriant joined #nim |
12:47:30 | FromDiscord | <Generic> this should work |
12:47:30 | FromDiscord | <Generic> sent a code paste, see https://play.nim-lang.org/#ix=4hNE |
12:47:48 | FromDiscord | <Generic> (edit) "what you need to do is generate code which indexes the array or seq ... " added "instead of directly indexing the AST" |
12:51:54 | FromDiscord | <emanresu3> It doesn't compile for me, should I change anything else? |
12:52:03 | * | TakinOver quit (Ping timeout: 252 seconds) |
12:52:15 | FromDiscord | <emanresu3> Still only works for array literals |
12:53:10 | * | ltriant quit (Ping timeout: 260 seconds) |
13:21:55 | * | TakinOver joined #nim |
13:56:36 | * | Phytolizer joined #nim |
13:57:11 | * | junaid_ joined #nim |
14:03:56 | * | junaid_ quit (Remote host closed the connection) |
14:33:30 | FromDiscord | <ringabout> What does `<=` mean for sets? `{sym1, sym2} <= flags`? |
14:37:32 | FromDiscord | <auxym> I know `<` means "strict subset", which doesnt include equal sets |
14:38:03 | FromDiscord | <auxym> logically `a <= b` should be be `a < b or a == b` |
14:38:59 | FromDiscord | <auxym> `{sym1, sym2} <= flags` should be equivalent to `sym1 in flags and sym2 in flags` |
14:41:20 | FromDiscord | <ringabout> Yeah, thanks. It is a bit too stretchy for operator overloading. Found a bug in the compiler. |
15:05:52 | noeontheend | I'm sure this has been asked before, but is there any way to pass an int *variable* (from a loop at compile time) to a macro and access its value? |
15:06:24 | FromDiscord | <Rika> No, macros are compile time only and values of a variable are run time |
15:06:41 | FromDiscord | <Rika> You can access the value but only through the generated code and not the generating code |
15:07:59 | noeontheend | Thanks, that's what I thought but wanted to make sure |
15:11:37 | * | PMunch quit (Quit: Leaving) |
15:46:43 | FromDiscord | <planetis> In reply to @ringabout "Yeah, thanks. It is": You mean it does the opposite it's supposed to do? It actually used correctly |
15:47:03 | FromDiscord | <planetis> (edit) "It" => "It's" | "correctly" => "correctly." |
15:50:14 | FromDiscord | <Jessa> i'm curious-↵↵would one get scolded in the Nim community for just using `return . . .` no matter when :P |
15:53:02 | FromDiscord | <auxym> huh? using `result` by default and `return` when really needed is idiomatic, but personally I wouldn't scold you for using return |
15:53:26 | FromDiscord | <auxym> `return` when really needed for control flow |
15:56:21 | FromDiscord | <Yepoleb> we don't scold people for their coding style in general i think |
15:58:15 | FromDiscord | <Jessa> i use `return` basically everywhere cus im used to that |
16:00:26 | FromDiscord | <demotomohiro> But there are many cases writing procs without `return` makes code simpler. |
16:02:16 | FromDiscord | <demotomohiro> `proc get(x: Foo): Bar = x.bar` is simpler than `proc get(x: Foo): Bar = return x.bar`. |
16:02:28 | FromDiscord | <Jessa> true↵↵which is just something ii'll have to try and get used to |
16:03:57 | FromDiscord | <Yepoleb> while you're learning the language just write the code the way you feel comfortable with |
16:05:33 | * | Phytolizer quit (Ping timeout: 260 seconds) |
16:07:24 | FromDiscord | <Gumbercules> In reply to @Jessa "i use `return` basically": Blocks and break and assigning to the implicit result are nice for getting rid of returns |
16:07:42 | FromDiscord | <Jessa> In reply to @Yepoleb "while you're learning the": basiically what i'm doing, yeah |
16:09:04 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/plugin.nim#L55 |
16:09:08 | FromDiscord | <Gumbercules> For instance |
16:09:50 | FromDiscord | <Jessa> rn just found out that the `result` thing is very nice |
16:32:09 | FromDiscord | <Gumbercules> In reply to @Jessa "rn just found out": I literally have zero return statements in my code base. I probably take it to an extreme but I'm used to handling early exits this way now so... |
16:41:17 | FromDiscord | <Require Support> how to: string to byteSeq and vice versa |
16:45:44 | FromDiscord | <Require Support> https://github.com/nim-lang/Nim/issues/14810 related |
16:47:19 | * | dtomato4 joined #nim |
16:47:27 | NimEventer | New thread by kaushalmodi: Is the use of doAssert in config.nims deprecated in the latest Nim devel?, see https://forum.nim-lang.org/t/9695 |
16:49:46 | * | ltriant joined #nim |
16:54:11 | * | ltriant quit (Ping timeout: 246 seconds) |
17:07:58 | * | Phytolizer joined #nim |
17:55:19 | FromDiscord | <auxym> I presume this is new in 1.6.10? `Warning: setLen can potentially expand the sequence, but the element type 'Instruction' doesn't have a valid default value [UnsafeSetLen]` |
17:55:43 | FromDiscord | <auxym> we don't have a way to provide a default value until v2, right? |
18:00:44 | FromDiscord | <Gumbercules> Why doesn't it just get zero initialized then? |
18:00:58 | FromDiscord | <Gumbercules> Seems annoying... |
18:04:59 | FromDiscord | <auxym> because the contained type might have 0 an an illegal value. eg. `A .. Z` or `Positive`. which is why it's unsafe, but its annoying when there's no alternative atm |
18:05:16 | FromDiscord | <Gumbercules> But does it? |
18:05:28 | FromDiscord | <auxym> ? |
18:05:36 | FromDiscord | <Gumbercules> If not then it should just zero initialize |
18:06:04 | FromDiscord | <Gumbercules> I'm asking if the type it's warning you about fits that description |
18:06:27 | FromDiscord | <Gumbercules> Where 0 is an invalid value |
18:07:12 | FromDiscord | <auxym> yes |
18:09:04 | FromDiscord | <auxym> the warning seems to be triggered even when initializing an empty seq as in `let x: seq[Positive]` |
18:09:15 | FromDiscord | <kaddkaka> How to iterate over a seq in reverse order? |
18:10:12 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4hP3 |
18:10:13 | FromDiscord | <kaddkaka> ~ `for i in countdown(<myseq.len, 0): myseq[i]` doesn't feel nice, couldnt find anything in the manual |
18:10:44 | FromDiscord | <kaddkaka> nice, is that iterator available in library? |
18:10:46 | FromDiscord | <auxym> yeah I don't think there's anything in the stdlib, I just add the iterator above to my code here and there |
18:11:24 | FromDiscord | <kaddkaka> ok thanks 👍 |
18:12:00 | FromDiscord | <auxym> maybe I should PR it? in sequtils? 🤔 |
18:13:47 | FromDiscord | <auxym> In reply to @kaddkaka "nice, is that iterator": there is `reverse` and `reversed` in std/algorithm btw, but they aren't iterators. One will reverse your seq in place, the second will create a copy |
18:13:50 | FromDiscord | <kaddkaka> it's a great way to force me to learn a simple iterator |
18:14:05 | FromDiscord | <kaddkaka> I called it `backwards` ^^ |
18:18:10 | FromDiscord | <jtv> Is there any good way to get the calling context for a macro? Particularly, I want to generate procs at the module scope to avoid weird errors, so if someone calls my macro within a proc/func context, I would like to error on that, instead of generating a nested proc. |
18:39:00 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4hPg |
18:39:33 | * | Phytolizer quit (Ping timeout: 260 seconds) |
18:41:21 | FromDiscord | <auxym> that looks like it should work, doesn't it? or you'd like to accept `s` as an iterator? |
18:42:15 | FromDiscord | <kaddkaka> yeah, but I guess, `io.lines` is not a closure iterator, which might be a problem |
18:42:25 | FromDiscord | <auxym> in which case you can't do that with inline (default) iterators, because they aren't "first class" values that can be passed around like procs, they are more similar to templates in that they are expanded (to an inline for loop) at compile time |
18:42:32 | FromDiscord | <kaddkaka> https://nim-lang.org/docs/io.html#lines.i%2Cstring |
18:42:39 | FromDiscord | <kaddkaka> right |
18:43:52 | FromDiscord | <kaddkaka> My original problem is that I want to do some logic for the header of a file, and then some other logic for the rest of the file, so if there is some way to break, but then continute the `lines` inline iterator, that would be nice |
18:44:15 | FromDiscord | <kaddkaka> (yes I'm doing AoC day5) |
18:44:32 | FromDiscord | <auxym> haha, just got done with that |
18:44:50 | FromDiscord | <kaddkaka> I parsed the header, but now I want to consume the rest of the file 😛 |
18:45:00 | FromDiscord | <Cheeseinator> i think iterators can take other iterators but i might be wrong |
18:45:06 | FromDiscord | <vestel> How does iterators work "under the hood"? |
18:45:07 | FromDiscord | <auxym> you might be interested in zero-functional, which is sort of iterators-on-steroids |
18:45:24 | FromDiscord | <auxym> In reply to @vestel "How does iterators work": they inline a for loop at compile time |
18:45:35 | FromDiscord | <auxym> like a template, sort of |
18:45:40 | FromDiscord | <kaddkaka> @vestel my guess (seeing them the first time today) is that inline iterators just expand to for loop |
18:45:41 | FromDiscord | <vestel> I mean there is no yield statement in backend languages |
18:45:57 | FromDiscord | <vestel> Doing code virtualizer and kinda stuck on this |
18:47:02 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4hPk |
18:47:36 | FromDiscord | <auxym> In reply to @kaddkaka "My original problem is": yeah you can't with inline iterators. maybe with a closure iterator. Or just use splitLines, AOC inputs won't fill up your ram 😉 |
18:47:39 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4hPk" => "https://play.nim-lang.org/#ix=4hPl" |
18:47:52 | FromDiscord | <kaddkaka> @auxym but but |
18:48:32 | FromDiscord | <MetuMortis> In Pegs is there any way to say X char or Y char |
18:48:36 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4hPl" => "https://play.nim-lang.org/#ix=4hPm" |
18:49:11 | FromDiscord | <kaddkaka> In reply to @auxym "yeah you can't with": 😦 I feel dirty reading all of it into. ALL OF IT |
18:49:20 | FromDiscord | <kaddkaka> (edit) "into." => "into ram." |
18:49:26 | FromDiscord | <MetuMortis> In reply to @vestel "I mean there is": nice name btw where are you fromn |
18:49:27 | FromDiscord | <MetuMortis> (edit) "fromn" => "from" |
18:49:59 | FromDiscord | <auxym> @kaddkaka maybe with this? https://nim-lang.org/docs/enumerate.html |
18:50:30 | FromDiscord | <vestel> In reply to @MetuMortis "nice name btw where": Ukraine |
18:51:33 | FromDiscord | <kaddkaka> In reply to @auxym "<@185793553539137537> maybe with this?": whoa! |
18:51:45 | FromDiscord | <vestel> sent a code paste, see https://play.nim-lang.org/#ix=4hPo |
18:51:46 | FromDiscord | <kaddkaka> I thought that wouldn't work with inline iterator, but I guess macro trumps it! |
18:52:25 | FromDiscord | <kaddkaka> In reply to @vestel "Thank you. So I": I have no idea, that was just my wild guess. I have never come across "code virtualizer". 🙈 |
18:52:48 | FromDiscord | <kaddkaka> @auxym so I should be able to do a macro of my `drop` iterator I guess? |
18:54:44 | FromDiscord | <vestel> In reply to @kaddkaka "I have no idea,": Basically it generates interpreter for virtual cpu and convert your code to bytecode for it |
18:55:06 | FromDiscord | <vestel> (edit) "convert" => "converts" |
18:55:11 | FromDiscord | <MetuMortis> sent a code paste, see https://play.nim-lang.org/#ix=4hPp |
18:58:47 | FromDiscord | <auxym> In reply to @kaddkaka "<@882793909246369864> so I should": not a macro expert but have a look at https://nim-lang.org/docs/manual.html#macros-for-loop-macro depply advanced stuff though |
18:59:00 | FromDiscord | <kaddkaka> @auxym (Also I was looking for `enumerate`, but I only found https://nim-lang.org/docs/manual.html#macros-for-loop-macro, in the manual) 🙂 |
18:59:27 | FromDiscord | <kaddkaka> heh, yeah, not for tonight to delve inte macros I think, but thanks |
19:00:19 | FromDiscord | <auxym> yeah, don't recommend 😉 I used splitLines and hardcoded the line number to split the top from the bottom |
19:01:01 | FromDiscord | <kaddkaka> 🙀 `HRDCDD` 🙀 |
19:01:12 | FromDiscord | <auxym> hm you could use https://nim-lang.org/docs/io.html#readLine%2CFile to read lazily from the file though |
19:01:38 | FromDiscord | <kaddkaka> ✝️ ⛪ 🎌 |
19:14:27 | * | claudius joined #nim |
19:14:38 | * | claudius is now known as Mat42 |
19:17:06 | Mat42 | G'day everyone. Is there any work on a native-code compiler for Nim known? |
19:18:12 | Mat42 | or does someone work on it? |
19:18:45 | FromDiscord | <jtv> Not sure where the advantage would be there. Targeting C and then running it on, say, clang, will generate code that should be as good as if you generated the LLVM directly... which will generally produce better code than naively targeting the underlying platform w/o the intermediary |
19:19:07 | * | PMunch joined #nim |
19:20:35 | FromDiscord | <auxym> i guess nlvm doesn't count as native? |
19:21:01 | FromDiscord | <auxym> but yeah that would be a huge amount of work, if you include the optimization that llvm/gcc do these days |
19:21:51 | FromDiscord | <jtv> Yeah, the major thing to note that modern compilers do an outstanding job (especially llvm), and you don't have to worry about the N different architectures at the instruction optimization level. There really is no good reason to do it |
19:23:50 | FromDiscord | <jmgomez> Not to mention that you lost one of the main Nim use cases, cpp interop |
19:24:31 | PMunch | A bit later than usual, but getting ready to stream advent of code again :) |
19:30:30 | oisota | PMunch where/when are going to be streaming? |
19:30:49 | PMunch | Twitch YouTube, in about five minutes :) |
19:31:11 | FromDiscord | <Andreas> In reply to @PMunch "Twitch YouTube, in about": with or without T-shirt ? |
19:31:23 | Mat42 | I'm primary interessted in system programming and as well as Nim can be used in this respect conventional C compiler bare some overhead in code size which is caused from the C model, where straight code-size optimized native-code compilation allows targeting architectures with low address spaces, like many common microprocessors or even small SoC. |
19:31:30 | PMunch | Haha, with shirt on :P |
19:31:33 | oisota | Nice! I started in python but I've been converting my solutions to Nim to help me learn the language |
19:32:04 | PMunch | Mat42, check out Ratel and my talks on Nim for microcontrollers if you want some nice benchmarks :) |
19:32:42 | Mat42 | I will do, thanks. |
19:32:52 | FromDiscord | <jtv> I fail to see the overhead in code size? Plenty of environments where not even stdlib is compiled in. |
19:33:38 | PMunch | Okay, stream is now live: https://www.twitch.tv/pmunche and https://www.youtube.com/watch?v=EsvLO8WVOg0 |
19:34:37 | Mat42 | jtv: If you have an data address-space of say 64 kB where half is used by a real-time kernel code-size become really important. |
19:35:50 | FromDiscord | <jtv> Like I said, I'm not sure where C is responsible for code bloat, if you control the linking environment. It doesn't even add bounds checks for you 🙂 |
19:38:10 | FromDiscord | <albassort> Schizo dragon question but where does blocks exist memory |
19:38:28 | FromDiscord | <albassort> Can I generate pointers to dreads blocks and then remotely break them |
19:38:57 | FromDiscord | <albassort> (edit) "dragon" => "threads" |
19:39:18 | Mat42 | jtv: The code bloat is resulted from the C model in which for example a call-frame can not be omitted. As does there exist some exellent C compilers, you end up with hand-optimized assembly code quite often. |
19:39:30 | FromDiscord | <albassort> Or do I have to pass a variable pointer to a while loop |
19:39:56 | Mat42 | Anyhow, as I see it there is no demand on native-code compilation. |
19:41:54 | FromDiscord | <jtv> Well, I've definitely seen C compilers, when compiling a static executable, able to optimize away call frames, since it has enough context to prove if non-tail recursion is present. But okay, I'll take your word for it |
19:41:55 | FromDiscord | <albassort> A native Nim Target would be very impressive |
19:42:09 | FromDiscord | <albassort> I highly doubt we can get anywhere near as fast as we currently do with our small community compiling to native |
19:42:18 | FromDiscord | <albassort> We kind of exist on the shoulders of giants here |
19:42:35 | FromDiscord | <albassort> And so do a ton of compiled C languages |
19:43:09 | Mat42 | jtv: Yes, as written there are enough cases where this is not possible. Another problem is that such kind of optimization is not guaranteed. |
19:43:42 | FromDiscord | <albassort> But the big problem would be getting stuff like macros to work |
19:45:27 | FromDiscord | <albassort> It would be incredible and a big community effort but it would only result in making executables smaller and more embedded friendly |
19:45:37 | FromDiscord | <albassort> Which what you want |
19:48:52 | FromDiscord | <kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4hPB |
19:49:11 | FromDiscord | <kaddkaka> (edit) "https://play.nim-lang.org/#ix=4hPB" => "https://play.nim-lang.org/#ix=4hPC" |
19:49:24 | Mat42 | albassort: A traditional use case is dynamic cross compilation, which I would prefer. In this case only the most important source fragments get compiled to native code and a minimal interpreter is generated which then execute the rest of code. This combines the possibility of high code compression with good performance. |
19:51:12 | Mat42 | For such the Nim compiler inclusive is macro possibilities is quite fine. Only the code generator is not available. |
19:52:54 | FromDiscord | <Jessa> is there any channel dedicated to showing the things you've made? |
19:53:08 | Mat42 | That may be an attractive feature for low-level programming, I would say. |
19:53:52 | Mat42 | ← hint |
19:54:32 | FromDiscord | <Yardanico> In reply to @Jessa "is there any channel": not really, people mostly seem to use the forum for that |
19:56:08 | FromDiscord | <Jessa> i see |
19:59:42 | Mat42 | albassort: What microporcesors do you use? |
20:00:08 | FromDiscord | <auxym> an intel i7 😛 (you probably mean microcontroller) |
20:00:50 | Mat42 | yes, I mean microcontroller, sorry for the typo |
20:00:56 | FromDiscord | <albassort> In reply to @Mat42 "<@217459674700578816>: What microporcesors do": I use an Intel i7. When I said microcontroller I meant the smaller baby ones and microprocessors |
20:01:07 | FromDiscord | <albassort> (edit) "i7." => "i5." |
20:01:22 | FromDiscord | <albassort> In reply to @albassort "I use an Intel": I currently don't use any microcontrollers but there's a project I'm planning on doing eventually which I will use them |
20:01:42 | FromDiscord | <albassort> Currently though I'm working on something else. And unfortunately since I have a job I will not have as much time to work on the other side |
20:01:52 | Mat42 | I see |
20:02:12 | FromDiscord | <auxym> fyi there's a few of us in #embedded running nim on AVR, ESP32, SAMD, rp2040, etc |
20:02:40 | FromDiscord | <albassort> I know nothing about embedded and I'm going to bother the hell out of you guys whenever I start out of the project |
20:02:54 | FromDiscord | <albassort> Get ready to explain to me how to load a program onto opram |
20:04:10 | FromDiscord | <auxym> generally: find some docs on how to do it in C and copy that |
20:04:38 | * | krux02 joined #nim |
20:06:10 | FromDiscord | <Gumbercules> I'm curious - do folks use Nim's stdlib for embedded stuff or roll their own / use some C library |
20:06:56 | FromDiscord | <Gumbercules> I got the Nim compiler compiling on my pinephone and I wrote a program and compiled it on the pinephone as well, but that's about as close as I've gotten to anything embedded - so , not very close 🙂 |
20:07:43 | FromDiscord | <BlueCore> Hello, new to Nim! I have a hashtable that I would like to create a clone (or copy) of, I found deepCopy(), and was just wondering if there is any better way of achieving this? |
20:07:46 | FromDiscord | <albassort> Orc usually works fine on embedded so I hear |
20:07:53 | FromDiscord | <auxym> nim's stdlib allocates a lot. if you're not trying to squeeze every bit of ram/speed, it works. |
20:08:08 | * | arkurious joined #nim |
20:08:13 | FromDiscord | <albassort> In reply to @BlueCore "Hello, new to Nim!": Well first of all why do you want to clone it |
20:08:22 | FromDiscord | <auxym> if you want to minimize/avoid allocation at all, better avoid seq, string and therefore most of the stdlib |
20:08:44 | FromDiscord | <albassort> I'm not trying to be dismissive but there's not too many times when you want to clone something in them |
20:08:50 | FromDiscord | <albassort> (edit) "them" => "Nim" |
20:09:07 | FromDiscord | <albassort> Deep copy is more of a memory thing, it shouldn't really be used for this purpose |
20:10:41 | FromDiscord | <BlueCore> Yup, I know cloning is not a good thing most of the time, I am just very lazy and want to pass the same hashtable into a function that would otherwise mutate it. There is probably a better way of doing it, so if you have suggestions for that I am pleased too |
20:11:05 | FromDiscord | <albassort> For example, when exchanging between threads you might deepcopy to make sure that nothing is pointing to another thread |
20:11:25 | FromDiscord | <Gumbercules> just pass it - you have a reference to it anyway |
20:11:35 | FromDiscord | <albassort> In reply to @BlueCore "Yup, I know cloning": Can you elaborate a bit more? |
20:12:09 | FromDiscord | <albassort> Where are you passing to something that you don't want to mutate it? That's not really a thing in the standard library (I don't think?) so you probably had a condition |
20:12:21 | FromDiscord | <albassort> (edit) "Where are you passing to something that you don't want to mutate it? That's not really a thing in the standard library (I don't think?) so you ... probably" added "should" |
20:12:27 | FromDiscord | <albassort> But, if you want to |
20:12:50 | FromDiscord | <albassort> This is the way I do it (I'm sure others will chip in) |
20:13:05 | FromDiscord | <Phil> Inim example |
20:13:06 | FromDiscord | <Phil> sent a long message, see http://ix.io/4hPK |
20:13:44 | FromDiscord | <Phil> As you can see, x only contains the key "a", but y contains "a" and "potato"↵Thus y is a copy of x |
20:14:14 | FromDiscord | <Phil> I mean, you can also explicitly copy if you want, but you don't really need to worry |
20:14:24 | FromDiscord | <Yardanico> because Table is a value type, yes |
20:14:31 | FromDiscord | <Yardanico> but TableRef is not |
20:14:35 | FromDiscord | <Yardanico> although you should generally just use Table anyway |
20:14:37 | FromDiscord | <Phil> That is correct and fair |
20:14:50 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hPL |
20:14:55 | FromDiscord | <albassort> or |
20:14:55 | Mat42 | thanks for the answers, ciao |
20:14:57 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4hPL" => "https://play.nim-lang.org/#ix=4hPM" |
20:15:00 | * | Mat42 quit (Quit: Leaving) |
20:15:02 | FromDiscord | <albassort> (edit) "or ... " added "something" |
20:15:13 | FromDiscord | <Phil> see ya |
20:15:20 | FromDiscord | <albassort> (edit) "https://play.nim-lang.org/#ix=4hPM" => "https://play.nim-lang.org/#ix=4hPN" |
20:15:30 | FromDiscord | <albassort> no need for a special function, no reference is passed to copy |
20:16:37 | FromDiscord | <Shield> hey, i'd like to ask about the status of running nim dlls in a nim executable, did the gc problem get solved? |
20:16:47 | FromDiscord | <kaddkaka> Adding to my wishlist, `scanf` should have a symbol to parse Naturals: `scanf("5 - 10", "$n - $n", a, b)` |
20:17:08 | FromDiscord | <Gumbercules> @Shield https://github.com/Tail-Wag-Games/frag/blob/master/src/plugin.nim |
20:17:19 | FromDiscord | <kaddkaka> Also why doesnt seq.delete take backward indices (`^`)? |
20:17:46 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/app.nim |
20:18:29 | FromDiscord | <albassort> what is this |
20:18:36 | FromDiscord | <albassort> why is there so much asm |
20:18:40 | FromDiscord | <Gumbercules> it wasn't really a "problem" per se it was just the architecture |
20:18:57 | FromDiscord | <Gumbercules> In reply to @albassort "why is there so": because fibers don't exist on any other OS than windows and I didn't feel like using continuations or closure iterators |
20:19:18 | FromDiscord | <albassort> are they talking about nim libraries not getting gc because that would be literally impossible? |
20:19:20 | FromDiscord | <Gumbercules> so a boost's context library, without the boost stuff in it, works well as a drop-in |
20:19:29 | FromDiscord | <Gumbercules> no - Nim's old memory model relied on a thread-local heap |
20:19:43 | FromDiscord | <albassort> it doesn't anymore? |
20:19:48 | FromDiscord | <Gumbercules> it includes a shared heap |
20:19:58 | FromDiscord | <kaddkaka> In reply to @kaddkaka "Also why doesnt seq.delete": `stacks_CrateMover_9001[src].delete(^n..^1)` complains: `■ type mismatch: got <stack, HSlice[system.BackwardsIndex, system.BackwardsIndex]> ...` 😦 |
20:20:03 | FromDiscord | <Gumbercules> but thread-local heaps weren't the only problem |
20:20:06 | FromDiscord | <Shield> i'm reading through the files but what's the giveway? does it work? there was a somebody here working on a text editor with plugins and dropped dlls altogether |
20:20:17 | FromDiscord | <Gumbercules> each DLL needed its own instance of the Nim runtime for that thread-local heap to be GC'd |
20:20:25 | FromDiscord | <albassort> that sounds insane |
20:20:33 | FromDiscord | <Gumbercules> so the GC's would clobber one another |
20:20:52 | FromDiscord | <Shield> i'm still dreaming about making a modable game without scripting |
20:20:54 | FromDiscord | <Gumbercules> eh it's' not too crazy - a lot of GC'd languages do this |
20:20:55 | FromDiscord | <albassort> and now you just embed them in the shared memory on compile? |
20:21:04 | FromDiscord | <Gumbercules> mmm no |
20:21:12 | FromDiscord | <Gumbercules> I load the plugin dynamically and load symbols from it and execute those |
20:21:26 | FromDiscord | <Gumbercules> but I don't have to worry about every DLL I compile / load having its own GC |
20:21:28 | FromDiscord | <albassort> i meant standard code lol |
20:21:46 | FromDiscord | <albassort> your code is an extendable plugin system |
20:21:51 | FromDiscord | <Gumbercules> yes |
20:21:55 | FromDiscord | <albassort> so it has to be dynamic and cant go into shared |
20:22:03 | FromDiscord | <Gumbercules> no I can access the shared heap |
20:22:10 | FromDiscord | <Gumbercules> my host program loads the DLLs |
20:22:24 | FromDiscord | <Gumbercules> I don't access the host program's memory inside my plugin - I pass anything I need to it |
20:22:40 | FromDiscord | <albassort> nim + asm |
20:22:40 | FromDiscord | <Gumbercules> I pass a plugin object to my init function in my plugin, this has a pointer to my API object |
20:22:41 | FromDiscord | <albassort> not even once |
20:22:52 | FromDiscord | <Gumbercules> well I use the asm code here - |
20:23:01 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/fiber.nim |
20:23:09 | FromDiscord | <albassort> and yes, what is a fiber? |
20:23:10 | FromDiscord | <Gumbercules> which gets used here - https://github.com/Tail-Wag-Games/frag/blob/master/src/job.nim |
20:23:15 | FromDiscord | <Gumbercules> a fiber is a green thread / software thread |
20:23:29 | FromDiscord | <albassort> like a coroutine? |
20:23:30 | FromDiscord | <Gumbercules> it has its own context / stack very similar to a closure iterator |
20:23:40 | FromDiscord | <Gumbercules> similar but not exactly |
20:23:58 | FromDiscord | <Gumbercules> fiber's context switches need to be managed by some sort of scheduler |
20:24:01 | FromDiscord | <albassort> a coroutine with its own stack? |
20:24:02 | FromDiscord | <Gumbercules> and they of course can be resumed |
20:24:16 | FromDiscord | <albassort> so its async and not threaded |
20:24:19 | FromDiscord | <Gumbercules> well coroutines aren't scheduled really |
20:24:22 | FromDiscord | <BlueCore> sent a code paste, see https://play.nim-lang.org/#ix=4hPP |
20:24:34 | FromDiscord | <Gumbercules> mmmm it's green threads running on threads |
20:24:34 | FromDiscord | <Gumbercules> OS threads |
20:24:40 | FromDiscord | <Gumbercules> in my engine's case |
20:24:48 | FromDiscord | <albassort> 🤔 ok im gonna read up on this |
20:24:56 | FromDiscord | <Gumbercules> it's very similar to the job system laid out in this slide deck:http://www.gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine |
20:25:02 | FromDiscord | <Gumbercules> (edit) "deck:http://www.gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine" => "deck: http://www.gdcvault.com/play/1022186/Parallelizing-the-Naughty-Dog-Engine" |
20:25:13 | FromDiscord | <demotomohiro> @kaddkaka There are no `delete` proc for seq that takes `BackwordIndex` or `HSlice`. You would need to implement yourself. |
20:25:38 | FromDiscord | <Gumbercules> or video I guess - I thought I linked the presentation slides, my bad |
20:25:40 | FromDiscord | <Shield> @Gumbercules so did you get it to work fine? no little headaches? |
20:25:52 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> There are no": I thought BackwardIndex was desugared before the function call? |
20:25:55 | FromDiscord | <Gumbercules> I mean... headaches are subjective |
20:25:56 | FromDiscord | <albassort> this is extremely interesting |
20:26:01 | FromDiscord | <Gumbercules> I've been coding in Nim for 7 years |
20:26:12 | FromDiscord | <Gumbercules> what gives someone here a headache might not bother me as much |
20:26:12 | FromDiscord | <kaddkaka> (but I guess not) |
20:26:13 | FromDiscord | <Shield> last time i tried it it was something in the std lib not playing well |
20:26:42 | FromDiscord | <Gumbercules> mmmm if you're referring to the hot reloading functionality that Nim has as an experimental feature - I don't know what the status of it is |
20:27:05 | FromDiscord | <Gumbercules> there was also the issue with the default allocator not being threadsafe and needing to synchronize allocations |
20:27:34 | FromDiscord | <Gumbercules> but you can work around those now - there's some new experimental allocator which is supposed to become default - I tried getting it to work on windows using the MSVC compiler and it wouldn't work |
20:27:46 | FromDiscord | <Gumbercules> but this is why I'm using `mimalloc` in my project and may end up rolling my own stdlib + allocators |
20:27:47 | FromDiscord | <Shield> i wish there was a possibility where you just pass the allocator back to the dll when you load it |
20:27:49 | FromDiscord | <Gumbercules> need to benchmark mimalloc first |
20:27:58 | FromDiscord | <Gumbercules> well you can do this - just need to roll your own stdlib |
20:28:07 | FromDiscord | <Shield> yeah |
20:28:09 | FromDiscord | <Gumbercules> you can also patch Nim's `alloc.nim` |
20:28:26 | FromDiscord | <Gumbercules> which is probably a quicker way to do it |
20:28:26 | FromDiscord | <demotomohiro> @kaddkaka There are `[]` proc for seq that takes `BackwordsIndex` or `HSlice`.https://nim-lang.org/docs/system.html#%5B%5D%2CopenArray%5BT%5D%2CHSlice%5BU%3A%20Ordinal%2CV%3A%20Ordinal%5D |
20:28:29 | FromDiscord | <albassort> @Gumbercules from waht im reading so far, why are conflating green threads with fibers? |
20:28:42 | FromDiscord | <albassort> (edit) "waht" => "what" |
20:28:52 | FromDiscord | <Gumbercules> but you still have no nice way to say - for this one allocation, use this allocator |
20:29:00 | FromDiscord | <Gumbercules> In reply to @albassort "<@204328759715692544> from what im": I'm not? they're essentially the same thing |
20:29:15 | FromDiscord | <Shield> what's the next sane way to handle plugins then? assume a game where you want to add and update new entities |
20:29:58 | FromDiscord | <albassort> noooo green threads use mulithreading in a user environment rather that a kernel level environment allowing for more universal compatibility at the cost of speed |
20:30:04 | FromDiscord | <albassort> fibers are special boy rocoutines |
20:30:21 | FromDiscord | <Gumbercules> green threads are software threads |
20:30:28 | FromDiscord | <Gumbercules> fibers are software threads |
20:30:32 | FromDiscord | <Gumbercules> I fail to see a difference really |
20:30:33 | FromDiscord | <albassort> (edit) "rocoutines" => "coroutines" |
20:30:45 | FromDiscord | <Gumbercules> neither are scheduled by the OS |
20:30:51 | FromDiscord | <albassort> https://en.wikipedia.org/wiki/Fiber_(computer_science) |
20:30:56 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> There are `[]`": How does that interact with `delete`? |
20:31:02 | FromDiscord | <albassort> green threads can run fibers |
20:31:08 | FromDiscord | <Gumbercules> sure |
20:31:14 | FromDiscord | <Gumbercules> fibers can run more fibers |
20:31:15 | FromDiscord | <albassort> because they are tied to threads in the cpu |
20:31:22 | FromDiscord | <albassort> fibers are not |
20:31:40 | FromDiscord | <Gumbercules> huh? no... |
20:31:43 | FromDiscord | <albassort> green threads cannot run more green threads in the same sense a fiber can do fibers |
20:31:47 | FromDiscord | <Gumbercules> green threads are not tied to OS threads |
20:32:03 | FromDiscord | <albassort> but they're tied to hardware thread, otherwise they wouldn't function |
20:32:07 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4hPR |
20:32:11 | FromDiscord | <Gumbercules> well you need a thread to run a fiber on too |
20:32:51 | * | bmp joined #nim |
20:33:03 | FromDiscord | <Gumbercules> In reply to @Shield "what's the next sane": the way I'm doing it |
20:33:13 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hPS |
20:33:18 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hPT |
20:33:20 | FromDiscord | <Gumbercules> right |
20:33:21 | FromDiscord | <albassort> they exten concurrency |
20:33:29 | FromDiscord | <albassort> (edit) "exten" => "extend" |
20:33:34 | FromDiscord | <Gumbercules> green threads aren't preemptive either |
20:33:37 | FromDiscord | <albassort> green threads are parallelism |
20:33:39 | FromDiscord | <demotomohiro> @kaddkaka I dont think they do nothing to `delete`. |
20:33:44 | FromDiscord | <albassort> nonconcurrent |
20:34:18 | FromDiscord | <Gumbercules> I'm going to leave you to your understanding here @albassort if it's working for you haha |
20:34:30 | FromDiscord | <Gumbercules> but I think you're saying basically the same thing I am |
20:34:49 | FromDiscord | <Gumbercules> I'm not saying they are 1:1 in terms of implementation but there's no reason you couldn't replace fibers with green threads |
20:34:50 | FromDiscord | <albassort> lol |
20:34:52 | FromDiscord | <Gumbercules> or vis versa |
20:34:54 | FromDiscord | <albassort> im not trying to argue with you |
20:34:58 | FromDiscord | <albassort> lov u |
20:35:05 | FromDiscord | <Gumbercules> no I didn't take it that way, don't worry 🙂 |
20:35:07 | FromDiscord | <albassort> probably just different words |
20:35:21 | FromDiscord | <Gumbercules> @Shield - I use a C library - https://github.com/fungos/cr |
20:35:32 | FromDiscord | <Gumbercules> and I use this to manage the loading and unloading and rollback for my plugins |
20:35:43 | FromDiscord | <Gumbercules> you could replace it with something written in Nim |
20:35:50 | FromDiscord | <Gumbercules> there are some gotchas though - like preserving state between reloads |
20:35:57 | FromDiscord | <Gumbercules> but this can be handled with a simple template that introduces a custom pragma |
20:36:06 | FromDiscord | <albassort> as a side note, i really wanna get coroutines working in nim |
20:36:10 | FromDiscord | <albassort> current coroutines stuff sucks |
20:36:20 | FromDiscord | <Gumbercules> the plugin architecture you're describing is exactly what I have implemented in my game engine |
20:36:21 | FromDiscord | <demotomohiro> @kaddkaka If you implement a `delete` proc that works with `BackwordsIndex`, you would create a new `delete` proc that takes `BackwordsIndex`, covert it to just an index and call existing `delete`. |
20:36:21 | FromDiscord | <albassort> potentially fibers might be a better alternative |
20:36:33 | FromDiscord | <Gumbercules> In reply to @albassort "potentially fibers might be": fibers only have native support on Windows |
20:36:36 | FromDiscord | <albassort> boost has fibers on unix |
20:36:48 | FromDiscord | <Gumbercules> well not real fibers but yeah - that's what I"m using essentially |
20:36:54 | FromDiscord | <Gumbercules> the boost context library without any boost stuff in it |
20:36:59 | FromDiscord | <Shield> @Gumbercules what's the gotchas of your way? not preserving states is fine for me, i just want to know if i have to ditch std lib from the start |
20:37:07 | FromDiscord | <Gumbercules> no you don't |
20:37:20 | FromDiscord | <Gumbercules> there are no real gotchas per se |
20:37:26 | FromDiscord | <Shield> i'll bookmark your project, the assembly folder is pretty scary |
20:37:28 | FromDiscord | <Gumbercules> if you look at my code - it works |
20:37:29 | FromDiscord | <albassort> In reply to @Gumbercules "the boost context library": hmm? I haven't used boost. Is it a viable to wrap it for arbitrary code? |
20:37:33 | FromDiscord | <Gumbercules> you dont' need to worry about the assembly library |
20:37:39 | FromDiscord | <Gumbercules> I compile the asm files into object files here |
20:37:50 | FromDiscord | <c4ulmu> Hi again. I've read in documentation that AsyncHttpClient doesn't support timeout? Is it true? Is there other ways to have timeout for async http requests ? |
20:37:54 | FromDiscord | <kaddkaka> In reply to @demotomohiro "<@185793553539137537> If you implement": Sorry I dont follow. Do you mean that one of the `delete`s can be implemented using the other one? |
20:37:57 | FromDiscord | <albassort> oh no its c |
20:37:59 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/config.nims |
20:38:21 | FromDiscord | <Gumbercules> you don't need the assembly for this @Shield |
20:38:24 | FromDiscord | <Gumbercules> these are two different conversations xD |
20:38:37 | FromDiscord | <Gumbercules> the assembly code is used for context switching in my game engine's job system |
20:38:54 | * | krux02 quit (Quit: Leaving) |
20:38:55 | * | bmp left #nim (#nim) |
20:38:58 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/thirdparty/cr.cpp |
20:39:00 | FromDiscord | <albassort> sent a code paste, see https://play.nim-lang.org/#ix=4hPV |
20:39:07 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4hPW |
20:39:10 | FromDiscord | <albassort> asediohndfgioj\ |
20:39:20 | FromDiscord | <Yardanico> In reply to @c4ulmu "Hi again. I've": there's withTimeout that can be used for any async procedures, but AFAIK there is a bug because asynchttpclient doesn't accept a usual timeout |
20:39:21 | FromDiscord | <Gumbercules> I compile that cpp file and then use it here - https://github.com/Tail-Wag-Games/frag/blob/master/src/plugin.nim |
20:39:24 | FromDiscord | <albassort> the only other option is withTiemout |
20:39:25 | FromDiscord | <Yardanico> so dial etc might hang |
20:39:29 | FromDiscord | <Shield> just tell me the default gc play nice on both the executable and the plugins, i think advertising nim to make plugins with native speed would be pretty good |
20:39:38 | FromDiscord | <Gumbercules> https://github.com/Tail-Wag-Games/frag/blob/master/src/app.nim is the entry point |
20:39:40 | FromDiscord | <albassort> In reply to @Yardanico "there's withTimeout that can": +100 never got withTimeout to work |
20:39:46 | FromDiscord | <Gumbercules> I use `--gc:arc/orc` |
20:39:46 | FromDiscord | <Yardanico> In reply to @albassort "+100 never got withTimeout": not what I mean |
20:39:53 | FromDiscord | <Gumbercules> for now - arc since I don't have any cycles in my program |
20:39:53 | FromDiscord | <Yardanico> withTimeout works fine for me |
20:40:02 | FromDiscord | <albassort> i suppose its the context i use it in |
20:40:12 | FromDiscord | <Gumbercules> `orc` will become the default gc in Nim 2.0 which is supposedly near |
20:40:27 | FromDiscord | <albassort> In reply to @Gumbercules "`orc` will become the": im excited and afraid |
20:40:30 | FromDiscord | <Gumbercules> I have no idea when, I haven't been following Nim that closely later |
20:40:35 | FromDiscord | <Gumbercules> eh, it will be fine |
20:40:52 | FromDiscord | <c4ulmu> Thank you. I will try withTimeout |
20:41:41 | FromDiscord | <Shield> the deal breaker for me are always async/network stuff, gui and the dlls |
20:41:51 | FromDiscord | <Shield> i didn't touch nim for a year and i'm out of the loop |
20:42:03 | FromDiscord | <Shield> it seems that gui is still not solved |
20:42:04 | FromDiscord | <Gumbercules> mmm - I don't use any async I rolled my own coroutines |
20:42:10 | FromDiscord | <demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4hPZ |
20:42:14 | FromDiscord | <Gumbercules> gui I use dearimgui |
20:42:26 | FromDiscord | <Gumbercules> and plugin architectures work now with the new memory model |
20:42:34 | FromDiscord | <Gumbercules> they could work before too - you just couldn't use Nim's stdlib |
20:42:51 | FromDiscord | <Yardanico> In reply to @Gumbercules "they could work before": wdym? |
20:42:59 | FromDiscord | <Yardanico> with nimrtl you could |
20:43:08 | FromDiscord | <Shield> nope |
20:43:12 | FromDiscord | <Shield> nimrtl didn't work well |
20:43:17 | FromDiscord | <kaddkaka> @demotomohiro right, I guess I was surprised that that proc doesn't come for free |
20:43:24 | FromDiscord | <Gumbercules> yeah but you couldn't really avoid the GC's from collecting since they had no clue multiple instances of the runtime existed |
20:43:27 | FromDiscord | <Yardanico> I'm talking if your whole program was using Nim, and the host app and plugins were using nimrtl |
20:43:30 | FromDiscord | <Shield> "didnt" (i dunno if it still doesn't) |
20:43:43 | FromDiscord | <Gumbercules> this is why the whole hot reload experimental feature never panned out |
20:43:48 | FromDiscord | <c4ulmu> I just very surprised that async http client doesn't support timeout. Timeouts is the very first thing for production use |
20:43:51 | FromDiscord | <kaddkaka> nimrtl?! is that a thing? |
20:44:08 | FromDiscord | <Gumbercules> it's a compiler option - it just indicated to the compiler that it should be linked to the program |
20:44:11 | FromDiscord | <kaddkaka> oh rtl is maybe not what I think it is ... |
20:44:15 | FromDiscord | <Gumbercules> runtime library |
20:44:20 | FromDiscord | <kaddkaka> ah... |
20:44:27 | FromDiscord | <Yardanico> you can compile nimrtl separately |
20:44:34 | FromDiscord | <Yardanico> so then all different nim dlls have a shared GC runtime |
20:44:43 | FromDiscord | <Yardanico> since they would load it dynamically |
20:44:44 | FromDiscord | <kaddkaka> I was thinking Register Transfer Level 😅 |
20:45:08 | FromDiscord | <Yardanico> https://nim-lang.org/docs/nimc.html#dll-generation |
20:45:32 | FromDiscord | <Gumbercules> if I allocated a sequence in my host program on its thread local heap and then passed it to my plugin, even if it was compiled with `nimrtl` program would eventually segfault / deadlock |
20:45:42 | FromDiscord | <Gumbercules> with the default refc gc |
20:46:03 | FromDiscord | <albassort> i wonder if puppy with stop dead locking in the middle of ssl requests |
20:46:22 | FromDiscord | <Gumbercules> this is no longer the case with `arc/orc` and you also no longer need to worry about linking anything against the nimrtl library |
20:46:36 | FromDiscord | <Gumbercules> it "just works" |
20:46:50 | FromDiscord | <albassort> gumber, should i ever learn asm? |
20:47:04 | FromDiscord | <albassort> I've had a hard time getting nim working with it embedded |
20:47:49 | FromDiscord | <Gumbercules> if you're interested in systems programming I'd say learning some assembly is most definitely worth it |
20:47:59 | FromDiscord | <Shield> i really wish --gc:regions went somewhere |
20:48:03 | FromDiscord | <Gumbercules> 6502 is easy to pick up, although not really used anymore |
20:48:06 | FromDiscord | <Shield> it was amazing |
20:48:38 | FromDiscord | <jmgomez> In reply to @Yardanico "https://nim-lang.org/docs/nimc.html#dll-generation": is it a pre-orc thing? I never ran into any issues with multiple dlls |
20:48:42 | FromDiscord | <Yardanico> yes |
20:49:02 | FromDiscord | <Gumbercules> https://repo.zenk-security.com/Magazine%20E-book/Hacking-%20The%20Art%20of%20Exploitation%20(2nd%20ed.%202008)%20-%20Erickson.pdf |
20:49:06 | FromDiscord | <Gumbercules> fun book that teaches some assembly |
20:49:13 | FromDiscord | <Yepoleb> i think reading assembly is great skill, but you almost never have to write it |
20:49:14 | FromDiscord | <jmgomez> where I did run into issues is if I try to use nim from other thread created in cpp. Is that a known problem? |
20:49:49 | FromDiscord | <Gumbercules> `setupForeignThreadGc ` |
20:49:58 | FromDiscord | <albassort> gumb one last thing |
20:50:06 | FromDiscord | <albassort> do you think i can do libaco |
20:50:13 | FromDiscord | <albassort> (edit) "do you think i can do libaco ... " added "in nim?" |
20:50:43 | FromDiscord | <Shield> @jmgomez so both your host and your dll ran nim just fine? |
20:50:46 | FromDiscord | <Gumbercules> sure - although it also relies on assembly |
20:50:49 | FromDiscord | <Shield> i'd like more input |
20:51:00 | FromDiscord | <albassort> In reply to @Gumbercules "sure - although it": will that be a pita |
20:51:03 | FromDiscord | <albassort> for wrappingf |
20:51:05 | FromDiscord | <albassort> (edit) "wrappingf" => "wrapping" |
20:51:16 | FromDiscord | <jmgomez> In reply to @Shield "<@726017160115126333> so both your": yes, and algo a third one, game.dll |
20:51:19 | PMunch | I've run a Nim DLL and so in production. Embedded into an existing C program |
20:51:23 | * | ltriant joined #nim |
20:51:36 | FromDiscord | <Gumbercules> It's no more difficult than wrapping C code |
20:51:42 | PMunch | It might be a bit finicky to get right, but isn't all that hard to figure out |
20:52:01 | FromDiscord | <Gumbercules> @PMunch they're talking about hot reloading w/ plugins from a Nim host |
20:52:09 | PMunch | Just need to make sure to call NimMain and with ARC/ORC I believe you don't even need NimRTL any longer |
20:52:12 | FromDiscord | <Gumbercules> plugins authored in Nim |
20:52:12 | PMunch | Aah |
20:52:24 | FromDiscord | <Gumbercules> shield trust me, this all works |
20:52:25 | FromDiscord | <Shield> i think the actual problem was when both the host and the dlls were made with nim, there was no problem if you use other languages |
20:52:26 | PMunch | Well the idea should be the same |
20:52:31 | FromDiscord | <Gumbercules> yeah |
20:52:46 | FromDiscord | <Gumbercules> I wouldn't be writing my game engine with a plugin architecture if I was concerned it wouldn't work |
20:52:56 | FromDiscord | <Gumbercules> that or I wouldn't be using Nim |
20:52:57 | PMunch | There where some weird limitations like that with refc, but with ARC/ORC this has become much easier |
20:53:57 | FromDiscord | <albassort> aco doesn't seem too hard to wrap |
20:54:02 | FromDiscord | <albassort> it looks really nice too |
20:54:04 | FromDiscord | <albassort> 👀 |
20:54:06 | FromDiscord | <Shield> time to try that again i guess |
20:54:28 | FromDiscord | <albassort> if i was born 20 years earlier i'd be a c programer |
20:54:50 | FromDiscord | <albassort> 25 i'd be a pascal |
20:55:00 | FromDiscord | <albassort> 30 c again |
20:55:14 | FromDiscord | <Shield> would you? wasn't c++ hot back in 2000 |
20:55:26 | FromDiscord | <Shield> nvm |
20:55:35 | FromDiscord | <Shield> ignore that please |
20:55:37 | PMunch | Oh no, just realised people commented on my stream without me noticing.. Damn you chat overlay program (which I forgot to actually start)! |
20:55:52 | FromDiscord | <Shield> link? |
20:56:11 | FromDiscord | <albassort> It was but I think my personality would still hate c++ |
20:56:12 | * | ltriant quit (Ping timeout: 268 seconds) |
20:56:35 | FromDiscord | <albassort> its the same reason i prefer JS over TS |
20:56:42 | FromDiscord | <albassort> i like the chaos i methinks |
20:57:11 | FromDiscord | <Shield> @exelotl ! my guy how's your game going? |
20:57:14 | FromDiscord | <exelotl> C++ was my first language and I've pretty much never enjoyed it... it's just pure friction and jumping through hoops and features that don't fit together and historical baggage |
20:57:28 | FromDiscord | <exelotl> it's going good thanks! |
20:57:37 | FromDiscord | <albassort> in 2000 it was a young baby lang |
20:57:40 | FromDiscord | <albassort> i imagine it wasn't so bad |
20:57:58 | FromDiscord | <Shield> i could use more nim videos and stream |
20:58:04 | FromDiscord | <exelotl> I started learning it around 2008 or so |
20:58:11 | FromDiscord | <albassort> it was very annoying, the only time i ever had to use C++, I had to update an old library because half of it was gutted |
20:58:24 | FromDiscord | <albassort> by like a 2012 update |
20:58:45 | * | PMunch quit (Quit: leaving) |
20:58:45 | FromDiscord | <albassort> so i had to fiercely google the replacement code while not knowing any C++ and barely any systems lang |
20:59:56 | FromDiscord | <exelotl> In reply to @Shield "<@90614688374624256> ! my guy": we hit a big milestone with the full game last week - 50% content complete (you can play the game from start to middle) |
21:01:39 | FromDiscord | <Gumbercules> I love coding in C/C++ |
21:01:53 | FromDiscord | <Gumbercules> C especially |
21:01:59 | FromDiscord | <Gumbercules> but I'm much more productive in Nim |
21:02:10 | FromDiscord | <Shield> cool, it's always nice going through your github and projects |
21:02:19 | FromDiscord | <Shield> i'm catching up a bit |
21:03:05 | FromDiscord | <Shield> btw, did araq finally document that goto pragma? |
21:07:19 | FromDiscord | <etra> huh, I just noticed that when I run my compiled program through valgrind, I get a lot of uninitialized values errors, but when I use `--gc:orc` I don't have any error |
21:10:18 | FromDiscord | <Yardanico> In reply to @etra "huh, I just noticed": if you want to actually use valgrind, then only use it with arc/orc + `-d:useMalloc` |
21:10:22 | FromDiscord | <Yardanico> because nim uses its own allocator by default |
21:10:29 | FromDiscord | <Yardanico> and valgrind doesn't like refc because it does stack scanning |
21:11:19 | FromDiscord | <etra> ooh, thanks, TIL! |
21:12:52 | FromDiscord | <etra> is there a way to always prefer `orc`? |
21:13:37 | * | pech quit (Read error: Connection reset by peer) |
21:13:57 | FromDiscord | <Yardanico> wdym? |
21:14:04 | FromDiscord | <auxym> `--mm:orc` ? |
21:14:15 | FromDiscord | <auxym> or add it to your project nim.cfg |
21:14:44 | * | disso_peach joined #nim |
21:16:12 | FromDiscord | <etra> yeah the nim.cfg was it! |
21:16:37 | FromDiscord | <etra> I still have a bit of trouble understanding when to use `ref`, and when not 😅 |
21:18:31 | FromDiscord | <auxym> seems to be a common question for newcomers |
21:18:43 | FromDiscord | <auxym> TLDR: don't use ref unless you need it |
21:19:02 | FromDiscord | <auxym> and you need it when you need multiple "handles" to a single piece of data |
21:19:10 | FromDiscord | <Elegantbeef> People still dont seem to get that auxym 😄 |
21:19:11 | FromDiscord | <Yardanico> or for mutability in async code |
21:19:16 | FromDiscord | <Yardanico> that's kind of all |
21:19:21 | FromDiscord | <Yardanico> otherwise you can just use `var` |
21:19:30 | FromDiscord | <Yardanico> if you e.g. need to mutate something in a proc |
21:19:33 | FromDiscord | <etra> so, for example, if I'm writing a _linked_ stack, the Node should not be ref? |
21:19:47 | FromDiscord | <Elegantbeef> I just link https://forum.nim-lang.org/t/8426#54529 whenever someone asks |
21:20:20 | FromDiscord | <Elegantbeef> Yes if you have a non terminating cyclical type you need a ref |
21:20:45 | FromDiscord | <Elegantbeef> Non ref objects are structs so require infinite memory when non terminating cycles appear |
21:22:04 | * | xet7 quit (Ping timeout: 260 seconds) |
21:22:57 | FromDiscord | <auxym> that too |
21:23:06 | FromDiscord | <Yepoleb> i use refs for things with destructors |
21:23:19 | FromDiscord | <Yardanico> In reply to @Yepoleb "i use refs for": so you mean shared mutability? |
21:23:26 | FromDiscord | <Yardanico> because you don't inherently need refs to use destructors |
21:23:38 | FromDiscord | <Yardanico> destructors are written as `var ObjectType` so they work for normal objects too |
21:24:43 | FromDiscord | <Yardanico> ah yeah I parsed your sentence incorrectly :P |
21:24:43 | FromDiscord | <Elegantbeef> Well destructors only work with value types 😄 |
21:24:44 | FromDiscord | <Yardanico> time to sleep |
21:25:06 | FromDiscord | <Elegantbeef> Yea i often also use refs with destructors as it better fits the semantics i want |
21:25:20 | FromDiscord | <Elegantbeef> But disabling copy and only sinking also works |
21:26:09 | FromDiscord | <Yepoleb> i think destructors are more specific in nim than in other language |
21:26:15 | FromDiscord | <Yepoleb> i mean a clean up function |
21:27:39 | FromDiscord | <Yepoleb> so os handles for examples, it's very hard to make them copyable in a meaninful way |
21:45:45 | * | anddam quit (Quit: WeeChat 3.6) |
21:56:55 | * | anddam joined #nim |
21:58:15 | * | anddam quit (Client Quit) |
21:58:57 | * | anddam joined #nim |
21:59:25 | * | disso_peach quit (Quit: Leaving) |
22:00:58 | * | jmdaemon joined #nim |
22:15:20 | * | ltriant joined #nim |
22:51:50 | FromDiscord | <MetuMortis> What is the best way to create a nim project? Is there any way to install dependencies per project not globally (like node_modules at NodeJS)? Is it possible to create different configs for each project (like package.json at NodeJS)? |
22:52:31 | FromDiscord | <Generic> post people use nimble to manage dependencies |
22:52:38 | FromDiscord | <Generic> (edit) "post" => "most" |
22:52:47 | FromDiscord | <MetuMortis> I have nimble too, is it like npm? |
22:52:49 | FromDiscord | <Elegantbeef> `nimble init`. I think with nimble 0.14 but that's not out, so no. Yes make a `config.nims` at the root of your project |
22:53:08 | FromDiscord | <Elegantbeef> It's a package manager yes |
22:53:31 | FromDiscord | <MetuMortis> thanks |
23:13:22 | * | xet7 joined #nim |
23:25:27 | * | xet7 quit (Ping timeout: 268 seconds) |
23:33:00 | * | xet7 joined #nim |
23:34:41 | * | dtomato4 quit (Quit: The Lounge - https://thelounge.chat) |
23:35:16 | * | dtomato4 joined #nim |
23:43:24 | FromDiscord | <jtv> Bumping from earlier today, assuming the answer here is I'm SOL: Is there any good way to get the calling context for a macro? Particularly, I want to generate procs at the module scope to avoid weird errors, so if someone calls my macro within a proc/func context, I would like to error on that, instead of generating a nested proc. |
23:47:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hQH |
23:47:45 | FromDiscord | <jtv> Thanks 🙂 |