00:06:05 | FromDiscord | <&_dükk ™> have a `set[string]`, getting error `ordinal type expected`, any thoughts? |
00:07:01 | FromDiscord | <Elegantbeef> `set` is a bitset not a hashset |
00:07:01 | FromDiscord | <Elegantbeef> look at `std/sets` |
00:09:24 | FromDiscord | <&_dükk ™> ah, i see |
00:09:24 | FromDiscord | <&_dükk ™> thanks! |
00:23:52 | * | rockcavera quit (Remote host closed the connection) |
00:47:37 | * | lucasta joined #nim |
01:08:13 | FromDiscord | <spikeisaac> In reply to @michaelb.eth "do you have any": maybe assembly |
01:08:31 | FromDiscord | <Elegantbeef> Nlvm might be for you |
01:08:33 | FromDiscord | <nwb^3> can anyone tell me if sequences really for have a builtin .find lambda or should i just give up using chatgpt as learning resource for nim 😛 |
01:08:47 | FromDiscord | <Elegantbeef> There is a built in procedure for `fin` |
01:08:50 | FromDiscord | <nwb^3> sent a code paste, see https://paste.rs/J3k |
01:08:54 | FromDiscord | <michaelb.eth> In reply to @spikeisaac "maybe assembly": maybe not exactly what you have in mind, but see nlvm: https://github.com/arnetheduck/nlvm |
01:08:59 | FromDiscord | <Elegantbeef> Yea that's not how find works |
01:09:14 | FromDiscord | <Elegantbeef> `people.find(Person(name: "John", age: 25))` |
01:09:58 | FromDiscord | <Elegantbeef> One could make a find proc that took a procedure instead of course |
01:10:28 | FromDiscord | <nwb^3> thanks i see |
01:11:24 | FromDiscord | <nwb^3> its creating a tmp_person and doing a quick iteration using tmp_person in people |
01:11:30 | FromDiscord | <nwb^3> thanks for the help |
01:11:50 | * | beholders_eye quit (Ping timeout: 260 seconds) |
01:11:52 | * | cm quit (Ping timeout: 252 seconds) |
01:12:12 | FromDiscord | <spikeisaac> In reply to @michaelb.eth "maybe not exactly what": oh that’s cool |
01:12:27 | FromDiscord | <Elegantbeef> Not that there is much benefit to using LLVM 😄 |
01:12:59 | * | cm joined #nim |
01:17:40 | FromDiscord | <auxym> nim already has a native backend, just happens to be called gcc 😉 |
01:20:19 | FromDiscord | <Elegantbeef> Or clang, or msvc |
01:20:19 | FromDiscord | <Elegantbeef> Or zig 😛 |
01:44:15 | FromDiscord | <michaelb.eth> In reply to @Elegantbeef "Or zig 😛": you mean via zig's compiler toolchain? or is someone working on a "transpiler" of Nim code to Zig code? |
01:45:58 | FromDiscord | <Elegantbeef> I mean using zig as a C compiler |
01:45:58 | FromDiscord | <Elegantbeef> Though Saem was interested in using Zig as a backend for the fork that shall not be named |
01:45:58 | FromDiscord | <Elegantbeef> No clue if he'll push that way 😄 |
01:52:40 | * | rockcavera joined #nim |
02:17:31 | * | rockcavera quit (Remote host closed the connection) |
02:18:02 | * | rockcavera joined #nim |
02:20:25 | systemdsucks | there's a fork of nim? |
02:22:44 | FromDiscord | <demotomohiro> https://github.com/nim-works/nimskull |
02:33:43 | systemdsucks | thanks |
02:35:34 | * | rockcavera quit (Remote host closed the connection) |
02:35:58 | * | rockcavera joined #nim |
02:54:03 | FromDiscord | <ArchGelod> it's weird: why would they leave unchanged nim icon and nim-related names if they want to make something "entirely different" and just forked for a compiler? |
02:54:41 | FromDiscord | <Elegantbeef> Cause they're still working on it and are dedicating time to more important things |
03:52:04 | * | TakinOver joined #nim |
05:06:37 | * | rockcavera quit (Remote host closed the connection) |
05:45:01 | * | ormiret quit (Read error: Connection reset by peer) |
05:45:24 | * | ormiret joined #nim |
05:45:48 | * | robertmeta quit (Ping timeout: 265 seconds) |
05:47:24 | * | robertmeta joined #nim |
06:08:30 | FromDiscord | <Yardanico> Beef look, nimscripter is taking over the world |
06:08:32 | FromDiscord | <Yardanico> http://github.com/gabbhack/nimplay↵↵https://nimplay.gabb.eu.org/ |
06:08:47 | FromDiscord | <Yardanico> Nim compiler running in the browser, right now Nimscript only |
06:08:51 | FromDiscord | <Yardanico> still funny |
06:09:01 | FromDiscord | <Elegantbeef> Nice |
06:09:27 | FromDiscord | <Yardanico> 0 modifications to the compiler itself apparently |
06:09:37 | FromDiscord | <Yardanico> emscripten is too good at emulating libc and stuff |
06:09:40 | FromDiscord | <Elegantbeef> Yea i knew Nim -\> Wasm worked 😄 |
06:09:57 | FromDiscord | <Elegantbeef> https://www.jasonbeetham.com/snake/nicoscripter.html has existed for quite some time |
06:10:26 | FromDiscord | <Elegantbeef> Someone really should take drawim and merge it with this 😄 |
06:11:06 | FromDiscord | <Yardanico> Now to compile Clang and LLVM into WASM so we can compile Nim into C into WASM and execute right in the browser |
06:11:11 | FromDiscord | <Yardanico> But first JS backend |
06:11:19 | FromDiscord | <Yardanico> Shouldn't be too hard |
06:11:41 | FromDiscord | <Elegantbeef> Yea the JS backend shouldnt be too bad |
06:12:33 | FromDiscord | <Elegantbeef> The real awesome thing is how small their file is |
06:12:42 | FromDiscord | <Elegantbeef> https://github.com/gabbhack/nimplay/blob/master/src/wasm.nim all it took |
06:14:15 | * | arkurious quit (Quit: Leaving) |
06:15:34 | FromDiscord | <Elegantbeef> Anywho thanks for sharing, quite chuffed to see Nimscripter in use |
06:16:11 | FromDiscord | <huantian> chuffed to bits |
06:16:29 | FromDiscord | <Elegantbeef> I do still need to cleanup the `parseObject` macro cause that is fugly |
06:18:30 | * | Guest9040 joined #nim |
06:19:04 | * | Guest9040 quit (Client Quit) |
06:20:14 | FromDiscord | <Elegantbeef> Hmm i might have a way to axe that now that i'm looking at this code again |
07:11:59 | FromDiscord | <Chronos [She/Her]> In reply to @Elegantbeef "Though Saem was interested": Oh? Why use Zig instead of C? Especially since zig has a fork of clang that works |
07:12:51 | FromDiscord | <Elegantbeef> Zig has better features and has a cross platform linker |
07:13:06 | FromDiscord | <Chronos [She/Her]> Hm fair |
07:14:06 | FromDiscord | <Chronos [She/Her]> I'm interested in Nimskull/Cyo but the Cyo ecosystem won't be as big as Nim, and considering they removed async (for now, due to difficulty in maintaining it and stuff) it kinda removes what I'd use it for anyway |
07:26:25 | * | PMunch joined #nim |
07:39:25 | * | beholders_eye joined #nim |
07:47:01 | * | advesperacit joined #nim |
08:01:39 | * | Notxor joined #nim |
08:08:24 | * | lucasta quit (Ping timeout: 252 seconds) |
08:09:06 | * | lucasta joined #nim |
08:20:59 | * | jmdaemon quit (Ping timeout: 248 seconds) |
08:31:13 | FromDiscord | <Rika> I’ve been ruined by OTP to use any other language for asynchrony or networking ever again |
08:34:48 | PMunch | OTP? |
08:38:19 | FromDiscord | <Andreas> In reply to @PMunch "OTP?": AFAIK https://en.wikipedia.org/wiki/Open_Telecom_Platform |
08:45:39 | * | cyraxjoe quit (Ping timeout: 255 seconds) |
08:45:48 | * | lucasta quit (Quit: Leaving) |
08:47:06 | PMunch | Ah Erlang stuff |
08:47:08 | PMunch | Makes sense |
08:47:36 | PMunch | What makes it so great @Rika? Or rather why wouldn't it be possible to implement something similar in Nim? |
08:48:16 | FromDiscord | <Andreas> In reply to @PMunch "What makes it so": It's all in the movie :=}} https://www.youtube.com/watch?v=xrIjfIjssLE |
08:48:30 | FromDiscord | <Rika> In reply to @PMunch "What makes it so": Well first is to adopt the process system and the ideology no? That is pretty Herculean I’d say |
08:49:14 | PMunch | Oh sorry, I'm on IRC so didn't realise that comment was in reference to something :P |
08:51:22 | FromDiscord | <Yardanico> hm? it wasn't |
08:51:27 | FromDiscord | <Yardanico> the irc bridge shows you replies |
08:51:35 | FromDiscord | <Yardanico> this is how it looks in discord https://media.discordapp.net/attachments/371759389889003532/1101430499353829437/image.png |
08:53:12 | FromDiscord | <Amun-Ra> And if you have a nice relay script this is how it may look on IRC: https://media.discordapp.net/attachments/371759389889003532/1101430905605718016/irc.png |
08:53:16 | PMunch | Oh, my bad again I guess. I thought someone had posted the Erlang movie before Rikas comment.. |
08:53:34 | PMunch | Ooh, I like those paragraphs |
08:53:54 | PMunch | Mine just shows as normal users |
08:54:02 | PMunch | Gotta update my script :) |
08:54:19 | Amun-Ra | I'm using weechat with parse_relayed_msg.pl |
08:54:30 | Amun-Ra | § is my char of choice |
08:54:58 | Amun-Ra | you just have to add the nick of the bot to the list and et voila |
08:55:46 | FromDiscord | <PMunch> I'm using a similar thing for HexChat |
08:55:55 | FromDiscord | <PMunch> With a Python script that I've modified |
08:56:58 | PMunch | There, I believe it should append a paragraph symbol now |
08:57:02 | Amun-Ra | :) |
08:57:26 | Amun-Ra | the nice thing is weechat autocompletes relayed nicks, too |
08:57:36 | PMunch | Ditto for HexChat |
08:58:02 | Amun-Ra | although relayed message containing the nick has to be fairly recent |
08:59:35 | PMunch | HexChat does all of them :) |
08:59:40 | Amun-Ra | nice :) |
09:01:21 | NimEventer | New thread by shirleyquirk: Type binding generic alias with extra parameter, see https://forum.nim-lang.org/t/10140 |
09:17:14 | FromDiscord | <Yardanico> @beef have you noticed that arc/orc don't work with emscripten? |
09:17:16 | FromDiscord | <Yardanico> which is weird |
09:17:21 | FromDiscord | <Yardanico> I think they should work just fine |
09:17:39 | FromDiscord | <Yardanico> simple programs do compile, but e.g. the compiler or nimes (nim nes emulator) throw memory out of bounds at runtime in the browser |
09:17:47 | FromDiscord | <Yardanico> (edit) "compile," => "compile and run just fine," |
09:22:08 | FromDiscord | <Elegantbeef> I have not noticed that |
09:47:56 | FromDiscord | <PMunch> So, anything fun happened this past week while I was gone? |
10:27:48 | * | ltriant quit (Ping timeout: 255 seconds) |
10:28:45 | NimEventer | New thread by drkameleon: Using named blocks with break instead of exceptions for targetted exception handling, see https://forum.nim-lang.org/t/10141 |
11:07:42 | FromDiscord | <spikeisaac> In reply to @Elegantbeef "Not that there is": well I want to compile to machine code, not c or c++ |
11:14:26 | PMunch | spikeisaac, well the C/C++ can be compiled to machine code.. |
11:14:35 | PMunch | Which is how Nim typically compiles stuff |
11:17:47 | PMunch | Hmm, Amun-Ra slight problem with my script. It now auto-completes with the paragraph symbol :P |
11:22:00 | Amun-Ra | PMunch: haha :D |
11:34:16 | FromDiscord | <spikeisaac> In reply to @PMunch "<@847850563604840488>, well the C/C++": yup |
11:34:39 | FromDiscord | <spikeisaac> but we compile our nim code to c or c++ than compile to machine code |
11:35:57 | PMunch | Huh? |
11:36:14 | FromDiscord | <spikeisaac> ? |
11:36:27 | PMunch | Not sure what you meant by that |
11:36:50 | PMunch | You want machine code, Nim can generate machine code, it just takes a mostly transparent step of going by a C compiler |
11:37:05 | FromDiscord | <spikeisaac> oh ok |
11:37:32 | FromDiscord | <spikeisaac> so using something like GCC or Clang? |
11:38:19 | PMunch | Yup |
11:38:46 | PMunch | When you run `nim c myprogram` you get a binary file. Behind the scenes Nim creates C code and invokes the C compiler |
11:39:05 | PMunch | By default it uses GCC, but you can easily swap in another |
11:39:57 | PMunch | For example you could use Clang, or the AVR compiler for doing stuff for Arduino, or even some other small C compilers like whatever they use for creating GBA games in Nim (I assume that's a separate compiler) |
11:40:22 | FromDiscord | <spikeisaac> So whats the difference between using that or LLVM? Isn't LLVM faster for compiling to machine code? |
11:40:55 | PMunch | Well the reason Nim uses C as a middle step is basically just because LLVM wasn't around/stable by the time Nim was created |
11:41:33 | FromDiscord | <Rika> In reply to @spikeisaac "So whats the difference": well is it? |
11:42:01 | PMunch | There are pros and cons to both approaches, but going with C compilers as a target means that you get a lot of optimisations for free because of how much time has been spent on creating fast compilers. And you get a lot of flexibility because C runs pretty much everywhere |
11:42:34 | FromDiscord | <spikeisaac> so is it just as fast as if I were to use LLVM |
11:42:49 | PMunch | To compile or to run? |
11:45:09 | PMunch | Nim both compiles and runs plenty fast |
11:45:48 | PMunch | The compilation can be slowed down quite a bit if you use a ton of macros, but that's just because you're actually doing work during compile-time :P |
11:46:25 | PMunch | And the binaries can be optimised just as much as C/C++ if you want to spend the time |
12:11:24 | FromDiscord | <jmgomez> Plus it allows for seamless interop which is one of the key features of Nim |
12:20:54 | FromDiscord | <planetis> How do you translate the asm statement in nim: https://stackoverflow.com/questions/15041519/benchmarking-code-reordering-volatile `asm volatile ("" : "+r" (m) : "r" (result));` |
13:47:42 | * | progranner joined #nim |
13:49:07 | * | progranner quit (Client Quit) |
13:49:32 | * | PMunch quit (Quit: Leaving) |
13:52:21 | * | progranner joined #nim |
13:57:34 | * | rockcavera joined #nim |
14:03:32 | FromDiscord | <demotomohiro> In reply to @spikeisaac "well I want to": Here is why Nim generate C/C++ code:↵https://internet-of-tomohiro.netlify.app/nim/faq.en.html#language-design-why-nim-generate-cslashcplusplus-codeqmark |
14:26:11 | FromDiscord | <Nerve> sent a long message, see http://ix.io/4usU |
14:38:46 | FromDiscord | <Yardanico> https://github.com/nim-lang/Nim/issues/21744 |
14:38:56 | FromDiscord | <Yardanico> you know what's funny? i didn't know that .nimcfg is valid either |
14:39:12 | FromDiscord | <Yardanico> and searching through github and all nimble packages - absolutely no one has ever used .nimcfg except the coro module in nim stdlib |
14:39:19 | FromDiscord | <Yardanico> :DD |
14:39:20 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
14:39:56 | FromDiscord | <Yardanico> at least there are no instances of .nimcfg on github other than for nim repo forks for coro.nimcfg, same goes for packages in nimble |
14:43:44 | FromDiscord | <sOkam!> has anyone cross-compiled nim apps for mac?↵would love to take a look at the compiler setup required to do so, since the docs are very sparse on information about it↵also, how does nim work natively on a mac? if i install with choosenim (is it even possible to do so?) then what compiler will nim on mac by default? 🤔 |
14:44:01 | FromDiscord | <sOkam!> (edit) "has anyone cross-compiled nim apps for mac?↵would love to take a look at the compiler setup required to do so, since the docs are very sparse on information about it↵also, how does nim work natively on a mac? if i install with choosenim (is it even possible to do so?) then what compiler will nim ... on" added "use" |
14:44:35 | FromDiscord | <Yardanico> In reply to @sOkam! "has anyone cross-compiled nim": > "then what compiler will nim use on mac by default?" |
14:44:43 | FromDiscord | <Yardanico> clang of course, nim supports clang just as well as gcc |
14:44:55 | FromDiscord | <sOkam!> clang is native for mac? didn't know |
14:45:01 | FromDiscord | <Rika> yes its what xcode uses |
14:45:03 | FromDiscord | <Yardanico> it is, apple are using clang for all of their stuff |
14:45:14 | FromDiscord | <Yardanico> swift uses llvm as the backend example |
14:45:14 | FromDiscord | <sOkam!> i barely know anything about apple software, so probably the question is super noob |
14:45:16 | FromDiscord | <Rika> iirc clang is partially also an apple creation |
14:45:18 | FromDiscord | <Yardanico> and for all native stuff they use clang |
14:45:29 | FromDiscord | <sOkam!> ah makes senses |
14:45:29 | FromDiscord | <Yardanico> In reply to @Rika "iirc clang is partially": it wasn't initially created by apple, but they did contribute heavily, yeah |
14:45:36 | FromDiscord | <Yardanico> because of permissive licensing compared to gcc |
14:46:42 | FromDiscord | <Yardanico> they did use GCC in the past, but of course not the way FSF would want GCC to be used :) |
14:46:50 | * | progranner joined #nim |
14:47:25 | FromDiscord | <sOkam!> #classic |
14:47:42 | FromDiscord | <Yardanico> actually sorry, it was even that way with NeXT |
14:47:45 | FromDiscord | <Yardanico> <https://en.wikipedia.org/wiki/Objective-C#Popularization_through_NeXT> |
14:48:15 | FromDiscord | <sOkam!> so, compiler question answered↵now, does choosenim have support for mac? i don't see it in the git readme 🤔 |
14:48:43 | FromDiscord | <Yardanico> again, it does |
14:49:21 | FromDiscord | <sOkam!> nice, that's great news to find build-testers easier ✍️ tyty |
14:49:43 | FromDiscord | <sOkam!> for crosscompiling to mac, what are the options? |
14:49:58 | FromDiscord | <Yardanico> for simple console apps you can use zig cc |
14:50:10 | FromDiscord | <sOkam!> its a game engine |
14:50:27 | FromDiscord | <Yardanico> In reply to @sOkam! "its a game engine": you're using Metal? |
14:50:32 | FromDiscord | <sOkam!> wgpu |
14:50:45 | FromDiscord | <Yardanico> uhh |
14:50:54 | FromDiscord | <Yardanico> yeah it should work, seems like wgpu supports metal |
14:51:14 | FromDiscord | <sOkam!> it uses metal in the background when running on mac, vulkan on linux and don't know what on windows |
15:13:32 | FromDiscord | <dlesnoff> How do we get random chars? rand('a'..'z') returns me a cryptic error. |
15:16:17 | FromDiscord | <dlesnoff> Oh sorry this works, I have to do a MWE before asking 😓 |
15:37:04 | * | xet7 joined #nim |
15:38:26 | FromDiscord | <0ffh> In reply to @Nerve "You seem pretty hell-bent": I've heard the argument being made that "transpilation" is limited to syntactic translation that does not change or add to the semantics.↵I think that's a good suggestion on where to draw a line, if one must. |
15:40:16 | FromDiscord | <Yardanico> In reply to @0ffh "I've heard the argument": that is partially true - e.g., with the C backend you can't fully control the alignment/ordering of fields in your structs |
15:40:22 | FromDiscord | <Nerve> In reply to @0ffh "I've heard the argument": Yeah, something like Babel.js or Coffeescript |
15:40:55 | FromDiscord | <Nerve> In this sense though, Python is definitely compiled to bytecode, though the bytecode is then interpreted |
15:40:56 | FromDiscord | <Yardanico> and Rust can do it because it uses LLVM |
15:41:19 | FromDiscord | <Yardanico> <https://camlorn.net/posts/April%202017/rust-struct-field-reordering/> |
15:41:32 | FromDiscord | <Nerve> Also herb Sutter's CppFront is a good transpiler example |
15:41:37 | FromDiscord | <Nerve> (edit) "herb" => "Herb" |
15:41:43 | FromDiscord | <Yardanico> sent a long message, see http://ix.io/4uto |
15:43:51 | FromDiscord | <Yardanico> but again, the C backend OTOH gives tons of interoperability with existing software, like emscripten :) |
15:44:14 | FromDiscord | <Yardanico> for example there's a game written in FreePascal, and because they don't have a C backend, you can't just take a game made with FPC + SDL2 and compile it for the web |
15:44:25 | FromDiscord | <Yardanico> they do have a wasm backend and llvm backend, but I think it will still be a big effort to make emscripten work with it |
15:46:35 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4utr |
15:47:31 | FromDiscord | <0ffh> In reply to @Yardanico "but again, the C": Also it's essential for targeting all kinds of CPUs and uControllers. |
15:47:39 | FromDiscord | <dlesnoff> Oh is that due to limit oh I am dumb |
15:47:49 | FromDiscord | <Yardanico> In reply to @0ffh "Also it's essential for": yeah that is the main part for having a C backend :) |
15:48:03 | FromDiscord | <Yardanico> wasm, esp, gba, niche OSes, whatever |
15:48:16 | FromDiscord | <dlesnoff> (edit) "https://play.nim-lang.org/#ix=4utr" => "https://play.nim-lang.org/#ix=4uts" |
15:48:36 | FromDiscord | <Yardanico> if some target exists, there's probably a C compiler for it |
15:50:15 | FromDiscord | <Anuke> Is there a way to force nimble to uninstall a package despite being dependent upon by other packages? |
15:51:05 | FromDiscord | <Anuke> I have (my) package A that depends on cligen@[older version]; I `nimble install cligen` to get a newer one, and attempt to uninstall the older one, but it fails with `Cannot uninstall cligen (1.5.32) because`... |
15:51:57 | FromDiscord | <Yardanico> In reply to @Anuke "I have (my) package": shouldn't you instead just update your package to depend on a newer cligen version? |
15:52:02 | FromDiscord | <Yardanico> in the .nimble file |
15:52:10 | FromDiscord | <Yardanico> then next time you do install or build it should just get that version |
15:52:50 | FromDiscord | <Anuke> so here's the funny thing: when I do that, nimble still uses the old one as a dependency in the actual code, and the only way to fix it is to go into `.nimble` and delete the old package folder |
15:53:02 | FromDiscord | <Yardanico> In reply to @Anuke "so here's the funny": and you're compiling with nim or nimble? |
15:53:09 | FromDiscord | <Anuke> nimble |
15:53:24 | FromDiscord | <Yardanico> that's really weird then, but yeah, I don't actually know if you can force nimble to delete a package even though other packages depend on it |
15:53:33 | FromDiscord | <Anuke> well, a nimble task that calls `nim r` |
15:53:38 | FromDiscord | <Yardanico> oh |
15:53:50 | FromDiscord | <Yardanico> not sure if the nimble dependencies will get resolved properly then |
15:55:17 | FromDiscord | <Anuke> ~~guess it's time for manual package management then~~ https://media.discordapp.net/attachments/371759389889003532/1101537130104234166/image.png |
16:00:29 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
16:01:56 | * | progranner joined #nim |
16:07:07 | * | lucasta joined #nim |
16:10:51 | NimEventer | New thread by choltreppe: A problem with refs on the js backend, see https://forum.nim-lang.org/t/10142 |
16:21:29 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
16:21:54 | * | progranner joined #nim |
16:38:54 | * | arkurious joined #nim |
16:38:55 | * | arkurious quit (Remote host closed the connection) |
16:43:52 | FromDiscord | <ricky> In reply to @Anuke "~~guess it's time for": is it ever time for that? |
16:43:54 | FromDiscord | <ricky> 😟 |
16:46:25 | * | arkurious joined #nim |
17:12:25 | FromDiscord | <Anuke> unfortunately yes |
18:27:30 | * | xet7 quit (Ping timeout: 265 seconds) |
18:27:48 | FromDiscord | <ieltan> Can someone explain to me `var T` vs `ref T`, like which one should I use? |
18:35:12 | * | Notxor quit (Remote host closed the connection) |
18:37:15 | * | Notxor joined #nim |
18:38:12 | FromDiscord | <JSONBash> might be mistaken, but `ref` is for `ptr`, if you're using it as a function argument then you'd most likely want `var` - allows for mutability but also passes as a reference (what i'm assuming you want). Anyone feel free to correct me |
18:38:23 | * | xet7 joined #nim |
18:41:13 | FromDiscord | <Yardanico> yes, object + var is generally if you just want to mutate something inside |
18:41:23 | FromDiscord | <Yardanico> ref is for shared ownership or where you can't use var, e.g. async or closures |
18:42:42 | FromDiscord | <ieltan> Okay, thanks you for answering |
18:44:55 | FromDiscord | <Yardanico> of course you should also use `ref object` if you want to allocate something specifically on the heap |
18:51:01 | FromDiscord | <ieltan> In reply to @Yardanico "of course you should": Well I don't think i need too, I just learned about `var T` while reading nim code for my binding code |
18:51:27 | FromDiscord | <Yardanico> but yeah, in most cases you don't actually need ref object |
18:51:36 | FromDiscord | <Yardanico> as well as you don't need TableRef or somilar (just Table is ok) |
18:51:42 | FromDiscord | <Yardanico> ah, right, forgot one more usecase for ref object |
18:51:49 | FromDiscord | <Yardanico> if you want object to possibly have itself |
18:52:09 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4utX |
18:52:11 | FromDiscord | <Yardanico> so you need to use ref object here instead |
18:57:06 | FromDiscord | <ieltan> sent a code paste, see https://play.nim-lang.org/#ix=4utZ |
18:57:34 | * | xet7 quit (Quit: Leaving) |
18:58:16 | FromDiscord | <ieltan> In reply to @Yardanico "so you need to": the binding code that directly interop with my C header uses ptr instead, is it bad ? |
18:58:26 | FromDiscord | <Yardanico> In reply to @ieltan "the binding code that": no, it's good to be explicit |
18:58:54 | FromDiscord | <Yardanico> In reply to @ieltan "It's my first time": that's fine, but you also need to have a custom =copy |
18:59:03 | FromDiscord | <halc> can someone explain to a dummy what the heck is "atomic reference counting" and how Nim is not doing that? |
18:59:06 | FromDiscord | <halc> I am the dummy |
18:59:30 | FromDiscord | <halc> specifically I have no clue what "atomic" means |
18:59:46 | FromDiscord | <ieltan> In reply to @Yardanico "that's fine, but you": Ah, alright, thanks for pointing this out ! |
18:59:50 | FromDiscord | <leorize> I take it that you already understand reference counting? |
18:59:55 | FromDiscord | <halc> yes |
18:59:58 | * | xet7 joined #nim |
19:00:18 | FromDiscord | <Yardanico> In reply to @ieltan "Ah, alright, thanks for": because otherwise it might happen that someone passes a copy of the variable to some other proc, the original gets destroyed so the other object also becomes invalid |
19:00:33 | FromDiscord | <leorize> "atomic" means "one action" at any given time |
19:00:33 | FromDiscord | <halc> I've looked at fusion's `SharedPtr` and I get it, I just don't know what Nim does that differs from it |
19:00:51 | FromDiscord | <leorize> this is useless in single-threaded world, so we will look at multi-threading |
19:01:11 | FromDiscord | <leorize> so imagine `var i: int; inc(i)` |
19:01:19 | FromDiscord | <leorize> what exactly is happening? |
19:01:53 | FromDiscord | <halc> you're probably setting i to zero, and then adding one to it |
19:03:28 | FromDiscord | <leorize> `i` is read into a register, then the register is incremented by one, then it is written back into `i` |
19:03:30 | FromDiscord | <leorize> suppose that 2 threads are doing this at the same time, with an initial `i` of `0` |
19:04:47 | FromDiscord | <leorize> sent a code paste, see https://play.nim-lang.org/#ix=4uu1 |
19:05:17 | FromDiscord | <leorize> so `i` is supposed to be `2` here, but due to a race condition, `i` is `1` after both thread has done their deeds |
19:06:00 | FromDiscord | <leorize> "atomic" in this case refers to the use of atomic synchronization primitives |
19:06:38 | FromDiscord | <leorize> modern processors have the capability to perform the entire `inc(i)` dance in a single operation with no races |
19:07:59 | FromDiscord | <leorize> this is slower than the regular stuff (a whole lot slower), but now you can do your counting in `n` threads without losing data like this |
19:09:43 | FromDiscord | <leorize> Nim don't do atomic ref count since it's very slow and instead rely on "moving" memory |
19:09:58 | FromDiscord | <leorize> that's the theory at least, in practice this "moving" magic doesn't work yet |
19:10:09 | FromDiscord | <ieltan> In reply to @Yardanico "because otherwise it might": Correct me if i'm wrong but If it's a copy should it be disctinct in memory from the original ? |
19:10:34 | FromDiscord | <Yardanico> i mean if the code wants to make a copy, you need to handle that, the C library probably provides a way to copy the C struct |
19:11:19 | FromDiscord | <ieltan> Yeah you're right |
19:11:21 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
19:11:36 | FromDiscord | <ieltan> thanks man ! |
19:14:29 | * | progranner joined #nim |
19:43:11 | * | xet7 quit (Ping timeout: 246 seconds) |
19:43:38 | FromDiscord | <halc> scuse me, had to go for a sec, thanks for the explanation |
19:59:59 | * | lucasta quit (Read error: Connection reset by peer) |
20:03:41 | FromDiscord | <Gabben> sent a code paste, see https://paste.rs/voG |
20:03:59 | FromDiscord | <Yardanico> shouldn't it be a ref object if it's a JS object? |
20:04:02 | FromDiscord | <Yardanico> since they all have ref semantics in JS |
20:04:19 | FromDiscord | <Yardanico> i've had a similar issue but it got fixed when I switched to `ref object` in Nim for the JS type |
20:06:13 | FromDiscord | <Gabben> In reply to @Yardanico "shouldn't it be a": You're right, thank you |
20:22:00 | FromDiscord | <Elegantbeef> @Anuke\: perhaps you might want to use atlas(depending on the version of Nim you're using), it's much simpler than nimble |
20:23:57 | FromDiscord | <Elegantbeef> Nimble 0.14 has so many annoying 'features' |
20:24:15 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/Nim/blob/devel/tools/atlas/atlas.md |
20:59:52 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
21:02:39 | * | progranner joined #nim |
21:13:36 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
21:48:37 | * | advesperacit quit () |
21:54:57 | FromDiscord | <michaelb.eth> there's also the nimbus-build-system, which can be used for any Nim project, if you're not afraid of Makefiles and git submodules |
21:55:27 | FromDiscord | <michaelb.eth> https://github.com/status-im/nimbus-build-system |
21:55:33 | FromDiscord | <michaelb.eth> granted it has some rough edges here and there |
22:01:19 | FromDiscord | <Elegantbeef> Yea just what a sane person wants... make |
22:39:46 | * | Notxor quit (Remote host closed the connection) |
22:47:11 | * | lucasta joined #nim |