00:20:35 | * | cedb quit (Quit: WeeChat 3.8) |
00:26:50 | FromDiscord | <wrld> how would I convert a string into a byte array |
00:33:18 | * | disso-peach joined #nim |
00:34:14 | * | derpydoo joined #nim |
00:36:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/P4NTE |
01:03:03 | * | krux02 quit (Remote host closed the connection) |
01:06:50 | FromDiscord | <michaelb.eth> In reply to @wrld "how would I convert": stew/byteutils has `[string].toBytes`:↵https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L244-L254 |
01:08:45 | FromDiscord | <michaelb.eth> note that `string`s in Nim:↵> are both zero-terminated and have a length field↵(quoting from the manual) |
01:09:18 | FromDiscord | <michaelb.eth> (edit) "manual)" => "Nim Manual)" |
01:11:04 | FromDiscord | <JJ> In reply to @mratsim "https://eli.thegreenplace.net/2016/the-expression-p": hey, that's a good read |
01:38:59 | FromDiscord | <arathanis> In reply to @Andreas "_Is Option[T] a Functor": i wish this worked. concepts are in a funky state right now |
01:47:02 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4ymq |
01:49:17 | FromDiscord | <Elegantbeef> Hmph do wonder if stew's `when nimvm` is required in devel anymore... |
01:49:36 | * | disso-peach quit (Remote host closed the connection) |
01:49:58 | * | disso-peach joined #nim |
01:51:30 | FromDiscord | <Elegantbeef> Does seems to work now, yay! |
02:13:20 | * | azimut quit (Ping timeout: 240 seconds) |
02:21:34 | * | rockcavera quit (Remote host closed the connection) |
02:40:29 | * | rockcavera joined #nim |
02:55:31 | FromDiscord | <_gumbercules> You know what would be great? |
02:56:07 | FromDiscord | <_gumbercules> If I could build Nim without having to kill every every terminal and editor session I have running on my PC. Every time... |
02:56:14 | FromDiscord | <_gumbercules> Fucking nimsuggest |
02:58:56 | FromDiscord | <arathanis> that is so wild to me, are they ever going to fix it? |
02:59:01 | FromDiscord | <arathanis> ive never had it explode liken that |
02:59:10 | FromDiscord | <arathanis> but i know it does cause so many people talk about it |
02:59:16 | FromDiscord | <arathanis> (edit) "liken" => "like" |
03:00:28 | FromDiscord | <_gumbercules> Well it's not so much an explosion as it is the VSCode extension (I'm not sure how other editors behave) spawning instances of Nimsuggest and them not terminating and then Nim trying to touch nimsuggest.exe while `build_all.bat` is executing on Windows |
03:00:40 | FromDiscord | <_gumbercules> I'm sure this plauges other operating systems as well |
03:00:43 | FromDiscord | <arathanis> i use vscode too |
03:00:53 | FromDiscord | <_gumbercules> do you build Nim from source? |
03:01:00 | FromDiscord | <arathanis> only a handful of times |
03:01:18 | FromDiscord | <_gumbercules> well that's the thing - I am almost always developing against devel and building from source |
03:01:30 | FromDiscord | <arathanis> i usually use choosenim to load devel |
03:01:45 | FromDiscord | <_gumbercules> so when Nim's build script goes to build Nim tools it fails at nimsuggest |
03:01:49 | FromDiscord | <arathanis> but ive built specific builds of nim from source, like i said, a handful of times |
03:01:53 | FromDiscord | <_gumbercules> ah yeah I don't touch choosenim or Nimble |
03:02:10 | FromDiscord | <_gumbercules> or most of the things that dom wrote, because they tend not to work |
03:02:20 | FromDiscord | <arathanis> i do know sometimes the nim extension (the good 3rd party one that sees updates) takes an unfortunate amount of time to initialize |
03:02:30 | FromDiscord | <arathanis> then once its running it works ok but before that it basically does nothing |
03:02:48 | FromDiscord | <arathanis> i imagine this is from what everyone is complaining about |
03:03:19 | FromDiscord | <_gumbercules> I'm not sure - people complain about a lot when it comes to Nim's developer experience |
03:04:16 | FromDiscord | <arathanis> yeah the extension could be better |
03:04:19 | FromDiscord | <arathanis> i hope it improves |
03:04:26 | FromDiscord | <arathanis> things like rename symbol dont work |
03:04:40 | FromDiscord | <_gumbercules> I think the problem really lies in nimsuggest itself |
03:04:41 | FromDiscord | <arathanis> go to definition either doesnt work or is intermittent, i dont remember |
03:04:57 | FromDiscord | <arathanis> id love for the dev experience to be better |
03:05:02 | FromDiscord | <arathanis> its not the worst ive ever seen |
03:05:11 | FromDiscord | <arathanis> but it is certainly not the best |
03:05:13 | FromDiscord | <graveflo> you could just not compile nimsuggest if that makes life easier for you |
03:05:43 | FromDiscord | <arathanis> > You could just abandon tooling completely↵↵- Graveflo, 2023-06-15 |
03:05:46 | FromDiscord | <arathanis> 😉 |
03:05:56 | FromDiscord | <arathanis> (edit) "completely↵↵-" => "completely↵↵\-" |
03:06:00 | FromDiscord | <graveflo> LOL true tho |
03:06:13 | FromDiscord | <Elegantbeef> Gumber you could try gitnim instead of choosenim 😄 |
03:06:18 | FromDiscord | <arathanis> WOAH, when did they add markdown for lists to discord? does it work for numbered lists? |
03:06:29 | FromDiscord | <arathanis> 1. does↵2. this↵3. do↵4. stuff? |
03:06:34 | FromDiscord | <arathanis> huh, it kind does |
03:06:37 | FromDiscord | <graveflo> but what I am saying is that if they are using the nim build script I assume they are compiling the nim executable often.. they can just compile nim and leave the nimsuggest executable alone |
03:06:41 | FromDiscord | <arathanis> wild this must be that last update |
03:06:58 | FromDiscord | <arathanis> In reply to @Elegantbeef "Gumber you could try": im still unsure about gitnim vs choosenim |
03:07:21 | FromDiscord | <arathanis> i wish there was some kind of full comparison that could show me how its better and/or different than choosenim and why i would use it over choosenim |
03:07:21 | FromDiscord | <Elegantbeef> Wait gumber uses windows so nevermind on gitnim |
03:07:43 | FromDiscord | <arathanis> oh is gitnim unix only? i need it to work on both platforms |
03:08:19 | FromDiscord | <_gumbercules> I think choosenim is not great because it's constantly breaking or doing bad things on various platforms |
03:08:34 | FromDiscord | <Elegantbeef> it uses libgit instead of using curl or similar, they're practically the same thing just one is a git executable |
03:08:49 | FromDiscord | <arathanis> In reply to @_gumbercules "I think choosenim is": the only issue ive ever had with choosenim is when nim 1.6.10 (i think?) was flagged by windows defender |
03:08:57 | FromDiscord | <_gumbercules> well that's probably not choosenim's fault |
03:09:22 | FromDiscord | <arathanis> and it wasnt choosenim's fault lol |
03:11:50 | FromDiscord | <_gumbercules> I think a lot of this depends on what you're doing and how you're doing it and what your expectations are regarding how the software should work |
03:12:36 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4ymL |
03:13:41 | FromDiscord | <michaelb.eth> occasionally it goes haywire and I need to quit vscode/emacs, possibly force-kill some nimsuggest processes, but that's become more and more infrequent, in my experience |
03:13:43 | FromDiscord | <arathanis> In reply to @michaelb.eth "I haven't had too": is there a nimlangserver? |
03:13:52 | FromDiscord | <arathanis> is there an extension for it? you got a link? |
03:13:56 | FromDiscord | <arathanis> id love to try alternatives |
03:14:08 | FromDiscord | <Elegantbeef> https://github.com/nim-lang/langserver |
03:14:45 | FromDiscord | <arathanis> In reply to @Elegantbeef "https://github.com/nim-lang/langserver": do i need to hook this up manually? |
03:14:47 | FromDiscord | <_gumbercules> hmm I might have to try out this mapping file thing |
03:14:56 | FromDiscord | <michaelb.eth> In reply to @_gumbercules "hmm I might have": works like a hose |
03:14:58 | FromDiscord | <Elegantbeef> "hook this up manually" |
03:14:59 | FromDiscord | <graveflo> In reply to @arathanis "do i need to": not in vscode. I had to in kate tho |
03:15:06 | FromDiscord | <_gumbercules> just install saem's vscode extension |
03:15:15 | FromDiscord | <_gumbercules> and it sounds like it's included |
03:15:17 | FromDiscord | <arathanis> In reply to @Elegantbeef ""hook this up manually"": did i stutter? |
03:15:34 | FromDiscord | <Elegantbeef> This isnt a 1940s switchboard |
03:15:37 | FromDiscord | <graveflo> Doesnt the lang server just use nimsuggest tho? I thought it was just for compat |
03:15:50 | FromDiscord | <arathanis> In reply to @Elegantbeef "This isnt a 1940s": and we are all thankful for that |
03:15:54 | FromDiscord | <graveflo> In reply to @Elegantbeef "This isnt a 1940s": your right its much more complicated with broken shit everywhere |
03:15:57 | FromDiscord | <Elegantbeef> It uses nimsuggest but it monitors it |
03:16:15 | FromDiscord | <Elegantbeef> It also uses v3 of nimsuggest which is supposed to be betterer |
03:16:53 | FromDiscord | <arathanis> 👀 nimsuggest 👀↵nimsuggest: eats the ram↵nimlangserver: 🔪 |
03:22:23 | FromDiscord | <wrld> In reply to @arathanis "👀 nimsuggest 👀 nimsuggest:": wtf s nimsuggest |
03:22:31 | FromDiscord | <wrld> I have like 60 of those in my task manager and they eat up 500mb of ram each |
03:22:45 | FromDiscord | <odexine> the thing that gives you completions for nim |
03:22:58 | FromDiscord | <arathanis> In reply to @wrld "wtf s nimsuggest": its a nim program that is part of the nim toolchain that you run against code and it gives completion options and shit |
03:23:06 | FromDiscord | <wrld> nice |
03:23:14 | FromDiscord | <arathanis> its notoriously buggy and likes to pretend it's chrome and gobble RAM |
03:26:13 | FromDiscord | <Elegantbeef> Turns out neutering a compiler and making it not do silly things is hard |
03:27:29 | FromDiscord | <arathanis> In reply to @Elegantbeef "Turns out neutering a": nimsuggest is just a lobotomized compiler? |
03:27:37 | FromDiscord | <odexine> q yes |
03:27:38 | FromDiscord | <odexine> (edit) removed "q" |
03:27:40 | FromDiscord | <arathanis> lmao that is amazing |
03:27:48 | FromDiscord | <arathanis> everything makes so much sense |
03:28:51 | FromDiscord | <Elegantbeef> That's how most tooling is |
03:29:04 | FromDiscord | <Elegantbeef> You want to do compiler stuff, but slightly different |
03:29:16 | FromDiscord | <Elegantbeef> You arent going to rewrite a compiler but make it just do suggestions |
03:41:25 | FromDiscord | <_gumbercules> I think it depends on the complexity of the compiler, but Nim's compiler definitely trends towards being complex af |
03:42:39 | FromDiscord | <michaelb.eth> hard for it not to be, since it's targeting multiple backends with the targets having divergent semantics? |
03:42:55 | FromDiscord | <michaelb.eth> (edit) "be," => "be?" |
03:43:13 | FromDiscord | <Elegantbeef> Also macros 😄 |
03:43:22 | FromDiscord | <_gumbercules> oh yeah I'm not tossing shade |
03:43:35 | FromDiscord | <_gumbercules> although I'm sure it could be written to be less complex - but Nim's a long running software project |
03:43:44 | FromDiscord | <_gumbercules> and we all know how those go in terms of being able to design and plan |
03:44:01 | FromDiscord | <_gumbercules> I do think Nim's compiler, esp the backend, is a bit hairier than it needs to be due to legacy cruft / half-baked features |
03:44:11 | FromDiscord | <_gumbercules> but untangling gand removing that stuff isn't trivial at this point so 🤷 |
03:44:15 | FromDiscord | <michaelb.eth> not saying it's the better or correct approach but back in early 2010+, attempts to provide Clojure backends for JavaScript were spun out to separate repositories, and they've stayed that way ever since |
03:44:17 | FromDiscord | <_gumbercules> I guess that's why Nimskull is ia thing |
03:44:33 | FromDiscord | <_gumbercules> (edit) "ia thing" => "a thing, amongst other reasons" |
03:44:43 | FromDiscord | <michaelb.eth> it's then up to the maintainers of ClojureScript, etc. to keep pace with clojure.org |
03:44:45 | FromDiscord | <_gumbercules> https://github.com/pmetras/nim0 - I still want to dive into this at some point |
03:45:04 | FromDiscord | <_gumbercules> In reply to @michaelb.eth "it's then up to": yeah that's an interesting model |
03:45:28 | FromDiscord | <michaelb.eth> (edit) "not saying it's the better or correct approach but back in early 2010+, attempts to provide Clojure backends for JavaScript ... were" added "and `C#`" |
03:45:30 | FromDiscord | <_gumbercules> Nim benefits and at the same time suffers I think from trying to do too much with all of its backends |
03:46:34 | FromDiscord | <Elegantbeef> Well that's partially due to how much backend leaks into transf and earlier code 😄 |
03:47:14 | FromDiscord | <_gumbercules> yeah - also I think it suffers from not having enough focus or direction - like all of the web stuff distracts from the systems programming stuff and vis versa |
03:47:14 | FromDiscord | <michaelb.eth> https://github.com/clojure/clojure-clr↵https://github.com/clojure/clojurescript↵↵note: their part of the same GH org, but otherwise separate codebases |
03:47:24 | FromDiscord | <michaelb.eth> (edit) "their" => "they're" |
03:47:53 | FromDiscord | <michaelb.eth> (edit) "https://github.com/clojure/clojure-clr↵https://github.com/clojure/clojurescript↵↵note:" => "https://github.com/clojure/clojure-clr↵https://github.com/clojure/clojurescript↵note:" |
03:48:11 | FromDiscord | <_gumbercules> like it'd be really nice to have hot code reloading for the C backend and it could be done right now, and Nim could have a repl |
03:49:17 | FromDiscord | <_gumbercules> and Nim could have taken that grant money back in the day and produced something usable but the focus and attention is always divided |
03:49:44 | FromDiscord | <_gumbercules> The advent of ARC/ORC was great and needed to provide an alternative to local GC'd heaps |
03:50:05 | FromDiscord | <_gumbercules> but there's always a lot of time wasted on bullshit experimental stuff that ends up sitting around and adding complexity and offering zero value |
03:50:07 | FromDiscord | <michaelb.eth> hindsight's 20/20 but you have a good point, maybe the community can propose a better way forward? |
03:50:16 | FromDiscord | <_gumbercules> another example - region GC |
03:51:09 | FromDiscord | <_gumbercules> well, the way forward would be to not allow something to be mainlined until it works beyond simple toy examples / adds actual value beyond looking or sounding cool in niche places |
03:51:31 | * | xet7 joined #nim |
03:51:43 | FromDiscord | <_gumbercules> I get that experimentation and ideation are necessary in moving things fowrard, but it shouldn't happen to the detriment of the compiler or stdlib |
03:52:02 | FromDiscord | <_gumbercules> which in the past it has - and yeah you're right it is 20/20 and I thankfully don't steer the ship that is Nim |
03:52:13 | FromDiscord | <_gumbercules> and I'm sure I'd probably do a much worse job at it than Andreas has |
03:52:39 | FromDiscord | <_gumbercules> at least re: hot code relaoding for C, it's easy enough to do in userland |
03:53:08 | FromDiscord | <michaelb.eth> right, but in likewise practical terms it could mean saying: "the canonical backend is C, the canonical backend is ORC/ARC", then plow forward with the implications of that, and alternative backends, GCs, etc. can deal with it, else die on the vine |
03:53:14 | FromDiscord | <Elegantbeef> gib views |
03:53:17 | FromDiscord | <michaelb.eth> (edit) "backend" => "GC" |
03:53:45 | FromDiscord | <michaelb.eth> In reply to @michaelb.eth "right, but in likewise": in their own repositories, I mean |
03:54:09 | FromDiscord | <_gumbercules> yeah - I think in hindsight this might have worked out better but who knows - it might have led to some kind of plugin design or architecture for the compiler |
03:54:27 | FromDiscord | <michaelb.eth> In reply to @_gumbercules "yeah - I think": not a bad thing? |
03:54:31 | FromDiscord | <_gumbercules> but Nim was first authored in Object Pascal I believe and shipped with a PHP backend |
03:54:35 | FromDiscord | <_gumbercules> at one point |
03:54:51 | FromDiscord | <_gumbercules> so things are quite different now than they were when the language was first being dessigned and implemented |
03:55:14 | FromDiscord | <_gumbercules> In reply to @michaelb.eth "not a bad thing?": no, just probably extremely difficult to do at this juncture |
03:55:37 | FromDiscord | <_gumbercules> maybe not - I'm not a compiler developer so 🤷 |
03:56:16 | FromDiscord | <_gumbercules> I am trying to figure out what scripting language to use in this thing I'm making though. I have to keep pushing the idea of writing my own out of my head. |
03:56:24 | FromDiscord | <_gumbercules> Although I would like to try some things out.... |
03:56:44 | FromDiscord | <Elegantbeef> You know my vote 😄 |
03:56:54 | FromDiscord | <_gumbercules> Nimscript? |
03:57:20 | FromDiscord | <_gumbercules> or Wasm? |
03:57:26 | FromDiscord | <_gumbercules> I'm already compiling my Nim program to wasm |
03:57:27 | FromDiscord | <Elegantbeef> Of course not |
03:57:28 | FromDiscord | <Elegantbeef> Use wasm instead of a scripting language 😛 |
03:57:28 | FromDiscord | <michaelb.eth> Lua (or TCL!) should have a low bar for that, as long the thing you're making is simple to interface to/from C |
03:57:32 | FromDiscord | <_gumbercules> maybe I should have it run wasm |
03:57:36 | FromDiscord | <_gumbercules> wasm in wasm |
03:58:14 | FromDiscord | <_gumbercules> I have this Elixir app which is hosting a Nim program compiled to wasm (via emscripten atm) in a phoenix live view |
03:58:34 | FromDiscord | <_gumbercules> it's also acting as the signaling server for the webrtc connections I'm establishing between the live view sessions |
03:59:03 | FromDiscord | <_gumbercules> which the Nim guest program will use for networking sockets (this is for game netcode btw) |
03:59:23 | FromDiscord | <_gumbercules> I want the Nim guest to really act as a sort of runtime for a fantasy console |
03:59:54 | FromDiscord | <_gumbercules> so it will expose an API which you'll be able to consume in some scripting language |
04:00:07 | FromDiscord | <_gumbercules> so you can write little games in - similar to a fantasy console or whatever |
04:01:22 | FromDiscord | <_gumbercules> In reply to @Elegantbeef "Use wasm instead of": What do you recommend for being able to execute wasm from a Nim host? |
04:01:32 | FromDiscord | <Elegantbeef> I have some bindings for wasm3 |
04:01:39 | FromDiscord | <_gumbercules> I'm curious to see if I can get it working in my Nim guest program haha |
04:01:53 | FromDiscord | <_gumbercules> In reply to @Elegantbeef "I have some bindings": okay thanks - I'll check em out |
04:02:01 | FromDiscord | <Elegantbeef> Pure C like 17 functions and compiles without any external deps |
04:03:00 | FromDiscord | <Elegantbeef> I havent tried to compile it to wasm I imagine it works |
04:07:55 | FromDiscord | <wrld> im currently using a single json file as my DB for 17k users |
04:08:03 | FromDiscord | <wrld> when will it blow 💀 |
04:10:41 | FromDiscord | <_gumbercules> time to partition it into multiple json files |
04:12:41 | FromDiscord | <_gumbercules> and then you could create some hooks in your program that unmarshal, update and marshal a b-tree so that you can lookup users faster |
04:13:08 | FromDiscord | <_gumbercules> when a user record in your json file is inserted updated or deleted |
04:13:27 | FromDiscord | <_gumbercules> json files excuse me, I forgot it was partitioned |
04:17:00 | FromDiscord | <michaelb.eth> been thinking about a Nim wrapper for CozoDB, could be fun/useful/interesting:↵https://github.com/cozodb/cozo |
04:17:41 | FromDiscord | <michaelb.eth> time travel in a db is a neat feature, got introduced to the idea re: Datomic some years ago |
04:19:23 | FromDiscord | <_gumbercules> Doesn't the whole vector thing make it only practical for AI? |
04:19:35 | FromDiscord | <_gumbercules> I don't even really know what a vector database is, I just know it has to do with AI and LLMs |
04:19:45 | FromDiscord | <michaelb.eth> the query language seems like it could be expressed/translated re: Nim's grammar, so you could write querys, etc. in plain Nim, i.e. without embedding them in `""" ... """` |
04:21:08 | FromDiscord | <_gumbercules> I always thought - https://apple.github.io/foundationdb looked interesting |
04:22:58 | FromDiscord | <_gumbercules> https://apple.github.io/foundationdb/design-recipes.html |
04:23:40 | FromDiscord | <_gumbercules> quite cool how you can simply add layers to add capabilities to your database model |
04:24:24 | FromDiscord | <_gumbercules> https://apple.github.io/foundationdb/api-c.html - there's a C API as well |
04:31:49 | FromDiscord | <odexine> In reply to @michaelb.eth "the query language *seems*": Seems possible but sounds like a pain |
05:10:51 | * | derpydoo quit (Ping timeout: 260 seconds) |
06:25:25 | FromDiscord | <JJ> In reply to @arathanis "nimsuggest is just a": a bunch of stuff nim does is weird because it did it early tbh |
06:26:27 | FromDiscord | <JJ> compiling to both c and javascript for coverage was fantastic but if you're writing a compiler today you want to target llvm and get backends for free |
06:26:27 | FromDiscord | <Elegantbeef> I still don't get how that's weird |
06:27:05 | FromDiscord | <JJ> similarly nimsuggest hit the scene before the language server protocol iirc |
06:27:27 | FromDiscord | <Elegantbeef> It did, but regardless the same logic needs to be used |
06:27:39 | FromDiscord | <JJ> eh it's not weird really it's just not what you would do today |
06:27:45 | FromDiscord | <JJ> yea |
06:28:42 | FromDiscord | <Elegantbeef> Well you replace nimsuggest's protocol with lsp, you'd still use the compiler's source 😄 |
06:29:52 | FromDiscord | <Elegantbeef> I do wonder how rust analyzer is written |
06:30:02 | * | rockcavera quit (Remote host closed the connection) |
06:49:02 | FromDiscord | <huantian> https://github.com/rust-lang/rust-analyzer/blob/master/docs/dev/architecture.md |
06:49:05 | FromDiscord | <huantian> Might help |
06:49:09 | FromDiscord | <huantian> Haven’t read |
06:50:59 | FromDiscord | <huantian> Yeah it seems they use a custom “syntax tree” that they have libraries to parse rust code into |
06:51:09 | FromDiscord | <huantian> Instead of relying on the compiler |
06:51:34 | FromDiscord | <Elegantbeef> That doesnt make sense given that it has macros |
06:51:59 | FromDiscord | <huantian> Kinda like what I talked about with python concrete syntax trees in the past I’d assume |
06:52:02 | FromDiscord | <huantian> In reply to @Elegantbeef "That doesnt make sense": No idea |
06:52:35 | FromDiscord | <Elegantbeef> > Rustc can produce metadata files (--emit metadata). These metadata files are like header files for Rust crates. They’re internally a compiler-specific binary format and cannot be inspected.↵They do call `rust --emit=metadata` so wonder if that helps a bit |
06:52:41 | FromDiscord | <huantian> Maybe the syntax.md doc goes into more detail |
06:55:15 | FromDiscord | <huantian> > Syntax trees are lossless, or full fidelity. All comments and whitespace get preserved.↵> Syntax trees are semantic-less. They describe strictly the structure of a sequence of characters, they don't have hygiene, name resolution or type information attached. |
06:55:24 | * | PMunch joined #nim |
06:56:28 | FromDiscord | <huantian> Maybe they use a combination of stuff from rust compiler and the syntax tree thing? |
06:57:24 | FromDiscord | <Elegantbeef> Perhaps, just trying to figure out how they get any semantically checked code inside 😄 |
06:57:38 | FromDiscord | <Elegantbeef> Seems they invoke rustc and it emits `.meta` which can be used |
06:57:47 | FromDiscord | <Elegantbeef> So in essence what IC will do |
06:58:27 | FromDiscord | <huantian> They stuff they talk about with salsa and ic in guide.md is kinda neat |
06:59:25 | FromDiscord | <czgchsz> Why hello elegant beef |
07:00:04 | FromDiscord | <czgchsz> What's salsa, I only know about salsa20 \:c |
07:05:51 | FromDiscord | <Elegantbeef> Hello whoever you are |
07:21:42 | NimEventer | New Nimble package! hyperloglog - A HyperLogLog data structure implementation in Nim, see https://github.com/deNULL/hyperloglog |
07:38:25 | * | ntat joined #nim |
07:40:29 | FromDiscord | <mratsim> In reply to @_gumbercules "I think the problem": Not only. Only 1 nimsuggest instance is needed. And nimsuggest shouldn't choke on generics/statics/macros. |
08:18:12 | * | ntat quit (Quit: Leaving) |
08:24:25 | FromDiscord | <Andreas> In reply to @arathanis "i wish this worked.": i wished, too. I found this while searching for concept examples. Maybe somebd can remove it from the docs... |
08:25:54 | FromDiscord | <Andreas> (edit) "In reply to @arathanis "i wish this worked.": i wished, too. I found this while searching for concept examples. Maybe somebd can remove it from the docs... ... " added "And the nice Graph-example as well, throws an error `of` not supported" |
08:37:42 | FromDiscord | <mratsim> In reply to @Andreas "i wished, too. I": Open bugs with repro. Then they get in the anti-regression suite |
08:38:12 | FromDiscord | <mratsim> I have made hundreds of bugs on the typesystem re generics/static/concepts |
08:39:06 | * | xet7 quit (Quit: Leaving) |
08:46:14 | FromDiscord | <thesherwood> Is there any `perror` equivalent in nim? |
08:49:16 | PMunch | getCurrentExceptionMsg() I guess is the closest |
08:49:25 | PMunch | Apart from just calling perror of course |
08:49:26 | FromDiscord | <arathanis> In reply to @mratsim "Open bugs with repro.": how do you open a bug when the functionality just isnt describes correctly? |
08:49:42 | FromDiscord | <arathanis> (edit) "describes" => "described" |
08:56:12 | FromDiscord | <thesherwood> sent a code paste, see https://play.nim-lang.org/#ix=4ynw |
08:58:28 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4yny |
08:59:32 | FromDiscord | <arathanis> (edit) "https://play.nim-lang.org/#ix=4yny" => "https://play.nim-lang.org/#ix=4ynz" |
09:00:22 | FromDiscord | <arathanis> oh the article taking about this was posted by @ringabout |
09:00:41 | FromDiscord | <arathanis> im assuming its the same one |
09:00:43 | FromDiscord | <arathanis> (edit) "one" => "person" |
09:01:21 | FromDiscord | <thesherwood> Thanks, I'll give that a go |
09:03:34 | FromDiscord | <thesherwood> That does the job |
09:03:41 | FromDiscord | <arathanis> slick |
09:03:45 | FromDiscord | <arathanis> good to know |
09:03:58 | FromDiscord | <arathanis> and glad it worked |
09:05:10 | FromDiscord | <thesherwood> yeah. me too. I would not have thought to try something like that. Am I right in thinking that `cstringConstImpl` is just an alias of `cstring`? Or is it narrower on account of the pragma? |
09:05:58 | * | ntat joined #nim |
09:06:06 | FromDiscord | <arathanis> so i dont really know |
09:06:17 | FromDiscord | <arathanis> my current assumption is that the importc teaches nim how to compile it to C |
09:06:26 | FromDiscord | <arathanis> setting it to cstring teaches Nim how to use it |
09:06:42 | FromDiscord | <arathanis> and making it distinct keeps it isolated so you can use it as its own type |
09:07:34 | FromDiscord | <arathanis> ive never combined importc with assignment before |
09:07:48 | FromDiscord | <leorize> since it's in the default-imported headers, you can use `{.importc, nodecl.}` or `{.importc, header: "<stdio.h>".}`↵(@thesherwood) |
09:07:53 | FromDiscord | <thesherwood> Okay. So the importc pragma is telling nim how to compile it and the `cstring` is telling nim that it can be used in the same places a `cstring` can? |
09:08:37 | FromDiscord | <arathanis> In reply to @thesherwood "Okay. So the importc": or at least to inherit the semantics, probably keeps garbace collection working and stuff |
09:08:48 | FromDiscord | <thesherwood> In reply to @leorize "since it's in the": Interesting, I'll try that too |
09:09:16 | FromDiscord | <thesherwood> In reply to @arathanis "or at least to": Gotcha. that makes sense |
09:09:30 | FromDiscord | <leorize> importc, surprisingly has little to do with c \:P |
09:09:36 | FromDiscord | <arathanis> also lets you do `"give me a const char ptr!".constCharPtr` |
09:10:11 | FromDiscord | <arathanis> In reply to @leorize "importc, surprisingly has little": its basically telling it how to represent it no whatever backend you choose, right? |
09:10:25 | FromDiscord | <leorize> so `importc` tells Nim that the implementation is in an external symbol using C's mangling (aka. no name mangling) |
09:10:38 | FromDiscord | <arathanis> there is also `importcpp` and `importjs` but they arent actually any different than `importc` |
09:10:58 | FromDiscord | <thesherwood> In reply to @leorize "so `importc` tells Nim": Oh. So that's why it is used with the js backend as well? just to prevent mangling? |
09:11:05 | FromDiscord | <leorize> it does not have an effect on how the function is called, how the parameters are interpreted, what calling convention should be used |
09:11:06 | FromDiscord | <leorize> yep |
09:11:17 | FromDiscord | <arathanis> In reply to @leorize "so `importc` tells Nim": unless you follow the importc with a string, in which case you are also showing it how to emit backend code |
09:11:21 | FromDiscord | <thesherwood> In reply to @arathanis "there is also `importcpp`": I did not realize that |
09:11:21 | FromDiscord | <leorize> `importjs` is an alias for `importc` |
09:11:34 | FromDiscord | <arathanis> In reply to @thesherwood "I did not realize": yeah |
09:11:41 | FromDiscord | <arathanis> importc used to be the only one that existed |
09:11:49 | FromDiscord | <arathanis> importcpp and importjs are just aliases for readability |
09:11:50 | FromDiscord | <leorize> if you follow `importc` with a string, you tell the compiler what the real external symbol name is, useful for names that are not valid Nim |
09:12:12 | FromDiscord | <leorize> `importcpp` does have some extra functions that affect codegen, mind you |
09:12:42 | FromDiscord | <leorize> in particular it supports a form of pattern substitution in the generated C++/JS code, mainly used for classes and/or namespaced symbols |
09:12:52 | FromDiscord | <thesherwood> Gotcha. Is objective-C also a backend or am I confusing that with some other language? |
09:12:56 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4ynC |
09:13:05 | FromDiscord | <arathanis> In reply to @leorize "in particular it supports": oh yeah, it supports the template lib stuff |
09:13:28 | FromDiscord | <arathanis> In reply to @thesherwood "Gotcha. Is objective-C also": its another language |
09:13:38 | FromDiscord | <arathanis> its Apple's Pre-Swift language |
09:13:41 | FromDiscord | <arathanis> (edit) "Pre-Swift" => "pre-Swift" |
09:13:43 | FromDiscord | <leorize> yes it is but it's so under utilized I don't know if it even work these days↵(@thesherwood) |
09:14:12 | FromDiscord | <thesherwood> gotcha. that is good to know |
09:15:25 | FromDiscord | <leorize> while not very apparent, `cstring` is as unsafe as `ptr char` for C backend (since it's the same thing, with even less obvious unsafe markers) |
09:15:40 | FromDiscord | <thesherwood> So no gc for cstring? |
09:15:52 | FromDiscord | <leorize> yes |
09:16:06 | FromDiscord | <leorize> cstring is mainly used for "loaned" resources |
09:16:30 | FromDiscord | <arathanis> now i thougt cstrings were GCed? do you actually need to be freeing them? |
09:16:37 | FromDiscord | <arathanis> (edit) "thougt" => "thought" |
09:16:45 | FromDiscord | <leorize> say, a `cstring` coming from `string` is the physical character buffer of that `string`, and will be freed when the originating `string` is GC-ed |
09:17:10 | FromDiscord | <arathanis> but doing `cstring("some init string")` is not that way? |
09:17:16 | PMunch | arathanis, correct |
09:17:30 | FromDiscord | <arathanis> whats the proper way to clean up such a cstring? |
09:17:36 | FromDiscord | <arathanis> dealloc(var)? |
09:17:43 | FromDiscord | <arathanis> (edit) "dealloc(var)?" => "dealloc(identifer)?" |
09:17:48 | FromDiscord | <arathanis> (edit) "dealloc(identifer)?" => "`dealloc(identifer)`?" |
09:17:53 | FromDiscord | <leorize> in that case it's a static cstring where the buffer is stored within the executable area of the executable↵(@arathanis) |
09:18:07 | FromDiscord | <arathanis> In reply to @leorize "in that case it's": ehh i shoudl have guessed that lol |
09:18:12 | FromDiscord | <arathanis> (edit) "shoudl" => "should" |
09:18:19 | FromDiscord | <leorize> no memory is actually allocated on the heap, so no freeing needed |
09:18:38 | FromDiscord | <arathanis> im trying to think of a way that would init a cstring without an underlying nim string |
09:18:43 | PMunch | If you actually wanted a heap allocated cstring you would need to get it memory somehow |
09:18:49 | FromDiscord | <arathanis> that isnt just a constant in the data block of the binary |
09:18:51 | PMunch | So how to clear it out would depend on how you got it |
09:19:09 | FromDiscord | <leorize> `alloc()` -\> `cast[cstring]` is the usual route |
09:19:17 | FromDiscord | <arathanis> ahh got it |
09:19:35 | FromDiscord | <arathanis> i was wondering if there was some way to do it that didnt make it obvious you were allocating non-GCed memory |
09:19:51 | FromDiscord | <arathanis> like a gotcha to look out for |
09:20:14 | FromDiscord | <arathanis> so one particular risk is if you pass a cstring into a C function that is based on a nim string |
09:20:22 | FromDiscord | <arathanis> and that function actually hold onto and needs that cstring |
09:20:25 | FromDiscord | <arathanis> but the GC cleans it up |
09:20:28 | FromDiscord | <arathanis> gonna blow up in your face |
09:20:34 | PMunch | `var myHeapCstring = cast[cstring](alloc0(100)); dealloc(myHeapCstring)` |
09:20:41 | FromDiscord | <leorize> yep, luckily most C functions actually clone the string |
09:20:52 | FromDiscord | <arathanis> and unluckily most is not all |
09:21:05 | FromDiscord | <leorize> so you gotta read the docs \:P |
09:21:07 | PMunch | Yeah, be sure to read the documentation for C libraries |
09:21:11 | FromDiscord | <arathanis> true |
09:21:15 | FromDiscord | <arathanis> docs are never innacurate 😎 |
09:21:19 | PMunch | :P |
09:21:38 | PMunch | It's unfortunately the best thing you've got in C, after looking at the impl of course |
09:22:03 | PMunch | You could also do something silly like make a cstring from something allocated on your heap |
09:22:10 | PMunch | *on your stack |
09:22:27 | PMunch | That would also blow up if the library tried to use it after your function returns |
09:23:32 | PMunch | Of course if it tries to realloc your cstring you'd likely run into issues as well |
09:24:09 | FromDiscord | <leorize> nim is pretty lackluster on the borrowing front |
09:26:15 | * | ntat quit (Quit: Leaving) |
09:28:14 | FromDiscord | <leorize> the easiest hidden bomb I can think of is loaning a `cstring` from `string` then you append into the `string` |
09:28:49 | FromDiscord | <leorize> the code will look pretty damn innocent and will work like 98% of the time too |
09:28:51 | FromDiscord | <arathanis> converting a string to cstring then apending to it? |
09:29:14 | FromDiscord | <leorize> like this\: `let cs = cstring(str); str.add "stuff"; use(cs)` |
09:29:23 | FromDiscord | <arathanis> ohhh cause if it decides to realloc in a new block instead of just extending the block then the cstring is unallocated pointer |
09:29:34 | FromDiscord | <arathanis> kablooey |
09:29:51 | FromDiscord | <arathanis> (edit) "ohhh cause if it decides to realloc in a new block instead of just extending the block then the cstring is ... unallocated" added "an" |
09:30:45 | PMunch | Yup |
09:30:56 | PMunch | That's actually a catcha I've never thought about.. |
09:31:35 | FromDiscord | <mratsim> In reply to @arathanis "how do you open": you took examples from the manual and they don't work though right? |
09:31:44 | FromDiscord | <arathanis> In reply to @mratsim "you took examples from": yeah |
09:31:50 | FromDiscord | <arathanis> havent worked for a long while |
09:31:55 | FromDiscord | <mratsim> In reply to @arathanis "yeah": that's a bug |
09:34:25 | FromDiscord | <arathanis> In reply to @mratsim "that's a bug": work around, different syntax? |
09:34:41 | FromDiscord | <arathanis> cause some of the features of concepts just dont seem to work at all |
09:34:47 | FromDiscord | <arathanis> granted its been a while since i last looked |
09:35:29 | FromDiscord | <leorize> concepts not working and generics 🥪 are classical nim problems |
09:35:57 | FromDiscord | <arathanis> generics sandwhich? what is that haha |
09:36:02 | FromDiscord | <arathanis> concepts im familiar with |
09:36:05 | FromDiscord | <arathanis> its cool when it works |
09:36:06 | FromDiscord | <arathanis> when |
09:36:13 | FromDiscord | <arathanis> (edit) "concepts ... im" added "not working" |
09:36:33 | FromDiscord | <mratsim> In reply to @arathanis "work around, different syntax?": no, if an example in the manual doesn't work, it's a bug, either in the manual or in the compiler but it's a bug for sure |
09:37:04 | FromDiscord | <mratsim> In reply to @arathanis "generics sandwhich? what is": https://tenor.com/view/first-time-meme-movie-james-cameron-western-gif-17538858 |
09:37:35 | FromDiscord | <arathanis> i guess it is, what is generics sandwich referring to? |
09:37:37 | FromDiscord | <mratsim> https://github.com/nim-lang/Nim/issues/11225 |
09:38:10 | FromDiscord | <mratsim> Don't be fooled by the closed status, it's a whack-in-a-mole |
09:38:34 | FromDiscord | <mratsim> Probably related to this: https://github.com/nim-lang/Nim/issues/8677 |
09:39:50 | FromDiscord | <leorize> basically if you try to use generics in a useful way to solve some complex problems, it jumps on you and you spend 2hrs debugging missing imports and/or binds or whatsnot |
09:40:05 | FromDiscord | <leorize> then you read about the 🥪 and contemplate switching languages |
09:49:01 | FromDiscord | <graveflo> that was very relatable |
10:32:25 | * | antranigv joined #nim |
10:42:58 | PMunch | Hmm, how do people here deal with repeating code with only minor differences? |
10:43:42 | PMunch | Like I've written a procedure which takes a sequence of rectangles and moves them to the left edge of the screen 2048 style (but not on the same kind of grid as 2048) |
10:44:22 | PMunch | Then I copied that procedure and changed all the x's for y's and the w's for h's, works fine. |
10:44:44 | NimEventer | New question by Miiao: black_box analogue in Nim, see https://stackoverflow.com/questions/76489400/black-box-analogue-in-nim |
10:44:54 | PMunch | The algorithm is also pretty much exactly the same, just with some minor tweaks to move them to the right and bottom |
10:45:07 | PMunch | But this has left me with 4 almost identical procedures |
10:47:00 | FromDiscord | <mratsim> sent a long message, see http://ix.io/4ynN |
10:47:32 | FromDiscord | <odexine> In reply to @mratsim "But what language would": theres no good alternative, which is pain xdddd |
10:47:45 | FromDiscord | <mratsim> In reply to @PMunch "But this has left": generics, template, factoring the same stuff in a proc or keeping those separate |
10:48:33 | FromDiscord | <mratsim> It really depends on the size of the code, how complex the program flow is, how buggy I expect that to be, how much rewrite I expect, the quality of the test suite |
10:49:11 | FromDiscord | <mratsim> Also there might be a mathematical name for what you did (applying a matrix?) |
10:49:34 | FromDiscord | <demotomohiro> @pmunch How about to add a enum param/static enum param and use `when`, or `case of` where code need to be changed.↵Or use template. |
10:50:17 | FromDiscord | <graveflo> lets not forget that mathematics leads itself to general algos too.. If you are just doing a type of transformation maybe you are just coding the procs logic wrong |
10:53:40 | PMunch | Yeah I've refactored to a template, like this: https://play.nim-lang.org/#ix=4ynS |
10:53:45 | PMunch | But it's not exactly pretty.. |
10:55:35 | PMunch | `shuffleUp` would then be implemented as `shuffleSmall(y, x, h, w)` |
10:55:42 | PMunch | But it's all pretty cryptic |
10:56:32 | FromDiscord | <graveflo> That is a monster if statement LOL |
10:57:33 | FromDiscord | <graveflo> you might want to join the larger sections of the if statement with `and` instead especially since the sub conditions are easily flippable |
11:07:40 | PMunch | Haha, yeah it's to check if there is another placed square which we would collide with. Basically just checks for overlay |
11:08:29 | PMunch | Not quite sure what you mean about joining the sections with `and`, that would change the logic of it.. |
11:11:57 | PMunch | Then of course you have the shuffleBig variant which is almost exactly the same thing: https://play.nim-lang.org/#ix=4ynW |
11:13:12 | PMunch | But I can't think of a good way to combine that which wouldn't just make them super hard to read |
11:21:11 | FromDiscord | <graveflo> no I was talking about demorgans law, flipping the inequalities and joining with `and` since its slightly faster.. Nevermind that though it doesn't really matter. |
11:21:56 | FromDiscord | <graveflo> having the members named things like `coord` and `dim` makes it pretty difficult to read the intent of that code |
11:36:51 | PMunch | Yeah.. |
11:37:07 | PMunch | It was either x/y or w/h depending on which way you applied it |
11:37:13 | PMunch | Not sure how to make it clearer.. |
11:37:26 | PMunch | I mean I could split that massive if into its own procedure :P |
11:38:52 | PMunch | And name things like `other.rect.y > square.rect.y + square.rect.h` something like `other.below(square)` |
11:39:19 | PMunch | Of course that makes it harder to put into a template.. |
11:39:29 | FromDiscord | <graveflo> so what is it that this code is trying to do? It looks almost like collision detection. What does "shuffle" mean here? |
11:42:19 | PMunch | Eh, shuffle is a very poor choice of name |
11:42:40 | PMunch | It takes a list of rectangles, then it moves them to an edge of the screen |
11:43:18 | PMunch | But they collide with each other like in Tetris or 2048 |
11:43:49 | FromDiscord | <graveflo> oh so this is predicting the trajectory as opposed to doing that in real time I suppose? |
11:44:55 | PMunch | Like this: https://play.nim-lang.org/#ix=4yo2 |
11:46:31 | FromDiscord | <graveflo> I see. If they are moving all in one direction and that direction is a straight line that sounds pretty manageable |
11:48:41 | PMunch | https://uploads.peterme.net/preshuffle.png -> https://uploads.peterme.net/shuffleright.png |
11:49:04 | PMunch | Yeah it's nothing complicated |
11:51:01 | FromDiscord | <odexine> sounds more like slamming |
11:51:36 | PMunch | Yeah.. |
11:51:45 | PMunch | As I said, shuffling is a terrible name :P |
11:52:11 | PMunch | If you shuffle up after you shuffle right you would end up with this: https://uploads.peterme.net/shufflerightup.png |
11:52:56 | FromDiscord | <odexine> yeah sounds like slamming |
12:01:14 | PMunch | Sure, but the name isn't the important part :P |
12:04:23 | FromDiscord | <odexine> smh its important to me |
12:04:24 | FromDiscord | <odexine> smh |
12:05:47 | * | azimut joined #nim |
13:01:29 | FromDiscord | <auxym> In reply to @odexine "yeah sounds like slamming": but then I'd confuse it with https://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping |
13:01:46 | FromDiscord | <odexine> ah this ive dabbled in this a little |
13:01:48 | FromDiscord | <auxym> collision detection? Or packing maybe? |
13:01:55 | FromDiscord | <auxym> I'm only in it for the semantics |
13:01:57 | FromDiscord | <auxym> important stuff |
13:02:18 | FromDiscord | <auxym> I've been adjacent to people who SLAM |
13:02:50 | * | syl quit (Read error: Connection reset by peer) |
13:02:59 | * | syl_ joined #nim |
13:09:53 | FromDiscord | <odexine> In reply to @auxym "collision detection? Or packing": collision det. |
13:10:03 | FromDiscord | <odexine> its hard so i didnt pursue it further |
13:11:29 | PMunch | I'm doing it for packing |
13:12:19 | PMunch | Collision detection isn't too bad, just a bunch of bounds checks |
13:39:02 | NimEventer | New thread by beckx: Neovim lsp setup: no autocompletion and suggestion, see https://forum.nim-lang.org/t/10276 |
13:47:48 | * | ntat joined #nim |
13:55:19 | FromDiscord | <auxym> packing is good I think, though I think in the strict math definition it's usually "fit given shapes in the smallest possible area" |
14:14:03 | NimEventer | New question by bugninja: Nim websocket client using threads instead of async, see https://stackoverflow.com/questions/76491029/nim-websocket-client-using-threads-instead-of-async |
14:16:20 | * | PMunch quit (Quit: Leaving) |
14:19:20 | FromDiscord | <odexine> oh you mean pmunch, i thoughjt you asked why i tried SLAM lol |
14:39:35 | * | rockcavera joined #nim |
14:44:15 | FromDiscord | <kumolonimbus> sent a long message, see https://paste.rs/ocwkB |
14:44:32 | FromDiscord | <kumolonimbus> (edit) "http://ix.io/4ypt" => "http://ix.io/4yps" |
14:44:40 | * | alapini joined #nim |
14:45:01 | FromDiscord | <kumolonimbus> (edit) "http://ix.io/4yps" => "http://ix.io/4ypu" |
14:49:50 | * | alapini quit (Quit: Client closed) |
14:54:38 | FromDiscord | <michaelb.eth> In reply to @kumolonimbus "Hey all, I am": to begin with, you can probably just rely on proc overloads |
14:55:03 | FromDiscord | <michaelb.eth> if you need runtime dispatch, you can consider using Nim's `method` facility |
14:57:56 | * | cnx quit (Remote host closed the connection) |
14:58:07 | FromDiscord | <kumolonimbus> Thanks, I don't need runtime dispatch thankfully, but I was also looking into overloads. I am just curious how I can explicity state 'these are the functions/types to be expected by a comms channel type'. I am mostly trying to think of communicating intention to contributors to make it easy to understand the necessary steps required to make a new comms channel. |
14:58:13 | * | cnx joined #nim |
14:59:27 | FromDiscord | <kumolonimbus> I coul just implement one (ex. HTTP) and state in docs somewhere 'overload all the functions in HTTP to make a new channel' but I was hoping for a generic of some sort |
14:59:28 | FromDiscord | <odexine> Concepts then |
15:00:17 | FromDiscord | <bostonboston> I'm attempting to use enums as a way to limit the options a user can input, later I need to convert the input to a byte to I have to do that explicitly everytime |
15:01:47 | FromDiscord | <bostonboston> (edit) "to" => "do" |
15:04:26 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ypJ |
15:04:53 | FromDiscord | <michaelb.eth> (edit) "https://play.nim-lang.org/#ix=4ypJ" => "https://play.nim-lang.org/#ix=4ypL" |
15:06:39 | NimEventer | New thread by dwhall256: Embedded: svd2nim for read/write of ARM Cortex micros, see https://forum.nim-lang.org/t/10277 |
15:24:34 | * | lucasta joined #nim |
15:33:17 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4ypQ |
15:45:41 | FromDiscord | <Chronos [She/Her]> How would I make it so the Redis wrapper by Araq (In Nim rg) can use my custom cert and key? |
15:46:57 | FromDiscord | <Chronos [She/Her]> Might just use a diff lib |
15:48:13 | FromDiscord | <Chronos [She/Her]> If there even is one |
15:50:52 | FromDiscord | <bostonboston> In reply to @michaelb.eth "so, actually, this works": I tried annotating with the 'u8 suffix and that didn't work so I'll try the cast |
15:55:24 | FromDiscord | <bostonboston> Casting did not work |
15:59:04 | FromDiscord | <michaelb.eth> note that cast and conversion aren’t the same thing |
16:13:18 | FromDiscord | <bostonboston> So byte(x) is a conversion |
16:21:32 | FromDiscord | <odexine> Yes |
16:34:15 | FromDiscord | <bostonboston> Unfortunately (byte)x, x.byte and x'u8 did not work |
16:58:13 | FromDiscord | <michaelb.eth> In reply to @bostonboston "Unfortunately (byte)x, x.byte and": can you give a bit more context? |
16:58:49 | FromDiscord | <michaelb.eth> as for `x'u8`, the integer literal syntax only works with a literal |
16:58:59 | FromDiscord | <michaelb.eth> e.g. `123'u8` |
17:02:06 | FromDiscord | <bostonboston> sent a code paste, see https://play.nim-lang.org/#ix=4yqv |
17:02:30 | FromDiscord | <bostonboston> But I'm doing send[i] in a hundred places and don't want to cast every time |
17:03:03 | FromDiscord | <bostonboston> (edit) "https://play.nim-lang.org/#ix=4yqv" => "https://paste.rs/VqHQl" |
17:11:45 | FromDiscord | <michaelb.eth> sent a code paste, see https://play.nim-lang.org/#ix=4yqD |
17:12:01 | FromDiscord | <michaelb.eth> https://nim-lang.org/docs/manual.html#converters |
17:34:20 | FromDiscord | <verdagon> In reply to @omentic "so i'm putting together": if you're doing a comparison of memory models, i have an absolute _treasure trove_ i think youd be interested in |
17:34:36 | FromDiscord | <verdagon> by my count, there's something like 14 (!) different ways for languages to achieve memory safety |
17:34:38 | FromDiscord | <JJ> In reply to @verdagon "if you're doing a": ah, hi! |
17:35:00 | FromDiscord | <verdagon> ive been wanting to write a series on it for a while (titled "the memory safety grimoire") but ive been too busy with vale 😆 |
17:35:11 | FromDiscord | <JJ> i'll take it 👀 the vale blog post list is also one of my reference links |
17:35:26 | FromDiscord | <verdagon> hah awesome, thats great to hear ^^ |
17:35:38 | FromDiscord | <verdagon> i'll DM you what i have, it's not structured at all |
18:15:08 | * | lucasta quit (Remote host closed the connection) |
18:23:25 | FromDiscord | <arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4yqU |
18:23:52 | FromDiscord | <bostonboston> In reply to @arathanis "casting the enum to": What I was doing in my example worked, I just didn't want to do it, a converter is the answer I was looking for |
18:24:26 | FromDiscord | <arathanis> In reply to @bostonboston "What I was doing": I;ve just been using `.byte` and it appears to worj |
18:24:28 | FromDiscord | <arathanis> (edit) "worj" => "work" |
18:25:06 | FromDiscord | <arathanis> https://media.discordapp.net/attachments/371759389889003532/1119331833214152796/image.png |
18:26:08 | FromDiscord | <bostonboston> Correct that works, I wanted an implicit conversion |
18:26:25 | FromDiscord | <arathanis> ahh, makes sense |
18:26:36 | FromDiscord | <arathanis> i always worry about blowing my own leg off doing that |
18:27:07 | FromDiscord | <arathanis> but it will make things cleaner, huh? |
18:28:23 | FromDiscord | <bostonboston> It makes things cleaner, and I'm using the enum itself as my safety. Since I'm defining the enum as long as I don't go over 255 I'll be okay (I can't go over 255 anyway) |
18:30:59 | FromDiscord | <bostonboston> Additionally I'm not going to the other way, anytime I'm reading a byte I will still explicitly cast it to the proper enum |
18:31:36 | FromDiscord | <arathanis> looks like converters don't work inside sequence initializations? |
18:31:57 | FromDiscord | <bostonboston> Not something I've tried |
18:33:03 | FromDiscord | <arathanis> sent a code paste, see https://paste.rs/d0ypk |
19:25:23 | FromDiscord | <Elegantbeef> you need a `seq[T]` converter @arathanis |
19:25:37 | FromDiscord | <Elegantbeef> Just cause two generic parameters match does not mean the data type is convertible |
19:26:02 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4yr2 |
19:27:24 | * | derpydoo joined #nim |
19:28:34 | FromDiscord | <Elegantbeef> `let s1 = @[byte fBar]` is just simpler |
19:33:44 | FromDiscord | <arathanis> In reply to @Elegantbeef "you need a `seq[T]`": a converter from seq[Foo] to seq[byte]? |
19:34:07 | FromDiscord | <Elegantbeef> Yes |
19:35:58 | FromDiscord | <arathanis> In reply to @Elegantbeef "Yes": cool: https://media.discordapp.net/attachments/371759389889003532/1119349666035798127/image.png |
19:38:36 | FromDiscord | <mratsim> converters are quite a pain for maintence, you rapidly get into ambiguous calls or them called in situations you don't wat, silently, because a proc exists for the converted type. |
19:39:08 | FromDiscord | <arathanis> yeah its cool to be able to enable implicit conversion but it is a common footgun |
20:06:39 | * | ntat quit (Quit: Leaving) |
20:10:34 | * | ced1 joined #nim |
20:11:55 | * | ced1 is now known as cedb |
20:34:31 | * | azimut_ joined #nim |
20:36:56 | * | azimut quit (Ping timeout: 240 seconds) |
22:01:06 | FromDiscord | <deech> sent a code paste, see https://play.nim-lang.org/#ix=4yrn |
22:20:05 | * | cm quit (Ping timeout: 240 seconds) |
22:26:01 | * | cm joined #nim |
22:28:12 | * | candlestick joined #nim |
22:29:07 | * | candlestick left #nim (#nim) |
22:35:56 | * | madprops_ joined #nim |
22:36:09 | * | madprops quit (Read error: Connection reset by peer) |
22:36:49 | * | madprops_ is now known as madprops |
22:36:49 | * | madprops quit (Changing host) |
22:36:49 | * | madprops joined #nim |
23:26:18 | * | derpydoo quit (Quit: derpydoo) |