00:00:04 | * | oprypin joined #nim |
00:00:04 | FromDiscord | <Elegantbeef> But yea horizon↵> Note\: var parameters are never necessary for efficient parameter passing. Since non-var parameters cannot be modified the compiler is always free to pass arguments by reference if it considers it can speed up execution. |
00:01:00 | FromDiscord | <Elegantbeef> At some time it used to explicitly state what the condition was but it's since been removed |
00:01:51 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "Bigger or equal to": Ah |
00:02:50 | FromDiscord | <Elegantbeef> For the most part Nim doesnt make the programmer think about optimisations or internals |
00:02:53 | FromDiscord | <<She>Horizon</Her>> In reply to @Elegantbeef "But yea horizon >": Ah alright then, must've missed that |
00:03:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l8z |
00:03:52 | FromDiscord | <Elegantbeef> For instance `b` and `a` use the same data |
00:04:53 | FromDiscord | <<She>Horizon</Her>> What happens when a is changed later on? b stays the same? a is copied and modified there? |
00:09:42 | FromDiscord | <MadScientistCarl> How does the do notation actually work? Is it just like a regular expression? |
00:14:24 | FromDiscord | <Elegantbeef> If you mutate a after the `b = a` it copies |
00:14:30 | FromDiscord | <Elegantbeef> But it only copies if needed |
00:14:57 | FromDiscord | <<She>Horizon</Her>> Makes sense |
00:16:34 | FromDiscord | <Elegantbeef> This is also how `sink T` works |
00:16:36 | FromDiscord | <Elegantbeef> Resources are only given if it is safe to do so otherwise a copy is made |
00:18:08 | FromDiscord | <MadScientistCarl> How do I turn an iterator into a sequence? I am trying to sort the values of a table and return a sequence, but can't get the types right |
00:19:22 | FromDiscord | <MadScientistCarl> Well, I `.collect()` then do the sorting and it works. Not sure if it is the best idea. |
00:19:23 | FromDiscord | <auxym> toSeq in sequtils |
00:21:10 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l8H |
00:21:16 | FromDiscord | <auxym> so... if `nim check` segfaults, that's a compiler bug, right? Not an issue with my code? |
00:21:46 | FromDiscord | <pyolyokh> if nim's segfaulting it's a bug in nim, yeah |
00:23:01 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l8I |
00:23:18 | FromDiscord | <MadScientistCarl> I just notice, do declarations must be in order? |
00:23:25 | FromDiscord | <<She>Horizon</Her>> In reply to @auxym "so... if `nim check`": Nah your code is so bad, Nim just crashes when gazing upon it (joking) |
00:23:49 | FromDiscord | <<She>Horizon</Her>> In reply to @MadScientistCarl "I just notice, do": For procs you can forward declare |
00:23:53 | FromDiscord | <pyolyokh> In reply to @MadScientistCarl "I just notice, do": you mean, does a proc have to come before procs that use it? yes. |
00:24:02 | FromDiscord | <MadScientistCarl> So no mutual recursion |
00:24:18 | FromDiscord | <<She>Horizon</Her>> In reply to @MadScientistCarl "So no mutual recursion": Forward declaration would be your friend, hold on |
00:24:50 | FromDiscord | <<She>Horizon</Her>> sent a code paste, see https://play.nim-lang.org/#ix=4l8K |
00:25:02 | FromDiscord | <MadScientistCarl> I see |
00:25:02 | FromDiscord | <<She>Horizon</Her>> You'll quickly hit the recursion limit with that example but it works lol |
00:25:50 | FromDiscord | <auxym> https://nim-lang.org/docs/tut1.html#procedures-forward-declarations |
00:25:56 | FromDiscord | <pyolyokh> In reply to @MadScientistCarl "So no mutual recursion": none of the these kinds of limitations are hard limits on the kinds of code you can write. They're just Araq not wanting to complicate the compiler or slow it down for something he thinks isn't wise. Part of the post-2.0 vision is lightening up on that. |
00:27:13 | FromDiscord | <auxym> If I use the latest nightly devel build, overloadable enums should be working right? |
00:27:45 | FromDiscord | <Elegantbeef> Yea |
00:27:53 | FromDiscord | <auxym> because they're a) not working and b) apparently causing a segfault in nim. I'll try to create a minimal repro |
00:34:30 | FromDiscord | <auxym> ah well apparently `{.pure.}` with overloaded enums (pointless but I forgot to remove it) causes nim to segfault |
00:34:37 | FromDiscord | <auxym> should I report that as an issue? |
00:34:56 | FromDiscord | <pyolyokh> it's a bug, yes. nim's not supposed to segfault |
00:38:37 | FromDiscord | <auxym> here's the repro: https://play.nim-lang.org/#ix=4l8S I'll write up an issue |
00:44:46 | FromDiscord | <auxym> https://github.com/nim-lang/Nim/issues/21257 |
00:46:47 | FromDiscord | <@thatrandomperson5-6310e3b26da03> how do i import compiler/ things? I installed using choosenim |
00:47:48 | FromDiscord | <Elegantbeef> Auxym remove `pure` |
00:47:56 | FromDiscord | <Elegantbeef> Oh lol you did |
00:48:23 | FromDiscord | <Elegantbeef> compile your program with `--path:"$nim"` |
00:48:23 | FromDiscord | <@thatrandomperson5-6310e3b26da03> > how do i import compiler/ things? I installed using choosenim↵Any ideas, i don’t think it kept the lib |
00:48:37 | FromDiscord | <auxym> In reply to @Elegantbeef "Oh lol you did": yeah, fixes the segfault |
00:48:45 | FromDiscord | <auxym> In reply to @Elegantbeef "compile your program with": why? |
00:48:53 | FromDiscord | <Elegantbeef> Cause it adds the compiler path |
00:48:59 | FromDiscord | <Elegantbeef> That message wasnt to you |
00:49:12 | FromDiscord | <auxym> oh |
00:51:27 | FromDiscord | <MadScientistCarl> Is there a `zipWith` function? |
00:52:14 | FromDiscord | <Elegantbeef> not that i know of |
00:52:38 | FromDiscord | <Elegantbeef> Worth noting that Nim is not rust so doing pure FP style code will generally be much much slower due to nested allocations |
00:52:59 | FromDiscord | <Elegantbeef> https://github.com/zero-functional/zero-functional is better in that regard |
00:53:05 | FromDiscord | <auxym> or use zero-functional if you really want to do it |
00:53:11 | FromDiscord | <auxym> yeah that |
00:53:20 | FromDiscord | <Elegantbeef> Too slow here |
00:53:25 | FromDiscord | <auxym> D: |
00:53:31 | FromDiscord | <Elegantbeef> Ah too slow on discord aswell 😄 |
00:53:38 | FromDiscord | <MadScientistCarl> That's cool |
00:54:00 | FromDiscord | <ShalokShalom> Can anybody explain me in stupid language, what an event store database is? |
00:54:09 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4l8X |
00:54:35 | FromDiscord | <Elegantbeef> Yea collect is likely the best since it doesnt hide imperative code in procedure calls |
00:55:04 | FromDiscord | <Elegantbeef> But then again i just avoid FP style Nim code as i find it not very efficient or readable |
00:59:25 | FromDiscord | <huantian> In reply to @ShalokShalom "Can anybody explain me": I think it’s when you have a database that doesn’t store its current state, but the operations performed to get to its current state |
01:15:30 | FromDiscord | <MadScientistCarl> What are some good command line prompt libraries? |
01:15:56 | FromDiscord | <MadScientistCarl> Like menus, prompts, etc |
01:16:29 | FromDiscord | <Elegantbeef> Depends what you're after, nimwave exists. Cligen and other argparsers exist aswell |
01:16:42 | FromDiscord | <MadScientistCarl> Not those. Think `nimble init` |
01:17:19 | FromDiscord | <Arathanis> doesn't nimble roll its own with std/terminal? |
01:17:46 | FromDiscord | <Elegantbeef> Yea |
01:17:59 | FromDiscord | <Elegantbeef> Nimwave or using illwill directly would be the best |
01:18:06 | FromDiscord | <Elegantbeef> I dont know if there are prerolled versions |
01:19:25 | FromDiscord | <Arathanis> im not aware of any either, so maybe use cligen to create your command line then rol your own presentation layer using std/terminal? |
01:19:32 | FromDiscord | <Arathanis> nimble is open source so you can see how they are doing it |
01:19:54 | FromDiscord | <Elegantbeef> really though a generic variation of "ChooseX" isnt too complicated |
01:20:04 | FromDiscord | <Arathanis> very true |
01:20:21 | FromDiscord | <Arathanis> Sounds like they want someone to port `rich` to nim |
01:20:53 | FromDiscord | <Elegantbeef> No clue what that is |
01:21:09 | FromDiscord | <Arathanis> its a python library for generating... basically exactly what they want. |
01:21:12 | FromDiscord | <Arathanis> its very nice |
01:21:15 | FromDiscord | <Arathanis> i like it a lot |
01:21:15 | FromDiscord | <Elegantbeef> Ah |
01:21:26 | FromDiscord | <Elegantbeef> It's like one procedure really though 😄 |
01:22:03 | FromDiscord | <Arathanis> true, though i sort of got the feeling they were looking for a library that could be used to build nimble's prompts and more |
01:22:18 | FromDiscord | <Elegantbeef> Well time to author it 😛 |
01:22:23 | FromDiscord | <Elegantbeef> Not me, them |
01:24:32 | FromDiscord | <Elegantbeef> I guess nimble init also does the whole keyboard select thing |
01:24:43 | FromDiscord | <Elegantbeef> Nimwave would be a good base for that |
01:34:35 | FromDiscord | <ambient> People talking about functional style in Nim, could I basically write a Forth like style instead of iterators? 🤔 |
01:34:44 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4l9i cause i cannot help myself i wrote a simple version of the query |
01:34:45 | FromDiscord | <ambient> I mean wouldn't stack based chained calls work better here |
01:35:27 | FromDiscord | <Elegantbeef> I dont know what you mean |
01:35:54 | FromDiscord | <Mustache Man> i don't either, but I do have a question related to iterators. I'm struggling to think of a way to pause/continue iterating over a hash table from a particular index. |
01:36:28 | FromDiscord | <ambient> instead of stuff.map(x=>x+1).filter(x=>x<3) you could do stuff +1 ❤️ filter |
01:36:35 | FromDiscord | <Mustache Man> sent a code paste, see https://play.nim-lang.org/#ix=4l9j |
01:36:43 | FromDiscord | <Mustache Man> (edit) "https://play.nim-lang.org/#ix=4l9j" => "https://play.nim-lang.org/#ix=4l9k" |
01:36:44 | FromDiscord | <ambient> (edit) "❤️" => "< 3" | "< 3filter ... " added "(goddamn discord)" |
01:37:04 | FromDiscord | <Elegantbeef> Ambient how does that resolve iterating twice and or allocating sequences |
01:37:41 | FromDiscord | <ambient> stuff+1 and < 3 is inplace. filter is setLen(whatever) |
01:37:52 | FromDiscord | <Elegantbeef> And i mean there are macro libraries zerofunctional and iterutils |
01:38:32 | FromDiscord | <Elegantbeef> I dont understand how changing the syntax changes the problem |
01:39:10 | FromDiscord | <Elegantbeef> you need to iterate over a sequence for instance adding 1, then you need to iterate over the sequence removing all elements that \>= 3 |
01:39:35 | FromDiscord | <ambient> you need to sort in place and setlen, no new memory alloc or anything |
01:39:47 | FromDiscord | <Elegantbeef> Well then make a macro that does that |
01:40:32 | FromDiscord | <Elegantbeef> But how does it work for `myThing.map(parseInt).filter(x => x > 30)` |
01:41:16 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9m |
01:42:23 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9n |
01:42:50 | FromDiscord | <Elegantbeef> Mustache you really need to clarify what you're after |
01:43:31 | FromDiscord | <pyolyokh> In reply to @Mustache Man "i don't either, but": put the keys in a seq and pop keys off of it. Or find a way to do your work during a .keys loop |
01:44:01 | FromDiscord | <Mustache Man> it's a simulation with a processing "limit" |
01:45:20 | * | nick2 joined #nim |
01:46:34 | FromDiscord | <huantian> Maybe uae beef’s thing to convert the inline itertator to a closure iterator? |
01:47:09 | FromDiscord | <Mustache Man> sent a code paste, see https://play.nim-lang.org/#ix=4l9o |
01:47:47 | FromDiscord | <Mustache Man> (edit) "https://play.nim-lang.org/#ix=4l9o" => "https://play.nim-lang.org/#ix=4l9p" |
01:49:01 | FromDiscord | <Mustache Man> (edit) "https://play.nim-lang.org/#ix=4l9p" => "https://paste.rs/1jo" |
01:49:16 | FromDiscord | <Mustache Man> it goes 'round and 'round the items, processing forever |
01:49:17 | FromDiscord | <Elegantbeef> Today is an iterator day↵(@huantian) |
01:50:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9u |
01:50:35 | FromDiscord | <Elegantbeef> Actually that probably needs to be `i (key, val)` |
01:50:42 | FromDiscord | <Elegantbeef> whoops `i, (key, val)` |
01:53:22 | FromDiscord | <Mustache Man> huh it doesn't like that, too many variables? |
01:54:44 | FromDiscord | <Elegantbeef> Works fine |
01:54:48 | FromDiscord | <Mustache Man> Elegantbeef I don't know how you're always helping out. You're a saint |
01:54:48 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9w |
01:55:02 | FromDiscord | <Mustache Man> oooh enumerate, i was missing that |
01:55:38 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/1E9 |
01:55:44 | FromDiscord | <pyolyokh> eh, that's what you wanted? How are you going to resume the loop after you break it? |
01:56:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9y |
01:56:36 | FromDiscord | <Elegantbeef> Instead of making 2 collections |
01:56:39 | FromDiscord | <Mustache Man> In reply to @pyolyokh "eh, that's what you": i think i'll have to use a closure |
01:56:43 | FromDiscord | <Mustache Man> as you suggested |
01:57:00 | FromDiscord | <Elegantbeef> @ambient\: no clue if you cared but yea the solution is just for loop macros imo 😛 |
01:57:51 | FromDiscord | <Elegantbeef> The dumb closureless way is to just store the last index and skip until you get it again |
01:58:01 | FromDiscord | <Elegantbeef> Since Nim hides the low level details of tables |
01:58:36 | FromDiscord | <Elegantbeef> It does make iteration a massive O notation |
01:58:56 | FromDiscord | <Elegantbeef> But then again iterating tables is bad for your health |
01:59:01 | FromDiscord | <Mustache Man> yeah >_< |
01:59:47 | FromDiscord | <Elegantbeef> What's your key and your value in your table? |
01:59:59 | FromDiscord | <Mustache Man> key is a distinct int16 |
02:00:20 | FromDiscord | <Elegantbeef> This sounds a lot like just an enum that you've made 65k size |
02:00:49 | FromDiscord | <Elegantbeef> Do you actually need 0..65k values |
02:02:00 | FromDiscord | <Mustache Man> value is a ref object with 5 ints, a bool, a set of distinct int16s, and another distinct int16 |
02:02:42 | FromDiscord | <Elegantbeef> Yea value doesnt matter as much, but yea do you really need the 65k range? |
02:02:58 | FromDiscord | <Mustache Man> it's not really an enum, it's a random ID, a "fingerprint" if you will |
02:03:19 | FromDiscord | <Elegantbeef> Ok so you promise it's not a subrange of that value that is an ordinal 😄 |
02:03:56 | FromDiscord | <Mustache Man> well it is generated in an ascending fashion lol |
02:04:04 | FromDiscord | <Mustache Man> 1, 2, 3 ... |
02:04:10 | FromDiscord | <Elegantbeef> Up to? |
02:04:16 | FromDiscord | <Mustache Man> as much as needed |
02:04:16 | FromDiscord | <Elegantbeef> 32k |
02:04:40 | FromDiscord | <Elegantbeef> \I'm just trying to figure if an `array[MyVal, T]` is an option |
02:04:48 | FromDiscord | <Elegantbeef> Or if that's too much memory to allocate |
02:05:28 | FromDiscord | <Mustache Man> well T isn't known ahead of time |
02:06:14 | FromDiscord | <Mustache Man> i'll say this: i was previously using a seq with no issue, i was just hoping to speed it up |
02:06:39 | FromDiscord | <Elegantbeef> Yea dont get me wrong, i was just trying to figure if an array would be valid here |
02:06:50 | FromDiscord | <Elegantbeef> If you need the sparseness that a table gets then likely not |
02:07:12 | FromDiscord | <Elegantbeef> Fully allocated the most you'd allocate assuming you only use natural values of int16 is 32k |
02:07:19 | FromDiscord | <Elegantbeef> So that's 262kb total |
02:08:08 | FromDiscord | <Mustache Man> oh i see what you're getting at, yeah that's pretty small |
02:08:40 | FromDiscord | <Mustache Man> i'm not a systems/game dev so i don't think about options like that 😅 |
02:09:04 | FromDiscord | <Elegantbeef> You still get the whole `O(1)` look up you get slightly faster iterations, but you lose the sparseness of a table and use a flat amount of memory |
02:10:06 | FromDiscord | <Elegantbeef> Yea I just avoid tables generally, unless they're the only option |
02:10:12 | FromDiscord | <Mustache Man> i'll look into trying that for awhile. thanks! |
02:10:17 | FromDiscord | <Elegantbeef> Enum indexed arrays go a long way |
02:10:27 | FromDiscord | <Mustache Man> unless you're interviewing for a job, then the answer is always "use a hashtable" |
02:10:46 | FromDiscord | <Elegantbeef> Bleh i like cache coherency and fast O(1) lookups |
02:11:41 | FromDiscord | <Elegantbeef> \I will never not refer to the person here that was using a `Table[OpCode, T]` for their powerPC VM that was sped up tremendously by diffing `{...}.toTable` to `[...]` |
02:12:02 | FromDiscord | <Elegantbeef> With that minor change they got like 20 times the performance |
02:12:24 | FromDiscord | <Elegantbeef> O(1)s are not all equal kids! |
02:13:03 | * | nick2 quit (Quit: WeeChat 3.8) |
02:15:30 | FromDiscord | <ambient> Or you could O(0.000001) with a GPU |
02:16:17 | FromDiscord | <Elegantbeef> That's ... not how any of this works |
02:17:36 | FromDiscord | <ambient> Writing a solver for equations dealing with 2D arrays is a completely different experience on CPU vs GPU even when technically they are the same complexity |
02:19:30 | FromDiscord | <Elegantbeef> Still have to account for the IO |
02:19:39 | FromDiscord | <Rika> In reply to @ambient "Or you could O(0.000001)": O notation dictates the shape and not the value |
02:19:42 | FromDiscord | <Elegantbeef> Though in many cases depending on the data set that's nothing |
02:19:58 | FromDiscord | <Elegantbeef> I'm sure ambient was joking |
02:19:59 | FromDiscord | <Elegantbeef> I hope ambient was joking |
02:21:00 | FromDiscord | <MadScientistCarl> Can I return a mutable reference? |
02:21:10 | FromDiscord | <MadScientistCarl> Of a `object`, not `ref` type |
02:21:17 | FromDiscord | <Elegantbeef> Yes |
02:21:35 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4l9G |
02:21:46 | FromDiscord | <MadScientistCarl> I get "expression has no address" |
02:21:57 | FromDiscord | <Elegantbeef> Code |
02:22:19 | FromDiscord | <MadScientistCarl> Oh, I forgot to put `var` in self |
02:22:44 | FromDiscord | <Elegantbeef> But it has to be consumed cause nim does not have a borrow checker |
02:22:59 | FromDiscord | <Elegantbeef> So `var a = myObj.doThing(); a = 300` doesnt do the same as `(myObj.doThing()) = 300` |
02:23:19 | FromDiscord | <MadScientistCarl> What do you mean by consumed |
02:23:30 | FromDiscord | <Elegantbeef> It needs to be used as an L-value |
02:23:56 | FromDiscord | <Elegantbeef> It cannot be stored, it has to go into a callable that operates on a `var T` if you want to keep it as a mutable refernece |
02:23:57 | FromDiscord | <MadScientistCarl> So it can't be stored in a variable and used later? |
02:24:00 | FromDiscord | <Elegantbeef> reference even |
02:24:14 | FromDiscord | <MadScientistCarl> What about `obj.getSomeTable()[i] = x` |
02:24:22 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
02:24:23 | FromDiscord | <MadScientistCarl> Does that do what I think it does? |
02:24:49 | FromDiscord | <Elegantbeef> Yes it cannot be stored in a variable |
02:24:52 | FromDiscord | <Elegantbeef> Yes that does do what you want |
02:24:55 | FromDiscord | <Elegantbeef> since `[]` consumes |
02:25:02 | FromDiscord | <MadScientistCarl> OK, that is good enough, I think |
02:25:17 | FromDiscord | <MadScientistCarl> Maybe Nim 3.0 can get a borrow checker 🙂 |
02:25:18 | FromDiscord | <Elegantbeef> I say consume but i dont know if it's the most apt verb |
02:25:24 | FromDiscord | <Elegantbeef> Nim 2.x will have one |
02:25:33 | FromDiscord | <Elegantbeef> It already has a broken one |
02:25:49 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual_experimental.html#view-types |
02:25:53 | FromDiscord | <ambient> Do we have to start worrying about lifetimes? |
02:25:59 | FromDiscord | <Elegantbeef> Nope |
02:26:52 | FromDiscord | <Elegantbeef> Atleast not like rust's |
02:27:17 | FromDiscord | <Elegantbeef> Nim's lifetimes are much simpler of "Making a view closes a variable from making a view until the most recently made view's last usage" |
02:28:12 | FromDiscord | <Elegantbeef> It's quite simple |
02:29:00 | FromDiscord | <Elegantbeef> This is likely to change a bit as views get worked on more, but from what i've seen it's not going to get that complex |
02:29:31 | FromDiscord | <ambient> So if I have a seq, I can't have multiple views, even when they do not overlap? |
02:30:07 | FromDiscord | <Elegantbeef> Openarray could be special cased |
02:31:46 | FromDiscord | <Elegantbeef> Either way it's not like you cannot just do `myProc(a.toOpenArray(0, 5), a.toOpenArray(6, 10))` |
02:31:52 | FromDiscord | <Elegantbeef> Since that's currently valid |
02:33:00 | FromDiscord | <ambient> Nim looks so simple and innocent on the surface... |
02:33:53 | FromDiscord | <MadScientistCarl> Does Nim's object initialization have shorthands? |
02:34:15 | FromDiscord | <Elegantbeef> Nope you either make a constructor proc or use `MyThing(a: 100, b: 300)` |
02:34:16 | FromDiscord | <MadScientistCarl> Like making `A(field1: field1)` `A(field1)` |
02:34:21 | FromDiscord | <ambient> I recently saw this https://github.com/beef331/constructor |
02:34:33 | FromDiscord | <Elegantbeef> \Or i guess you could use macros) |
02:35:41 | FromDiscord | <Elegantbeef> Hmph this does give me yet another constructor idea |
02:51:14 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4l9O |
02:51:17 | FromDiscord | <Elegantbeef> There that seems nice |
02:51:22 | FromDiscord | <Elegantbeef> Might even throw it in constructor |
02:51:32 | FromDiscord | <Elegantbeef> @Phil\: My 'legacy' code grows |
02:52:17 | FromDiscord | <MadScientistCarl> How would I append a sequence to another sequence in place? |
02:52:28 | FromDiscord | <Elegantbeef> `.add` |
02:52:44 | FromDiscord | <MadScientistCarl> That adds one element |
02:52:52 | FromDiscord | <Elegantbeef> It's overloaded |
02:53:01 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#add%2Cseq%5BT%5D%2CopenArray%5BT%5D |
02:53:11 | FromDiscord | <MadScientistCarl> Ah OK, the error was not using `var` |
02:53:34 | FromDiscord | <MadScientistCarl> The message says it is method not found |
02:53:44 | FromDiscord | <MadScientistCarl> I guess it makes sense under Nim's dispatch rules |
03:19:03 | FromDiscord | <Elegantbeef> Well there we go more code for the legacy code machine! 😛 https://github.com/beef331/constructor#struct-intialisers |
03:21:50 | FromDiscord | <MadScientistCarl> What's the best way to habdle errors? Does Nim have something like the ? operator? |
03:22:21 | FromDiscord | <ambient> The use of [] in your code is not really obvious what it does |
03:22:27 | FromDiscord | <Elegantbeef> Nim has try except |
03:23:01 | FromDiscord | <Elegantbeef> I mean it's the dereference operator |
03:23:04 | FromDiscord | <Elegantbeef> I'm not teaching Nim basics inside of a constructor library |
03:23:48 | FromDiscord | <ambient> Just saying that I hadn't seen it before and reading through the docs I'm not a fan of that language construct |
03:24:05 | FromDiscord | <Elegantbeef> I think it's very nice |
03:24:47 | FromDiscord | <Elegantbeef> It's the same as array, and seq access |
03:24:51 | FromDiscord | <ambient> It's both an array constructor and a deref apparently |
03:25:20 | FromDiscord | <MadScientistCarl> Are exceptions more used or Result? |
03:26:18 | FromDiscord | <MadScientistCarl> Wait, is there even a result type? |
03:26:42 | FromDiscord | <Elegantbeef> not in the stdlib, there is a `option` type |
03:26:52 | FromDiscord | <Elegantbeef> Nim uses exception error handling |
03:27:22 | FromDiscord | <Elegantbeef> Which is ideal imo, minus performance implications |
03:30:35 | FromDiscord | <MadScientistCarl> I like Result type with sugar better, but exceptions are ok |
03:31:55 | FromDiscord | <Elegantbeef> Bleh results load the code with forced handling |
03:32:02 | FromDiscord | <Elegantbeef> If i'm writing code that i dont care if it raise an exception I dont like that one is forced to `?` it all away |
03:32:22 | FromDiscord | <Elegantbeef> I much prefer the Nim semantic of "If you dont want code to raise an exception, you can annotate it with `raises: []` |
03:32:26 | FromDiscord | <Elegantbeef> It's way less invasive imo |
03:32:49 | FromDiscord | <MadScientistCarl> ? Passes the error above like exceptions |
03:33:02 | FromDiscord | <Elegantbeef> I know how it works |
03:33:04 | FromDiscord | <Elegantbeef> It's an explicit behaviour required to be called |
03:33:21 | FromDiscord | <Elegantbeef> It's just wrong imo |
03:33:38 | FromDiscord | <MadScientistCarl> I like it more because I know what to expect just by looking at the types |
03:33:54 | FromDiscord | <Elegantbeef> I mean i can say the same with Nim's effect tracking |
03:34:03 | FromDiscord | <Elegantbeef> I know what a proc will raise by looking at it's type |
03:34:08 | FromDiscord | <MadScientistCarl> I am not there yet |
03:34:24 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/1063662339951440003/image.png |
03:34:31 | FromDiscord | <Elegantbeef> Click 3 dots in docs |
03:34:35 | FromDiscord | <Elegantbeef> You see `raises: [...]` |
03:34:46 | FromDiscord | <Elegantbeef> That's the compiler telling you that this proc raises those exceptions |
03:34:49 | FromDiscord | <ambient> Is there something like Rust question mark for Options? https://doc.rust-lang.org/rust-by-example/std/result/question_mark.html 🤔 |
03:34:53 | FromDiscord | <Elegantbeef> Nim tracks what procedures rais what |
03:34:58 | FromDiscord | <MadScientistCarl> Ok, if the compiler helps, then great |
03:35:15 | FromDiscord | <Elegantbeef> https://github.com/arnetheduck/nim-result |
03:35:26 | FromDiscord | <MadScientistCarl> Time to add Monads |
03:36:38 | FromDiscord | <ambient> Now I don't know which to use nim-result or options |
03:36:39 | FromDiscord | <Elegantbeef> I just really think that the semantics of exceptions are nice, would be nifty if the compiler optimised heap allocated exceptions when it can |
03:36:47 | FromDiscord | <Elegantbeef> Neither use exceptions |
03:36:48 | FromDiscord | <Elegantbeef> 😛 |
03:37:52 | FromDiscord | <Rika> In reply to @ambient "Now I don't know": Options are not meant to indicate an error response |
03:38:27 | FromDiscord | <ambient> Ok, so there is no ? lang construct for options |
03:38:44 | FromDiscord | <Elegantbeef> You can implement a `?` operator all day long |
03:38:49 | FromDiscord | <Elegantbeef> Nim is one of the most extensible language |
03:38:58 | FromDiscord | <Elegantbeef> s |
03:38:58 | FromDiscord | <ambient> I probably will |
03:39:41 | FromDiscord | <Rika> You cannot make it similar to rust |
03:39:53 | FromDiscord | <Rika> https://github.com/PMunch/nim-optionsutils |
03:43:14 | FromDiscord | <Gumbercules> https://github.com/alaviss/union |
03:44:56 | FromDiscord | <Gumbercules> If you're looking for an alternative to Nim's options |
03:45:19 | FromDiscord | <Elegantbeef> That's more like an alternative to results |
03:45:26 | FromDiscord | <Elegantbeef> Not really either way though |
03:45:32 | FromDiscord | <Elegantbeef> It's just sumtypes 😄 |
03:46:07 | FromDiscord | <Gumbercules> Well it can work for both |
03:49:26 | FromDiscord | <Elegantbeef> Yea but it loses some intent, unless you do `type Option[T] = union(bool or T)` |
03:51:58 | FromDiscord | <Gumbercules> Yeah I was just pointing it out since results and options were being discussed and conceptually you can model both with ^ |
03:54:02 | FromDiscord | <Elegantbeef> This is where i jokingly say "Why do we even have `Option[T]`, `ref T` works just fine?!" |
03:57:44 | FromDiscord | <ambient> So you suggest I would do something like this and just catch the exceptions? https://nim-lang.org/docs/manual.html#types-nil |
03:58:13 | FromDiscord | <Elegantbeef> No you cannot catch nil ref exceptions, and do not use `ref T` as a optional |
03:58:14 | FromDiscord | <ambient> Can an "an unrecoverable fatal runtime error" be caught? |
03:58:34 | FromDiscord | <Elegantbeef> Do people not get what "jokingly say" means? |
03:58:50 | FromDiscord | <ambient> You have to consider that I'm a noob |
04:23:31 | * | tiorock joined #nim |
04:23:31 | * | tiorock quit (Changing host) |
04:23:31 | * | tiorock joined #nim |
04:23:31 | * | rockcavera quit (Killed (calcium.libera.chat (Nickname regained by services))) |
04:23:31 | * | tiorock is now known as rockcavera |
04:23:59 | * | rockcavera quit (Remote host closed the connection) |
04:29:08 | * | rockcavera joined #nim |
04:45:47 | * | azimut quit (Ping timeout: 255 seconds) |
05:48:02 | * | arkurious quit (Quit: Leaving) |
06:08:11 | FromDiscord | <Gumbercules> sent a code paste, see https://play.nim-lang.org/#ix=4lal |
06:53:44 | FromDiscord | <fabricio> https://github.com/markspanbroek/questionable |
06:54:23 | FromDiscord | <Rika> I was trying to remember that |
07:07:54 | FromDiscord | <Gumbercules> so many options |
07:08:28 | FromDiscord | <Gumbercules> (edit) "options" => "options!" |
07:12:18 | FromDiscord | <Rika> What will result from this |
07:12:27 | FromDiscord | <Elegantbeef> Exceptional code |
07:12:50 | FromDiscord | <Rika> That’s something |
08:33:28 | * | rockcavera quit (Remote host closed the connection) |
09:04:39 | FromDiscord | <sealmove> `osproc.hasData` hangs when used on a process with the `poParentStreams` option enabled. |
09:30:32 | * | azimut joined #nim |
09:31:11 | FromDiscord | <sealmove> `stream access not allowed when you use poParentStreams` |
09:38:01 | * | azimut quit (Remote host closed the connection) |
09:38:26 | * | azimut joined #nim |
09:39:50 | FromDiscord | <pyryrin> how do i check in nim code if it's a release build |
09:40:19 | FromDiscord | <Elegantbeef> `when defined(release)` |
09:40:42 | FromDiscord | <pyryrin> its not working |
09:43:40 | FromDiscord | <Rika> In what way is it not working |
09:44:28 | FromDiscord | <pyryrin> sent a code paste, see https://play.nim-lang.org/#ix=4laW |
09:46:07 | FromDiscord | <Rika> Parentheses |
09:46:13 | FromDiscord | <Rika> Though I guess those shouldn’t matter |
09:46:27 | FromDiscord | <Rika> Where did you write the define |
09:46:28 | FromDiscord | <pyryrin> nope its the same with parenthesis |
09:46:35 | FromDiscord | <Rika> What’s the command you ram |
09:46:41 | FromDiscord | <Rika> Ran |
09:47:45 | FromDiscord | <pyryrin> i tried `nimble run -d:release --gc:orc` and `nim c -r src/temp.nim -d:release --gc:orc` both same output |
09:49:53 | FromDiscord | <pyryrin> and for some reason the nim c command says im building a debug build |
09:50:46 | FromDiscord | <pyryrin> ohhhhh you're supposed to put -d:release before the filename |
09:54:08 | FromDiscord | <Rika> Release goes before the file name in the second command |
09:54:20 | FromDiscord | <Rika> Nimble run does not pass arguments |
09:54:57 | FromDiscord | <pyryrin> someone said it does |
09:55:05 | FromDiscord | <Rika> I don’t remember it doing so |
09:56:25 | FromDiscord | <pyryrin> i didnt know all the options have to go before the filename |
09:57:00 | FromDiscord | <pyryrin> i've been building all my nim projects with gc:refc instead of orc by accident |
09:57:59 | FromDiscord | <Rika> After the file name the options are passed to the program itself |
09:58:44 | FromDiscord | <pyryrin> In reply to @pyryrin "i didnt know all": and as debug builds |
10:10:50 | * | ltriant joined #nim |
10:15:38 | * | ltriant quit (Ping timeout: 265 seconds) |
10:38:11 | FromDiscord | <badmachine> Hey all |
10:38:21 | FromDiscord | <badmachine> Does nim have something like python's fsspec? |
10:38:50 | FromDiscord | <badmachine> I was thinking of writing something but I wanted to make sure it wasn't already done |
10:41:03 | FromDiscord | <ringabout> In reply to @badmachine "Does nim have something": I don't think there is one |
10:45:07 | FromDiscord | <badmachine> Cool then I'll go ahead. `fsspec` has been super useful for libraries that work with data in "the cloud". I should call it something different though, maybe `abstract_fs`. |
10:53:37 | FromDiscord | <badmachine> So python's implementation uses inheritance. There is an abstractFS object and a bunch of methods have to be implemented. Given that procs are separate from object definitions in nim, how does one implement such a thing? |
10:56:21 | FromDiscord | <ringabout> You can use `methods` to implement dynamic dispatch. |
10:56:44 | FromDiscord | <badmachine> I guess I've found this: https://nim-by-example.github.io/oop/↵But I was wondering if there is a way to do this without using dynamic dispatch |
11:07:03 | FromDiscord | <badmachine> Is there a way to do this with generics maybe? |
11:07:50 | FromDiscord | <Rika> Probably? |
11:07:59 | FromDiscord | <Rika> I haven’t seen the Python implementation |
11:19:48 | FromDiscord | <planetis> Concepts ofc. |
11:25:39 | FromDiscord | <badmachine> Thanks bot |
11:26:03 | FromDiscord | <Phil> That's a new one, typically beef is hit with that line |
11:28:38 | FromDiscord | <badmachine> Is there a way to specify type in concepts? |
11:29:01 | FromDiscord | <badmachine> (edit) "type" => "types" |
11:30:15 | * | xet7 joined #nim |
11:31:47 | FromDiscord | <Rika> Concepts are more for narrowing down types in a generic, kinda |
11:31:58 | FromDiscord | <Rika> People compare it with interfaces |
11:32:05 | FromDiscord | <Rika> The difference is that concepts are compile time only |
11:32:20 | FromDiscord | <badmachine> sent a code paste, see https://play.nim-lang.org/#ix=4lbg |
11:33:29 | FromDiscord | <badmachine> ahhh maybe I could do |
11:36:05 | FromDiscord | <badmachine> sent a code paste, see https://play.nim-lang.org/#ix=4lbh |
11:36:47 | FromDiscord | <Rika> That’s kinda wrong iirc |
11:37:19 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4lbi |
11:37:32 | FromDiscord | <Rika> (edit) "https://play.nim-lang.org/#ix=4lbi" => "https://play.nim-lang.org/#ix=4lbj" |
11:38:22 | FromDiscord | <badmachine> Gotcha. Let me try to implement this with local filesystem. |
11:38:24 | FromDiscord | <badmachine> Thanks 🙂 |
11:38:27 | FromDiscord | <Rika> These are old style concepts too by the way, there’s a newer syntax for them (but I don’t recall how to use them) |
11:42:00 | FromDiscord | <ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4lbm |
11:42:27 | FromDiscord | <ringabout> (edit) "https://play.nim-lang.org/#ix=4lbm" => "https://play.nim-lang.org/#ix=4lbn" |
11:42:52 | FromDiscord | <badmachine> Thanks! this looks much neater. Is it supported on 1.6? That's the version I'm running |
11:43:47 | FromDiscord | <ringabout> Yes |
11:44:16 | FromDiscord | <badmachine> Just confirmed, my VS Code is not yelling at me when I pasted it in. Just had to change `Self` to `Filesystem` |
11:53:24 | FromDiscord | <badmachine> sent a code paste, see https://play.nim-lang.org/#ix=4lbt |
11:54:09 | * | ltriant joined #nim |
11:59:57 | FromDiscord | <badmachine> sent a code paste, see https://play.nim-lang.org/#ix=4lbu |
12:00:19 | FromDiscord | <badmachine> I don't really understand what that means - and I wasn't able to find examples of how concepts are used online |
12:00:26 | FromDiscord | <Rika> That’s not how to use concepts |
12:01:11 | FromDiscord | <Rika> I’d write more but I don’t really want to program on a phone so maybe in a few hours or so or wait for someone else to answer |
12:01:21 | FromDiscord | <Rika> It’s also hard to explain in words |
12:06:51 | FromDiscord | <badmachine> Fair enough, thanks again to everyone for being so helpful |
12:08:04 | FromDiscord | <Rika> Let me try words anyway |
12:08:38 | FromDiscord | <Rika> Basically you have a concept and a type right? The type doesn’t “inherit” the concept just like how a type wouldn’t inherit an interface either |
12:09:26 | FromDiscord | <Rika> You implement them, in other languages using interfaces you do it explicitly by saying “I implement this interface by having these functions” but in Nim for concepts you just make a procedure that matches all procedures in the concept |
12:09:35 | FromDiscord | <Rika> No need to declare you implement the concept |
12:10:38 | FromDiscord | <Rika> Then in other functions where you would want to use all types that are compatible with that concept you write this: `proc useFs(fs: FilesystemConcept, ...)`↵And then you can pass any type that matches the concept to that function |
12:10:52 | FromDiscord | <Rika> If it doesn’t match it will error out |
12:11:48 | FromDiscord | <Rika> @badmachine |
12:12:08 | FromDiscord | <Rika> If you don’t understand then wait one and a half hours lol |
12:13:51 | FromDiscord | <badmachine> I think it makes sense. Let me try to code it to see if I can wrap my head around it |
12:25:02 | FromDiscord | <badmachine> sent a code paste, see https://play.nim-lang.org/#ix=4lbC |
12:25:29 | FromDiscord | <badmachine> and it outputs exactly what we want: `elif ru em sti yeh` |
12:25:34 | FromDiscord | <Rika> Exactly, but be careful as reverse isn’t checked there |
12:25:38 | FromDiscord | <Rika> Wait |
12:25:40 | FromDiscord | <Rika> Dumb |
12:25:46 | FromDiscord | <Rika> Reverse is for string okay that’s all good then |
12:28:32 | FromDiscord | <badmachine> There are about 50 methods that exist for AbstractFileSystem in fsspec, let's see how many I can implement 😄 |
12:34:23 | FromDiscord | <badmachine> sent a long message, see http://ix.io/4lbF |
12:40:43 | FromDiscord | <hotdog> In reply to @badmachine "I sorta get that": I haven’t used concepts in a while, but one thing I remember doing that helped: break your concept up into smaller units, then put a bunch of `assert LocalFS is FileSystemCat` etc |
12:40:52 | FromDiscord | <hotdog> You can template it to make it less verbose |
13:19:37 | FromDiscord | <scipio> sent a long message, see http://ix.io/4lbM |
13:20:47 | FromDiscord | <scipio> @sOkam! is you reply with :?: you were MiA the last days, scroll up... |
13:21:04 | FromDiscord | <scipio> (edit) "is" => "if" |
13:21:23 | * | koltrast quit (Ping timeout: 255 seconds) |
13:21:41 | FromDiscord | <sOkam!> In reply to @scipio "<@186489007247589376> if you reply": because i don't get why you would call nim a glue or chameleon lang. the fact that it passes through C doesn't mean its not unique 🤷♂️ |
13:22:16 | FromDiscord | <MadScientistCarl> If Nim can call C without an FFI then I woulf say it is really a glue language |
13:22:31 | FromDiscord | <MadScientistCarl> (edit) "woulf" => "would" |
13:22:46 | FromDiscord | <scipio> In reply to @sOkam! "because i don't get": Did I say Nim is not unique? That's your interpretation and it's wrong |
13:23:09 | FromDiscord | <sOkam!> In reply to @scipio "Did I say Nim": i was refering to the "not having an identity" part of the message |
13:23:31 | FromDiscord | <Rika> In reply to @scipio "I have the solution,": I see and somewhat agree with what you said, not sure if I would fully agree because I need time to think about it lol |
13:23:38 | FromDiscord | <sOkam!> In reply to @MadScientistCarl "If Nim can call": so cpp is a glue lang too? |
13:23:41 | FromDiscord | <scipio> In reply to @sOkam! "i was refering to": I also didn't say it doesn't have an identity |
13:23:55 | FromDiscord | <sOkam!> In reply to @scipio "I also didn't say": https://media.discordapp.net/attachments/371759389889003532/1063810698834092052/image.png |
13:24:17 | FromDiscord | <scipio> An identity problem is a branding issue....↵🤦♀️ |
13:24:23 | FromDiscord | <MadScientistCarl> Cpp not quite. Cpp is a monster of a language that is probably as big as Rust now |
13:24:49 | FromDiscord | <scipio> It's not what you think about it, it's how its criticasters not using it would label it |
13:24:56 | FromDiscord | <ringabout> In reply to @MadScientistCarl "If Nim can call": You can use https://github.com/PMunch/futhark to import c headers automatically without ffi. |
13:25:08 | FromDiscord | <MadScientistCarl> Nim is smaller. It is actually not quite C compatible (ergonomic wise) |
13:25:09 | FromDiscord | <sOkam!> alright, im dumb and not understand a single word. i'll exit myself out of this discussion, since i clearly don't know what im talking about |
13:25:30 | FromDiscord | <cow> wait |
13:25:35 | FromDiscord | <cow> futhark is not bindings to futhark? |
13:25:43 | FromDiscord | <MadScientistCarl> I am aware of Futhark. But if it is not in stdlib, it is not "in the language" |
13:25:58 | FromDiscord | <cow> https://futhark-lang.org/ |
13:26:03 | FromDiscord | <scipio> @sOkam! regarding branding and communication I think that is the correct assumption indeed. I have no idea about your programming skills. You're probably l33t in that, no pun intended. |
13:26:11 | FromDiscord | <Rika> No it’s not |
13:26:25 | FromDiscord | <Rika> The two things are independent and unrelated |
13:27:33 | FromDiscord | <MadScientistCarl> Nim's C compat is probably on Rust level, where you can declare stuff like "extern C" before using a function |
13:27:43 | FromDiscord | <scipio> @sOkam! also I am not here for a pissing contest; I am a very open minded person and I am not conflict seeking. |
13:27:48 | FromDiscord | <MadScientistCarl> But you still have to declare it |
13:28:00 | FromDiscord | <Rika> In reply to @scipio "<@186489007247589376> also I am": Damn I wish I were like that |
13:28:02 | FromDiscord | <scipio> ☮️ @sOkam! |
13:28:11 | FromDiscord | <Rika> In reply to @MadScientistCarl "But you still have": Pretty much yes |
13:29:43 | FromDiscord | <MadScientistCarl> So that led to my point: if Nim can just call C by including, with support of language or std, then it is a much better glue language |
13:29:43 | FromDiscord | <scipio> In reply to @MadScientistCarl "Nim's C compat is": What do you think has a more positive connotation to it?↵-a- Master of None↵or↵-b- Glue |
13:30:03 | FromDiscord | <scipio> That's what I meant with branding problem |
13:30:07 | FromDiscord | <MadScientistCarl> I would not use either |
13:30:31 | FromDiscord | <Rika> Neither have that much of a positive connotation, both are neutral skewed to negative imo |
13:31:12 | FromDiscord | <MadScientistCarl> If only Nim can "script easily with all the C library" 🙂 |
13:31:27 | FromDiscord | <scipio> In reply to @MadScientistCarl "I would not use": Then what would you suggest would be a better "label" to define what Nim is? |
13:31:41 | FromDiscord | <MadScientistCarl> I am too new to say that |
13:31:43 | FromDiscord | <scipio> What does it excel at? What is Nim's absolute unique USP ? |
13:32:06 | FromDiscord | <MadScientistCarl> I started using it three days ago |
13:32:26 | FromDiscord | <scipio> We both have the green leave icon 😉 |
13:32:34 | FromDiscord | <scipio> I beat you by one day tho |
13:32:47 | FromDiscord | <scipio> (edit) "leave" => "leaf" |
13:32:58 | FromDiscord | <MadScientistCarl> Right now I see it as a fast compile, small binary, lightweight quick language |
13:33:30 | FromDiscord | <cow> Nim seems to me like a better Go, with better FFI |
13:33:30 | FromDiscord | <scipio> And I've been researching about 40 ways to build a GUI application with Nim |
13:33:39 | FromDiscord | <MadScientistCarl> But its C interop is what I am really after |
13:33:44 | FromDiscord | <cow> being able to glue, doesn't make it a glue language |
13:33:44 | FromDiscord | <Rika> Most people would probably say it’s an easy prototyping language that’s much faster than Python |
13:33:45 | FromDiscord | <Rika> Maybe |
13:34:08 | FromDiscord | <scipio> In reply to @cow "Nim seems to me": That would be V |
13:34:14 | FromDiscord | <scipio> In terms of branding |
13:34:18 | FromDiscord | <MadScientistCarl> Nim's FFI is better than Go |
13:34:19 | FromDiscord | <scipio> Its syntax is near identical |
13:34:27 | FromDiscord | <cow> syntax is irrelevant |
13:34:48 | FromDiscord | <cow> unless it's as annoying as COBOL's syntax or something |
13:35:55 | FromDiscord | <cow> In reply to @scipio "That would be V": let's also not consider languages that haven't passed 1.0 |
13:36:20 | FromDiscord | <MadScientistCarl> Well, seamless C FFI would reauire a C compiler inside Nim. Maybe that is hard. |
13:36:24 | FromDiscord | <scipio> sent a long message, see http://ix.io/4lbQ |
13:36:42 | FromDiscord | <scipio> In the case of "glue", it's definitely a feature |
13:37:28 | FromDiscord | <MadScientistCarl> I actually don't like indentation based syntax |
13:38:02 | FromDiscord | <cow> me neither, but I got used to it |
13:38:04 | FromDiscord | <scipio> That's not something to laugh at, it's something to _identify as a core feature_↵↵A spoon isn't better or worse as a knife, but I prefer eating my soup with a spoon when I want to eat soup. |
13:38:05 | FromDiscord | <MadScientistCarl> It is really problematic when code gets long or if you paste stuff |
13:38:39 | FromDiscord | <cow> In reply to @scipio "Syntax is only irrelevant": those features might make nim better at gluing, but they don't make it worse at the tasks Go is used for |
13:39:07 | FromDiscord | <MadScientistCarl> I would still be using Go if not because Nim's binary is 100 times smaller |
13:39:43 | FromDiscord | <scipio> Indentation is also a feature @MadScientistCarl , as it forces you to write human readable code for example. ↵nodeJS' "callback hell" after Ryan Dahl created it wasn't meant as a compliment |
13:39:46 | FromDiscord | <MadScientistCarl> So yeah, a great advantage of Nim is actually C~sized binary and compile time |
13:40:36 | FromDiscord | <MadScientistCarl> No, you don't need indentation sybtax to be readable. Enforcing indentation gives a lot of possibilities of mistakes |
13:40:44 | FromDiscord | <scipio> In reply to @cow "those features might make": But it does make Nim a better candidate for that as a language which deliberately does not support meta programming |
13:40:53 | FromDiscord | <cow> also, Nim has an official identity, as a systems programming language |
13:41:03 | FromDiscord | <MadScientistCarl> If you paste code and it is one level off? Good luck finding that one out |
13:41:50 | FromDiscord | <cow> In reply to @MadScientistCarl "If you paste code": you shouldn't be nesting more than 3-4 levels anyways |
13:42:02 | FromDiscord | <cow> it's bad practice |
13:42:05 | FromDiscord | <MadScientistCarl> If you really need 4 nested for loops and can' avoid it, and the next statements are on level 3, then 1, skipping 2? Well be careful |
13:42:48 | FromDiscord | <MadScientistCarl> Sure, but you can't always avoid 4 nested for loops |
13:42:57 | FromDiscord | <scipio> In reply to @cow "also, Nim has an": Arguably the person who created that "official identity" isn't the world's best PR strategist in computer science. ↵Jonathan Blow uses a slightly different approach for Jai. There's a lesson in there somewhere... |
13:43:01 | FromDiscord | <cow> if those for loops iterate, write a function that does it and use sequtils |
13:43:49 | FromDiscord | <MadScientistCarl> As I said, not always. Perhaps there is an algorithm that really calls for it |
13:44:00 | FromDiscord | <cow> yeah not always |
13:44:13 | FromDiscord | <cow> sometimes nesting is the easiest way |
13:44:42 | FromDiscord | <MadScientistCarl> Or maybe every statement use all variables that if you make functions, their argument list goes on for half a page |
13:44:57 | FromDiscord | <cow> that's what ref objects are good for |
13:45:15 | FromDiscord | <cow> to encapsulate related state variables |
13:45:26 | FromDiscord | <MadScientistCarl> Thdn each function have a different subset, so you have three pges of object type definition |
13:45:43 | FromDiscord | <MadScientistCarl> Of course that's contrived |
13:46:15 | FromDiscord | <cow> big objects is the least big problem of the three, I would say |
13:46:18 | FromDiscord | <MadScientistCarl> So the only practical problem I regularly see, are code pasting and long code |
13:46:18 | FromDiscord | <cow> if it's ref objects |
13:46:57 | FromDiscord | <MadScientistCarl> Your editor needs to be really smart, and it will never be sure |
13:47:33 | FromDiscord | <MadScientistCarl> Because when you copy code, the first line can be hanging, or your cursor just didn't include the indentation |
13:47:54 | FromDiscord | <cow> yeah but that's something you should fix anyways, when using brackets |
13:48:03 | FromDiscord | <MadScientistCarl> Your editor, even if ot understands Nim, is never sure if you mean to paste with or without indwntation |
13:48:11 | FromDiscord | <cow> i don't tolerate misindented lines in non-indentation sensitive langauges either |
13:48:22 | FromDiscord | <MadScientistCarl> If using brackets, there is no ambiguitiy |
13:48:32 | FromDiscord | <cow> but it's the same effort on the human's part |
13:48:35 | FromDiscord | <MadScientistCarl> Misindented lines are ugly, but correct |
13:48:53 | FromDiscord | <MadScientistCarl> You can have it misindent for one second, then auto indent it immediately |
13:49:19 | FromDiscord | <cow> i get what you mean, but in my experience, on the problems i was working on, it was never a problem |
13:49:25 | FromDiscord | <MadScientistCarl> In an indentation based language, you get incorrect code, and a formatter cannot fix it. Because, it is correct syntactically |
13:49:28 | FromDiscord | <cow> editors can be smarter with brackets indeed |
13:50:48 | FromDiscord | <cow> I also rarely copy-paste |
13:51:12 | FromDiscord | <cow> (edit) "I also rarely copy-paste ... " added "into more nested places" |
13:51:19 | FromDiscord | <MadScientistCarl> On the broght side, indentation based language don't need closing brackets, so it's shorter on page |
13:51:29 | FromDiscord | <cow> you can move everything out of nested places with templates |
13:51:39 | FromDiscord | <cow> the end result might or might not be more readable though |
13:52:25 | FromDiscord | <cow> In reply to @MadScientistCarl "On the broght side,": now it's just time to convince languages that () are evil too |
13:52:49 | FromDiscord | <MadScientistCarl> No, I use Lisp too |
13:53:16 | FromDiscord | <cow> they shouldn't be removed, but it's ugly to nest () |
13:53:23 | FromDiscord | <MadScientistCarl> But lisp convention is to put closing stuff on same line |
13:54:18 | FromDiscord | <scipio> Jai brands itself as a high level language for game development. That is choosing which problem you want to solve. That's identity management, a clear mission. |
13:55:40 | FromDiscord | <scipio> And I predict that the minute it releases as stable it'll have a job market and a cult following. |
13:56:41 | FromDiscord | <scipio> Nim can achieve the same choosing a problem to solve. I', thinking Glue / Cement |
13:56:50 | FromDiscord | <scipio> (edit) "I'," => "I'm" |
13:57:00 | FromDiscord | <MadScientistCarl> Maybe call it Soldering because it is compiled |
13:57:44 | FromDiscord | <MadScientistCarl> Or Welding because it is statically compiled |
13:58:36 | * | jjido joined #nim |
13:58:57 | FromDiscord | <scipio> Many languages are compiled. |
13:59:13 | FromDiscord | <scipio> Branding isn't about choosing a name |
14:00:13 | FromDiscord | <scipio> Jai is probably called like so because its founder is named Jon(athan) and it also has "ai" in it. |
14:01:08 | FromDiscord | <scipio> I don't see an issue with the "name Nim" |
14:02:02 | FromDiscord | <Rika> Until you discover it’s old name? Lol |
14:02:03 | FromDiscord | <scipio> I'm asking myself why after 15 years of existing it has 50 GUI repos and no job market. |
14:02:16 | FromDiscord | <scipio> In reply to @Rika "Until you discover it’s": Nimrod is a biblical figure |
14:02:27 | FromDiscord | <Rika> Not to most people it ain’t |
14:02:40 | FromDiscord | <scipio> That's something else that's also true |
14:03:06 | FromDiscord | <scipio> Like I said, there are better PR strategists in the world |
14:03:53 | FromDiscord | <scipio> But if you like Nim and would like a fuckton of companies/clients throwing suitcases filled with money at you to write it for them, I suggest you listen to me. |
14:04:44 | FromDiscord | <cow> the cartoon bunny used the word in the biblical sense |
14:04:54 | FromDiscord | <cow> people just didn't get it |
14:05:12 | FromDiscord | <MadScientistCarl> Well, sometimes _not_ having a backing company is a feature... |
14:05:40 | FromDiscord | <MadScientistCarl> Though I am in no place to declare it because I am just getting started |
14:06:43 | FromDiscord | <cow> In reply to @scipio "But if you like": it's possible that you can improve the PR of a language, sure |
14:07:21 | FromDiscord | <cow> but "glue/cement" feels like a deviation from nim's current identity i think |
14:07:29 | FromDiscord | <cow> (edit) "but "glue/cement" feels like a ... deviation" added "large" |
14:10:16 | FromDiscord | <sealmove> does nim support process piping? |
14:10:53 | FromDiscord | <pyolyokh> it has <https://nim-lang.org/docs/osproc.html> |
14:12:09 | FromDiscord | <sealmove> yes i am looking at this and trying to figure out how to run a posix pipeline and manipulate its output within nim |
14:12:43 | FromDiscord | <scipio> @pyolyokh if you'd have to pick one feature Nim excels at, either currently or could excel it, which one? I do trust your technical assessment on Nim. |
14:12:48 | FromDiscord | <pyolyokh> Despite knowing all of those words, and even having a pretty good idea of them, I don't know what you're asking. |
14:13:29 | FromDiscord | <pyolyokh> if you want to spawn multiple processes and manage I/O between them, you're going to have to do much of that yourself. |
14:13:52 | FromDiscord | <pyolyokh> if you want to spawn a shell command containing pipes, just do that, and how much trouble the result is depends on what precisely you want to do with the shell command |
14:14:36 | FromDiscord | <pyolyokh> for example, the procs there that don't take an array of strings for the arguments, like the `execCmd("blah")`, those work by giving a shell the string |
14:14:56 | FromDiscord | <pyolyokh> but you could also use the array-of-strings ones and just pass the array to "/bin/bash" |
14:17:30 | FromDiscord | <MadScientistCarl> Can I not inherit a specialized generic type? |
14:18:10 | FromDiscord | <sealmove> I have the following issue. I want to run `A | B` and parse the output of `A` to know the progress. |
14:18:12 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lc5 |
14:18:35 | FromDiscord | <pyolyokh> In reply to @รєคɭ๓๏שє "I have the following": just run the command "A | B", then, implicitly or explicitly to a shell |
14:19:09 | FromDiscord | <pyolyokh> execCmdEx is the simplest way to do that |
14:19:40 | FromDiscord | <sealmove> But the process takes minutes to complete. I am trying to spawn it with `startProcess` and monitor its progress. |
14:20:13 | FromDiscord | <pyolyokh> execCmdEx gives you the same set[processOptions] that you're trying to use with startProcess |
14:20:26 | FromDiscord | <pyolyokh> you can also used startProcess though |
14:20:41 | FromDiscord | <pyolyokh> just pass "A", "|", "B" to "/bin/bash" |
14:20:51 | FromDiscord | <sealmove> isn't execCmdEx blocking? |
14:21:32 | FromDiscord | <pyolyokh> oh yeah, it returns output as a string. |
14:21:47 | FromDiscord | <sealmove> I think only `startProcess` is non-blocking |
14:27:08 | FromDiscord | <scipio> In reply to @pyolyokh "oh yeah, it returns": Thanks for your reply. |
14:28:57 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lca |
14:29:11 | FromDiscord | <sealmove> oh smart let me try |
14:29:34 | FromDiscord | <pyolyokh> input to a command that only does something when input's exhausted is a pretty annoying use of osproc that I ran into recently |
14:31:58 | FromDiscord | <pyolyokh> particularly as the document says you're not supposed to close the handles |
14:32:17 | FromDiscord | <pyolyokh> (edit) "document" => "documention" |
14:32:19 | FromDiscord | <MadScientistCarl> Is it generally true that I have to put everything related in the same file? I can't find a good way to split up files without causing cyclic imports |
14:33:02 | FromDiscord | <pyolyokh> In reply to @MadScientistCarl "Is it generally true": yes. modules = files and being generally order-dependent has that consequence |
14:34:39 | FromDiscord | <pyolyokh> there are languages where it's very noticeably less of an issue, but it's easier to cut with the grain of Nim than fight it |
14:35:35 | FromDiscord | <MadScientistCarl> I am putting all my types into one `types` module now |
14:35:35 | FromDiscord | <cow> In reply to @รєคɭ๓๏שє "I have the following": osproc is what you wanna use, just beware that if you don't read the output of pipes, they can fill up and pause the program that's writing to it |
14:35:59 | FromDiscord | <cow> there's an OS limit on pipe buffer size |
14:36:00 | FromDiscord | <MadScientistCarl> Then hopefully everything is in a tree now |
14:36:12 | FromDiscord | <cow> (edit) "there's an OS limit on pipe buffer size ... " added "(a few KBs)" |
14:36:25 | FromDiscord | <sealmove> In reply to @MadScientistCarl "I am putting all": yes this is the method i always use as well |
14:37:56 | * | koltrast joined #nim |
14:38:43 | FromDiscord | <cow> also, with osproc you can have the option of either giving the stdin/stdout of the nim process implicitly, or to provide your own |
14:39:21 | FromDiscord | <sealmove> with `env` parameter |
14:39:26 | FromDiscord | <sealmove> (edit) "parameter" => "parameter?" |
14:39:58 | FromDiscord | <sealmove> how do I specify the output stream of the command? |
14:40:03 | FromDiscord | <sealmove> (edit) "command?" => "process?" |
14:40:42 | FromDiscord | <pyolyokh> you don't. You either specify all parent streams or you get the output stream from the process after starting it |
14:41:58 | FromDiscord | <sealmove> yes, and if you use parent streams then you can't read output ( : |
14:42:09 | FromDiscord | <sealmove> `poParentStreams notin p.options API usage error: stream access not allowed when you use poParentStreams [AssertionDefect]` |
14:43:15 | FromDiscord | <cow> let me look at how i did it 2 years ago |
14:44:09 | FromDiscord | <pyolyokh> depending on what you're doing it might be simpler to fork osproc and ship that with your program. It's less flexible than the underlying API |
14:45:10 | FromDiscord | <pyolyokh> or, use <https://github.com/cheatfate/asynctools/tree/master/asynctools> |
14:46:11 | FromDiscord | <cow> yeah I just did osproc startProcess, and then wrote to the input stream and read from the output stream |
14:46:35 | FromDiscord | <cow> no parent streams |
14:46:43 | FromDiscord | <cow> (edit) "no parent streams ... " added "option" |
14:46:45 | FromDiscord | <sealmove> so no pipe basically? |
14:47:04 | FromDiscord | <cow> I did not need pipe |
14:47:24 | FromDiscord | <sealmove> ok i see. i didn't expect stdlib to not support this |
14:47:28 | FromDiscord | <cow> so maybe checking how osproc implements startProcess is the way? |
14:47:51 | FromDiscord | <cow> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/osproc.nim#L662 |
14:48:24 | FromDiscord | <sealmove> okay thanks |
14:53:49 | * | arkurious joined #nim |
14:55:22 | FromDiscord | <MadScientistCarl> Any ETA for Nim 2.0? |
14:58:30 | FromDiscord | <pyolyokh> sent a long message, see http://ix.io/4lcc |
15:01:05 | FromDiscord | <Phil> TIL that nimble will refuse to work properly unless your project is a git repo and you have a first commit going... huh |
15:01:17 | FromDiscord | <pyolyokh> OTOH one-word salespitches are always lies, or charitably "fake it til you make it" |
15:01:40 | FromDiscord | <pyolyokh> In reply to @Isofruit "TIL that nimble will": I'm using nimble right now in a fossil repo with no git presence. |
15:02:36 | FromDiscord | <Phil> In reply to @pyolyokh "I'm using nimble right": I kept getting shell errors in my qml-play-around project where I hadn't run git init and done a commit because it wasn't finding a HEAD |
15:02:53 | FromDiscord | <Phil> Based on that I can only assume that git is mandatory shrugs |
15:03:46 | FromDiscord | <pyolyokh> there might be some feature I haven't used yet in this one that expects it, like nimble develop, or nimble install. But fetching other stuff, building the app, running tests, that works without git |
15:04:04 | FromDiscord | <Phil> My typical workflow is using nimble tasks for basically everything |
15:04:20 | FromDiscord | <Phil> My custom build task was the one that bombed |
15:04:32 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lci |
15:05:42 | FromDiscord | <pyolyokh> shrug, that exact command works for me without git |
15:05:49 | FromDiscord | <Phil> Though I guess I got ahead of myself in stating nimble refuses to work. For me nimble tasks are roughly 80% of my nimble useage, the other 20% being install, so that bombing was annoying |
15:06:02 | FromDiscord | <Phil> Nim version 1.9.1 |
15:06:43 | FromDiscord | <pyolyokh> even with that version. |
15:07:10 | FromDiscord | <pyolyokh> well, it doesn't need a git repo, but it still uses CLI git to pull source. |
15:07:30 | FromDiscord | <pyolyokh> if you have other local dependencies that you're pulling, it probably expects those to be git repos |
15:08:35 | FromDiscord | <Phil> The only ones I had were ones that worked fine under nim 1.6.10, namely nimqml which is a gitrepo and hosted on github |
15:24:20 | FromDiscord | <MadScientistCarl> If something is not a ref object and not `var`, is it safe to assume that it is immutable? |
15:24:49 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lcp |
15:31:15 | FromDiscord | <eyes> hm i am new and here to ask questions |
15:31:30 | FromDiscord | <eyes> there appears to be no help channel so i guess i am raw dogging this general chat 😳 |
15:32:21 | FromDiscord | <eyes> I am trying to figure out the correct return type for functions which return json objects defined by pmunch's ``jsonschema`` package |
15:32:54 | FromDiscord | <eyes> oh i cant make threads |
15:34:15 | FromDiscord | <Phil> In reply to @MadScientistCarl "If something is not": Yes. Even if its a ref object, often times you'll find that nim copies stuff in the heap, so chances of you passing an object somewhere, that place modifying the object and that change affecting you from the outside are low.↵As in, I couldn't construct a scenario off the top of my head where that'd be doable in any manner, you'll just get copies |
15:34:23 | FromDiscord | <pyolyokh> In reply to @MadScientistCarl "If something is not": apart from interior mutability. And object can have ref/ptr fields |
15:34:49 | FromDiscord | <Phil> In reply to @eyes "there appears to be": The "main" chat is what questions are there for |
15:35:12 | FromDiscord | <eyes> sent a code paste, see https://play.nim-lang.org/#ix=4lcq |
15:35:17 | FromDiscord | <jtv> The reference itself is immutable but the object it points to can be mutable |
15:35:21 | FromDiscord | <Phil> And you might want to avoid using threads, as I'm not sure how well those works for the folks using matrix/irc that are communicating to these channels via bridges |
15:35:32 | FromDiscord | <eyes> ah fair point |
15:35:36 | FromDiscord | <scipio> @eyes this is an extremely friendly community |
15:35:44 | FromDiscord | <scipio> Ask away |
15:36:02 | FromDiscord | <EyeCon> sent a code paste, see https://play.nim-lang.org/#ix=4lcs |
15:36:07 | FromDiscord | <EyeCon> Sorry for the wall of text |
15:36:15 | FromDiscord | <jtv> Oh, eyes, the error messages are poor, but usually that means you used 'let' and then tried to change it |
15:36:24 | FromDiscord | <jtv> 'Change the variable declaration to 'var' |
15:36:42 | FromDiscord | <eyes> oh if the types are the same? |
15:36:52 | FromDiscord | <eyes> why does the return type need to be mutable? |
15:37:33 | FromDiscord | <pyolyokh> In reply to @jtv "Oh, eyes, the error": the parameter in this case isn't a `var something`, it doesn't need to be mutable |
15:37:50 | FromDiscord | <eyes> yeah unfortunately changing to var did not fix it |
15:38:05 | FromDiscord | <eyes> here is the function |
15:38:05 | FromDiscord | <eyes> sent a code paste, see https://play.nim-lang.org/#ix=4lcu |
15:38:38 | FromDiscord | <eyes> it returns a ``JsonNode`` type defined by the ``jsonschema`` package found here https://github.com/PMunch/jsonschema |
15:39:02 | FromDiscord | <eyes> ive already tried defining the return type as JsonNode |
15:39:12 | FromDiscord | <eyes> and argument |
15:39:19 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lcv |
15:39:37 | FromDiscord | <eyes> hm okay i saw that too but im new to nim |
15:39:43 | FromDiscord | <Phil> Wouldn't it complain about ambiguous types then? |
15:39:52 | FromDiscord | <eyes> can you explain what a module is and how to be explicit about using them |
15:41:10 | FromDiscord | <eyes> In my mind, nim would have defaulted to the type definition which is actually included in that file |
15:41:10 | FromDiscord | <Phil> 1 module = 1 nim file |
15:41:18 | FromDiscord | <eyes> ah okay |
15:41:25 | FromDiscord | <pyolyokh> In reply to @eyes "can you explain what": well, `include` copies and pastes code into the current source, so types in that file are defined in the current module |
15:41:42 | FromDiscord | <pyolyokh> misusing include is how ran into this myself |
15:41:42 | FromDiscord | <eyes> yes i believe thats the intended method of using the types |
15:41:52 | FromDiscord | <eyes> here wait let me show you |
15:41:53 | FromDiscord | <pyolyokh> you're not importing the same type that other users are importing |
15:41:58 | FromDiscord | <pyolyokh> you are copy and pasting that code into the module |
15:42:11 | FromDiscord | <pyolyokh> and that code creates `differentmodule.Type` types |
15:42:19 | FromDiscord | <eyes> https://github.com/PMunch/nimlsp/blob/master/src/nimlsp.nim |
15:42:33 | FromDiscord | <eyes> this is the nimlsp code, and im also writing an lsp implementation in nim |
15:42:40 | FromDiscord | <Phil> Generally you will want to use import over include, include is for some specific edgecases on how you want to set up your code |
15:43:02 | FromDiscord | <eyes> okay hm |
15:43:17 | FromDiscord | <eyes> could you help me decipher why pmunch is using include in that link i sent? |
15:43:18 | FromDiscord | <Phil> Like when you have one massive module that must be in one file for some reason (e.g. because of private object fields) and still want to split it into smaller "sub"-modules that then comprise the full module |
15:44:25 | FromDiscord | <Phil> I can't, I don't have an understanding of the nimlsppkg that would allow me to quickly see what his technical reason for using include is |
15:44:36 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lcw |
15:44:52 | FromDiscord | <Phil> It's just useful to know that typically include can be the source of a fair bit of weird behaviour if you don't have a very exact idea of why you want it and how you want to make use of it |
15:45:13 | FromDiscord | <pyolyokh> the names in this code are a.A, b.f ... and c.A, which is a different A |
15:45:26 | FromDiscord | <Phil> Because it's not a "normal" way of importing and thus has behaviour like suddenly the same procs existing in 2 places: Your original module and the module that you just included the code in |
15:45:27 | FromDiscord | <pyolyokh> because include is just copy and pasting, not importing |
15:46:01 | FromDiscord | <eyes> okay i think i understand the implications of include better then |
15:46:17 | FromDiscord | <eyes> so if you both imported and included a module, the symbols would be defined twice and conflict |
15:46:26 | FromDiscord | <pyolyokh> they wouldn't conflict. |
15:46:30 | FromDiscord | <eyes> oh thats nice |
15:46:33 | FromDiscord | <pyolyokh> but they wouldn't be the same |
15:46:37 | FromDiscord | <eyes> wha |
15:46:43 | FromDiscord | <eyes> okay so thats the namespaces thing then |
15:46:47 | FromDiscord | <Phil> When you want to dive deeper into information hiding and private fields is imo where includes become more useful |
15:46:49 | FromDiscord | <eyes> modulename.symbol |
15:47:19 | FromDiscord | <eyes> okay so uh im going to switch to import and see if that just magically makes things work |
15:48:10 | FromDiscord | <sealmove> `re` vs `nre` ? |
15:48:45 | FromDiscord | <eyes> uh oh |
15:48:47 | FromDiscord | <eyes> ``Error: undeclared identifier: 'RequestMessage'`` |
15:49:29 | FromDiscord | <eyes> i dont think jsonscheme can be configured to export the symbols it creates |
15:49:46 | FromDiscord | <eyes> sent a code paste, see https://play.nim-lang.org/#ix=4lcy |
15:50:04 | FromDiscord | <eyes> here is where the types are defined and jsonschema does its magic |
15:50:04 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcz |
15:50:36 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lcz" => "https://play.nim-lang.org/#ix=4lcA" |
15:50:53 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lcA" => "https://play.nim-lang.org/#ix=4lcB" |
15:51:06 | FromDiscord | <eyes> okayyy |
15:52:30 | FromDiscord | <eyes> sent a code paste, see https://play.nim-lang.org/#ix=4lcC |
15:52:52 | FromDiscord | <Phil> Now the key thing to figure out is "Where does the RequestMessage type come from", skimming over it I'm not quite finding it quickly |
15:53:14 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lcD |
15:53:34 | FromDiscord | <eyes> ahh |
15:54:09 | FromDiscord | <MadScientistCarl> If I pass a `table[key]` into a `var` argument of a mutating function, will the original element be mutated? |
15:54:38 | FromDiscord | <Phil> Should be |
15:54:49 | FromDiscord | <MadScientistCarl> OK |
15:55:00 | FromDiscord | <Phil> Assuming the table is itself also a var |
15:55:29 | FromDiscord | <MadScientistCarl> is `let x, y = tuple` invalid syntax? |
15:55:49 | FromDiscord | <pyolyokh> it's not valid, but it's probably not what you want |
15:55:55 | FromDiscord | <pyolyokh> (edit) "valid," => "invalid," |
15:56:35 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lcE |
15:56:38 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcF |
15:57:54 | FromDiscord | <MadScientistCarl> Hmm, `for` loop doesn't seem to require a pair of parentheses |
15:58:05 | FromDiscord | <pyolyokh> `let (x, y) = (1, 2)` will do what you want. In general the other syntax is the same thing as `let x = thing; let y = thing`, with thing copied-and-pasted, not the same object. Analogous to `var x, y: int` |
15:58:20 | FromDiscord | <pyolyokh> yeah it doesn't. |
15:58:28 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcG |
15:59:40 | FromDiscord | <Phil> Fascinatingly, without the paranthesis, x will be the index in the seq and y will be the entire tuple entry |
16:00:30 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcI |
16:01:04 | FromDiscord | <Rika> personally i think that feature is a mistake |
16:01:26 | FromDiscord | <Phil> Yeah I was mildly confused, I thought that was precisely the reason why we have `enumerate` |
16:01:42 | FromDiscord | <Rika> enumerate came MUCH much later than pairs |
16:02:18 | FromDiscord | <Phil> Either way, I don't think I'd make much of a fuss about it, I think it's still within the realm of what's a reasonable expectation |
16:02:22 | FromDiscord | <Phil> To implicitly get an index |
16:02:53 | FromDiscord | <Phil> I'd likely prefer the enumerate version myself to be more explicit that I want to have an index, but eh |
16:03:16 | FromDiscord | <pyolyokh> go has it, odin has it. It's just Python that's too old and stodgy to have a reasonable syntax like that. |
16:03:18 | FromDiscord | <MadScientistCarl> The Nim By Example page should probably demonstrate some more advanced patterns |
16:06:38 | FromDiscord | <Phil> Something that can actually be also a nice learning experience is either making SO questions out of the stuff learned here, or making small PRs to add to the examples provided by "nim by example" |
16:07:41 | FromDiscord | <Phil> https://github.com/flaviut/nim-by-example↵This is the repo in case you're interested |
16:10:02 | FromDiscord | <eyes> this sucks |
16:10:31 | FromDiscord | <eyes> anyways i solved my problem, ``jsonschema`` doesnt support exporting, so im just using more includes so now my shit is all one big module |
16:10:56 | FromDiscord | <eyes> i could created exported aliases for everything but code duplication makes me bleh |
16:11:19 | FromDiscord | <eyes> (edit) "created" => "create" |
16:11:24 | FromDiscord | <pyolyokh> put it all in one file. the includes'll just get you later |
16:11:39 | FromDiscord | <eyes> this is possible |
16:11:44 | FromDiscord | <eyes> i live on the edge |
16:11:58 | FromDiscord | <Phil> PMunch , when you're there how were people intended to make use of `RequestMessage`? (See discussion with eyes) |
16:14:25 | Amun-Ra | (not strictly Nim related) I fixed leak in my nim code - it appears one has not to call dlclose at the end of the code ;> |
16:30:29 | * | xet7 quit (Ping timeout: 260 seconds) |
16:30:44 | FromDiscord | <MadScientistCarl> Can I reexport symbols of another module? |
16:30:54 | Amun-Ra | yes |
16:31:23 | Amun-Ra | you can export any symbols visible in the module you export from |
16:31:39 | FromDiscord | <Phil> You can also export an entire module |
16:31:40 | FromDiscord | <MadScientistCarl> Can I export every symbol? |
16:31:43 | FromDiscord | <Phil> `export <modulename>` |
16:31:52 | FromDiscord | <Phil> After importing it of course |
16:32:04 | FromDiscord | <MadScientistCarl> Does that export all symbols? |
16:32:07 | Amun-Ra | yes |
16:32:11 | FromDiscord | <auxym> all visible ones |
16:32:14 | FromDiscord | <auxym> `` |
16:32:15 | FromDiscord | <MadScientistCarl> That's great |
16:32:17 | Amun-Ra | any symbols marked with `*` |
16:32:30 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcP |
16:34:32 | FromDiscord | <Saint> What does {1: "one", 2: "two"} produce if you don't do toTable |
16:34:56 | FromDiscord | <auxym> an array of tuples |
16:35:09 | FromDiscord | <auxym> https://nim-lang.org/docs/manual.html#statements-and-expressions-table-constructor |
16:35:23 | FromDiscord | <Phil> So basically [(1, "one"), (2, "two")] |
16:35:29 | Amun-Ra | nim secret: let s = {1: "ab"}; s → [(1, "ab")]: array[0..0, (int, string)] |
16:35:37 | FromDiscord | <auxym> I didn't feel like typing it out 😛 |
16:36:18 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lcQ |
16:36:39 | FromDiscord | <auxym> !eval [(1, "one"), (2, "two")].type |
16:36:43 | NimBot | Compile failed: /usercode/in.nim(1, 25) Error: expression 'typeof([(1, "one"), (2, "two")])' is of type 'typedesc[array[0..1, (int, string)]]' and has to be used (or discarded) |
16:36:56 | FromDiscord | <auxym> (edit) "!eval ... [(1," added "echo" |
16:37:03 | FromDiscord | <auxym> !eval echo [(1, "one"), (2, "two")].type |
16:37:08 | NimBot | array[0..1, (int, string)] |
16:37:37 | FromDiscord | <Saint> In reply to @auxym "an array of tuples": Oh thank you! |
16:37:53 | FromDiscord | <Saint> In reply to @Isofruit "You can figure that": Do you use a nim REPL at all? I saw one but didn't seem like it was being maintained |
16:38:07 | FromDiscord | <Phil> For quick stuff I use inim |
16:38:17 | Amun-Ra | "nim secret" is poor man's repl |
16:38:27 | FromDiscord | <Phil> It's not a "true" repl, the closest thing is nim secret, but that only works with a subset of nim |
16:38:33 | FromDiscord | <Phil> Basically the part of nim that can work at compiletime |
16:39:08 | FromDiscord | <rakgew> I like inim |
16:39:29 | FromDiscord | <rakgew> I would love it it was closer to what ptpython offers |
16:41:35 | FromDiscord | <rakgew> like multi line repeats and edits, doc strings, colored syntax highlighting, saving repl sessions into files.. |
16:42:38 | FromDiscord | <rakgew> using inim with tcc I found to be a nice upgrade, though. |
16:43:21 | * | xet7 joined #nim |
16:43:42 | FromDiscord | <Saint> In reply to @rakgew "I like inim": I'l check it out thanks! |
17:11:34 | FromDiscord | <Yasuke> sent a code paste, see https://play.nim-lang.org/#ix=4ld2 |
17:11:55 | FromDiscord | <Yasuke> (edit) "https://play.nim-lang.org/#ix=4ld2" => "https://play.nim-lang.org/#ix=4ld3" |
17:17:39 | * | rockcavera joined #nim |
17:37:14 | FromDiscord | <hmmm> sent a code paste, see https://play.nim-lang.org/#ix=4lda |
17:41:03 | FromDiscord | <Saint> Is there a way to concat two tables? |
17:43:52 | FromDiscord | <Rika> In reply to @hmmm "broskis shouldn't be possible": Not functions with no arguments |
17:44:11 | FromDiscord | <Rika> Otherwise it would be indistinguishable from functions you want to pass as values |
17:45:53 | FromDiscord | <hmmm> ah I see |
17:45:54 | FromDiscord | <hmmm> ty rika |
17:47:31 | FromDiscord | <MadScientistCarl> Hmm, does `cligen` not support positional arguments? |
17:51:41 | FromDiscord | <MadScientistCarl> Also, where's argv? I see paramStr, but that is returning the i-th parameter |
17:52:04 | FromDiscord | <⚶ Zeno> make ur own `sys.argv` |
17:52:07 | FromDiscord | <⚶ Zeno> theres paramCount iirc |
17:52:25 | FromDiscord | <pyryrin> why isn't `cdecl` nim default calling convention? whats wrong with iit? |
17:52:30 | FromDiscord | <MadScientistCarl> Yeah, but I am trying to use `std/parseopt` here. The doc never explains how to get the arguments in the first place |
17:52:36 | FromDiscord | <⚶ Zeno> oh |
17:52:40 | FromDiscord | <⚶ Zeno> idk about that |
17:56:39 | FromDiscord | <MadScientistCarl> OK, `initOptParser` gets it if no cmdline is specified. |
17:57:22 | FromDiscord | <kots> see also os.commandLineParams: https://nim-lang.org/docs/os.html#commandLineParams |
18:03:46 | FromDiscord | <kots> sent a code paste, see https://play.nim-lang.org/#ix=4ldl |
18:04:46 | FromDiscord | <Saint> How do I add/merge to a Json obj/node? |
18:05:02 | FromDiscord | <Saint> This doesn't seem to be working |
18:05:04 | FromDiscord | <Saint> sent a code paste, see https://play.nim-lang.org/#ix=4ldm |
18:05:06 | FromDiscord | <Saint> payload is a json object |
18:05:19 | FromDiscord | <Saint> sent a code paste, see https://play.nim-lang.org/#ix=4ldn |
18:11:36 | * | SinfulSorrow joined #nim |
18:18:48 | FromDiscord | <Saint> Or rather is there a shortcut for a newJstring? |
18:28:19 | FromDiscord | <ShalokShalom> @Phil What do you think of Nextcloud? |
18:28:45 | FromDiscord | <badmachine> I know nim is snake and underscore insensitive - but is there a clear majority for either `snake_case` or `pascalCase` in the community? |
18:28:56 | FromDiscord | <badmachine> (edit) "snake" => "case" |
18:35:29 | FromDiscord | <ShalokShalom> we all want kebab-case |
18:35:39 | FromDiscord | <ShalokShalom> absolute majority, its not even close 😄 |
18:35:51 | FromDiscord | <leetnewb> In reply to @ShalokShalom "<@180601887916163073> What do": Not phil obviously, but that's a very broad question! |
18:36:09 | FromDiscord | <ShalokShalom> yep |
18:36:28 | FromDiscord | <ShalokShalom> I am broad today 😋 |
18:37:05 | FromDiscord | <Saint> In reply to @ShalokShalom "we all want kebab-case": whats the advantage of kebab-case? |
18:37:20 | FromDiscord | <Saint> Is it word boundaries in vim for example? |
18:37:54 | FromDiscord | <badmachine> I think it's a joke, a hyphen would be parsed and the minus operator |
18:38:00 | FromDiscord | <badmachine> (edit) "and" => "as" |
18:38:22 | FromDiscord | <ShalokShalom> i just think it looks good |
18:38:26 | FromDiscord | <ShalokShalom> personal preference |
18:38:29 | FromDiscord | <Saint> I don't think it's ajoke |
18:38:30 | FromDiscord | <ShalokShalom> readable |
18:38:46 | FromDiscord | <ShalokShalom> yeah, I imagine it could fail in Nim |
18:38:54 | FromDiscord | <ShalokShalom> I dont write Nim code, only hang out here 😄 |
18:39:48 | FromDiscord | <ShalokShalom> not so case insensitive, what? 🤪 |
18:39:53 | FromDiscord | <badmachine> In reply to @badmachine "I know nim is": Well if someone has a real answer that would be nice |
18:40:16 | FromDiscord | <ShalokShalom> I see a lot of camelCase |
18:40:20 | FromDiscord | <ShalokShalom> PascalCase is like taht |
18:40:25 | FromDiscord | <ShalokShalom> (edit) "taht" => "that" |
18:40:54 | FromDiscord | <ShalokShalom> But I guess its different, considered what it is |
18:41:10 | FromDiscord | <ShalokShalom> types are usually single words and capitalised |
18:44:50 | FromDiscord | <exelotl> @badmachine the recommended style is https://nim-lang.org/docs/nep1.html |
18:45:47 | FromDiscord | <Yasuke> Anyone know how to read from a file without getting an error that it cant open the text file? would love assistance |
18:46:44 | FromDiscord | <exelotl> does the file exist, the path correct, and the program has permission to read it? |
18:47:37 | FromDiscord | <MadScientistCarl> How do I specify types in `@[]`? |
18:50:01 | FromDiscord | <Yasuke> In reply to @exelotl "does the file exist,": yeah its a readable file. same location. even just a↵ var book = open("book.txt") ↵with a text file in that location causes that "cannot open" error. is there some special way I have to compile it when reading from a file? |
18:50:22 | FromDiscord | <exelotl> sent a long message, see http://ix.io/4ldC |
18:50:45 | FromDiscord | <MadScientistCarl> What about empty sequence? |
18:54:33 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=4ldD |
18:54:44 | * | SinfulSorrow quit (Quit: Leaving) |
18:56:09 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=4ldE |
18:56:32 | FromDiscord | <badmachine> In reply to @exelotl "<@147474779627192320> the recommended style": thanks, looks like it's psscal case |
18:57:23 | FromDiscord | <Yasuke> In reply to @exelotl "you shouldn't have to": https://media.discordapp.net/attachments/371759389889003532/1063894614106447922/image.png |
18:58:59 | FromDiscord | <exelotl> well, PascalCase for types, unprefixed enums, and constants if you feel like it. camelCase for everything else |
18:59:21 | FromDiscord | <exelotl> (edit) "enums," => "enum values," |
19:00:59 | FromDiscord | <exelotl> In reply to @Yasuke "": what is the location of test.txt ? |
19:02:08 | * | xet7 quit (Ping timeout: 246 seconds) |
19:02:08 | FromDiscord | <Yasuke> its the same location as the nim file |
19:02:41 | FromDiscord | <Yasuke> oh my mother goose. wait a minute |
19:03:08 | FromDiscord | <Saint> Isn't there a way to do the tostring after the variable name? |
19:03:11 | FromDiscord | <Yasuke> wait so my....cmd has to be in the same location as the file??? |
19:03:23 | FromDiscord | <Yasuke> and not just the nim file itself? |
19:03:24 | FromDiscord | <Lord Hellgrim The Infinite> sent a long message, see http://ix.io/4ldG |
19:03:41 | FromDiscord | <exelotl> yes, you have to `cd Documents` |
19:03:48 | FromDiscord | <Lord Hellgrim The Infinite> In reply to @Lord Hellgrim The Infinite "When I follow the": Shouldn't the version be 2.0.0, not 1.9.1? |
19:03:50 | FromDiscord | <Yasuke> https://tenor.com/view/key-and-peele-son-of-abitch-upset-gif-4276606 |
19:04:00 | FromDiscord | <Yasuke> oof |
19:04:30 | FromDiscord | <Phil> In reply to @ShalokShalom "<@180601887916163073> What do": Nothing really, I don't use cloud services wherever I can avoid it. |
19:04:42 | FromDiscord | <exelotl> once your current working directory is correct, you don't even need to pass the full path of the nim file, you can just `nim c -r testStuff.nim` |
19:04:46 | FromDiscord | <ShalokShalom> Self setup |
19:04:54 | FromDiscord | <ShalokShalom> Also this? |
19:05:11 | FromDiscord | <ShalokShalom> Like, you only deploy static websites? |
19:05:38 | FromDiscord | <Yasuke> In reply to @exelotl "once your current working": thanks.... i guess since its gotta compile that makes since. im so used to python. never had this problem. literallly have had it the last few hours |
19:05:39 | FromDiscord | <exelotl> In reply to @Lord Hellgrim The Infinite "Shouldn't the version be": the convention is that odd numbers is for development versions, even numbers is for release versions↵so 1.9.x is correct since 2.0 isn't released yet |
19:05:50 | FromDiscord | <Phil> In reply to @Lord Hellgrim The Infinite "Shouldn't the version be": I haven't looked into the install instructions there, but that seems like it's just the devel branch of the compiler |
19:06:01 | FromDiscord | <Phil> Which is what nim 2.0 will be very soon |
19:06:08 | FromDiscord | <Lord Hellgrim The Infinite> In reply to @exelotl "the convention is that": Thank you! |
19:06:44 | FromDiscord | <Phil> In reply to @ShalokShalom "Like, you only deploy": I have a Linode server and don't really need more... and don't really deploy any static websites other than docs, which go on github pages |
19:07:18 | FromDiscord | <Saint> how to I use a method on a toString of an object? |
19:07:22 | FromDiscord | <ShalokShalom> you sounded like a full fledged web dev |
19:07:31 | FromDiscord | <Saint> Like on the string value of it, I thought there was some way to call $ after the var name |
19:07:40 | FromDiscord | <Phil> In reply to @Saint "how to I use": ($obj).method |
19:07:54 | FromDiscord | <Phil> In reply to @ShalokShalom "you sounded like a": and? |
19:08:04 | FromDiscord | <Saint> Is that the only way @Phil ? |
19:08:16 | FromDiscord | <exelotl> In reply to @Yasuke "thanks.... i guess since": you'd probably have the same issue in Python if you did `python ./foo/bar/myscript.py` and `myscript.py` was trying to read some file that existed in the same directory as the script. |
19:08:17 | FromDiscord | <Phil> In reply to @Saint "Is that the only": myproc($obj) |
19:08:40 | FromDiscord | <Phil> due to method call syntax these two ways are equivalent.↵Also myproc $obj |
19:09:08 | FromDiscord | <Saint> Oh okay |
19:09:17 | FromDiscord | <Saint> Theres no like obj.$().myproc |
19:09:17 | FromDiscord | <Yasuke> In reply to @exelotl "you'd probably have the": well I do that all the time. as long as I can call the python script from wherever I am, it grabs the file as long as its in the same location. which is why i was stumped |
19:09:24 | FromDiscord | <Saint> I thought I remembered something like that |
19:09:53 | FromDiscord | <exelotl> In reply to @Yasuke "well I do that": oh, that's surprising to me haha |
19:09:56 | FromDiscord | <Phil> That coooouuuuld work as well, actual symbols like `$`may behave weirdly though |
19:10:10 | FromDiscord | <ShalokShalom> In reply to @Isofruit "and?": web devs deploy to the web 😅 |
19:10:20 | FromDiscord | <Saint> Btw also is there a difference between tuples made with () vs {} |
19:10:28 | FromDiscord | <Phil> In reply to @ShalokShalom "web devs deploy to": I do, just don't need more than one side project |
19:10:30 | FromDiscord | <ShalokShalom> sorry, I did get that |
19:10:40 | FromDiscord | <ShalokShalom> In reply to @Isofruit "I do, just don't": ah, I see |
19:10:53 | FromDiscord | <ShalokShalom> I thought you are working for a company too? |
19:10:59 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=4ldJ |
19:11:03 | FromDiscord | <ShalokShalom> Or did you understand, I mean only your opinion as a hobbist? |
19:11:08 | FromDiscord | <Phil> In reply to @ShalokShalom "I thought you are": I am, we deploy on premise there |
19:11:34 | FromDiscord | <ShalokShalom> Aaaah |
19:11:40 | FromDiscord | <ShalokShalom> That makes a whole lot more sense |
19:11:40 | FromDiscord | <Phil> In reply to @ShalokShalom "Or did you understand,": I was under the assumption you just wanted to have my personal opinion on nextcloud |
19:11:41 | FromDiscord | <ShalokShalom> thy |
19:11:53 | FromDiscord | <ShalokShalom> In reply to @Isofruit "I was under the": Ah, I see. No, your general 😄 |
19:11:58 | FromDiscord | <ShalokShalom> As a web expert 😛 |
19:12:34 | FromDiscord | <Phil> My general one is that I've only used Linode and have a rough idea of AWS since we use them for image hosting and caching images |
19:12:52 | FromDiscord | <Phil> So can't really speak from experience |
19:12:57 | FromDiscord | <ShalokShalom> i see i see |
19:13:06 | FromDiscord | <ShalokShalom> I often overlook, how huge this space is |
19:13:10 | FromDiscord | <Phil> Generally at this point I just want any cloud provider to give me a vm I can easily manage and add volumes to on demand, ideally with a backup plan |
19:13:11 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
19:13:24 | FromDiscord | <ShalokShalom> one can literally work several years in it, and dont touch certain subjects |
19:13:43 | FromDiscord | <ShalokShalom> In reply to @Isofruit "Generally at this point": isnt that already standard? |
19:14:02 | FromDiscord | <ShalokShalom> and I meant more about the PHP codebase, and general architecture 😄 |
19:14:24 | FromDiscord | <Phil> In reply to @ShalokShalom "isnt that already standard?": Yeh, that was my way of expressing that I don't want any pre-built stuff because that means I have to learn whatever custom stuff they built |
19:14:43 | FromDiscord | <Phil> Which would bring me no benefit for other providers |
19:15:01 | FromDiscord | <Phil> Which is particularly why I like the Linode server - it's just vanilla |
19:15:30 | FromDiscord | <Phil> I can do a whole lot more with it if I want to, but I can also just have it as a Debian machine that I configure my own docker images to run on |
19:15:40 | * | xet7 joined #nim |
19:15:41 | * | xet7 quit (Remote host closed the connection) |
19:15:54 | FromDiscord | <sealmove> how well does nim support mongodb? |
19:15:54 | FromDiscord | <Phil> In reply to @ShalokShalom "I often overlook, how": In terms of the amount of technologies to do the jobs its somewhat insane |
19:16:08 | FromDiscord | <Phil> Couldn't tell you, haven't used the drivers. There are packages though |
19:16:17 | * | xet7 joined #nim |
19:16:39 | FromDiscord | <Phil> And even if all they do is give you the document as a json string, with jsony together it should be fairly smooth sailing |
19:16:41 | FromDiscord | <sealmove> i am looking at nimongo, it has 100 stars... if someone has experience please comment :) |
19:18:37 | FromDiscord | <Phil> I kinda want to summon the desire to code since I have a couple spare hours finally, but I'm just really not feeling it. QML luckily isn't that hard to get into, but it would require like a concentrated week or so to dive into and I kinda can't summon the passion for anything that big right now |
19:19:43 | FromDiscord | <ShalokShalom> In reply to @รєคɭ๓๏שє "i am looking at": something with such a name.. can it even be a failure? 😄 |
19:20:20 | FromDiscord | <ShalokShalom> In reply to @Isofruit "I kinda want to": Yeah, I can see that. The QT Widget bindings do look good actually |
19:20:29 | FromDiscord | <ShalokShalom> I never considered that, cause it looks horrible in C++ |
19:20:45 | FromDiscord | <ShalokShalom> And GPU acceleration, mobile compability goes out of the window |
19:20:53 | FromDiscord | <ShalokShalom> I just really like this API |
19:21:02 | FromDiscord | <Phil> Which one? QT Widget? Or QML? |
19:22:39 | FromDiscord | <ShalokShalom> Nim Widget |
19:22:44 | FromDiscord | <ShalokShalom> QML anyway |
19:23:02 | FromDiscord | <ShalokShalom> But the connection between logic and UI seems tedious with QML |
19:46:00 | FromDiscord | <MadScientistCarl> Does anyone with experience compare Nim and Zig? |
19:48:59 | FromDiscord | <ShalokShalom> Zig is more lower level |
19:49:23 | FromDiscord | <auxym> I don't know zig in detail. Zig seems to require manual memory management, while nim, though it allows manual MM, is mostly built around automatic MM. They are both statically typed, and both have an AST-based macro system |
19:49:39 | FromDiscord | <ShalokShalom> You do a lot of stuff by hand |
19:49:40 | FromDiscord | <ShalokShalom> Also, you can use the Zig compiler to cross compile Nim code |
19:49:57 | FromDiscord | <ShalokShalom> (edit) "level" => "level↵You do a lot of stuff by hand" |
19:50:26 | FromDiscord | <MadScientistCarl> Seems like it can use C directly |
19:50:35 | FromDiscord | <ShalokShalom> https://github.com/enthus1ast/zigcc |
19:50:55 | FromDiscord | <ShalokShalom> Yeah, I think it also compiles to C? |
19:51:06 | FromDiscord | <ShalokShalom> Ah, no |
19:51:14 | FromDiscord | <ShalokShalom> I think Zigcc is just a linker |
19:51:20 | FromDiscord | <ShalokShalom> Whatever |
19:57:24 | FromDiscord | <MadScientistCarl> So in Nim, is it not possible to extend a specialized generic type? |
19:57:54 | FromDiscord | <huantian> what does that mean |
19:58:43 | FromDiscord | <MadScientistCarl> Say I have a base class A[T]. I want B to extend A[int] |
19:59:17 | FromDiscord | <MadScientistCarl> My real question, though, is to find a way to make interfaces with associated types |
20:01:22 | FromDiscord | <huantian> uhh like |
20:02:39 | FromDiscord | <ShalokShalom> @MadScientistCarl I did thought about object variants? |
20:02:54 | FromDiscord | <MadScientistCarl> Like I want an interface with function f. However, different types have a compile time decided signature |
20:03:09 | FromDiscord | <ShalokShalom> I assume they are a bit different, and still might fit your use case |
20:03:51 | FromDiscord | <huantian> In reply to @huantian "uhh like": https://play.nim-lang.org/#ix=4ldW maybe? |
20:04:12 | FromDiscord | <MadScientistCarl> sent a code paste, see https://paste.rs/E1v |
20:05:07 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4ldY |
20:05:44 | FromDiscord | <MadScientistCarl> I don't know if Nim has anything like that |
20:08:03 | FromDiscord | <ted__> In reply to @MadScientistCarl "I don't know if": A combination of what huantian posted in that nim play snippet above and object variants (https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants) which are nim's way of doing sum types, have solved most of my design cases in this area |
20:08:11 | * | jjido joined #nim |
20:11:20 | FromDiscord | <eyes> https://media.discordapp.net/attachments/371759389889003532/1063913224438829157/IMG_5893.png |
20:11:31 | FromDiscord | <MadScientistCarl> I am not looking for sum type, though an absence of those is also a bit problematic for me |
20:11:32 | FromDiscord | <eyes> is anyone else annoyed by the pure pragma |
20:12:12 | madprops | sounds like some hindu philosophy thing |
20:12:20 | FromDiscord | <eyes> clutters up the scope with a ton of variables, i’ve been using nim for like five minutes and i’ve been bitten in the ass 2/3 of the times i used pure |
20:12:32 | FromDiscord | <eyes> lol yeah |
20:13:00 | FromDiscord | <eyes> In reply to @eyes "": Also i hate variable abbreviations in names |
20:13:08 | FromDiscord | <eyes> like bro do you not have autocomplete |
20:13:23 | FromDiscord | <eyes> raw vi user? |
20:13:46 | FromDiscord | <ted__> then don't use `{.pure.}` and don't use hungarian prefixes. you'll just have to deal with possible collisions in your code then |
20:14:02 | FromDiscord | <huantian> in 2.0 with overloadableEnums, we'll get the best of both worlds |
20:14:15 | FromDiscord | <eyes> overloadableEnums? |
20:14:17 | FromDiscord | <MadScientistCarl> I guess I can give the generic a try |
20:14:43 | FromDiscord | <MadScientistCarl> Wait, I don't think it does what I'd like |
20:14:46 | FromDiscord | <eyes> In reply to @ted__ "then don't use `{.pure.}`": why would not using pure cause collisions? |
20:15:00 | FromDiscord | <MadScientistCarl> What if type `A` and `B` both use the same `T`? |
20:15:57 | FromDiscord | <Saint> what does regex study do? |
20:17:43 | FromDiscord | <ted__> sent a code paste, see https://play.nim-lang.org/#ix=4le3 |
20:17:44 | FromDiscord | <MadScientistCarl> Not sure if it is a good idea to have a method with generic `T` and specialize on that |
20:19:03 | FromDiscord | <MadScientistCarl> I guess I will need to see if I can do it just with Nim's dispatching rules |
20:20:57 | FromDiscord | <ShalokShalom> In reply to @MadScientistCarl "I am not looking": https://github.com/andreaferretti/patty#constructing-variant-objects |
20:20:59 | FromDiscord | <ShalokShalom> sum types |
20:21:07 | FromDiscord | <ShalokShalom> just named and implemented Nim way |
20:21:32 | FromDiscord | <ShalokShalom> In reply to @huantian "in 2.0 with overloadableEnums,": this |
20:21:51 | FromDiscord | <MadScientistCarl> Ok, a macro. I'll try to use as much stdlib as possible when I am starting out |
20:21:55 | FromDiscord | <ShalokShalom> @MadScientistCarlNim is crude. Get used to it 😉 |
20:21:57 | FromDiscord | <ShalokShalom> Its worth |
20:22:03 | FromDiscord | <ShalokShalom> And fits you, kinda 😄 |
20:22:32 | FromDiscord | <ShalokShalom> In reply to @MadScientistCarl "Ok, a macro. I'll": This is just a shorthand for object variants with an enum attached |
20:23:07 | FromDiscord | <MadScientistCarl> If I have a thousand variants, does it take 1000x memory? |
20:24:49 | FromDiscord | <eyes> In reply to @ted__ "if you have a": okay it seems that pure does the opposite of what I thought it did? I’m not sure whats going on because I thought changing it fixed my problems |
20:25:31 | FromDiscord | <eyes> I was under the impression that pure causes an enum’s values to be accessible without prefixing the enum type |
20:25:40 | FromDiscord | <ShalokShalom> sent a code paste, see https://paste.rs/Rvr |
20:25:46 | FromDiscord | <ShalokShalom> Up is fsharp |
20:26:09 | FromDiscord | <ShalokShalom> And Discord highlighting for Nim is broken |
20:27:12 | FromDiscord | <ted__> In reply to @eyes "I was under the": `{.pure.}` encapsulates the values it contains and forces you to fully qualify the value with the containing enum type: https://nim-lang.org/docs/manual.html#pragmas-pure-pragma |
20:27:14 | FromDiscord | <ShalokShalom> (edit) |
20:27:21 | FromDiscord | <ShalokShalom> even that for ml fits it better |
20:27:23 | FromDiscord | <ShalokShalom> in my opinion |
20:28:36 | FromDiscord | <eyes> In reply to @ted__ "`{.pure.}` encapsulates the values": okay yeah i have no clues what my problems earlier were. pure is great! i have changed my mind |
20:29:06 | FromDiscord | <ShalokShalom> 💡 🧠 |
20:30:06 | FromDiscord | <MadScientistCarl> Does Nim have union types? |
20:30:16 | FromDiscord | <MadScientistCarl> I mean that it overlaps the memory |
20:30:54 | FromDiscord | <MadScientistCarl> Or is that what the case under object do? |
20:34:50 | * | kenran joined #nim |
20:36:34 | FromDiscord | <konsumlamm> that is what case objects do, yes |
20:36:47 | FromDiscord | <huantian> Yes with case under object it’ll only use the memory of the largest variant |
20:39:11 | FromDiscord | <Phil> TFW you think "async won't be so bad, you'll just need to pass a proc, easy right?" And then nim has some custom stuff that you first need to wrap your head around |
20:39:15 | FromDiscord | <cow> In reply to @MadScientistCarl "Does Nim have union": yep https://media.discordapp.net/attachments/371759389889003532/1063920251462504568/image.png |
20:39:24 | FromDiscord | <Phil> (edit) "proc," => "proc that deals with the unpacked value," |
20:39:43 | FromDiscord | <cow> (this type is an AST node for example) |
20:40:10 | FromDiscord | <cow> you should use enums to specify what types |
20:40:19 | FromDiscord | <cow> but beware, you can't have the same name in different cases |
20:40:44 | FromDiscord | <ted__> as others have said, that's what case statements are for. you can play with this a bit to see for yourself with the `sizeof` proc, here's an example: https://play.nim-lang.org/#ix=4lec |
20:42:52 | FromDiscord | <Phil> Turns out it is not quite as fancy as I thought... I hope, you just need to do the unpacking yourself via the read proc |
20:48:20 | FromDiscord | <Phil> Do you have to await with async? Doesn't that block? Or is it non-blocking? |
20:56:53 | FromDiscord | <Elegantbeef> Await doesnt block |
20:57:02 | FromDiscord | <Phil> and waitFor? |
20:57:36 | FromDiscord | <Phil> Yeah waitFor blocks, alrighty |
20:57:46 | FromDiscord | <Elegantbeef> Yes |
20:58:23 | FromDiscord | <Elegantbeef> You dont have to await a future, you can technically make the future then use a callback or `finished` on it to get the value |
20:59:09 | FromDiscord | <ShalokShalom> @jmgomez I just see the video of yours, Getting started with NimForUE on Windows and I think your voice is really well suited to make tutorials |
20:59:11 | FromDiscord | <Elegantbeef> Not that it's overly idiomatic |
20:59:20 | FromDiscord | <ShalokShalom> and everything else, where you hear a voice a long time |
20:59:47 | FromDiscord | <Phil> And "await" is supposed to... unpack a value from within a Future or sth? |
21:00:18 | FromDiscord | <Elegantbeef> Await allows giving up the cpu and is continuable |
21:00:43 | FromDiscord | <Elegantbeef> It goes "hey we can give the cpu up for this process, come back here when this future is finished" |
21:01:11 | FromDiscord | <Phil> Ah so basically await doesn't unpack anything, it just means "cpu, do other shit and only continue working on this piece of code when the future is finished. We're not unpacking, the user can do that in the followign lines of code" |
21:01:29 | FromDiscord | <Elegantbeef> Well it 'unpacks' the future since you're waiting for it |
21:01:35 | FromDiscord | <Elegantbeef> There isnt much reason to await and not unpack the future |
21:05:31 | FromDiscord | <Phil> Okay, so "await" is only for within async procs and unpacks values of a future.↵Async procs must return futures.↵Outside of async procs you cannot use await, you must use waitFor, which is blocking |
21:05:47 | FromDiscord | <Phil> Or you can use addCallback |
21:06:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lek |
21:06:11 | FromDiscord | <Elegantbeef> Or use a callback |
21:06:41 | FromDiscord | <Elegantbeef> Both are a bit faux pas |
21:07:46 | FromDiscord | <Elegantbeef> You do need to use `poll` or similar proc that gives up cpu in sync code to allow the cpu to process other logic |
21:08:01 | FromDiscord | <Saint> How do I get the first element of a table? |
21:09:48 | FromDiscord | <Elegantbeef> You use `OrderedTable` and do `for key, val in myOrderedTable.pairs: result = val` |
21:10:09 | FromDiscord | <Elegantbeef> Alternatively you question whether you need a table |
21:10:12 | FromDiscord | <MadScientistCarl> Can you define bitwise logical ops on enums? |
21:10:23 | FromDiscord | <Elegantbeef> You dont need to |
21:10:23 | FromDiscord | <jmgomez> In reply to @ShalokShalom "<@726017160115126333> I just see": My spoken english kinda sucks but I appreciate the comment 😄 |
21:10:25 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lel |
21:10:28 | FromDiscord | <Elegantbeef> You use a `set[MyEnum]` |
21:10:44 | FromDiscord | <Elegantbeef> Yea jmgomez i wasnt going to be the dick that said "It's kinda hard to understand" |
21:10:51 | FromDiscord | <MadScientistCarl> Well, what if interfacing with C |
21:11:10 | FromDiscord | <Elegantbeef> You use a `set[MyEnum]` unless the C code doesnt use contiguous enums |
21:11:24 | FromDiscord | <Elegantbeef> A `set[MyEnum]` is a bitset but 100000 times more ergonomic |
21:11:32 | FromDiscord | <Elegantbeef> And with that i'll be back in a bit |
21:11:42 | FromDiscord | <MadScientistCarl> Well, Vulkan has enum bitset |
21:12:10 | FromDiscord | <ShalokShalom> In reply to @jmgomez "My spoken english kinda": its more the tone, that is soothing and I like the English as well |
21:12:17 | FromDiscord | <ShalokShalom> there is far more worse |
21:12:27 | FromDiscord | <MadScientistCarl> So each enum is actually defined one-hot bit, and using OR on them is normal operation |
21:12:41 | FromDiscord | <Phil> In reply to @ShalokShalom "there is far more": Written like a true german in search for his breakfast mirror egg |
21:13:32 | FromDiscord | <ShalokShalom> 😅 |
21:13:58 | FromDiscord | <ShalokShalom> German English is only topped by that one from Indians. |
21:14:24 | FromDiscord | <ShalokShalom> Who ever invented Indians, thought surely "lets see how to make it the most funny, if they ever speak English" |
21:15:14 | FromDiscord | <Phil> In reply to @ShalokShalom "Who ever invented Indians,": Nothing beats people from Sachsen |
21:16:05 | FromDiscord | <ShalokShalom> A friend of mine is from Vienna |
21:16:19 | FromDiscord | <Phil> Anyway, I don't quite get why procs added with "addCallback" don't execute.↵Maybe I do have to waitFor the future in order for it to actually ever execute all its attached callbacks |
21:16:24 | FromDiscord | <ShalokShalom> And her way of talking English causes me to feel physically hurt |
21:16:53 | FromDiscord | <ShalokShalom> Its even on video |
21:16:57 | FromDiscord | <ShalokShalom> But I have mercy with you |
21:17:26 | FromDiscord | <Phil> Aaaaaand yep, you have to `waitFor` a future in order for its callback chain to get executed |
21:18:26 | FromDiscord | <Phil> So basically a future must sooner or later always end in a waitFor? |
21:19:00 | FromDiscord | <Phil> Well, or a while-loop that's also blocking as beef pointed out |
21:20:33 | FromDiscord | <jmgomez> As a side note Phil, if you use Nim as a library you could also have a exposed epol(0) via FFI and call it from that library loop. In the case of a game engine, the tick function |
21:21:21 | FromDiscord | <Phil> What benefit does that provide?↵Like, what does that give me? |
21:21:55 | FromDiscord | <jmgomez> In the particular case of the game engine being able to use await/async in the game thread |
21:22:52 | FromDiscord | <jmgomez> I guess it's applicable to UIs too |
21:23:00 | FromDiscord | <Phil> Check, I'm not going to do games so I'm likely not that much performance bound though ^^ |
21:23:24 | * | jjido quit (Quit: My laptop has gone to sleep. ZZZzzz…) |
21:23:49 | FromDiscord | <Phil> I do wonder though what the equivalent in nim is to Javascripts `then` function |
21:24:14 | FromDiscord | <Phil> `addCallback` isn't quite an equivalent because `addCallback` requires you to waitFor the future that you're adding callbacks to |
21:24:18 | FromDiscord | <Phil> There is no such requirement in JS |
21:24:20 | FromDiscord | <ShalokShalom> You mean andThen? |
21:24:24 | FromDiscord | <ShalokShalom> In functional languages |
21:24:46 | FromDiscord | <Phil> I wouldn't know, I haven't done functional and nim itself has no `andThen` proc |
21:24:47 | FromDiscord | <jmgomez> It's `await` |
21:24:53 | FromDiscord | <Phil> await only works within async procs |
21:24:59 | FromDiscord | <Phil> As far as I've seen so far |
21:25:00 | FromDiscord | <jmgomez> you can wrap it in a func |
21:25:12 | FromDiscord | <ShalokShalom> No, doesnt seem so |
21:25:15 | FromDiscord | <Phil> Which then returns a future, which itself again must be waitfor'd again |
21:25:17 | FromDiscord | <jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4lep |
21:25:27 | FromDiscord | <ShalokShalom> I just had seen Javascript |
21:25:39 | FromDiscord | <ShalokShalom> please excuse me for a second |
21:25:43 | FromDiscord | <ShalokShalom> I have to wash out my eyes |
21:27:01 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4leq |
21:27:15 | FromDiscord | <jmgomez> In reply to @Isofruit "Which then returns a": just like `then` although then is not composable, that is. Nothing stops you from doing a flatmap or merge (think of rx extensions) |
21:28:25 | FromDiscord | <jmgomez> that map gets executed, you can turn it into a then by not returning. If you call epol at somepoint it will be resolved |
21:28:28 | FromDiscord | <Phil> In nim you're always sooner or later landing in a place in your call-hierarchy where you won't have an async proc, so you can't await while still having a Futurer[T] and at that point you're either while-looping over that until its finished or you use waitFor |
21:28:50 | FromDiscord | <Phil> So the equivalent in nim always needs an additional line after the "addCallback" that does a waitfor somewhere |
21:29:11 | FromDiscord | <jmgomez> but that's just because js calls the loop internally for you |
21:29:25 | FromDiscord | <Phil> Ah so JS does the same thing but implicitly? |
21:29:39 | FromDiscord | <Phil> Or rather you never get out of the equivalent of being in an async proc |
21:29:48 | FromDiscord | <Phil> (edit) "proc" => "proc?" |
21:29:57 | FromDiscord | <jmgomez> https://developer.mozilla.org/en-US/docs/Web/JavaScript/EventLoop |
21:30:08 | FromDiscord | <Phil> Yeah EventLoop, just haven't yet connected the dots fully |
21:30:26 | FromDiscord | <Phil> Watched a pretty nice talk about it and about the different stages it has etc. |
21:37:13 | FromDiscord | <Phil> Okay so maybe I'm just tired, but this:↵> min time avg time std dv runs name↵> 23.221 ms 27.428 ms ±2.204 x179 Aldrune calls↵Basically means the proc "aldrune calls" needed an average time of 27 and a half milliseconds... right? |
21:47:03 | * | kenran quit (Remote host closed the connection) |
21:48:23 | FromDiscord | <Elegantbeef> Then Nim's bitset should work↵(@MadScientistCarl) |
21:48:57 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4lew |
21:49:03 | FromDiscord | <Elegantbeef> Whoops that should be `1 or 2 or 4` |
21:49:22 | FromDiscord | <MadScientistCarl> But can I explicitly assign which bit is which name? |
21:50:02 | FromDiscord | <Elegantbeef> Order of declaration |
21:50:14 | FromDiscord | <Elegantbeef> The ordinal value is the bit it is |
21:50:27 | FromDiscord | <MadScientistCarl> Not sure if that will actually work if I am generating from C code... |
21:50:35 | FromDiscord | <Elegantbeef> so a is bit 0 and b is bit 1 |
21:51:22 | FromDiscord | <System64 ~ Flandre Scarlet> Is it normal I still can't compile Owlkettle examples? https://media.discordapp.net/attachments/371759389889003532/1063938401356763317/message.txt |
21:51:42 | FromDiscord | <Elegantbeef> I mean if it's an ordinal enum Nim's bitset is identical to manually bitwise oring integers |
21:51:42 | FromDiscord | <Elegantbeef> Like what is your C enum definition? |
21:52:46 | FromDiscord | <Elegantbeef> If it's a contiguous enum it's fine, if it's non contiguous then you get to do `ord(myEnum) or ord(myOtherEnum)` |
21:53:14 | FromDiscord | <MadScientistCarl> Hopefully they are actually ordinal |
21:53:27 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4lex |
21:54:50 | FromDiscord | <MadScientistCarl> sent a code paste, see https://play.nim-lang.org/#ix=4ley |
21:55:18 | FromDiscord | <Elegantbeef> Yea typical shitty C enums |
21:55:52 | FromDiscord | <Phil> sent a code paste, see https://play.nim-lang.org/#ix=4lez |
21:56:15 | FromDiscord | <Phil> (edit) "https://play.nim-lang.org/#ix=4lez" => "https://play.nim-lang.org/#ix=4leA" |
21:56:24 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4leB |
21:56:33 | FromDiscord | <MadScientistCarl> The missing value is there, but below. Out of order. |
21:57:00 | FromDiscord | <Phil> But what actually happens is:↵It prints every echo once and then nothing happens, the proc body of `callAldrune` does not get executed a second time |
21:57:02 | FromDiscord | <MadScientistCarl> I can just hope that everything is at least continuous, so I can fill up holes with something like `ReservedBit10` |
21:57:14 | FromDiscord | <Elegantbeef> You could do that |
21:57:27 | FromDiscord | <Elegantbeef> I dislike these C enums, since they're just so damn annoying |
21:57:46 | FromDiscord | <MadScientistCarl> I guess distinct also works |
21:58:08 | FromDiscord | <Elegantbeef> You could also make a Nim enum to C val array |
21:58:21 | FromDiscord | <MadScientistCarl> Well, they are annoying, but have an extremely portable ABI |
22:01:13 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4leF |
22:01:14 | FromDiscord | <Elegantbeef> This is another option |
22:01:26 | FromDiscord | <Elegantbeef> When using static values it's 0 runtime cost |
22:01:50 | FromDiscord | <Elegantbeef> When using runtime values it has to iterate the set, which is cheap but it's a consideration |
22:02:14 | FromDiscord | <MadScientistCarl> Which one is the static value? |
22:02:50 | FromDiscord | <MadScientistCarl> I guess I will go for hole-filling bitsets |
22:05:00 | FromDiscord | <Elegantbeef> What? |
22:05:29 | FromDiscord | <MadScientistCarl> Like, generating bitset from enums |
22:05:45 | FromDiscord | <Elegantbeef> I mean what to the "Which one is the static value" |
22:05:57 | FromDiscord | <MadScientistCarl> You mention static values have 0 runtime cost |
22:06:11 | FromDiscord | <Elegantbeef> Yes they're compile time constants |
22:06:33 | FromDiscord | <Elegantbeef> So like `doThingThatTakesCint({TransferSrc, MidPointChromaSample})` |
22:07:39 | FromDiscord | <Elegantbeef> The last code i supplied works using static values to reduce overhead whilst giving an ergonomic API |
22:07:40 | FromDiscord | <Elegantbeef> You do have to repeat yourself though |
22:07:55 | FromDiscord | <MadScientistCarl> OK |
22:10:30 | * | krux02 joined #nim |
22:46:51 | FromDiscord | <voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4leR |
22:47:32 | FromDiscord | <voidwalker> any idea ? the cinclude dir is in that path, but minus the `/src` |
23:02:25 | * | krux02 quit (Remote host closed the connection) |
23:25:18 | FromDiscord | <voidwalker> does say ` Success: ffmpeg installed successfully.` if I choose `y`, but if I `import ffmpeg` : Error: cannot open file: ffmpeg |
23:57:58 | FromDiscord | <MadScientistCarl> Do enum types have default values? |
23:59:52 | FromDiscord | <pyolyokh> sent a code paste, see https://play.nim-lang.org/#ix=4lf6 |