00:10:52 | * | derpydoo joined #nim |
00:18:40 | * | disso-peach joined #nim |
00:20:50 | * | krux02_ quit (Remote host closed the connection) |
00:22:33 | NimEventer | New post on r/nim by insomniac_lemon: Anybody still trying to make Godot 4.X bindings?, see https://reddit.com/r/nim/comments/13kj1cb/anybody_still_trying_to_make_godot_4x_bindings/ |
01:06:22 | FromDiscord | <Elegantbeef> @sOkam! I assume you'll be interested |
01:06:23 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1108561182564040824/image.png |
01:06:47 | FromDiscord | <Elegantbeef> https://github.com/beef331/truss3d/blob/guirewrite/src/truss3D/guiimpl.nim |
01:07:09 | FromDiscord | <Elegantbeef> It's wholly agnostic |
01:07:46 | FromDiscord | <Elegantbeef> Doesnt use any specific vector, nor backend |
01:12:51 | * | nanxiao joined #nim |
01:58:31 | FromDiscord | <@theperfectcomputer-628303036da0> How can I only import those fields into another file |
01:58:32 | FromDiscord | <@theperfectcomputer-628303036da0> sent a long message, see https://paste.rs/WvO6n |
01:58:41 | FromDiscord | <Elegantbeef> There is no selective importing of fields |
01:58:45 | FromDiscord | <@theperfectcomputer-628303036da0> For example, I know that NIm supports qualified imports with `from` |
01:58:47 | FromDiscord | <@theperfectcomputer-628303036da0> oh |
01:58:55 | FromDiscord | <@theperfectcomputer-628303036da0> That's kinda not fun |
01:59:03 | FromDiscord | <Elegantbeef> If you have access to the type you have access to the field if it's exported |
01:59:08 | FromDiscord | <Elegantbeef> It's kinda unimportant |
01:59:33 | FromDiscord | <@theperfectcomputer-628303036da0> Well, I'm trying to do `from parse_git import MovedFile` |
01:59:36 | FromDiscord | <Rika> I don’t know a language that has field specific imports… |
01:59:40 | FromDiscord | <@theperfectcomputer-628303036da0> But that doesn't bring fields with it |
01:59:47 | FromDiscord | <@theperfectcomputer-628303036da0> Haskell...↵(@Rika) |
01:59:54 | FromDiscord | <Elegantbeef> That does bring the fields with it, if they're exported |
02:00:14 | FromDiscord | <Rika> In reply to @@theperfectcomputer-628303036da0 "Haskell... (<@259277943275126785>)": Okay, what else has it |
02:00:42 | FromDiscord | <@theperfectcomputer-628303036da0> I think you're right - my issue was unrelated - need to forward declare function |
02:00:46 | FromDiscord | <@theperfectcomputer-628303036da0> Man - I'm so used to Haskell |
02:01:03 | FromDiscord | <@theperfectcomputer-628303036da0> Haskell is so easy - I thought Nim would be too \:P |
02:01:07 | FromDiscord | <Elegantbeef> It is easy |
02:02:16 | FromDiscord | <Rika> In reply to @@theperfectcomputer-628303036da0 "Haskell is so easy": A good amount of people would also say the opposite |
02:03:30 | FromDiscord | <JJ> ah, you'll be thrown off by the module system, coming from an ml descendant |
02:04:36 | FromDiscord | <@theperfectcomputer-628303036da0> @JJ\: you have a preffered FPL? |
02:05:13 | FromDiscord | <@theperfectcomputer-628303036da0> I used to use Nim a couple years ago actually |
02:05:31 | FromDiscord | <@theperfectcomputer-628303036da0> But I must have forgotten some of the finer details |
02:07:14 | FromDiscord | <Rika> In reply to @apropos "ah, you'll be thrown": honestly the loss of pattern matching hits really hard in nim lol |
02:07:32 | FromDiscord | <JJ> In reply to @@theperfectcomputer-628303036da0 "<@572634810917322773>\: you have a": nim! ha |
02:07:49 | FromDiscord | <Rika> is nim really an fpl |
02:07:55 | FromDiscord | <Rika> its like uh |
02:07:57 | FromDiscord | <Rika> an fpl lite |
02:08:15 | FromDiscord | <JJ> actually if nim counts (which it definitely doesn't) then i'd probably say rust instead |
02:08:17 | FromDiscord | <@theperfectcomputer-628303036da0> Building programs by value construction is the first thing that comes to mind in Nim |
02:08:32 | FromDiscord | <michaelb.eth> I think the answer is probably "no" (unless we're talking about enums), but is there a way to display the name of a constant (i.e. the identifier used in the source code) at runtime rather than its value? |
02:08:39 | FromDiscord | <@theperfectcomputer-628303036da0> isn't |
02:08:47 | FromDiscord | <Rika> In reply to @michaelb.eth "I think the answer": technically yes |
02:08:56 | FromDiscord | <Rika> `astToStr` exists |
02:09:15 | FromDiscord | <@theperfectcomputer-628303036da0> Rust has a pretty nice Macro system |
02:09:17 | FromDiscord | <JJ> i don't actually know too many purely functional languages. racket i suppose, just because it's the only one i actually know: i just hang out around enough haskell fans to know some stuff about it |
02:09:37 | FromDiscord | <Elegantbeef> Constants fold in their callsite with any macro/template |
02:10:14 | FromDiscord | <@theperfectcomputer-628303036da0> Honestly functional purity is overrated |
02:10:24 | FromDiscord | <@theperfectcomputer-628303036da0> Now what's really cool is functional purity with laziness |
02:11:14 | FromDiscord | <@theperfectcomputer-628303036da0> I regularly build software using infinite lists in Haskell that would be hard using other approaches |
02:11:46 | FromDiscord | <JJ> i should learn haskell or ocaml but rust has adts so i just use rust instead. i don't think purity is very helpful without a full blown effects system. |
02:12:23 | FromDiscord | <@theperfectcomputer-628303036da0> unless you're using Elm |
02:12:34 | FromDiscord | <@theperfectcomputer-628303036da0> But yeah - generally you need an effects manager |
02:13:14 | FromDiscord | <JJ> laziness throws me off: it's one of those things i don't think i appreciate yet. rust's approach to laziness as types to chain maps etc is cool, but i think doing it entirely in the compiler like beef's iterators implementation would be better |
02:13:58 | FromDiscord | <@theperfectcomputer-628303036da0> http://yager.io/talks/CLaSH.pdf |
02:14:01 | FromDiscord | <@theperfectcomputer-628303036da0> page 14 |
02:14:29 | FromDiscord | <@theperfectcomputer-628303036da0> It turns out that circuits are purely functional machines with state captured as infinite lists |
02:14:40 | FromDiscord | <JJ> In reply to @Rika "honestly the loss of": also 100%↵i've been playing around with writing an rfc for proper pattern matching in nim for quite some time but it's hard because for it to not be clunky you also do need proper adts instead of variant objects |
02:14:40 | FromDiscord | <@theperfectcomputer-628303036da0> That's primarily what I've been using Haskell for |
02:15:21 | FromDiscord | <Rika> god bless, verilog sucks |
02:15:22 | FromDiscord | <JJ> the downsides of variant objects (even ignoring the weird restriction of field names) far outweigh the downsides of adts imo |
02:15:33 | FromDiscord | <Elegantbeef> The upsides of variants! |
02:15:50 | FromDiscord | <@theperfectcomputer-628303036da0> I could never really grasp variant in Ocaml |
02:15:53 | FromDiscord | <@theperfectcomputer-628303036da0> That just confused me |
02:16:30 | FromDiscord | <JJ> ik it makes reusing fields across multiple objects easier but i use that far less than having an enum of different objects rust-style |
02:16:31 | FromDiscord | <@theperfectcomputer-628303036da0> with polymorphic variants |
02:16:54 | FromDiscord | <@theperfectcomputer-628303036da0> haskell variants - much more sane |
02:16:55 | FromDiscord | <Elegantbeef> Believe it or not james, but fungus is a perfect base to write a RFC for tagged unions |
02:17:18 | FromDiscord | <@theperfectcomputer-628303036da0> nim no has tagged unions? |
02:17:25 | FromDiscord | <Elegantbeef> It has tagged unions |
02:17:27 | FromDiscord | <Elegantbeef> Of course it does |
02:17:54 | FromDiscord | <Elegantbeef> They do not require unpacking so field names cannot be shared |
02:18:14 | FromDiscord | <@theperfectcomputer-628303036da0> hehe↵(@Rika) |
02:18:15 | FromDiscord | <@theperfectcomputer-628303036da0> yes |
02:19:37 | FromDiscord | <JJ> i don't really want object variants though |
02:19:42 | FromDiscord | <JJ> where did i put my notes |
02:20:00 | FromDiscord | <Elegantbeef> Who said you did? |
02:20:17 | FromDiscord | <Elegantbeef> Fungus is a fantastic basis to describe the relations and API internally that the compiler needs |
02:20:29 | FromDiscord | <Elegantbeef> Maybe i'm just biased 😄 |
02:21:19 | FromDiscord | <@theperfectcomputer-628303036da0> what is fungus? |
02:21:24 | FromDiscord | <JJ> https://github.com/beef331/fungus |
02:21:39 | FromDiscord | <JJ> oh i definitely agree adts are perfect for anything compilers |
02:21:45 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5G |
02:21:54 | FromDiscord | <Elegantbeef> No i mean you said you wanted an RFC |
02:22:09 | FromDiscord | <JJ> the thing i was thinking of is a little more powerful - gah where did i put my notes |
02:22:13 | FromDiscord | <Elegantbeef> This library mostly describes the requirements for the type system to achieve your pattern matching |
02:23:12 | FromDiscord | <Elegantbeef> Your notes are going to fall flat to me likely unless you use small words like 'I', 'a', and 'by' |
02:23:14 | FromDiscord | <@theperfectcomputer-628303036da0> Fungus is cool - even if a little janky looking |
02:23:29 | FromDiscord | <@theperfectcomputer-628303036da0> I honestly wish all Python code would be replaced by Nim |
02:24:25 | FromDiscord | <@theperfectcomputer-628303036da0> Is fungus a reference to the Rust fungus? |
02:24:41 | FromDiscord | <Elegantbeef> It is indeed |
02:24:50 | FromDiscord | <@theperfectcomputer-628303036da0> As opposed to ferric oxide? |
02:24:51 | FromDiscord | <Elegantbeef> I like pun filled/allusive names |
02:24:59 | FromDiscord | <JJ> well drat i don't know where they went, it was just some example code |
02:25:07 | FromDiscord | <Elegantbeef> Jokes on you bub |
02:26:13 | FromDiscord | <@theperfectcomputer-628303036da0> rust is to metal as mold is to... |
02:26:33 | FromDiscord | <Elegantbeef> My lungs |
02:26:41 | FromDiscord | <@theperfectcomputer-628303036da0> oh no!! |
02:26:46 | FromDiscord | <Elegantbeef> Sorry that's mould |
02:26:52 | FromDiscord | <@theperfectcomputer-628303036da0> chat GPT says "food" |
02:27:08 | FromDiscord | <Elegantbeef> Never can trust AI i say |
02:27:30 | FromDiscord | <@theperfectcomputer-628303036da0> You have iron lungs? |
02:27:42 | FromDiscord | <Elegantbeef> Nah I don't have polio |
02:27:58 | FromDiscord | <@theperfectcomputer-628303036da0> Oh - 'nuf with the puns |
02:28:17 | FromDiscord | <@theperfectcomputer-628303036da0> You can't trust me? |
02:28:37 | FromDiscord | <Elegantbeef> You use gitter of course i cannot |
02:28:44 | FromDiscord | <Elegantbeef> That's like matrix but slightly weird |
02:29:26 | FromDiscord | <JJ> sent a code paste, see https://play.nim-lang.org/#ix=4w5I |
02:29:29 | FromDiscord | <@theperfectcomputer-628303036da0> Well - we're presently all using Matrix |
02:29:31 | FromDiscord | <JJ> arbitrary inline type composition |
02:29:44 | FromDiscord | <Elegantbeef> No james is on discord |
02:29:47 | FromDiscord | <Elegantbeef> The rapscallion |
02:30:04 | FromDiscord | <Elegantbeef> Get your ugly inline struct declaration and shove it |
02:30:18 | FromDiscord | <@theperfectcomputer-628303036da0> Oof |
02:30:21 | FromDiscord | <Elegantbeef> `typeof(Shape.Cube.dims)` |
02:30:24 | FromDiscord | <@theperfectcomputer-628303036da0> I'm kinda cracking up over here |
02:30:53 | FromDiscord | <Elegantbeef> What even is the type there James, and how would I access it in any sensible way |
02:30:58 | FromDiscord | <Elegantbeef> Anonymous types make no sense to me |
02:31:33 | FromDiscord | <JJ> i don't know what you're talking about beef |
02:31:41 | FromDiscord | <Elegantbeef> There we go |
02:31:42 | FromDiscord | <Elegantbeef> The cooler james |
02:31:48 | FromDiscord | <Elegantbeef> Even goes by JJ |
02:31:51 | FromDiscord | <JJ> christ the bridge fucked that |
02:32:17 | FromDiscord | <Elegantbeef> Truth be told, I don't think bridges have the required anatomy for that |
02:32:19 | FromDiscord | <JJ> didn't even get my pfp much less my punctuation |
02:32:43 | FromDiscord | <JJ> yeah, james is actually my last name |
02:33:10 | FromDiscord | <Elegantbeef> Fuck who gave me a keyboard |
02:33:11 | FromDiscord | <JJ> my first name sounds like a last name though and for a while i went by j-james everywhere so most people just called me james |
02:33:13 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1108583036821458974/image.png |
02:36:58 | FromDiscord | <JJ> In reply to @Elegantbeef "What even is the": so that's another thing i was working on fleshing out in my notes, if i could find them [insert timmy turner's dad here] |
02:41:02 | FromDiscord | <Elegantbeef> Yay I have anchoring working with my gui rewrite |
02:41:52 | FromDiscord | <JJ> sent a code paste, see https://play.nim-lang.org/#ix=4w5J |
02:42:24 | FromDiscord | <Elegantbeef> That is a horrid syntax |
02:42:27 | FromDiscord | <JJ> i'm sure there are loads of edge cases, i kept discovering them while trying to seriously describe it |
02:42:32 | FromDiscord | <Elegantbeef> It doesnt even align with Nim's present syntax |
02:42:38 | FromDiscord | <Dudugz> sent a code paste, see https://paste.rs/SyHL8 |
02:43:05 | FromDiscord | <Elegantbeef> Bleh you people and your weird desired syntaxs |
02:43:32 | FromDiscord | <Dudugz> lol, say that because you don't have a json configuration file with several fields |
02:43:37 | FromDiscord | <JJ> In reply to @Elegantbeef "It doesnt even align": yeah it doesn't at all. that's wrong and something i have to fix, i was adapting it from a model that used `match/of` and types following the colon for fancy types and a bunch of other Different changes |
02:43:50 | FromDiscord | <Dudugz> Then you have to create thousands of types just to be able to deserialize. |
02:44:10 | FromDiscord | <JJ> actually i'll put that in more proper nim syntax real quick i hope it doesn't break the bridge |
02:45:41 | FromDiscord | <Dudugz> If types could be created at runtime we wouldn't even need to define them when deserializing as it would be possible to create objects like JS |
02:47:33 | FromDiscord | <JJ> In reply to @@theperfectcomputer-628303036da0 "That's primarily what I've": also - sounds like i really should learn haskell. i thought that between rust and agda (in the future: learning it is a goal for the next few months) i covered haskell's major features (adts and type fuckery) but hadn't really though about laziness on its own |
02:47:46 | * | nanxiao quit (Quit: Client closed) |
02:58:04 | FromDiscord | <sOkam!> In reply to @Elegantbeef "image.png": 100% 👀. thats epics |
02:58:47 | FromDiscord | <Elegantbeef> Still uncertain how to abstract things like `Label` and `Button`, dont think I can without silly generics |
02:59:56 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5M |
03:02:12 | FromDiscord | <JJ> sent a code paste, see https://play.nim-lang.org/#ix=4w5O |
03:02:33 | FromDiscord | <Elegantbeef> I do not get why people insist on calling those enums 😄 |
03:03:08 | FromDiscord | <Elegantbeef> Yes I know i called it an `adtEnum`, but they're not `enum` so stop it |
03:03:25 | FromDiscord | <Elegantbeef> The worst part is that would cause issues with `proc doThing(t: enum)` |
03:03:34 | FromDiscord | <Elegantbeef> It should be a `union` or other typeclassable type |
03:04:42 | FromDiscord | <Elegantbeef> Edits are one way here Discord -\> Matrix |
03:04:43 | FromDiscord | <Elegantbeef> The bridge is really sad |
03:05:09 | FromDiscord | <Elegantbeef> One day I'll write a Nim bridge, but that requires expanding the matrix api which is tedious 😄 |
03:05:16 | FromDiscord | <JJ> probably a good idea to disallow edits as much as possible because irc |
03:05:38 | FromDiscord | <JJ> although i guess for code blocks it doesn't matter since those are like playground links or smth |
03:06:09 | FromDiscord | <Elegantbeef> It's a general bridge it's not nim specific so doesnt really matter 😄 |
03:06:36 | FromDiscord | <Elegantbeef> The Irc discord bridge can handle that and it's Nim specific |
03:07:31 | FromDiscord | <JJ> In reply to @Elegantbeef "The worst part is": wdym by this? |
03:08:00 | FromDiscord | <Elegantbeef> You're using `enum` to declare an tagged union |
03:08:04 | FromDiscord | <JJ> also if i ever do finish a formal proposal in the future defo going to post it here to iron out all the edge cases |
03:08:05 | FromDiscord | <Elegantbeef> a tagged union\ |
03:08:25 | FromDiscord | <Elegantbeef> `enum` in Nim presently means an ordinal enumerated type |
03:08:40 | FromDiscord | <Elegantbeef> So why doesnt `doThing(Shape(..))` compile? |
03:09:07 | FromDiscord | <Elegantbeef> If it does compile that means we now need a new typeclass `NumericEnum` |
03:09:32 | FromDiscord | <Elegantbeef> We've conflated `enum` in your present state |
03:09:48 | FromDiscord | <Elegantbeef> `union` is a better word in my view |
03:10:21 | FromDiscord | <Elegantbeef> I still despise the internally declared types |
03:10:48 | FromDiscord | <JJ> what are the current semantics of enums around containing values? |
03:11:45 | FromDiscord | <JJ> sent a code paste, see https://play.nim-lang.org/#ix=4w5P |
03:12:03 | FromDiscord | <Elegantbeef> That and `Four = (4, "This is Four")` |
03:12:37 | FromDiscord | <Elegantbeef> This compiles |
03:12:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5Q |
03:12:48 | FromDiscord | <Elegantbeef> You've conflated `enum` to be more than a numeric data type |
03:13:14 | FromDiscord | <JJ> oh i see, right |
03:13:25 | FromDiscord | <JJ> i wasn't aware of the `enum` typeclass |
03:14:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5R |
03:14:20 | FromDiscord | <Elegantbeef> Whoops |
03:14:26 | FromDiscord | <Elegantbeef> One moment |
03:14:36 | FromDiscord | <JJ> (actually something similar came up with my stropping-as-case-sensitive proposal too: there's a conflict in a feature of nim i was totally unaware about. still haven't figured that out) |
03:14:47 | FromDiscord | <Elegantbeef> There we go that's the sane API |
03:14:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5S |
03:15:04 | FromDiscord | <JJ> sent a code paste, see https://paste.rs/qizJx |
03:15:11 | FromDiscord | <Elegantbeef> It does |
03:15:21 | FromDiscord | <JJ> like currently? |
03:15:24 | FromDiscord | <Elegantbeef> Yes |
03:15:33 | FromDiscord | <Elegantbeef> And it should continue to compiler |
03:15:34 | FromDiscord | <JJ> what on earth why |
03:15:36 | FromDiscord | <Elegantbeef> compile even |
03:15:42 | FromDiscord | <Elegantbeef> cause `enum` is a built in type class? |
03:16:11 | FromDiscord | <JJ> oh i'm dumb i was thinking it'd take types |
03:16:27 | FromDiscord | <JJ> and thinking that'd want a `seq[int]` or smth |
03:16:42 | FromDiscord | <Elegantbeef> `typedesc[enum]` is what you thought |
03:17:21 | FromDiscord | <JJ> gross taking the literal label of an enum |
03:17:22 | FromDiscord | <JJ> hmm |
03:17:42 | FromDiscord | <JJ> it doesn't seem very useful, honestly |
03:18:11 | FromDiscord | <Elegantbeef> Well you're wrong |
03:18:59 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/json.html#%25_2 |
03:19:12 | FromDiscord | <JJ> what the fuck |
03:19:19 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/typetraits.html#enumLen.m%2Ctypedesc%5B%5D |
03:19:29 | FromDiscord | <Elegantbeef> Why is this so confusing? |
03:19:31 | FromDiscord | <JJ> okay that one seems useful |
03:19:40 | FromDiscord | <Elegantbeef> a typeclass across all enums is fantastic |
03:20:09 | FromDiscord | <JJ> sure, but it's across one variant of an enum! |
03:20:17 | FromDiscord | <Elegantbeef> "one variant"? |
03:20:21 | FromDiscord | <JJ> yeah |
03:20:44 | FromDiscord | <JJ> for `%` it's constructing a JsonNode with the label of the variant of the enum that was passed in right |
03:20:57 | FromDiscord | <Elegantbeef> It's jsonifying the enum |
03:21:14 | FromDiscord | <Elegantbeef> That might mean string or integer |
03:21:15 | FromDiscord | <JJ> enumLen takes a `typedesc[enum]` which i think would remain fine |
03:21:16 | FromDiscord | <Elegantbeef> I do not know |
03:21:44 | FromDiscord | <JJ> either is pretty gross, i think: that seems much better suited to a macro |
03:21:49 | FromDiscord | <Elegantbeef> The simple fact is any code that presently expects `enum` to be an numeric type you've now made it so it now has to operate on a union or disable it |
03:21:53 | FromDiscord | <Elegantbeef> Why would it be a macro? |
03:22:04 | FromDiscord | <JJ> (i say, like i have written more than a single-digit number of macros in my life) |
03:22:07 | FromDiscord | <Elegantbeef> How do you even constrain the macro to only accept enum |
03:22:23 | FromDiscord | <Elegantbeef> Like the entire point of the typeclass is to restrain the input |
03:22:28 | FromDiscord | <Elegantbeef> A macro doesnt solve anything |
03:22:43 | FromDiscord | <Elegantbeef> "Always use the simplest tool for the job"↵JJ\: "So a macro?" |
03:22:51 | FromDiscord | <JJ> i don't think the label of the enum should be accessible by regular code |
03:22:53 | FromDiscord | <JJ> lmao |
03:23:11 | FromDiscord | <Elegantbeef> I mean this works for `tuple` and `object` and `distinct` |
03:23:21 | FromDiscord | <Elegantbeef> It's wonderful when you're writing generic interfaces |
03:24:07 | FromDiscord | <JJ> i don't think i have an issue with typeclasses for `tuple` and `object` and `distinct` but i'm conceptualizing `enum` as very different |
03:24:15 | FromDiscord | <Elegantbeef> It's identical |
03:24:26 | FromDiscord | <Elegantbeef> It's a typeclass across all enums both Ordinal and not |
03:26:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5T |
03:26:05 | FromDiscord | <JJ> a typeclass for `object` means all objects, a typeclass for `enum` means all enum variants: but i don't think enum variants should exist |
03:26:16 | FromDiscord | <Elegantbeef> What's an enum variant?! |
03:26:37 | FromDiscord | <JJ> uh, what do you call one of the enums of an enum type? |
03:26:39 | FromDiscord | <sOkam!> In reply to @Elegantbeef "Doesnt use any specific": what do you mean by `specific vector`? 🤔 |
03:26:40 | * | nanxiao joined #nim |
03:26:47 | FromDiscord | <Elegantbeef> Enum Field? |
03:26:59 | FromDiscord | <Elegantbeef> I mean that it's bring your own render + vector |
03:27:18 | FromDiscord | <sOkam!> vector as in vmath/vec3? |
03:27:28 | FromDiscord | <JJ> an instance of an object or a tuple is like a whole thing right |
03:27:34 | FromDiscord | <JJ> but an instance of an enum is an enum field |
03:27:39 | FromDiscord | <Elegantbeef> Of course sokam |
03:27:48 | FromDiscord | <sOkam!> kk. thats dope |
03:27:57 | FromDiscord | <JJ> which is, depending on the representation, only a number or only a label |
03:28:08 | FromDiscord | <Elegantbeef> "only" |
03:28:35 | FromDiscord | <JJ> i mean yeah |
03:28:45 | FromDiscord | <JJ> i don't think it's very helpful on its own |
03:28:50 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5U |
03:29:09 | FromDiscord | <Elegantbeef> Well i disagree |
03:29:26 | FromDiscord | <Elegantbeef> It's symmetric with all other type introducers |
03:29:43 | FromDiscord | <Elegantbeef> No one is complaining "You can use `proc(r: ref)`" |
03:29:52 | FromDiscord | <JJ> i don't think it should be though |
03:30:02 | FromDiscord | <Elegantbeef> I think you're wrong and we'll never agree |
03:30:21 | FromDiscord | <Elegantbeef> An enum is a specific type and it's good to be able to distinguish it for whatever reason you need |
03:31:38 | FromDiscord | <JJ> yeah, but as far as i can think of the reasons you need are scant to none compared to every other type, including objects and refs |
03:31:55 | FromDiscord | <JJ> with a ref generic you get a reference: you can like manipulate that and stuff |
03:32:29 | FromDiscord | <JJ> with an enum generic you only have the label. the json-ifying case is the only one i can think of |
03:32:30 | FromDiscord | <Elegantbeef> 😛 |
03:32:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/bbi6b |
03:32:50 | FromDiscord | <Elegantbeef> In fact that's what my dropdown is going to be |
03:32:52 | FromDiscord | <JJ> hmm wait what's this doing |
03:33:03 | FromDiscord | <Elegantbeef> Constraining the T to be only an enum type |
03:33:06 | FromDiscord | <huantian> sent a code paste, see https://paste.rs/pVIt5 |
03:33:21 | FromDiscord | <JJ> ah i see |
03:33:43 | FromDiscord | <Elegantbeef> I'll probably be using that for making my dropdowns in my GUI |
03:33:59 | FromDiscord | <Elegantbeef> Atleast one type |
03:34:06 | FromDiscord | <JJ> yeah my general thoughts are that enums as labels are much less useful than enums as type containers |
03:34:11 | FromDiscord | <Elegantbeef> Another type will take a `seq[string]` |
03:34:21 | FromDiscord | <JJ> but i think you've convinced me it'd have to be something separate for nim |
03:34:23 | FromDiscord | <Elegantbeef> I do not see why you cannot have `union` and `enum` |
03:34:31 | FromDiscord | <JJ> yea that's a good idea |
03:34:39 | FromDiscord | <Elegantbeef> A enum is an enumeration a list of values |
03:34:57 | FromDiscord | <Elegantbeef> A union is a overlapping declaration of types |
03:35:15 | FromDiscord | <Elegantbeef> Who ever though a union was an enum was a silly willy |
03:35:31 | FromDiscord | <Elegantbeef> two typos in a single sentence i'm making great strides |
03:36:08 | FromDiscord | <JJ> coming at it from using them in rust i want to make it as rusty as possible, and i always use enums as labels on containers and nothing else really, but that is better i think |
03:36:47 | FromDiscord | <JJ> as long as that `%` operator is representing the label and not the underlying number. if it is i will cry (std/json makes me cry in general though) |
03:37:01 | FromDiscord | <Elegantbeef> Conflation of the two types makes metaprogramming harder or more confusing, cause arguably a `union` is closer to `object` than `enum` |
03:37:15 | FromDiscord | <Elegantbeef> I think it was using ordinal at one point |
03:37:18 | FromDiscord | <Elegantbeef> I do not recall |
03:37:43 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5Y |
03:37:47 | FromDiscord | <JJ> hmm, okay, i'm going to find my notes and see how this would actually work |
03:38:10 | FromDiscord | <JJ> that would then clear up some other semantics issues i was having iirc |
03:38:26 | FromDiscord | <Elegantbeef> Probably, I still do not get why my syntax is so abhorrent |
03:38:27 | FromDiscord | <JJ> maybe it's actually feasible that'd be cool |
03:39:12 | FromDiscord | <JJ> fungus? if i understood it right it'd be less powerful than this |
03:39:19 | FromDiscord | <Elegantbeef> Nope |
03:39:27 | FromDiscord | <JJ> much more so than variant objects currently ofc |
03:39:34 | FromDiscord | <Elegantbeef> This |
03:39:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w5S |
03:39:47 | FromDiscord | <Elegantbeef> It doesnt use `=` to confuse with the new defaults syntax |
03:40:14 | FromDiscord | <Elegantbeef> It doesnt do anything odd, it's fairly concise |
03:40:30 | FromDiscord | <JJ> oh no that's nice |
03:41:42 | FromDiscord | <JJ> wait but, are you allowed to do nested objects and enums |
03:41:53 | FromDiscord | <Elegantbeef> Nested? |
03:42:07 | FromDiscord | <Elegantbeef> Suggesting nested type defs is a surefire way of getting any RFC declined |
03:42:56 | FromDiscord | <JJ> In reply to @apropos "hmm looks like the": was the `sides = enum` line a thing you had a problem with in this one? |
03:43:09 | FromDiscord | <JJ> looking at yours ig it wouldn't be needed at all |
03:43:13 | FromDiscord | <Elegantbeef> Was the entire usage of `enum` for a union |
03:43:20 | FromDiscord | <Elegantbeef> And also `sides =` |
03:43:30 | FromDiscord | <Elegantbeef> In nim 2.0 `=` will be valid inside typedefs |
03:44:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w60 |
03:44:16 | FromDiscord | <JJ> yea i like your syntax much more i think |
03:44:38 | FromDiscord | <Elegantbeef> Good cause it doesnt conflate anything and is practically fungus |
03:45:22 | FromDiscord | <Elegantbeef> I know Zig and friends like the idea of declaring anonymous types, but I feel that it's a very odd thing |
03:46:28 | FromDiscord | <JJ> i originally wrote this for something where `:` is always used as a type declaration, and also inheritance and aliasing, so you have `type Foo: Bar` instead of `type Foo = Bar` and `type Foo: object` instead of `type Foo = object` |
03:46:57 | FromDiscord | <JJ> but yea putting them nested like that doesn't work with nim currently and is also ugly lol |
03:47:03 | FromDiscord | <Elegantbeef> Yea that's a big old breaking change that'd never be passed 😄 |
03:47:31 | FromDiscord | <Elegantbeef> The nice thing about the current OOP is it's also symetric |
03:47:34 | FromDiscord | <Elegantbeef> I know C loves that 😛 |
03:47:47 | FromDiscord | <Elegantbeef> `if x of MyParent` is the same as you declare it |
03:47:53 | FromDiscord | <JJ> i never use it lol |
03:48:28 | FromDiscord | <JJ> i had a use case for it once, but just copy-pasted instead because it was not much duplication |
03:48:52 | FromDiscord | <Elegantbeef> I use it for my GUI cause there is not much better to copy fields 😄 |
03:49:01 | FromDiscord | <JJ> i rarely find myself reaching for oop methods outside of oop languages |
03:49:14 | FromDiscord | <JJ> yeah, gui is definitely one thing that oop is great at |
03:49:39 | FromDiscord | <Elegantbeef> I'm not even really using any runtime polymorphism |
03:49:39 | FromDiscord | <Elegantbeef> Just for field copying |
03:50:05 | FromDiscord | <Elegantbeef> Everything is statically dispatched, I just want that `ref` so I can create closures |
03:50:46 | FromDiscord | <JJ> oh huh |
03:51:26 | FromDiscord | <Elegantbeef> Is valid for instance |
03:51:29 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/bIrXa |
03:51:37 | FromDiscord | <Elegantbeef> This is inside a tuple, not a sequence |
03:52:16 | FromDiscord | <Elegantbeef> simplescreenrecorder-2023-05-17\_21.51.56.mp4 https://media.discordapp.net/attachments/371759389889003532/1108602930958979122/simplescreenrecorder-2023-05-17_21.51.56.mp4 |
03:52:23 | FromDiscord | <Elegantbeef> Just for the showcase of what's going on |
03:52:48 | FromDiscord | <JJ> oh actually beef are you familiar with template identifier concatenation? |
03:53:02 | FromDiscord | <Elegantbeef> Yes |
03:53:22 | FromDiscord | <Elegantbeef> It's technically not unique to templates |
03:53:29 | FromDiscord | <JJ> i'm not very experienced with templates but that's the thing blocking the literal stropping rfc |
03:54:20 | FromDiscord | <Elegantbeef> Inside accquotes(what the compiler calls stropping) each identifier is looked up |
03:54:31 | FromDiscord | <Elegantbeef> Well not looked up but yea |
03:54:51 | FromDiscord | <Elegantbeef> Each identifier is unique lexical stropping creates an array of identifiers |
03:55:12 | FromDiscord | <Elegantbeef> That with a comma after "unique" |
03:55:33 | FromDiscord | <JJ> okay, so is `'foo'` useless? (pretend the quotes are backticks) |
03:55:53 | FromDiscord | <Elegantbeef> It's not useless |
03:56:01 | * | disso-peach quit (Quit: Leaving) |
03:56:04 | FromDiscord | <Elegantbeef> cause `var \`var\` = 300\` is valid |
03:56:13 | FromDiscord | <Elegantbeef> You're kidding me |
03:56:26 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w66 |
03:56:47 | FromDiscord | <JJ> ah, yes, good |
03:56:53 | * | azimut quit (Remote host closed the connection) |
03:56:58 | FromDiscord | <Elegantbeef> This is moot point |
03:57:23 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w67 |
03:57:25 | FromDiscord | <JJ> the tl;dr of my rfc is an extension of that but i was worried template identifier concatenation would cause issues |
03:57:32 | * | azimut joined #nim |
03:59:16 | FromDiscord | <JJ> sent a code paste, see https://play.nim-lang.org/#ix=4w68 |
03:59:21 | FromDiscord | <JJ> (edit) |
03:59:40 | FromDiscord | <JJ> for use in C ffi: particularly the goddamn keyboard interface libraries |
04:00:03 | FromDiscord | <Elegantbeef> Ugh |
04:00:40 | FromDiscord | <huantian> your Nim function doesn’t need to have the same name as the c function tho right? |
04:00:43 | FromDiscord | <JJ> haxstramper brought up that stropping is also used for template identifier concatenation: i didn't (still don't, actually) know enough about templates to know if that would be an issue |
04:01:00 | FromDiscord | <JJ> In reply to @huantian "your Nim function doesn’t": yes: but this makes c ffi harder |
04:01:04 | FromDiscord | <JJ> lemmie grab an example |
04:01:04 | FromDiscord | <Elegantbeef> It likely wouldnt be an issue |
04:01:14 | FromDiscord | <Elegantbeef> Just replace underscores with a unicode character |
04:01:17 | FromDiscord | <Elegantbeef> Problem solved |
04:01:23 | FromDiscord | <JJ> case is the bigger problem |
04:01:55 | FromDiscord | <JJ> https://github.com/j-james/nim-xkbcommon/blob/main/src/xkb/keysyms.nim#L575 |
04:02:01 | FromDiscord | <Elegantbeef> I mean pmunch has resolved this |
04:02:22 | FromDiscord | <Elegantbeef> I do not know if supporting bad code is a good idea |
04:02:27 | FromDiscord | <JJ> sure, it'd just be a small quality of life improvement for when you write manual wrappers |
04:02:31 | FromDiscord | <Elegantbeef> But we've probably heard enough of what i think |
04:02:44 | FromDiscord | <JJ> well it's not really about that |
04:02:50 | FromDiscord | <Elegantbeef> It is really |
04:03:06 | FromDiscord | <JJ> i would argue most c libraries are bad code because i think c is kind of a bad language |
04:03:07 | FromDiscord | <Elegantbeef> If the case or underscores are important you're trying to support bad code |
04:03:39 | FromDiscord | <Elegantbeef> No one will dispute that having two longnames with casing as the only difference as bad code 😛 |
04:04:08 | FromDiscord | <JJ> yeah no i agree that it's bad code: this would make it easier to make good code on top of it |
04:04:27 | FromDiscord | <Elegantbeef> I do not know how really |
04:04:55 | FromDiscord | <Elegantbeef> It's no different than appending a number or unicode character to the end |
04:05:38 | FromDiscord | <JJ> essentially i imagine for high-quality c wrappers you have private 1:1 imported functions from the c library, and the idiomatic nim functions you export call them as needed |
04:05:43 | FromDiscord | <JJ> In reply to @Elegantbeef "It's no different than": i agree |
04:06:59 | FromDiscord | <Elegantbeef> Just imagine if we used pascal instead of C we'd be in a star trek future |
04:07:08 | FromDiscord | <Elegantbeef> It had full insensitivity and modules! |
04:07:10 | FromDiscord | <JJ> god |
04:07:41 | FromDiscord | <JJ> the more i learn about c the more i dislike it (i thought it would be the opposite) |
04:08:08 | FromDiscord | <JJ> in my ideal world c is a read-only language as the output of disassemblers and used nowhere else |
04:09:44 | * | nanxiao quit (Quit: Client closed) |
04:11:17 | FromDiscord | <JJ> oh beef i found a better (worse) example |
04:11:18 | FromDiscord | <JJ> https://github.com/j-james/nim-xkbcommon/blob/main/src/xkb/keysyms.nim#L489 |
04:11:28 | FromDiscord | <Elegantbeef> Oh i remember how bad it can be |
04:11:34 | FromDiscord | <JJ> `XKB_KEY_C_h_cap_underscore_nocap` rofl |
04:14:53 | FromDiscord | <Elegantbeef> It's not like a unicode character is any less informative than that, C supports utf8 identifiers iirc, time to get to town making PRs! |
04:15:33 | FromDiscord | <JJ> blurgh |
04:16:07 | FromDiscord | <JJ> beef, to clarify, how would `'a b'` work inside a template? (with single quotes as backticks) |
04:16:37 | FromDiscord | <Elegantbeef> the same it works everywhere `a` and `b` are different identfiers, if either are a template paramter it's pasted there |
04:17:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6a |
04:17:37 | FromDiscord | <JJ> ah okay i found the manual section |
04:17:38 | FromDiscord | <JJ> ty |
04:18:42 | FromDiscord | <michaelb.eth> sent a long message, see http://ix.io/4w6b |
04:19:24 | FromDiscord | <michaelb.eth> (edit) "http://ix.io/4w6b" => "http://ix.io/4w6c" |
04:22:18 | FromDiscord | <michaelb.eth> Seems to me Nim could be called a functional language in the same sense that a kangaroo is a horse if you hung a sign around its neck with the word "horse" written on it. 🤪 |
04:22:36 | FromDiscord | <michaelb.eth> (edit) "is" => "could be called" |
04:22:56 | FromDiscord | <Elegantbeef> You hang the sign and hope no one knows anything about biology |
04:46:23 | FromDiscord | <michaelb.eth> hmm, no Nim example-code for HOFs in wikipedia: https://en.wikipedia.org/wiki/Higher-order_function |
04:49:27 | FromDiscord | <Elegantbeef> Hood no one should use sequtils 😛 |
04:49:29 | FromDiscord | <Elegantbeef> Good even |
04:50:29 | FromDiscord | <michaelb.eth> perf bomb? |
04:50:54 | FromDiscord | <Elegantbeef> Since they return a sequence and are not lazily evaluated each call allocates a sequence so chaining is bad |
04:50:55 | FromDiscord | <Elegantbeef> Really bad |
04:52:22 | FromDiscord | <Elegantbeef> There is a slightly hacky PR in devel that I made that allows chaining of iterators with 0 cost |
04:53:27 | FromDiscord | <michaelb.eth> Ah, right. For procs with small inputs (and I mean written with expectation that inputs are always small), seems like sequtils should be okay for the convenience, no? |
04:53:55 | FromDiscord | <Elegantbeef> Sure if you're not anally retentive it's fine |
04:56:12 | FromDiscord | <Elegantbeef> https://github.com/beef331/slicerator/blob/itermacros/tests/titermacros.nim#L25 for instance |
04:56:29 | FromDiscord | <Elegantbeef> This is the same as the manually written loop mostly |
04:56:55 | * | lucasta quit (Quit: Leaving) |
04:57:30 | FromDiscord | <michaelb.eth> In reply to @Elegantbeef "There is a slightly": nice! |
05:01:31 | FromDiscord | <Elegantbeef> If interested this is the closest Nim has had to good pluggable iterator operations https://github.com/beef331/slicerator/blob/itermacros/src/itermacros.nim |
05:01:35 | FromDiscord | <Elegantbeef> Simple macro but easy to use code |
05:04:12 | FromDiscord | <michaelb.eth> thanks for link, definitely interested |
05:05:55 | FromDiscord | <voidwalker> what is the difference vs https://github.com/zero-functional/zero-functional ? |
05:06:32 | FromDiscord | <Elegantbeef> It doesnt use an abhorrent syntax |
05:08:05 | FromDiscord | <Elegantbeef> It also doesnt use macros outside from the defining operations |
05:08:12 | FromDiscord | <Elegantbeef> And that macro is practically just a thunk generator |
05:09:25 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6h |
05:09:30 | FromDiscord | <voidwalker> btw is it possible to access/cast a single byte from an multi byte integer without using copymem ? |
05:09:44 | FromDiscord | <Elegantbeef> It's possible but aliasing is fun |
05:10:08 | FromDiscord | <Elegantbeef> Generally it's suggest to use bitwise operators for what you're doing |
05:10:43 | FromDiscord | <michaelb.eth> isn't there something in nim-stew that helps with that |
05:11:02 | FromDiscord | <michaelb.eth> I might be thinking of something else... |
05:11:02 | FromDiscord | <Elegantbeef> No clue |
05:11:04 | FromDiscord | <voidwalker> I was trying to see if I can beat the countBits64 operation speed in nim by using a const count table for each individual byte |
05:11:34 | FromDiscord | <voidwalker> I got about 7% or so faster using copymem in individual vars |
05:13:10 | FromDiscord | <Elegantbeef> It's a single line to extract a byte from an int, so you'll love it void! |
05:13:14 | FromDiscord | <voidwalker> but I don't think it can be made faster than that, casting an individual byte still has to be copies somewhere |
05:13:27 | FromDiscord | <voidwalker> (edit) "copies" => "copied" |
05:13:32 | FromDiscord | <Elegantbeef> You're likely copying anway |
05:13:35 | FromDiscord | <Elegantbeef> anyway |
05:29:00 | FromDiscord | <voidwalker> any ways to check if a variable is on the stack or heap ? |
05:35:38 | FromDiscord | <Rika> If it’s not within a ref it’s on the stack |
05:35:52 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4w6k |
05:36:25 | FromDiscord | <Rika> upload[T: not seq](... ↵For the first one |
05:36:33 | FromDiscord | <voidwalker> https://github.com/bpr/vla/blob/master/src/vla.nim this uses alloca which is supposed to be on the stack, I just wanted to make sure |
05:36:40 | FromDiscord | <sOkam!> ty rika |
05:37:09 | FromDiscord | <voidwalker> T: not seq ? nice |
05:37:23 | FromDiscord | <Elegantbeef> I'm scared you're writing an upload proc sokam 😄 |
05:38:06 | FromDiscord | <Elegantbeef> That's what I called my proc that handles the conversion of a ui to it's destination |
05:38:50 | FromDiscord | <sOkam!> its referring to `upload this data buffer to the GPU vram` |
05:40:26 | FromDiscord | <Elegantbeef> Flashbacks to fighting generics |
05:40:45 | FromDiscord | <sOkam!> tru. they were so unintuitive to learn 😄 |
05:40:59 | FromDiscord | <Elegantbeef> I mean it's not even to learn |
05:41:11 | FromDiscord | <Elegantbeef> Just today i was fighting Nim's generic resolution |
05:41:26 | FromDiscord | <Elegantbeef> Since all my code is generic it really was a battle to make it work |
05:41:39 | FromDiscord | <sOkam!> ah yeah, makes senses |
05:46:53 | Amun-Ra | voidwalker: yes, alloca allocates bytes in the stack frame |
05:55:59 | * | rockcavera quit (Remote host closed the connection) |
06:24:01 | * | fallback quit (Ping timeout: 240 seconds) |
06:24:29 | FromDiscord | <Dudugz> ``Error: 'args' is of type <varargs[string]> which cannot be captured as it would violate memory safety``↵trying to use ``varargs[string, `$`]`` but i think i can't with threads:on |
06:28:06 | FromDiscord | <Elegantbeef> That's not the reason |
06:28:21 | FromDiscord | <Elegantbeef> You're trying to use varargs with a closure |
06:31:10 | * | Jjp137 quit (Ping timeout: 250 seconds) |
06:33:41 | * | Jjp137 joined #nim |
06:34:33 | FromDiscord | <Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4w6r |
06:34:45 | FromDiscord | <Elegantbeef> How are you using foo? |
06:34:52 | FromDiscord | <Dudugz> calling it directly? |
06:34:58 | FromDiscord | <Dudugz> foo(1, false, "blah") |
06:35:15 | FromDiscord | <Elegantbeef> Is foo inside a `async` proc? |
06:35:22 | FromDiscord | <Dudugz> yup |
06:35:29 | FromDiscord | <Dudugz> is this a issue? |
06:35:35 | FromDiscord | <Elegantbeef> Yep |
06:35:38 | FromDiscord | <Dudugz> ;-; |
06:36:05 | FromDiscord | <Elegantbeef> Async procs are closures |
06:36:19 | FromDiscord | <Elegantbeef> `varargs` cannot exist inside a closure cause it can point to memory that is freed |
06:36:27 | FromDiscord | <Dudugz> hm |
06:36:35 | FromDiscord | <Dudugz> well the way then is to use seq[string] |
06:40:35 | FromDiscord | <Ras> how much overhead does a cast usually incur? Should I worry about very heavily casting a `string` to `seq[uint8]` and vice versa? |
06:40:48 | FromDiscord | <Elegantbeef> Cast has 0 cost |
06:40:54 | FromDiscord | <Ras> excellent, thank you |
06:40:54 | FromDiscord | <Elegantbeef> But you shouldnt cast between types like that |
06:40:58 | FromDiscord | <Ras> oh |
06:41:37 | FromDiscord | <Ras> why not? |
06:41:42 | FromDiscord | <Elegantbeef> there is a `toOpenArrayByte` for string, so write a proc that takes a `openArray[uint8]` |
06:41:52 | FromDiscord | <Elegantbeef> Aimlessly casting around is not how a type system works |
06:42:03 | FromDiscord | <Elegantbeef> Cast is a bitwise cast and is the wrong way around 99% of issues |
06:42:20 | FromDiscord | <Ras> well, it's pretty deliberate :D but i see what you mean |
06:42:26 | FromDiscord | <Ras> thanks for the openArray hint |
06:42:53 | FromDiscord | <Elegantbeef> Unless you need to mutate the size always prefer `openArray` |
06:43:01 | FromDiscord | <Elegantbeef> It's what other languages call a slice |
06:43:20 | FromDiscord | <Ras> super, thanks |
06:48:46 | FromDiscord | <JJ> finished the adt portion of the rfc [@Elegantbeef](https://matrix.to/#/%40elegantbeef%3Amatrix.org) |
06:48:47 | FromDiscord | <JJ> nim-adts.md https://media.discordapp.net/attachments/371759389889003532/1108647352237035530/nim-adts.md |
06:48:58 | FromDiscord | <JJ> now it's on to `match` |
06:58:12 | FromDiscord | <Elegantbeef> Already lost me quit calling them enums! 😛 |
07:00:45 | FromDiscord | <Elegantbeef> `shape = Point()` should be how it's done |
07:01:00 | FromDiscord | <Elegantbeef> `shape = Point` should be invalid cause `Point` should be a type |
07:01:19 | FromDiscord | <JJ> haha, don't worry i went with `union` |
07:01:25 | FromDiscord | <JJ> good idea |
07:01:45 | FromDiscord | <Elegantbeef> I also do not think types should be comma seperated |
07:02:18 | FromDiscord | <JJ> for the `Empty, Error, Unit...` line? |
07:02:24 | FromDiscord | <Elegantbeef> Also `Function: tuple[from, to: Type]` cannot compile |
07:02:24 | FromDiscord | <Elegantbeef> Yea |
07:02:58 | FromDiscord | <JJ> what's wrong with `Function` |
07:03:10 | FromDiscord | <Elegantbeef> A type contains a type that is not indirected |
07:03:48 | FromDiscord | <JJ> oh yea right |
07:04:21 | FromDiscord | <Elegantbeef> Actually I dont know about `A, B, C` |
07:04:31 | FromDiscord | <Elegantbeef> Just that it invites `A, B, C: tuple[x, y: int]` |
07:05:00 | FromDiscord | <JJ> hmm, `ref union` wouldn't be great here |
07:05:14 | FromDiscord | <Elegantbeef> You only need the ref on the interal no? |
07:05:17 | FromDiscord | <Elegantbeef> internal\ |
07:05:40 | FromDiscord | <JJ> yeah, i'm unsure of how to represent it syntactically |
07:05:41 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6u |
07:05:52 | FromDiscord | <JJ> is `to: ref Type` consistent? |
07:06:04 | FromDiscord | <Elegantbeef> `ref union` is fine imo |
07:06:17 | FromDiscord | <Elegantbeef> Did you even look at my examples?! |
07:07:04 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6v |
07:07:42 | FromDiscord | <Elegantbeef> One thing you do not mention is that each entry of the union emits a type |
07:07:42 | FromDiscord | <JJ> in fungus? or did i miss them earlier oh no |
07:07:48 | * | Notxor joined #nim |
07:07:50 | FromDiscord | <Elegantbeef> Yes in fungus |
07:08:04 | FromDiscord | <Elegantbeef> In nim you can put `ref` before anything and it creates a ref of that type |
07:08:15 | FromDiscord | <Elegantbeef> It's that simple |
07:08:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6w |
07:08:48 | FromDiscord | <JJ> how did i not know this?? |
07:09:14 | FromDiscord | <JJ> for some reason i thought there was a deliberate design decision to only allow it as a distinction between objects and ref objects |
07:09:17 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6x |
07:09:22 | FromDiscord | <Elegantbeef> Nope |
07:09:35 | FromDiscord | <Elegantbeef> It'd be consistent to allow `ref union` in the type def |
07:10:36 | FromDiscord | <Elegantbeef> You also do not mention that a tupleless Union branch is implicitly converted to the base type |
07:10:40 | FromDiscord | <JJ> also re: fungus i'll be looking at it and patty closely (and rust match) for `match` but do you know of others to check out |
07:10:49 | FromDiscord | <Elegantbeef> But this is really just fungus |
07:11:03 | FromDiscord | <Elegantbeef> Eh patty emits a object variant |
07:11:12 | FromDiscord | <Elegantbeef> Probably biased, but it doesnt help that much |
07:11:49 | FromDiscord | <Elegantbeef> You're basically suggesting bringing fungus to Nim, so study its semantics 😄 |
07:12:09 | FromDiscord | <JJ> haha, the closer i look, the more that's true |
07:12:10 | FromDiscord | <Elegantbeef> `--expandMacro:adtEnum` |
07:13:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6y |
07:13:53 | FromDiscord | <Elegantbeef> The only thing fungus is probably really lacking is pattern matching |
07:13:58 | FromDiscord | <Elegantbeef> That and the object construction |
07:14:08 | Amun-Ra | are const objects passed to functions as pointers? |
07:15:06 | FromDiscord | <JJ> hmm i've got some stuff i could rewrite in fungus to get a feel for it |
07:15:11 | FromDiscord | <Elegantbeef> I think they might be, hard to say |
07:15:20 | * | azimut quit (Ping timeout: 240 seconds) |
07:15:37 | FromDiscord | <Elegantbeef> Well looking at my examples compiled with `--expandMacros:adtEnum` would help you understand what it does |
07:16:45 | FromDiscord | <JJ> oh also re: commas and newlines for `union`s, the idea was that because they're a blend of object and enum semantics they should have a blend of object and enum syntax |
07:17:15 | FromDiscord | <JJ> or functionally something like the Type example is bound to come up a lot |
07:17:30 | FromDiscord | <JJ> perhaps it'd be better to stick with only commas though |
07:20:21 | FromDiscord | <Elegantbeef> Well it does invite `A, B: T` |
07:20:29 | FromDiscord | <Elegantbeef> I guess that's fine |
07:20:50 | FromDiscord | <Elegantbeef> Commas are probably fine there |
07:20:57 | FromDiscord | <JJ> yeah, that's a bit misleading |
07:21:28 | FromDiscord | <Elegantbeef> Well I do not think it's that misleading |
07:21:36 | FromDiscord | <Elegantbeef> A and B would be type T just distinct variations of the same branch |
07:22:03 | Amun-Ra | I guess large objects that do not fit in a few registers are passed inside as pointers, https://play.nim-lang.org/#ix=4w6z |
07:22:31 | FromDiscord | <Elegantbeef> Easier to look at the C compiled with `--mm:arc -d:danger` 😛 |
07:22:41 | Amun-Ra | right :) |
07:23:00 | FromDiscord | <Elegantbeef> In Nim that object would be passed by ref eitherway |
07:23:15 | FromDiscord | <Elegantbeef> Anything larger than 24bytes is passed by ref as far as i know |
07:23:43 | * | junaid_ joined #nim |
07:23:56 | FromDiscord | <Elegantbeef> Hence `{.byref.}` and `{.bycopy.}` existing for interop |
07:24:09 | FromDiscord | <JJ> with union construction, i'm unsure how viable it is without polluting the global namespace |
07:24:15 | FromDiscord | <JJ> that is probably a problem for later though |
07:24:27 | FromDiscord | <Elegantbeef> This is Nim there is no polluting global namespace |
07:24:30 | Amun-Ra | hmm |
07:24:53 | FromDiscord | <JJ> that's actually so true you're right |
07:25:22 | FromDiscord | <Elegantbeef> Each union branch is a type |
07:25:22 | FromDiscord | <JJ> oh, no, i guess it still is a problem if these are used similarly to overloadable enums |
07:25:31 | FromDiscord | <Elegantbeef> No it's not |
07:25:34 | FromDiscord | <Elegantbeef> I already gave you the solution earlier |
07:25:45 | FromDiscord | <Elegantbeef> Scroll up to my three `doThing`s |
07:26:26 | FromDiscord | <Elegantbeef> In the case of ambiguity you can disambiguate with the Union's type |
07:26:36 | FromDiscord | <Elegantbeef> Otherwise you can disambiguate with the module |
07:26:51 | FromDiscord | <Elegantbeef> Since a union like this is nothing more than a set of types |
07:27:13 | FromDiscord | <JJ> dur yeah |
07:27:15 | FromDiscord | <JJ> i need slep |
07:27:22 | FromDiscord | <Elegantbeef> And to read my messages |
07:27:24 | FromDiscord | <JJ> (edit) "slep" => "sleep" |
07:27:33 | FromDiscord | <JJ> rofl yeah |
07:28:28 | FromDiscord | <JJ> well tomorrow i will read through swift and haxe's pattern matching, make sure i'm not missing anything about rust's and racket's, and closely inspect your fungus |
07:28:43 | FromDiscord | <Elegantbeef> Get really in there it's stuck on the big toe |
07:30:51 | * | nanxiao joined #nim |
07:32:14 | * | Notxor quit (Remote host closed the connection) |
07:39:31 | FromDiscord | <Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4w6C |
07:40:05 | FromDiscord | <huantian> no i don't think so? |
07:40:17 | FromDiscord | <Dudugz> :/ |
07:40:37 | FromDiscord | <Elegantbeef> Just write your own `get` that is a generic |
07:41:01 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6E |
07:41:04 | FromDiscord | <Elegantbeef> Put an `=` in there |
07:41:26 | FromDiscord | <Dudugz> I tried but got error saying getInt(node, 0) is of type int and expected string, in case compilation error. |
07:43:03 | FromDiscord | <Dudugz> sent a code paste, see https://play.nim-lang.org/#ix=4w6F |
07:43:12 | FromDiscord | <huantian> `when` not `if` |
07:43:22 | FromDiscord | <Dudugz> Oh :> |
07:44:49 | FromDiscord | <huantian> If you don’t like the colon generic syntax you can have it take a typedec[T] |
07:46:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w6G |
07:46:24 | FromDiscord | <Elegantbeef> We did it! |
07:46:56 | FromDiscord | <huantian> Honestly I don’t know if I like get, I feel like as makes more sense |
07:47:05 | FromDiscord | <huantian> But that’s irrelevant |
07:47:09 | FromDiscord | <Elegantbeef> Yea it does |
07:47:13 | FromDiscord | <Elegantbeef> it's also cooler |
07:47:24 | FromDiscord | <Dudugz> Hm |
07:47:25 | FromDiscord | <Elegantbeef> `name = bleh["name" as string` chef kiss |
07:47:52 | FromDiscord | <Dudugz> Agreed :v |
07:48:00 | FromDiscord | <Elegantbeef> Well implement it |
07:49:03 | FromDiscord | <Elegantbeef> I'd say implement `as` and `to` or similar so you can chain |
07:49:34 | FromDiscord | <Elegantbeef> `(bleh[..] as int).other()` is worse than `bleh[..].to(int).other()` |
07:50:59 | FromDiscord | <Dudugz> Hm yea, but you can bleh[..].as(int).other() |
07:51:06 | FromDiscord | <Dudugz> It's just not idiomatic i think |
07:51:34 | FromDiscord | <Dudugz> (edit) "bleh[..].as(int).other()" => "``bleh[..].as(int).other()``" |
07:53:09 | * | Notxor joined #nim |
07:55:10 | * | Notxor quit (Remote host closed the connection) |
07:59:12 | FromDiscord | <Dudugz> :3 https://media.discordapp.net/attachments/371759389889003532/1108665074727534614/image.png |
07:59:17 | FromDiscord | <Dudugz> so much better |
08:07:12 | * | Notxor joined #nim |
08:18:45 | * | junaid_ quit (Remote host closed the connection) |
08:27:38 | * | nanxiao quit (Quit: Client closed) |
08:56:31 | * | jmdaemon quit (Ping timeout: 240 seconds) |
09:17:31 | FromDiscord | <sOkam!> what effect does `-d:useRealtimeGC` have on `arc/orc`? |
09:17:48 | FromDiscord | <sOkam!> does it do anything, or is it for the older gcs only? |
09:19:30 | FromDiscord | <Rika> I believe there is no effect for ARC |
09:20:18 | FromDiscord | <sOkam!> ic |
09:20:28 | FromDiscord | <sOkam!> does it affect orc, though? |
09:26:34 | FromDiscord | <Bung> am looking at chronos, when I use devel it doesn't need import posix, but when I switched to 1.6.0 it error about undeclared `sigprocmask` as it's defined in posix. |
09:27:49 | FromDiscord | <Bung> why this happen? |
09:32:18 | FromDiscord | <voidwalker> Any way to get the inner representation of whatever data a typeclass holds ? |
09:33:56 | FromDiscord | <sOkam!> @voidwalker you mean something like : https://nim-lang.org/docs/typetraits.html ? |
09:36:14 | FromDiscord | <voidwalker> I don't know, do I ? What can I use from there to see how a typeclass I define is actually.. represented in nim |
09:36:34 | FromDiscord | <voidwalker> Asking cause I don't really understand them, I'd like to get an idea |
09:37:03 | FromDiscord | <Rika> i dont understand, typeclass means typedef? |
09:37:06 | FromDiscord | <Rika> (edit) "typedef?" => "typedesc?" |
09:38:59 | FromDiscord | <voidwalker> I don't suppose there's a typeclass to string proc, so I guess something that outputs.. its ast node structure ? idk |
09:39:44 | FromDiscord | <sOkam!> by typeclass you mean `typedesc`? |
09:40:09 | FromDiscord | <Rika> typeclass is not a word commonly used in nim so i ask you, what you mean by that |
09:40:12 | FromDiscord | <Rika> (edit) "typeclass is not a word commonly used in nim so i ask you, what ... you" added "do" |
09:41:22 | FromDiscord | <voidwalker> `A type class is a special pseudo-type that can be used to match against types in the context of overload resolution or the is operator. Nim supports the following built-in type classes:` |
09:42:58 | FromDiscord | <Rika> OH those okay |
09:43:14 | FromDiscord | <Rika> but youre using it incorrectly |
09:43:50 | FromDiscord | <Rika> i mean, you use the word incorrectly |
09:44:09 | FromDiscord | <sOkam!> i think the word for it would be typedesc, since all "super types" match with the base typedesc if using `is` etc |
09:44:12 | FromDiscord | <Rika> typeclasses cannot be represented in nim because theyre not real types |
09:44:29 | FromDiscord | <Rika> it says in the text you sent that theyre "pseudo-types" |
09:44:56 | FromDiscord | <demotomohiro> In reply to @voidwalker "Any way to get": You probably need to read Nim source code if you want to know how type classes represented in Nim compiler at compile time. |
09:45:16 | FromDiscord | <sOkam!> in any case, `std/typetraits` is probably what you need, unless some functionality is not there |
09:47:09 | FromDiscord | <voidwalker> I just want a high quality introduction to generics and all the relevant stuff around them. |
09:48:22 | FromDiscord | <voidwalker> So I actually understand what happens instead of trying out various code until it compiles, and then until it works : P |
09:49:25 | FromDiscord | <sOkam!> maybe printing the ast of the type could be useful in that case |
09:49:35 | FromDiscord | <voidwalker> ok, how do you do that |
09:49:39 | FromDiscord | <sOkam!> there is functionality for that in `std/macros` |
09:49:42 | FromDiscord | <jmgomez> you can see typeclasses as constraints to generics |
09:50:59 | FromDiscord | <sOkam!> In reply to @voidwalker "ok, how do you": probably a start. but there might be something in there more useful. don't know the topic beyond this function https://nim-lang.org/docs/macros.html#dumpAstGen.m%2Cuntyped |
09:52:33 | FromDiscord | <jmgomez> TBH I dont see how that's gonna help you understand typeclasses |
09:53:32 | FromDiscord | <Rika> i dont even understand what you need help with |
09:56:45 | * | ttkap quit (Ping timeout: 246 seconds) |
09:59:08 | FromDiscord | <voidwalker> I guess I forgot to read this: https://ssalewski.de/nimprogramming.html#_generics |
10:08:46 | * | derpydoo quit (Read error: Connection reset by peer) |
10:08:56 | FromDiscord | <sOkam!> oh i didn't know about that tutorial. yeah, thats pretty much all there is to them on a practical level↵added to bookmarks, to be able to reference it. didn't know it exists, but that's a good one |
10:25:45 | om3ga | Amun-Ra: under MacOs all is the same: https://i.imgur.com/FFZxBHT.png |
10:26:33 | om3ga | Or maybe I misunderstand something, but should the total number of bytes be the same as residual ram? |
10:28:28 | FromDiscord | <Rika> heap usage isnt all usage |
10:28:38 | FromDiscord | <Rika> there's still stack and code no? |
10:28:53 | FromDiscord | <Rika> let me see what residual really means because i forgot |
10:29:11 | om3ga | I put the sleep there, to see leftovers |
10:29:45 | om3ga | Rika: residual means the amount of ram actually used by process |
10:30:00 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4w75 |
10:30:49 | FromDiscord | <Rika> residual -> resident i can read i swear |
10:31:07 | om3ga | :) |
10:31:53 | om3ga | for some reason playground not opening here |
10:32:56 | om3ga | Error code 504 |
10:33:00 | FromDiscord | <Rika> sent a code paste, see https://paste.rs/Svqci |
10:33:03 | FromDiscord | <Rika> but it includes stack |
10:34:13 | om3ga | yeah, but max stack size as I remember is 100meg |
10:34:17 | om3ga | not the 1.8GB |
10:34:38 | FromDiscord | <Rika> ah i think i remember |
10:34:47 | FromDiscord | <Rika> nim gc frees memory as in marks it as free |
10:34:51 | FromDiscord | <Rika> but does not return it to the os |
10:34:59 | FromDiscord | <Rika> not until program execution finishes |
10:35:32 | FromDiscord | <Rika> i think if the os is feeling memory pressure then nim does free it back to the os but i dont actually know if thats true |
10:35:42 | om3ga | that's really what I want to avoid |
10:36:11 | om3ga | I use malloc, so it's not about how nim's alloc works |
10:36:43 | om3ga | looks loke memory manager holds that allocations |
10:36:45 | om3ga | *like |
10:37:35 | om3ga | memory manager -> GC |
10:38:32 | om3ga | Is there any function that can force gc to free all that allocs? |
10:39:11 | om3ga | I tried to find by myself, but failed to do so |
10:39:18 | * | Notxor quit (Read error: Connection reset by peer) |
10:40:23 | * | Notxor joined #nim |
10:41:45 | om3ga | `=destroy`() frees, but at termination step the program segfaults |
10:57:11 | * | Notxor quit (Ping timeout: 240 seconds) |
11:33:53 | * | fredrikhr joined #nim |
11:42:37 | Amun-Ra | om3ga: what was the value of shared memory? RES includes SHR |
11:58:15 | * | xet7 joined #nim |
12:36:47 | NimEventer | New post on r/nim by Uwu_Uwu135: How to detect and even save key presses, see https://reddit.com/r/nim/comments/13kxxxo/how_to_detect_and_even_save_key_presses/ |
13:12:38 | FromDiscord | <Bung> any clue https://github.com/bung87/scorper/blob/devel/tests/trouter.nim get stucked at last case with `gc:arc` and `gc:orc` |
13:36:06 | * | progranner joined #nim |
13:45:21 | * | fredrik92 joined #nim |
13:46:32 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
13:48:51 | * | fredrikhr quit (Ping timeout: 268 seconds) |
13:54:18 | * | progranner joined #nim |
14:03:26 | * | rockcavera joined #nim |
14:27:35 | * | junaid_ joined #nim |
14:35:12 | * | Notxor joined #nim |
14:36:39 | arkanoid | I've just glanced into the world of hardware design, and I find potential for nim in there |
14:50:07 | FromDiscord | <@theperfectcomputer-628303036da0> Some time ago - I started writing an HDL in Nim as a DSL' |
14:50:07 | FromDiscord | <@theperfectcomputer-628303036da0> That was two years ago |
14:51:46 | FromDiscord | <@theperfectcomputer-628303036da0> Anyways, I seem to vaguely remember being able to collect values into a Seq in NIm inside a block |
14:55:23 | * | fallback joined #nim |
14:55:43 | FromDiscord | <typist🎯> nim defaults to c as the backend and typically adds GC, I like python so I'm comfortable with nim's syntax, meanwhile I need an "easier" C for bare metal, question is, is nim a good fit? I'm comparing nim with zig now, zig seems more close to the hardware, it's really a 'better' C for embedded systems and such. is nim for general c coding that size is not a big concern? both seems better than C but nim seems "larger" to me |
15:01:26 | FromDiscord | <Chronos [She/Her]> In reply to @typist🎯 "nim defaults to c": For memory management, there is `arc`? |
15:02:03 | FromDiscord | <Chronos [She/Her]> Alternative memory management system, not a GC, it basically inserts destructor calls on an object when it's no longer being used (from what I understand) |
15:02:15 | FromDiscord | <Chronos [She/Her]> I haven't used Zig so I can't comment on that really |
15:02:30 | FromDiscord | <Rika> In reply to @typist🎯 "nim defaults to c": wdym by size? |
15:02:51 | FromDiscord | <Rika> also nim is embedded capable yes, relatively well suitd |
15:02:51 | FromDiscord | <@theperfectcomputer-628303036da0> Am I hallucinating? |
15:02:52 | FromDiscord | <Rika> (edit) "suitd" => "suited" |
15:03:06 | FromDiscord | <Rika> In reply to @@theperfectcomputer-628303036da0 "Am I hallucinating?": no, sugar.collect? |
15:05:03 | FromDiscord | <@theperfectcomputer-628303036da0> yeah - that's it |
15:05:04 | FromDiscord | <@theperfectcomputer-628303036da0> thx |
15:08:25 | * | junaid_ quit (Remote host closed the connection) |
15:11:12 | * | junaid_ joined #nim |
15:21:03 | FromDiscord | <demotomohiro> In reply to @typist🎯 "nim defaults to c": There is #embedded channel for embedded/bare metal programming. |
15:53:33 | * | fredrik92 quit (Quit: Disconnecting) |
15:55:06 | * | junaid_ quit (Remote host closed the connection) |
16:28:25 | FromDiscord | <@theperfectcomputer-628303036da0> I'd consider the following behavior in Nim surprising... |
16:28:29 | FromDiscord | <@theperfectcomputer-628303036da0> sent a long message, see http://ix.io/4w8u |
16:29:07 | FromDiscord | <@theperfectcomputer-628303036da0> oh |
16:29:07 | FromDiscord | <@theperfectcomputer-628303036da0> https://nim-lang.org/docs/strformat.html#nimfmt-vsdot-nimamp |
16:29:11 | FromDiscord | <@theperfectcomputer-628303036da0> mentioned right here |
16:29:38 | FromDiscord | <@theperfectcomputer-628303036da0> It'd make more sense if there was a `fmt` and `rfmt` |
16:30:50 | FromDiscord | <Rika> `fmt` is like that because it uses an alphanumeric name |
16:31:07 | FromDiscord | <Rika> changing it to `fmt`/`rfmt` would have the same problem |
16:31:13 | FromDiscord | <Rika> it is simply how nim was designed |
16:31:23 | FromDiscord | <Rika> if you want a hack, you can add a space and itll work normally |
16:31:29 | FromDiscord | <Rika> `fmt "xxx \n"` |
16:31:42 | FromDiscord | <@theperfectcomputer-628303036da0> ... |
16:32:29 | FromDiscord | <@theperfectcomputer-628303036da0> I'm starting to remember why I left for Haskell |
16:33:21 | FromDiscord | <@theperfectcomputer-628303036da0> but I guess for this particular project - I needed executables that were only KB in size |
16:33:37 | FromDiscord | <@theperfectcomputer-628303036da0> So Nim,C, or Zig were the only choices |
16:34:16 | * | jmdaemon joined #nim |
16:34:25 | FromDiscord | <Rika> i feel you'd be especially peeved by zig due to its design decisions |
16:36:01 | FromDiscord | <@theperfectcomputer-628303036da0> yeah - prolly |
16:42:30 | FromDiscord | <Nerve> `echo &"hello \n"` should do what you expect |
16:44:25 | FromDiscord | <Rika> yes it was implied |
16:49:55 | om3ga | Amun-Ra: shared was not used there |
16:50:46 | om3ga | Amun-Ra: all the data should be in heap, it's ref type objects mostly and seq[char] |
16:51:09 | om3ga | seq[seq[char] also |
16:51:17 | * | azimut joined #nim |
17:07:27 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
17:14:58 | * | progranner joined #nim |
17:19:50 | * | progranner quit (Client Quit) |
17:20:17 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
17:22:37 | * | jmdaemon joined #nim |
17:24:48 | FromDiscord | <jmgomez> In reply to @Nerve "`echo &"hello \n"` should": Better switching to Haskell 😛 |
17:36:20 | * | Notxor quit (Remote host closed the connection) |
17:59:29 | * | progranner joined #nim |
17:59:43 | * | progranner quit (Client Quit) |
18:04:33 | * | progranner joined #nim |
18:07:37 | NimEventer | New post on r/nim by crevicepounder3000: How to write JsonNode to a json file?, see https://reddit.com/r/nim/comments/13l65ge/how_to_write_jsonnode_to_a_json_file/ |
18:09:47 | * | lucasta joined #nim |
18:10:12 | * | pharonix71 quit (Remote host closed the connection) |
18:10:41 | * | pharonix71 joined #nim |
18:31:17 | FromDiscord | <JJ> In reply to @typist🎯 "nim defaults to c": re: embedded, the usual recommended library is https://github.com/PMunch/ratel |
18:36:15 | FromDiscord | <JJ> nim is larger than zig or c: some objects that the compiler cannot infer the lifetimes of will be reference counted, so an extra byte attached to an object and an extra few cycles every time it is referenced. but these often are elided, and in exchange you have memory safety |
18:37:17 | FromDiscord | <JJ> and you can always turn off arc and manually manage pointers c-style though it's not recommended unless you're byte-golfing (and even then) |
18:37:27 | om3ga | executables are kilobytes in size only when not compiled statically |
18:39:02 | om3ga | when compiler includes all used functions in executable file, with all the code of used functions the exe can be hundreds of kilobytes or even megabytes |
18:40:43 | FromDiscord | <JJ> oh, the stdlib can also be large - i know you can compile without it but i'm unsure why that's an option if the compiler only compiles in functions it needs |
18:46:15 | om3ga | it definitely includes not the whole libc in it |
18:46:45 | om3ga | but it depends on what used in the code, some std functions use a lot other stuff inside |
18:47:38 | om3ga | also there are some functions that cannot be compiled statically, for example getline() in C |
18:48:21 | om3ga | for that reason I coded my own getline |
18:57:30 | FromDiscord | <System64 ~ Flandre Scarlet> Did someone already created a context menu on ImGUI with Nim?↵If yes, how?↵Thanks for your answer |
19:00:23 | * | Notxor joined #nim |
19:20:47 | * | jmdaemon quit (Ping timeout: 240 seconds) |
19:31:04 | * | rockcavera quit (Remote host closed the connection) |
19:33:14 | * | rockcavera joined #nim |
20:05:22 | FromDiscord | <Gumbercules> In reply to @System64 "Did someone already created": it shouldn't be any different than how you'd do it in C |
20:05:23 | FromDiscord | <demotomohiro> In reply to @System64 "Did someone already created": Doesn't imgui have any documentation about how do it?↵https://github.com/ocornut/imgui |
20:05:41 | FromDiscord | <Gumbercules> it's probably going to be easier to find an example of whatever you're trying to do, written in C/C++, and then port that to Nim |
20:06:03 | FromDiscord | <Gumbercules> this goes for all computer graphics related stuff, if you don't feel like digging into documentation / manuals |
20:16:42 | * | lucasta quit (Remote host closed the connection) |
20:20:18 | NimEventer | New thread by jojocoding: Get cursor position in terminal, see https://forum.nim-lang.org/t/10204 |
20:36:16 | FromDiscord | <System64 ~ Flandre Scarlet> In reply to @demotomohiro "Doesn't imgui have any": I found out why it didn't work, I missused it |
21:02:52 | * | jmdaemon joined #nim |
21:29:26 | NimEventer | New Nimble package! nmostr - Library for Nostr: a simple, open protocol enabling censorship-resistant social media., see https://github.com/Gruruya/nmostr |
22:27:37 | * | lucasta joined #nim |
22:30:51 | FromDiscord | <wick3dr0se> Is there a way to unset an array? Would be nice if there was an unset proc for vars/arrays |
22:31:17 | FromDiscord | <Elegantbeef> You mean `reset`? |
22:31:17 | FromDiscord | <Elegantbeef> "unset" |
22:31:18 | FromDiscord | <Elegantbeef> That works on all datatypes |
22:31:28 | FromDiscord | <wick3dr0se> Well empty the array |
22:31:47 | FromDiscord | <Elegantbeef> Arrays can never be empty |
22:31:53 | FromDiscord | <Elegantbeef> They're static size |
22:32:08 | FromDiscord | <wick3dr0se> What if I empty each value? |
22:32:24 | FromDiscord | <Elegantbeef> What do you mean by empty? |
22:32:31 | FromDiscord | <Elegantbeef> If you mean to zero that's what `reset` is for |
22:32:58 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4w9B |
22:33:48 | FromDiscord | <wick3dr0se> Well to unset a string i've been using strVar = "", so I was thinking I could just do the same, a space would work in my case but I can work with 0's |
22:34:02 | FromDiscord | <Elegantbeef> `reset myString` |
22:34:10 | FromDiscord | <wick3dr0se> Ty |
22:34:15 | FromDiscord | <Elegantbeef> `reset` 'unset's values |
22:34:40 | FromDiscord | <Elegantbeef> But remember that `= ""` deallocates the previous string |
22:34:43 | FromDiscord | <Elegantbeef> Same with `reset` |
22:35:39 | FromDiscord | <wick3dr0se> It's the only way I could find to nil the variable. Reset would be easier though |
22:36:16 | FromDiscord | <Elegantbeef> `setLen` allows you to reuse memory if you're of that dispostion |
22:37:47 | FromDiscord | <wick3dr0se> It's just for a TUI file manager. It's pretty basic but I have to clear the files array each time I change directories. I tried overwriting the values but it didn't seem to work |
22:40:01 | FromDiscord | <wick3dr0se> `reset` says it's immutable even though it's defined as var. Maybe it's due to using `seq` |
22:41:02 | FromDiscord | <Elegantbeef> How are you using it? |
22:42:48 | FromDiscord | <BoomBang> I have a large problem |
22:46:15 | FromDiscord | <wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4w9C |
22:46:46 | FromDiscord | <Elegantbeef> It'd set it to `@[]` every time you call `getFIles` |
22:47:17 | FromDiscord | <Elegantbeef> There is no reason to do `@[]` as it's a local variable |
22:47:38 | FromDiscord | <Elegantbeef> `var files: seq[string]` is the same and it will get cleared everytime it `getFiles` is called since it's a local variable |
22:47:59 | FromDiscord | <wick3dr0se> Well the files var is also returned from that proc and is passed to two other procs |
22:50:29 | FromDiscord | <Andreas> In reply to @wick3dr0se "Well the files var": how about simply using the `result`-return ? |
22:50:58 | * | Notxor quit (Quit: Leaving) |
22:52:24 | * | jmdaemon quit (Ping timeout: 264 seconds) |
22:54:03 | FromDiscord | <wick3dr0se> I haven't really messed with that yet but it may be a better solution. I'm still learning a lot and I'm too used to writing bash but I can put it on GitHub real quick if anyone wants to check it out |
22:56:55 | FromDiscord | <Elegantbeef> If you do not do `var a = getFiles(...); a.doThing()` you will not be able to reset it |
22:57:01 | FromDiscord | <Elegantbeef> the parameter has to be passed as `var` to another proc |
22:59:32 | FromDiscord | <wick3dr0se> That's how I'm trying to. I just uploaded it and I put a single comment where I'm trying to overwrite the array. It's just 54 LOC https://github.com/wick3dr0se/fml-nim |
23:00:28 | FromDiscord | <Elegantbeef> `files: var seq[string]` |
23:05:48 | FromDiscord | <Andreas> In reply to @Elegantbeef "`files: var seq[string]`": ? really ? where happens the mutation on `seq[string]` ? |
23:13:47 | FromDiscord | <wick3dr0se> I could only get `files = getFiles("")` to work but that's what I needed! Thought I would've tried that by now |
23:29:18 | * | progranner quit (Quit: My Mac has gone to sleep. ZZZzzz…) |
23:32:46 | * | jmdaemon joined #nim |
23:42:53 | FromDiscord | <turtlebasket> With nim macros, is there any standard way to just do the typical lisp quasiquoting stuff without any additional syntactic complexity? |