<< 20-12-2022 >>

00:02:11*Lord_Nightmare joined #nim
00:28:01arkanoidis the first argument always the king of the argument army? https://play.nim-lang.org/#ix=4j4v
00:42:28FromDiscord<arkanoid> in this example here, with `convert` you mean runtime conversion, or compile time conversion
00:51:26FromDiscord<Elegantbeef> CT
00:54:13FromDiscord<arkanoid> thanks
00:55:04FromDiscord<arkanoid> can I consider a rule that the first argument in a generic function fixes the size in case multiple compatible real types are passed?↵(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
00:57:40FromDiscord<Elegantbeef> Ah typeclasses
00:57:52FromDiscord<Elegantbeef> In nim if you use a named typeclass the first bound value applies to all
00:58:09FromDiscord<Elegantbeef> If you want it not to you need to do `distinct NamedTypeClass`
00:58:48FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4j4B
01:08:09FromDiscord<Elegantbeef> I will say that feature is extremely unintiutive at first but if you ever need it it's grand 😄
01:09:19FromDiscord<auxym> also, that's an implicit generic
01:50:38FromDiscord<arkanoid> wait, what's happening here
01:52:54*wallabra joined #nim
01:55:25FromDiscord<auxym> it's basically equivalent to `proc foo[U: SomeFloat, V: SomeFloat](x: U, y: V) = ...`, I think
02:04:20*wallabra quit (Ping timeout: 272 seconds)
02:19:34*xet7 quit (Remote host closed the connection)
02:21:07*xet7 joined #nim
02:46:15*v9fk quit (Remote host closed the connection)
02:59:43FromDiscord<basilajith> Can someone kindly point me to a good resource to help me set up an environment for Nim in Emacs?
03:03:10*v9fk joined #nim
03:05:49*v9fk quit (Remote host closed the connection)
03:06:03*v9fk joined #nim
03:25:25*v9fk left #nim (#nim)
04:17:49FromDiscord<Bung> anyone here has privilege to push tag in httpbeast?
04:37:16*arkurious quit (Quit: Leaving)
06:31:54FromDiscord<ambient> is there a better way of using an int to index an array than foo[(i + foo.len) mod foo.len] ?
06:32:37FromDiscord<ambient> i basically want to use whatever integer value to limit itself inside the array indices, even negative integer values
06:36:34FromDiscord<Bung> there's `Natural = range[0 .. high(int)]`
06:36:51FromDiscord<ambient> i basically want a simple way to wrap around an array
06:38:15FromDiscord<Bung> could you elaborate more "wrap around an array"
06:39:23FromDiscord<Elegantbeef> Saturated indexing array
06:39:29FromDiscord<Elegantbeef> What you suggest is the best
06:40:23FromDiscord<ambient> sent a code paste, see https://play.nim-lang.org/#ix=4j5q
06:41:24FromDiscord<Rika> In reply to @Elegantbeef "Saturated indexing array": No they want modular
06:41:37FromDiscord<Rika> Saturated is clamp, modular is mod
06:42:20FromDiscord<Rika> https://nim-lang.org/docs/math.html#floorMod,T,T
06:42:28FromDiscord<Rika> This is akin to Python mod
06:43:44FromDiscord<Bung> I guess better give pseudo code explain what you want to do, now am confusing why topic change from array index to mod ...
06:44:27FromDiscord<Rika> He wants to index an array with an arbitrary size integer, which should be bounded back into the array size by using mod
06:44:33FromDiscord<ambient> when i have an index that goes down or up, i can just put a floorMod around it to not worry about going out of bounds
06:45:46FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4j5s
06:47:01FromDiscord<ambient> that doesn't work if index goes negative
06:47:40FromDiscord<Elegantbeef> So handle it
06:56:23FromDiscord<ezquerra> I’ve seen people (eg @ElegantBeef) mention OpenArray many times lately. What’s the deal with that? Are there changes related to that in nim 2.0?
06:59:00FromDiscord<Elegantbeef> Nope i just want people to use them
07:00:34FromDiscord<Bung> https://github.com/nim-lang/Nim/pulls?q=is%3Apr+author%3Abeef331+openarray these are the in coming changes beef made
07:05:42FromDiscord<ezquerra> In reply to @Elegantbeef "Nope i just want": Is there some doc I can read to understand them and when to use them?
07:06:52FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4j5v
07:12:16FromDiscord<Elegantbeef> Literally wherever you want either `seq` or `array` and dont care which↵(@ezquerra)
07:12:33FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#types-open-arrays
07:14:57FromDiscord<Elegantbeef> The benefit of them is you can without copying take a slice using `toOpenArray`
07:15:02NimEventerNew thread by jasonfi: Proposed method of writing filters in Nexus v2, see https://forum.nim-lang.org/t/9741
07:15:06FromDiscord<Elegantbeef> Which means without any allocating you can slice up a collection and operate on it
07:17:20FromDiscord<ezquerra> Like a “view”?
07:17:33FromDiscord<Elegantbeef> Yes but it must be consumed directly
07:17:54FromDiscord<Elegantbeef> WIthout a borrow checker you can do `myCollection.toOpenArray(3, 5)` and not copy
07:17:55FromDiscord<Elegantbeef> It's easy to get speed
07:27:04NimEventerNew thread by nospher: Converting C++ typedef to nim-lang, see https://forum.nim-lang.org/t/9742
08:56:58Amun-Rais there a switch for nim not to use mmap at all?
09:00:57Amun-Rahmm, or is there a way to provide own system/osalloc.nim or dyncalls.nim without modifying default one?
09:02:21FromDiscord<ezquerra> In reply to @Elegantbeef "Yes but it must": I don't understand what you mean by that
09:02:46FromDiscord<ezquerra> In reply to @Elegantbeef "WIthout a borrow checker": Nor what a borrow checker has to do with it?
09:03:15FromDiscord<Elegantbeef> you must feed `openArray` into a procedure
09:03:24FromDiscord<Elegantbeef> you cannot do `let a = myCollection.toOpenArray(3, 5)`
09:03:31FromDiscord<Elegantbeef> as that requires a borrow checker to be memory safe
09:06:44FromDiscord<Elegantbeef> amun-ra with `--mm:orc` or `--mm:arc` you can do `-d:useMalloc`
09:07:23FromDiscord<Elegantbeef> Otherwise you can copy what yardanico has done here https://github.com/Yardanico/mimalloc_nim
09:08:03Amun-Raah, right
09:08:15Amun-RaI only had -d=usemalloc
09:09:29Amun-RaI don't think I can override dyncall's nimLoadLibrary, nimGetProcAddr etc.
09:09:36Amun-Ra(via command line)
09:10:07FromDiscord<Elegantbeef> Well 'technically' you can use patchfile inside a nimconfigs so you kinda can
09:10:12FromDiscord<luteva> Hi!↵Is it possible to use a compiled (c/c++) library and use it within a wasm app? If yes, is there an example? I mean instead of using e.g. FFMPEG.WASM, use a precompiled version of ffmpeg and call/use it in a nim app. This app should then be compiled to wasm (using ffmpeg as a static lib) and run in a browser.
09:10:46Amun-RaElegantbeef: I didn't know such thing exist
09:10:49FromDiscord<Elegantbeef> Assuming you generated the static library for wasm it should work fine
09:11:11Amun-RaI'm targetting non-posix system
09:11:28FromDiscord<Elegantbeef> Yea amun that repo i provided replaces Nim's allocator with mimalloc using it
09:11:28FromDiscord<Elegantbeef> It's a bit hacky to do but it works
09:11:53FromDiscord<Elegantbeef> Like sdl2 and opengl work with wasm with the proper emscripten configs, but wasm ships sdl2 iirc
09:12:21Amun-RaI'll check how it's done, thanks
09:14:09FromDiscord<Elegantbeef> Two conversations at once is always fun 😄
09:14:56FromDiscord<luteva> 😖
09:14:59FromDiscord<luteva> 😄
09:16:22Amun-Rathe other way to get around that problem is to create C wrappers for mmap (it's used exctlusively with MAP_ANONYMOUS), signal, flockfile and funclockfile
09:16:28FromDiscord<Elegantbeef> Luteva you should follow https://stackoverflow.com/a/66955188
09:17:00FromDiscord<Elegantbeef> You might be able to use https://github.com/momeemt/ffmpeg.nim
09:18:31FromDiscord<Elegantbeef> Though those bindings use dynlib so you'll need to use `dynLibOverride` and make a long list of them
09:19:17FromDiscord<luteva> thx a lot @ElegantBeef
09:19:19FromDiscord<luteva> !
09:19:51FromDiscord<Elegantbeef> You obviously have to statically link all libraries you use if they're not shipped with the browser wasm runtime
09:21:28Amun-RaElegantbeef: I can't use the method used in mimmalloc
09:22:08Amun-Rahe is patching calls on compiler level, I'd have to do this on nim one
09:22:30FromDiscord<Elegantbeef> What?
09:23:44Amun-RaI'd have to modify the code in https://github.com/nim-lang/Nim/blob/devel/lib/system/dyncalls.nim#L197-L198 or provide my own dyncalls.nim
09:24:02FromDiscord<Elegantbeef> That's how patchfile would work
09:24:16FromDiscord<Elegantbeef> You'd override `dyncalls` for your own variant that doesnt have that error there
09:24:20Amun-Rahmm
09:24:41FromDiscord<Elegantbeef> https://github.com/Yardanico/mimalloc_nim/blob/master/src/main.nims#L32
09:24:41Amun-Rahmm, I missed patchFile… :/
09:26:51FromDiscord<Elegantbeef> Yea just tested it indeed works
09:27:04Amun-Rathanks, I'm blind
09:27:20FromDiscord<Elegantbeef> though it's' `patchFile("stdlib", "dyncalls", ...)` afaict
09:28:17FromDiscord<Elegantbeef> I'd also say after you get the port functioning a PR would be best 😄
09:28:53Amun-Rasure :>
09:29:06Amun-RaI have one patch for intel compiler almost ready
09:29:34Amun-Ra(missing _popcnt)
09:57:15FromDiscord<fabricio> sent a code paste, see https://play.nim-lang.org/#ix=4j6l
09:57:47FromDiscord<Rika> your iterator is not a closure
09:57:49FromDiscord<fabricio> (edit) "https://play.nim-lang.org/#ix=4j6l" => "https://play.nim-lang.org/#ix=4j6m"
09:58:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4j6n
09:59:08FromDiscord<Elegantbeef> First class iterators(closures) require opt in through `closure`, otherwise it's an inline iterator
10:00:57FromDiscord<fabricio> yeah I know but forgot to write it, I have made it a closure already
10:08:50FromDiscord<Rika> what is the issue
10:10:45FromDiscord<fabricio> oh wait nvm I think it was because I was trying to pass a closure that takes a union type to a function
10:10:52FromDiscord<fabricio> sorry for bothering
10:47:28*ltriant quit (Ping timeout: 272 seconds)
10:49:12NimEventerNew Nimble package! openai - Basic API handling for openAI, see https://github.com/ThomasTJdev/nim_openai
11:06:59*ltriant joined #nim
12:15:51FromDiscord<HitBlast> In reply to @Isofruit "If you figure something": Following yesterday's screenshot, I ran into some problems. Say I have some arrays with the `string, string` pattern but what if I want a `string, array` pattern inside it too? https://media.discordapp.net/attachments/371759389889003532/1054733868776816661/Screenshot_2022-12-20_at_6.14.34_PM.png
12:16:14FromDiscord<HitBlast> (edit) "but" => "inside the sequence. But"
12:19:28FromDiscord<Phil> sent a long message, see http://ix.io/4j71
12:19:52FromDiscord<Phil> (edit) "http://ix.io/4j71" => "https://paste.rs/VSa"
12:20:37FromDiscord<HitBlast> In reply to @Isofruit "Ahhh now you're running": Ah sho what if I could solve this problem by implementing a bunch of objects inside the sequence with the same attributes as the arrays I would've put in the first place?
12:20:42FromDiscord<HitBlast> (edit) "sho" => "so"
12:22:14FromDiscord<Phil> Could you throw out a pseudo-code example?
12:22:27FromDiscord<Phil> Doesn't have to run, I'm just not quite getting what you're thinking
12:22:40FromDiscord<Phil> So expressing that in some pseudo-code might help me
13:39:30*kenran joined #nim
13:55:50FromDiscord<0x454d505459> Just found my first ever nim code (made in 1.4.1 I think) turns it was a shell, So I guess it's comes full cirlce
13:55:54FromDiscord<0x454d505459> (edit) "cirlce" => "circle"
13:56:00*kenran quit (Remote host closed the connection)
13:56:34FromDiscord<0x454d505459> (edit) "Just found my first ever nim code (made in 1.4.1 I think) turns ... it" added "out"
13:59:13FromDiscord<luteva> @HitBlast you could also write a converter
13:59:51FromDiscord<luteva> sent a code paste, see https://play.nim-lang.org/#ix=4j7t
14:00:36FromDiscord<luteva> (edit) "https://play.nim-lang.org/#ix=4j7t" => "https://play.nim-lang.org/#ix=4j7v"
14:11:38FromDiscord<luteva> but you will then ofcourse have an object of type Ab in the seq. Not of type Bc. So if you need the type to be Bc in this case, this won't work
14:22:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4j7D
14:22:59FromDiscord<Phil> How did I manage to skirt past this for an entire year or sth
14:23:25FromDiscord<Rika> what
14:23:26FromDiscord<Rika> how
14:24:15FromDiscord<Phil> In my defense, I've never seen a language that had a keyword set aside solely for type-conversion relationships
14:26:14FromDiscord<luteva> it is nice, as you do not have the toBlabla call all over in the code!
14:26:38FromDiscord<Phil> Basically this then does implicit type conversions all over the place I take it?
14:26:41FromDiscord<Phil> God damn that's useful
14:26:57FromDiscord<Phil> Somewhat implicit magic on the other hand
14:27:20FromDiscord<Phil> But I could see that being pretty neat for some other stuff
14:28:38FromDiscord<Phil> I am honestly somewhat shocked this just has never come up while I was in this chat, I do try to at least skim what happens and I've never seen it brought up
14:29:29FromDiscord<luteva> i know that from this chat as far as i remember.... so it should be here
14:29:39FromDiscord<luteva> some time ago... can't remember
14:30:32*jmdaemon quit (Ping timeout: 252 seconds)
14:30:42FromDiscord<Phil> It is either way very useful to know there's a language standard when it comes to procs that define type conversions
14:34:07FromDiscord<luteva> @Phil here it is:↵https://discord.com/channels/371759389889003530/371759389889003532/1052196129569259520
14:34:30FromDiscord<luteva> it is basically the same, i wrote. just one week ago
14:34:58FromDiscord<luteva> (edit) "same," => "same" | "wrote." => "wrote her." | "ago" => "ago, by amadan"
14:35:06FromDiscord<luteva> (edit) "her." => "here."
14:36:41FromDiscord<ieltan> In reply to @Isofruit "It is either way": I can only find it deep inside the gigormous Nim manual (so it easily get skipped by if you're not looking explicitly for type convertions there)
14:44:29FromDiscord<luteva> yeah and the doc only says that a converter is "similar to procs". this is just why i was asking here in the chat, one week ago:↵https://discord.com/channels/371759389889003530/371759389889003532/1052195443427266600
14:45:57FromDiscord<luteva> but thanks to the community we now all know what it is 😄
14:45:59FromDiscord<ambient> If I'm doing multithreaded code I should be using --mm:orc, and for single threaded --mm:arc?
14:50:44*arkurious joined #nim
14:53:20FromDiscord<auxym> shouldn't make a difference wrt threads, the only difference is the cycle collector (in ORC)
15:15:22FromDiscord<Phil> sent a long message, see http://ix.io/4j7W
15:15:51FromDiscord<ambient> sent a code paste, see https://play.nim-lang.org/#ix=4j7X
15:17:40FromDiscord<Phil> I think the typical example is if you have a node type that can have a ref to other node types and then you have 2 nodes a and b where a references b and vice versa
15:18:39FromDiscord<Phil> Orc and refc are both pretty safe defaults
15:19:31FromDiscord<ambient> I'm just wondering how can I determine when ARC leaks memory
15:20:21FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4j7Z
15:20:44FromDiscord<ieltan> In reply to @ambient "I'm just wondering how": I think Araq mentioned a checkCycles flag or something i dont really remember
15:21:38FromDiscord<auxym> In reply to @ambient "I'm just wondering how": Araq has mentioned that it should in principle be possible to modify ORC to use it as a "cycle detector". Would be a cool feature to have in a future nim version: compile and run your program with ORC, if no cycles detected, then you are safe to use ARC.
15:22:13FromDiscord<auxym> the overhead from ORC is really not that bad though, unless you are micro-optimizing for some reason, just use ORC and be happy
15:22:33FromDiscord<ambient> sometimes my entire program is the inner loop
15:22:46FromDiscord<ambient> (doing the heavy part of the calculation)
15:23:09FromDiscord<Phil> Anyway, I wouldn't worry unless I was writing a game engine, other such high performance code or my environment was low on resources like in embeded
15:23:24FromDiscord<ieltan> If you know for sure you will have cycles just use orc
15:25:39FromDiscord<ambient> I would rather use ARC is it's not too much of a hassle to structure my program in that way if the perf improvement is more than 20%
15:26:03FromDiscord<ambient> (edit) "is" => "if"
15:29:25FromDiscord<Yepoleb> There's a guy around here who punishes people for premature optimization
15:29:30FromDiscord<Phil> Difference in philosophy, 20% speed up wouldn't be worth it to be typically if I had to start worrying about yet another thing in exchange
15:29:39FromDiscord<Phil> I support that guy
15:30:28FromDiscord<auxym> In reply to @ambient "I would rather use": benchmark it, I'd be surprised if you get 20%...
15:32:36FromDiscord<ambient> of course it's always a bunch of tradeoffs and everyone makes their own
15:33:31FromDiscord<Yepoleb> Value your time and don't waste it on decisions that don't matter
15:33:42FromDiscord<ShalokShalom> If anybody missed it
15:34:18FromDiscord<ShalokShalom> Oracle is spending huge amounts of resources
15:34:22FromDiscord<ShalokShalom> https://www.oracle.com/cloud/free/
15:34:27FromDiscord<Phil> On?
15:34:48FromDiscord<ambient> "always free" (until further notice)
15:34:50FromDiscord<ShalokShalom> 250 gig space, 4 virtual ARM cores, 2 AMD cores and 24 GB RAM
15:35:11FromDiscord<ShalokShalom> In reply to @ambient ""always free" (until further": No, there is also 100 free credits for the first 30 days
15:35:20FromDiscord<ShalokShalom> You can spend that on AI training and stuff
15:35:33FromDiscord<ShalokShalom> They try to tackle into that space
15:35:45FromDiscord<ambient> the thing about cloud services I don't like is they always have an API lock-in
15:35:51FromDiscord<ShalokShalom> And I found APEX quite interesting
15:35:58FromDiscord<ShalokShalom> Seems rather simple to build a website
15:36:02FromDiscord<ShalokShalom> https://apex.oracle.com/de/
15:36:18FromDiscord<ShalokShalom> In reply to @ambient "the thing about cloud": You host your own software?
15:36:21FromDiscord<Phil> Look, I can host my website on a shared CPU that is secretly a potato and 1gb ram and still get sub 100ms responses!↵2 CPUs is too much power!
15:36:41FromDiscord<ShalokShalom> Sure 😅
15:36:44FromDiscord<ShalokShalom> Welcome
15:37:42FromDiscord<ambient> can I set a price cap that I can be 100% sure is honored?
15:37:48FromDiscord<ambient> with AWS it's like walking on land mines
15:40:38FromDiscord<ieltan> In reply to @ShalokShalom "https://www.oracle.com/cloud/free/": Wtf lol
15:40:56FromDiscord<ieltan> thanks man
15:46:04FromDiscord<Rika> In reply to @ambient "with AWS it's like": mm i love accidentally spending 5000 bucks because i clicked the wrong thing and didnt notice until the next day
15:58:57FromDiscord<ShalokShalom> In reply to @ieltan "thanks man": Sure
15:59:18FromDiscord<ShalokShalom> In reply to @Rika "mm i love accidentally": Wow↵Actually?
15:59:35FromDiscord<Rika> not actually but ive seen people say theyve done it a
15:59:37FromDiscord<Rika> (edit) removed "a"
15:59:41FromDiscord<ShalokShalom> In reply to @ambient "can I set a": Free tier is free
15:59:49FromDiscord<ShalokShalom> You spend explicitly
16:00:02FromDiscord<Rika> i'm always scared shitless trying to navigate aws because of that
16:00:03FromDiscord<ShalokShalom> I use a prepaid credit card
16:00:14FromDiscord<ShalokShalom> So they couldn't charge me much more
16:00:18FromDiscord<ShalokShalom> Bunq or N26
16:42:58*Phytolizer joined #nim
16:56:26FromDiscord<Yepoleb> I like the second core for the background tasks↵(@Phil)
16:58:53FromDiscord<Rika> me when the rp2040 came out:
17:10:50*wallabra joined #nim
17:19:07*pro joined #nim
17:20:58*pro quit (Client Quit)
17:37:34arkanoiddo know know some examples how to create types at compile time running iterators.fieldPairs, typetraits.arity, typetraits.genericParams ?
18:03:25*pro joined #nim
18:07:26*pro left #nim (#nim)
18:12:18FromDiscord<Yandall> Hey @Phil I was starting to make something but it is really necessary to make a library for this? Or there is something I'am missing? https://media.discordapp.net/attachments/371759389889003532/1054823573681881169/image.png
18:16:23FromDiscord<Phil> sent a long message, see http://ix.io/4j8D
18:18:06FromDiscord<Phil> Ultimately the goal is less to provide a package that checks the HTML, but does so in the context of simplifying unit-tests that need to do so, so ideally it also does some of the syntax you'd otherwise need to write for said unittest for you
18:24:00FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4j8F
18:24:42FromDiscord<Phil> Or alternatively ` assertContainsElementNTimes(html, ".potato", 5)`, both are equivalent anyway
18:25:32FromDiscord<Yandall> Ok, so the idea is to create a library to help removing some boiler plate when making this types of tests
18:25:48FromDiscord<Phil> Aye, that and make it so I don't have to actually think about HTML parsing and the like
18:25:59FromDiscord<Phil> The less I have to think about that, the more I can focus on actual tests related to that
18:27:16FromDiscord<Phil> The core essence of a test related to HTML is "Do I have this element", "Does it have these attributes/classes/ids/whatever", "Do I have this text" and for all of these question the variations of "Do I have 'it' once/not at all/N times/more than N times/less than N times/more or equal to N times/less or equal to N times"
18:27:56FromDiscord<Phil> So the problem at large to solve is how can that be tested for as conveniently as possible
18:28:09FromDiscord<Phil> (edit) "conveniently" => "conveniently, concisely and accurately"
18:28:31FromDiscord<Phil> while still being easily understandable
18:35:02FromDiscord<Yandall> Got it
18:38:08FromDiscord<Phil> Don't be discouraged by it potentially being tiny (though given the various test cases I'd assume you'll end up either with >20 tiny and very simple templates or less than a dozen more complex templates that deal with multiple usecases in nice ways.↵And with you focussing on HTML at large this will be nicely testable for any server side rendering lib (and maybe client-side-rendering libs like karax as well ? I don't know enough about karax
18:38:22FromDiscord<Phil> (edit) "ways.↵And" => "ways).↵And"
18:38:58FromDiscord<Phil> (for hotdog when he shows up: Does karax pump out an HTML string somewhere or can you koax karax easily to do that for testing purposes?)
18:39:52*wallabra quit (Ping timeout: 252 seconds)
18:42:12FromDiscord<hotdog> I have been summoned 🙂
18:42:38FromDiscord<hotdog> In reply to @Isofruit "(for hotdog when he": Yes you can, you can use `$` on a VNode to get html out
18:42:57FromDiscord<hotdog> You can use this for SSR, or for testing
18:44:08FromDiscord<hotdog> To fully test a dynamic app you'd probably want to check event handlers etc in the browser, but this would work for more straightforward templating
18:48:53*wallabra joined #nim
19:11:25*krux02 joined #nim
19:42:09FromDiscord<0x454d505459> Reading the experimental features manual, somes features seems cool↵https://nim-lang.org/docs/manual_experimental.html
19:42:17FromDiscord<0x454d505459> like the concept one
19:42:46FromDiscord<0x454d505459> I don't see where I would use yet but it will for sure be usefull for someone
19:44:25FromDiscord<Phil> In reply to @0x454d505459 "I don't see where": Generics that you want to specify based on capability (e.g. are specific procs within scope for the used datatype)
19:44:37FromDiscord<0x454d505459> the manual goes far beyond my understanding lol
19:45:05FromDiscord<Phil> It's sort of kind of like duck typing in that sense, you accept any type that has a "quack" proc defined, no matter whether it's an object, or a distinct bool alias
19:45:07FromDiscord<0x454d505459> In reply to @Isofruit "Generics that you want": I understood what they are, just that I don't where I would use them im my current workflow
19:45:19FromDiscord<0x454d505459> (edit) "In reply to @Isofruit "Generics that you want": I understood what they are, just that I don't ... where" added "know"
19:45:26FromDiscord<0x454d505459> (edit) "workflow" => "way of programming"
19:46:14FromDiscord<Phil> In reply to @0x454d505459 "I understood what they": Ahhh check.↵I really like the idea and know where I'd use it, e.g. in Snorlogue to ensure "You can only use this proc with Models that have a `$` proc defined"
19:46:21FromDiscord<Phil> (edit) "In reply to @0x454d505459 "I understood what they": Ahhh check.↵I really like the idea and know where I'd use it, e.g. in Snorlogue to ensure "You can only use this proc with ... Models" added "norm"
19:47:00FromDiscord<0x454d505459> true, would be usefull in this ~~context~~ concept
19:47:41FromDiscord<Phil> 👉 👉
19:51:28*Phytolizer quit (Remote host closed the connection)
19:51:47*Phytolizer joined #nim
19:53:46FromDiscord<0x454d505459> I see strict functions may be useful to ensure memory safety in a low level environment (ig)
19:54:23FromDiscord<0x454d505459> reach end of manual
19:54:56FromDiscord<0x454d505459> the do notation seems like a fun way to write procedures
19:55:31FromDiscord<0x454d505459> though it's kinda hard to understand at first
19:59:47FromDiscord<0x454d505459> Phil (Isofruit), mind checking this crap I made with your help on running processes ? `https://github.com/0x454d505459/nimSh/blob/main/nimSh.nim`
20:16:12FromDiscord<Phil> What exactly is it doing again?
20:17:03FromDiscord<Phil> At first glance, too many in-proc comments
20:17:18FromDiscord<Phil> Doc-comments for procs are fine, making every second line a comment less so 😛
20:17:55FromDiscord<0x454d505459> In reply to @Isofruit "Doc-comments for procs are": true
20:18:05FromDiscord<0x454d505459> In reply to @Isofruit "What exactly is it": just a basic shell
20:18:28FromDiscord<0x454d505459> In reply to @Isofruit "Doc-comments for procs are": I need them to be sure I remember what I wrote
20:18:32Amun-Raand never comments that act as direct code translation
20:18:39FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4j9k
20:18:51Amun-Raplace*
20:18:57FromDiscord<0x454d505459> I would like to avoid strformat
20:19:36FromDiscord<Phil> Why? In terms of readability it blows 11 string concats out of the water
20:20:21FromDiscord<0x454d505459> If I ever need to move it in a template or anything that need to be expended I can't
20:20:29FromDiscord<0x454d505459> (edit) removed "I can't"
20:20:44FromDiscord<kaddkaka> sum all entries in seq fulfilling a predicate? what are alternatives to `sum(filterIt(it > N))` ?
20:20:58FromDiscord<auxym> In reply to @0x454d505459 "I can't If I": you can use `%` in strutils
20:21:18FromDiscord<0x454d505459> In reply to @auxym "you can use `%`": true, never thought of that
20:21:19FromDiscord<4zv4l> does anyone have an example of `aes enc/dec` in Nim with openssl ?
20:21:20FromDiscord<Phil> Strformat does not run in templates?
20:21:38FromDiscord<0x454d505459> `fmt` and `&` are macros
20:21:46FromDiscord<Phil> In reply to @kaddkaka "sum all entries in": As in, you want something that does `@[1,2,3,4] --> 10`?
20:21:53FromDiscord<0x454d505459> In reply to @0x454d505459 "`fmt` and `&` are": that's tend to not work in templates
20:22:10FromDiscord<0x454d505459> gonna fix some stuff in it ig
20:22:28FromDiscord<kaddkaka> In reply to @Isofruit "As in, you want": That doesn't capture the predicate/filter part, but yes
20:23:11FromDiscord<kaddkaka> as in `assert @[1, 2, 3, 4].sum(filterIt(it > 2)) == 7`
20:29:07FromDiscord<Phil> sent a long message, see http://ix.io/4j9q
20:29:13FromDiscord<Phil> it's in sequtils, same as filterIt
20:31:31*kenran joined #nim
20:32:11*kenran quit (Remote host closed the connection)
20:32:13FromDiscord<kaddkaka> sum seems simpler though?
20:32:35FromDiscord<kaddkaka> also, why would this approach be slower than for loop?
20:33:04FromDiscord<Phil> In reply to @kaddkaka "also, why would this": You create interim sequences and nim does not optimize those away, so you're iterating over your sequence twice
20:38:33FromDiscord<Phil> In reply to @kaddkaka "sum seems simpler though?": As for adding this stuff, I agree that sum is simpler but you asked for alternatives 😛
20:39:07FromDiscord<kaddkaka> ok 👍
20:40:00FromDiscord<Boston> If I have this UDP packet, how do I receive it in Nim https://media.discordapp.net/attachments/371759389889003532/1054860744501493780/IMG_20221220_143934.jpg
20:40:15FromDiscord<kaddkaka> `sumIt(it > N)` would have been useful and could avoid interim sequence I guess? 🤔
20:40:33FromDiscord<Phil> In reply to @kaddkaka "`sumIt(it > N)` would": Anything in sequtils shares this issue
20:40:53FromDiscord<Phil> Basically the second you are chaining operators you will be slower than just doing a single forloop
20:41:21FromDiscord<Phil> Depends on if that matters to you though
20:41:27FromDiscord<kaddkaka> In reply to @Isofruit "Basically the second you": has there been effort to "understand" the chaining and actually generate more effective output?
20:41:32FromDiscord<Phil> Because while yeah, it is "wasteful", it's also arguably more readable
20:42:50FromDiscord<Phil> Generally nim is mostly optimized towards procedural programming so typically functional-programming optimizations aren't in there
20:43:02FromDiscord<kaddkaka> I see
20:44:07FromDiscord<auxym> In reply to @Boston "If I have this": https://nim-lang.org/docs/net.html create a socket, bind, listen, accept, recv
20:45:17FromDiscord<auxym> Found a full example here: https://github.com/mashingan/nim-etc/blob/master/udp-server/server.nim
20:45:24FromDiscord<Boston> In reply to @auxym "https://nim-lang.org/docs/net.html create a socket,": Am I binding the sending address, my address or the broadcast address, source port or rec port
20:53:51FromDiscord<Boston> Copied the example exact and still not reading the packet
20:57:58FromDiscord<auxym> In reply to @Boston "Am I binding the": you are binding a local port. the client, who sends the packet, will need to send it to your IP address + the port you bound
20:58:24FromDiscord<auxym> In the same git repo there's an example of a client who sends data to that server. you could start by running these examples.
20:58:31FromDiscord<Boston> Not an option, the "client" will and always will send to the broadcast address
20:58:59FromDiscord<auxym> I've never worked with UDP broadcast, no idea how that works
21:00:05FromDiscord<Boston> I have the code in c#, but can't seem to figure out how to port it to Nim
21:00:23FromDiscord<Boston> It's easy enough to send to the broadcast address with nim
21:08:58FromDiscord<Phil> In reply to @0x454d505459 "that's tend to not": Further feedback from me will have to wait due to it being dnd time
21:09:13FromDiscord<0x454d505459> In reply to @Isofruit "Further feedback from me": no issue
21:10:43FromDiscord<0x454d505459> i'll go sleep so yeah
21:37:55FromDiscord<kaddkaka> is there anything like pythons `else:` on for loops, to run if a for loop was not `break`ed?
21:38:13FromDiscord<kaddkaka> (edit) "was" => "exhausts (was" | "`break`ed?" => "`break`ed)?"
21:41:16FromDiscord<huantian> unfortunately not
21:41:21FromDiscord<huantian> there isnt' anything built in
21:45:26FromDiscord<4zv4l> what's the equivalent of `RAND_bytes` in nim ?
21:48:50FromDiscord<huantian> https://nim-lang.org/docs/sysrand.html might be good enough
21:52:10FromDiscord<4zv4l> thanks !
21:52:17FromDiscord<4zv4l> a bit sad it returns a seq tho
21:52:27FromDiscord<4zv4l> but it's alright I guess
21:53:31FromDiscord<amadan> sent a code paste, see https://paste.rs/wH6
21:53:36FromDiscord<huantian> what format did you want your random bytes in?
21:54:36FromDiscord<kaddkaka> @amadan thanks!
21:55:32FromDiscord<huantian> if you wanted an array you can use the other overload
21:56:29*ltriant quit (Ping timeout: 246 seconds)
21:57:10FromDiscord<LazyGamer111> How can i get the libmysql.dll file?
21:58:14FromDiscord<huantian> https://nim-lang.org/download/dlls.zip
21:58:35FromDiscord<LazyGamer111> thanks
21:59:12FromDiscord<LazyGamer111> but there isnt a libmysql dll in there
21:59:32FromDiscord<huantian> oh sorry I thought you were asking for sqlite for some reason
21:59:38FromDiscord<LazyGamer111> ah np
22:01:16FromDiscord<huantian> not sure then
22:03:44FromDiscord<4zv4l> In reply to @huantian "if you wanted an": I'll check that ^^
22:04:52FromDiscord<LazyGamer111> In reply to @huantian "not sure then": i found it, for other people looking for it, it's in this with the zip https://downloads.mysql.com/archives/c-c/
22:14:25*jmdaemon joined #nim
22:15:23*sagax quit (Ping timeout: 260 seconds)
22:26:44FromDiscord<jtv> sent a code paste, see https://paste.rs/VCm
22:27:38FromDiscord<4zv4l> yeah thanks !
22:27:42FromDiscord<4zv4l> I think I am a bit lost because
22:27:47FromDiscord<4zv4l> I have issue with my key size xD
22:28:32FromDiscord<4zv4l> does it seem correct ?
22:28:33FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4j9N
22:28:53FromDiscord<vindaar> there's https://github.com/zero-functional/zero-functional for that↵(@kaddkaka)
22:31:42FromDiscord<4zv4l> when I print `iv` right after that I get↵`59161207197201192222381191972615290196164105`
22:31:50FromDiscord<4zv4l> which is 44 bytes
22:31:53FromDiscord<4zv4l> not 16
22:32:02FromDiscord<4zv4l> and seems to be only numbers
22:35:32FromDiscord<kaddkaka> In reply to @vindaar "there's https://github.com/zero-functional/zero-fun": awesome 🙂
22:38:48FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4j9R
22:39:42FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4j9S
22:40:16FromDiscord<4zv4l> it's a different number each time
22:40:44FromDiscord<kaddkaka> How can I supply a generic function like `(a, b) => (a, inc b)` to a function that expects a typed function like `(int, int) -> (int, int)`?
22:42:18FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4j9T
22:42:42FromDiscord<kaddkaka> Let me rephrase: `func dostuff(f: (int, int) -> (int, int))` how can I supply `(a, b) => (a, inc b)` to it? Do I need to explicitly type my generic?
22:42:55FromDiscord<kaddkaka> (edit) "it?" => "`f` argument?"
22:46:51FromDiscord<4zv4l> you give a proc to dostuff ?
22:47:44FromDiscord<4zv4l> I don't know much, I usually just pass `f: proc`
22:49:54*Phytolizer quit (Remote host closed the connection)
22:52:40FromDiscord<auxym> In reply to @Boston "I have the code": link the c#, maybe someone can
22:52:56FromDiscord<auxym> figure out how to port it to nim
22:53:42FromDiscord<kaddkaka> sent a code paste, see https://play.nim-lang.org/#ix=4j9W
22:55:18FromDiscord<Elegantbeef> The `->` expands `(a, b)` into `proc(a: int, b: int)`
22:55:24FromDiscord<Elegantbeef> And it only works on untyped AST
22:55:33FromDiscord<Elegantbeef> So yes `Pair` will not work
22:55:49FromDiscord<Elegantbeef> Sorry expands `(int, int)`
23:01:05FromDiscord<kaddkaka> hmm, not sure I get it, but I guess => is unusable in this case then
23:02:00FromDiscord<kaddkaka> it feels strange, since I thought `Pair` was somewhat of a synonym to `(int, int)` after the type declaration.
23:02:36FromDiscord<Elegantbeef> Sure but the `->` doesnt operate on typed ast
23:02:37FromDiscord<Elegantbeef> So all it sees is a literal named `Pair`
23:03:14FromDiscord<kaddkaka> oh, hmm
23:05:11FromDiscord<kaddkaka> so, how do I resolve this elegantly? `->` seems to be the problem, but perhaps I should just ditch the anonymous function with `=>` and name and type it?
23:05:22FromDiscord<Elegantbeef> Rewrite the `->` macro
23:06:13FromDiscord<kaddkaka> How come -> isn't already operating on typed ast? Does such a version of `->` have other limitations?
23:06:26FromDiscord<Elegantbeef> No clue i didnt implement -\>
23:06:30FromDiscord<Elegantbeef> It can work on typed ast
23:08:57FromDiscord<kaddkaka> Rewriting `->`, I have no idea if that is easy or not, feels like big task 🙈
23:09:12FromDiscord<Elegantbeef> It's really not that bad
23:14:41FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4ja0
23:14:54FromDiscord<Elegantbeef> Whoops that `noSide` pragma is pointless
23:15:13FromDiscord<Elegantbeef> The only limitation this has is you cannot define a `func` this way
23:18:15FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4ja1 but that's easy to support with a `asFunc`
23:19:07FromDiscord<Elegantbeef> It's also a simpler macro than the stdlib one
23:19:53FromDiscord<kaddkaka> To me it's bad 😂
23:20:38FromDiscord<kaddkaka> So, should that `->` be upstreamed?
23:21:24FromDiscord<Elegantbeef> No clue i dont use the arrow operators
23:24:04FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4ja2 though one can also use even more macros to add more functionality
23:24:28FromDiscord<Elegantbeef> All of this is still less complex than the stdlibs 😛
23:24:45FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/sugar.nim#L22-L53 I mostly joke
23:30:42*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
23:31:17FromDiscord<brendo-m> sent a code paste, see https://play.nim-lang.org/#ix=4ja3
23:33:27*jmdaemon joined #nim
23:35:52FromDiscord<Elegantbeef> ` header = "libaws-c-common.a",` .a isnt a header file
23:37:13FromDiscord<Elegantbeef> I've not used nimterop though so i dont knowanything else
23:44:49FromDiscord<Elegantbeef> Damn term rewriting macros now respect `noRewrite` which means we now have easy user defined linters
23:47:47FromDiscord<brendo-m> In reply to @Elegantbeef "` ": hmm maybe it's not intended to be used this way, I got the idea to use the built archive from https://github.com/nimterop/nimterop/blob/bf088be9e925fb16d664d092afad4ab6019a78c7/nimterop/build/getheader.nim#L452
23:53:57*krux02 quit (Remote host closed the connection)