<< 04-04-2021 >>

00:36:14FromDiscord<nailuj29> I'm trying to build nimkernel, and I get this error, even with the solutions on the forums `Error: system module needs: nimErrorFlag`
00:45:56*PMunch quit (Quit: leaving)
00:49:30*oculux joined #nim
00:51:44*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
00:52:05*njoseph joined #nim
01:05:31Kumoolstarting with nim, was looking at the lang manual, but... its kind of terrible, Is there anything better?
01:07:32*oculuxe joined #nim
01:07:39FromDiscord<Yardanico> it's not "terrible", but ok :)
01:07:42FromDiscord<Yardanico> check out resources at https://nim-lang.org/learn.html
01:09:18*oculux quit (Ping timeout: 240 seconds)
01:10:20FromDiscord<fenrave> Its pretty descriptive for what it is, the only complaint I'd really have is the non-descript variable names that are used.
01:10:27FromDiscord<Yardanico> manual might be "terrible" if you're just starting to learn nim, but it's not really bad
01:10:33FromDiscord<Yardanico> In reply to @fenrave "Its pretty descriptive for": PRs are always welcome :P
01:10:49FromDiscord<Yardanico> https://github.com/nim-lang/Nim/blob/devel/doc/manual.rst
01:13:07FromDiscord<fenrave> I don't have enough confidence in my ability to write documentation for nim
01:13:45Kumoolhttps://nim-lang.org/docs/manual.html#lexical-analysis-operators I was specifically checking out the operators I can use, I noticed there was a !, thought it was <not> but turns out theres a "not" ok so what does ! do? manual doesn't appear to say
01:14:32FromDiscord<Yardanico> manual is about the specification, this shows you all possible characters for operators
01:14:35FromDiscord<fenrave> like using it for !=
01:14:36FromDiscord<Yardanico> in nim you can overload almost all operators
01:15:57FromDiscord<Yardanico> I don't remember there being a `!` in Nim's stdlib, but no one stops you from overloading ! for yourself
01:16:09FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2UXm
01:16:47Kumoolso its a placeholder operator
01:17:13FromDiscord<Yardanico> there's no such thing as "placeholder" operator
01:17:20FromDiscord<Yardanico> the stdlib is no different than user code in terms of defining operators
01:17:31Kumoolso where is the documentation which actually states what is the default behavior of each operator?
01:17:50FromDiscord<Yardanico> for all the operators that are available in any empty nim file - https://nim-lang.org/docs/system.html
01:18:21FromDiscord<Yardanico> it's a long list, yes, because there's a lot of types and operators on them
01:18:44FromDiscord<Yardanico> but even if the operator is implemented as a compiler magic, it doesn't really differentiate from user operators in terms of declaration
01:20:01FromDiscord<fenrave> https://media.discordapp.net/attachments/371759389889003532/828076404822114324/unknown.png
01:20:02FromDiscord<fenrave> sent a code paste, see https://play.nim-lang.org/#ix=2UXq
01:20:11FromDiscord<fenrave> i'm not sure where else its used though
01:20:23Kumoolok, this is what I'm looking for, thanks yard
01:20:39FromDiscord<Yardanico> if you have an editor with nimsuggest support, you can usually go to definition of almost any symbol
01:20:41FromDiscord<Yardanico> including operators
01:20:58*oculuxe quit (Ping timeout: 240 seconds)
01:22:28FromDiscord<Yardanico> or just hover https://media.discordapp.net/attachments/371759389889003532/828077022496292924/unknown.png
01:31:27FromDiscord<nailuj29> In reply to @nailuj29 "I'm trying to build": can someone help me with this
01:39:11FromDiscord<Yardanico> what's your nim version?
01:39:39FromDiscord<Yardanico> but generally nimkernel's codebase is quite old, and that error is related to exception handling
01:41:26*waleee-cl quit (Quit: Connection closed for inactivity)
01:46:54FromDiscord<nailuj29> In reply to @Yardanico "what's your nim version?": https://media.discordapp.net/attachments/371759389889003532/828083174936543242/unknown.png
01:47:05FromDiscord<Yardanico> latest is 1.4.4, can you try with it?
01:47:20FromDiscord<nailuj29> i just `apt install nim` today
01:47:39FromDiscord<Yardanico> repos have older nim sometimes
01:47:41FromDiscord<Yardanico> use choosenim
01:47:57FromDiscord<nailuj29> where do i get that
01:48:20FromDiscord<Yardanico> https://github.com/dom96/choosenim
01:49:47FromDiscord<nailuj29> still get the same error
01:50:15FromDiscord<Yardanico> i doubt that you actually installed 1.4.4 and removed your old installation and added the choosenim install to $PATH in such a short time span
01:52:12FromDiscord<nailuj29> https://media.discordapp.net/attachments/371759389889003532/828084505096880138/unknown.png
01:52:40FromDiscord<nailuj29> @Yardanico
02:24:55*anoj[m] quit (*.net *.split)
02:24:55*sekao[m] quit (*.net *.split)
02:24:55*Clonkk[m] quit (*.net *.split)
02:24:55*ForumUpdaterBot quit (*.net *.split)
02:24:55*literal_ quit (*.net *.split)
02:24:55*JStoker quit (*.net *.split)
02:24:55*ormiret quit (*.net *.split)
02:25:02*literal joined #nim
02:25:02*ForumUpdaterBot joined #nim
02:25:33*ormiret joined #nim
02:27:38*sekao[m] joined #nim
02:28:07*Clonkk[m] joined #nim
02:28:13*anoj[m] joined #nim
02:33:27*JStoker joined #nim
02:51:08leorizenimkernel not working isn't too surprising
02:51:37leorizeit depends on terribly documented features (--os:standalone)
02:52:33leorizenowadays I think --os:any replaced most of --os:standalone use cases, but that stuff is terribly documented also :P
03:34:32*spiderstew joined #nim
03:35:39*spiderstew_ quit (Ping timeout: 246 seconds)
03:59:35*Jjp137 quit (Remote host closed the connection)
04:11:34*Jjp137 joined #nim
05:53:19*NimBot joined #nim
06:26:19FromDiscord<mattrb> Probably a dumb question. If I have a large array and I want to take a chunk of it as a smaller array, do I have an option other than getting the address, adding to it, then casting as the smaller array that I want to use?
06:26:46FromDiscord<mattrb> I see slices https://nim-lang.org/docs/tut1.html#advanced-types-slices↡but I also need the returned slice to be a var array
06:26:57FromDiscord<ElegantBeef> well you could make an iterator if you're iterating over it
06:27:18*beshr joined #nim
06:28:05FromDiscord<ElegantBeef> There are also experimental views that'd let them be `var` but aside from those i guess casting is the best way
06:31:07FromDiscord<mattrb> For the specific usecase, I'm making a framebuffer of 240x160 pixels. I'm filling it per scanline, so per chunk of 240. I'd like to take a given line, clear it, then write to those treating `240 row` as the 0 index, if that makes sense. Is there a nice way you can think of to implement this in Nim, or probably just take an offset of `240 row` from the address and cast as an `array[240, T]`?
06:31:29FromDiscord<mattrb> I'm just casting for now but don't love it if there's a nicer way
06:31:34FromDiscord<ElegantBeef> Oh the custom iterator could work
06:31:37FromDiscord<ElegantBeef> One second
06:36:56FromDiscord<ElegantBeef> This is one way https://play.nim-lang.org/#ix=2UY3
06:37:41FromDiscord<ElegantBeef> Oh should be `(0..<h)`
06:39:58*beshr quit (Quit: Leaving)
06:42:08*beshr joined #nim
06:45:45FromDiscord<ElegantBeef> I tend to give shitty suggestions so this silence is unnerving πŸ˜›
06:46:00FromDiscord<mattrb> Sorry, stepped afk for a sec!
06:48:51FromDiscord<mattrb> I think iterRow will definitely be useful, and I like the idea of making the buffer its own type. I won't be able to just iterate over mitems though since that's not what's driving the rendering. Not sure if that makes sense. I'll post a clip from my Crystal implementation to see if maybe that clarifies a little bit what I'm hoping to implement here
06:52:44FromDiscord<mattrb> sent a long message, see http://ix.io/2UY4
06:55:23FromDiscord<ElegantBeef> I dont follow how it's different
06:56:39FromDiscord<ElegantBeef> What does `clear` do? Write 0s?
06:56:50FromDiscord<mattrb> Yeah just write 0s
06:57:05FromDiscord<mattrb> So just the same as your `for pixel in buf.iterRow(2): pixel = 0`
06:57:07FromDiscord<ElegantBeef> And why doesn the iterator work?
06:59:49FromDiscord<ElegantBeef> Pretend i'm a big dumb dumb(cause i am one)
06:59:56FromDiscord<mattrb> The iterator works fine for clearing the row
07:00:12FromDiscord<mattrb> Haha I'm also a big dumb
07:01:06FromDiscord<mattrb> I was just thinking it'd be nice to get back an actual scanline var array. I guess that's not super relevant, it's just a small abstraction off of what I currently have
07:02:02FromDiscord<mattrb> I'd also have to update the row iterator to yield the index too, but I can just return a tuple
07:02:40FromDiscord<ElegantBeef> Yea i was just curious, but yea aside from experimental views the casting is all you can do
07:02:50FromDiscord<mattrb> I can tell I'm not being super clear haha. I think this will totally work. Maybe I just have some idea in my head for what I'd _want_ the syntax to look like, but I think this totally works
07:04:04FromDiscord<mattrb> I'll use you row iterator (thank you :)) and see how this actually comes together. I just feel like I'm making this project in a way that doesn't really conform to how Nim "should" be written so I'm trying to learn how people normally do things in Nim πŸ™‚
07:04:45FromDiscord<ElegantBeef> Well there are many ways to skin a cat
07:05:18FromDiscord<ElegantBeef> `cast` doesnt mean you're doing something wrong if you're using it properly
07:06:46FromDiscord<mattrb> sent a code paste, see https://paste.rs/0mt
07:07:05FromDiscord<ElegantBeef> I dont know i've never really had issue with many type defs
07:07:29FromDiscord<ElegantBeef> Though might cause some weird logic for the importing/logic
07:08:53FromDiscord<mattrb> On the plus side, I currently have a gba emulator written in nim that compiles to wasm and works in a browser πŸ™‚ It currently only boots like 2 roms, but nice to see that working at least
07:10:00FromDiscord<mattrb> _web dev_ https://media.discordapp.net/attachments/371759389889003532/828164480113311774/image0.jpg
07:11:46FromDiscord<ElegantBeef> Nice
07:17:39FromDiscord<ElegantBeef> Also do feel like pointing out you can make your Scanline a generic object if you really want that method of having an object
07:21:08FromDiscord<ElegantBeef> @mattrb something like this https://play.nim-lang.org/#ix=2UYg though dont know what you currently have so this might be redundant πŸ˜„
07:38:05*rockcavera quit (Killed (adams.freenode.net (Nickname regained by services)))
07:38:06*rockcavera joined #nim
07:48:01FromDiscord<mattrb> In reply to @ElegantBeef "<@!221832495367323648> something like this": This is what I'm currently looking at https://play.nim-lang.org/#ix=2UYo but I don't understand why the scanline I get back is a copy of the result.. I'm probably just misunderstanding something fundamental about nim haha
07:50:45FromDiscord<ElegantBeef> TIL you can attempt to cast to a `var T`
07:52:41FromDiscord<ElegantBeef> Ah the issue is you cannot cache a `var T` without that experimental views i keep mentioning, so it does a copy there
07:52:55FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=2UYr proves that point
08:01:04FromDiscord<mattrb> Interesting.. If I wanted effectively the functionality there, do you think it's preferred to use the experimental views or just use byaddr?
08:03:49FromDiscord<ElegantBeef> I'd probably use the ScanLine object i made earlier given the 3 options and their interactions
08:08:03FromDiscord<mattrb> Or I guess I could do this in theory https://play.nim-lang.org/#ix=2UYp
08:08:20FromDiscord<mattrb> Since the `ScanLine.start` field isn't really necessary for me
08:08:57FromDiscord<mattrb> Just returning a ptr
08:09:18FromDiscord<ElegantBeef> Yep
08:09:45FromDiscord<ElegantBeef> I dont like manual dereferencing so i'd either use `implictDeref` or custom iterators cause i'm dumb like that πŸ˜„
08:10:55FromDiscord<mattrb> What's implicitDeref?
08:10:59FromDiscord<mattrb> I wasn't able to find anything on that
08:12:01FromDiscord<ElegantBeef> Yet another experimental feature https://nim-lang.org/docs/manual_experimental.html#automatic-dereferencing
08:13:46FromDiscord<mattrb> Hmm interesting..
08:14:15FromDiscord<mattrb> Just out of curiosity, how often is it that an experimental feature gets moved to the stdlib vs trashed vs remaining experimental?
08:14:52FromDiscord<ElegantBeef> From what i've seen they tend to be built upon and made better, but i havent ever seen them move afaik
08:15:36FromDiscord<ElegantBeef> Like we have `notNil` and `strictNotNil` the latter of which is a much stricter(yes as the name implies) version and nicer to use
08:16:14FromDiscord<Rika> For loop macro moved from ex to stable
08:16:26FromDiscord<Rika> Unless it didn’t and I was lied to
08:17:45FromDiscord<ElegantBeef> Oh it's stable
08:18:14FromDiscord<ElegantBeef> It seems so much like experimental i searched the docs there for a while then thought i had a fever dream
08:18:34ForumUpdaterBotNew thread by Japplegame: Arm-none-eabi-gcc doesn't compile volatileStore, see https://forum.nim-lang.org/t/7743
08:18:45FromDiscord<mattrb> Gotcha, well maybe someday πŸ™‚ I've paid a little attention to nim for a couple of years now, but this is my first _actual_ nim project. It seemed like there was a lot to pick up when I first skimmed the docs years ago, and there always seems to be new stuff I haven't seen yet πŸ™‚
08:19:00FromDiscord<mattrb> Anyway, I'm out for the night. Thanks for all of the insight and help on everything today!
08:19:24FromDiscord<ElegantBeef> I helped? I thought i just said a bunch of silly stuff
08:19:43FromDiscord<Rika> You did you’re just hallucinating the help part
08:19:58FromDiscord<ElegantBeef> Thanks rika for being the lantern in the dark
08:20:15FromDiscord<mattrb> Haha you exposed me to a bunch of new stuff I hadn't seen before in nim, which is always useful
08:20:32FromDiscord<mattrb> And my implementation is definitely cleaner than it was before, imo
08:20:39FromDiscord<mattrb> So I'd say so
08:40:37*lritter joined #nim
08:49:13*shmorgle quit (Ping timeout: 265 seconds)
08:56:42*algun joined #nim
08:58:17*haxscramper joined #nim
09:43:01FromDiscord<G-force 4760> Hey people↡I've been trying nico and it seems an awesome library for picel art games, but a bit lacking for generative art, any p5js/processing/OPENRNDR alternative?
09:45:13FromDiscord<Rika> there are p5 bindings i believe?
09:46:01FromDiscord<G-force 4760> I tried it but got a error I could not solve πŸ˜₯
09:47:15FromDiscord<Rika> what error?
09:47:30FromDiscord<G-force 4760> createGraphics has no type
09:47:48FromDiscord<G-force 4760> the docs say that it's type Graphics, but that did not solve it
09:47:57FromDiscord<G-force 4760> (edit) "createGraphics" => "createGraphics()"
09:48:02*tane joined #nim
09:50:46FromDiscord<Rika> whats the whole error
09:53:09FromDiscord<G-force 4760> let me build it again
09:54:20FromDiscord<G-force 4760> sent a code paste, see https://play.nim-lang.org/#ix=2UYR
09:58:27FromDiscord<hamidb80> i can't install nim with `choose-nim`
09:59:03FromDiscord<hamidb80> it gives me connection error
09:59:15FromDiscord<hamidb80> after a long time waiting
10:00:41FromDiscord<Rika> sorry wait i cant check right now since my pc is fucky again rn
10:09:37*aeverr quit (Read error: Connection reset by peer)
10:09:51*aeverr joined #nim
10:18:19*algun quit (Ping timeout: 260 seconds)
10:29:05*algun joined #nim
10:29:54FromGitter<acroobat> Hi Gitter! Nim rocks.
10:30:52*Vladar joined #nim
10:48:37FromDiscord<dk> Why, yes, indeed, it does
10:51:24*natrys joined #nim
11:12:33ForumUpdaterBotNew post on r/nim by gforce4760: Error: expression has no type or is ambiguous, see https://reddit.com/r/nim/comments/mju9fq/error_expression_has_no_type_or_is_ambiguous/
11:32:38FromGitter<acroobat> Good replacement for c++
11:33:49*krux02 joined #nim
11:34:31*krux02 quit (Remote host closed the connection)
11:34:46FromGitter<acroobat> The only ugly thing is mixing `let` and `var`
11:35:40FromDiscord<Rika> ? wdym
11:35:45FromDiscord<Rika> what would ya prefer
11:36:28FromGitter<acroobat> `const` ofc
11:36:36FromGitter<acroobat> of course
11:37:09FromDiscord<Rika> const means something else already
11:37:35FromGitter<acroobat> nobody knows
11:37:43FromDiscord<Rika> and removing var would mean that setting an already made variable would be indistinguishable to creating a new variable
11:38:14FromDiscord<IDF(ardek66)> i like the `let` and `var` diferenciation
11:38:19FromDiscord<Rika> me too
11:38:23FromGitter<acroobat> everything works with `let` it is non-functional
11:38:48FromDiscord<Rika> nim is the kind of language that does not want to enforce a single style on anyone
11:39:00FromGitter<acroobat> `const` is legacy from c language
11:39:20FromGitter<acroobat> that is why python rocks more
11:39:28FromDiscord<Rika> so how do you propose compile-time variables would be created
11:39:36FromDiscord<Rika> uh
11:39:37FromDiscord<Rika> okay
11:39:38FromDiscord<IDF(ardek66)> `const` means the value is evaluated at compile-time
11:40:02FromDiscord<IDF(ardek66)> `let` means the "variable" is immutable, but it can be runtime
11:40:04FromGitter<acroobat> it is compiler's problem
11:40:25FromDiscord<Rika> what are you even saying anymore
11:40:34*arne` joined #nim
11:40:49*arne` is now known as krux02
11:41:03FromGitter<acroobat> ok
11:43:20liblq-devthe semantic differences between var, let, and const, are a common point of confusion among beginners.
11:43:41FromDiscord<Rika> that is very true
11:43:58liblq-dev`const` means that the variable's value is evaluated by the compiler during compilation, and then is used like a regular constant during runtime
11:44:58liblq-devif the compiler didn't do any constant folding, eg. having `const a = 1 + 1` and doing `echo a` produces the same code as `echo 2`
11:45:13liblq-devthe `1 + 1` is evaluated during compilation and inlined in the echo call
11:45:37liblq-devif i replaced the `const` with a `let`, the `1 + 1` would be evaluated while the program is running (ie. at runtime)
11:45:54FromGitter<acroobat> No this is limitaion of language
11:46:02liblq-devit's not a limitation
11:46:04liblq-devit's a feature
11:46:06FromGitter<acroobat> Rpython already exist
11:46:09FromGitter<acroobat> s
11:46:17liblq-devof course modern compilers are smart, and fold the constant expression `1 + 1` into `2` anyways
11:46:18FromDiscord<IDF(ardek66)> a little trolling perhaps
11:46:26FromGitter<acroobat> It has the same problems
11:47:06FromGitter<acroobat> Nim has no future without shared libraries
11:47:13FromDiscord<Rika> what are you saying
11:47:13liblq-devyeah i feel like they're trolling tbh
11:47:16FromDiscord<Rika> nim has shared libraries
11:47:17liblq-devso i'll just shut up
11:47:24FromDiscord<Rika> okay
11:47:54FromDiscord<Rika> probably some smart sentence generator given that theyre able to make sentences but is incoherent
11:53:34*algun quit (Remote host closed the connection)
11:54:00*algun joined #nim
11:56:06FromDiscord<Goel> Does Nim have Iota or something like that, to use while initializin an Enum?
11:56:14FromDiscord<Goel> (edit) "initializin" => "initializing"
11:56:48FromDiscord<Goel> (edit) "Iota" => "`Iota`"
11:56:56FromDiscord<Rika> no, why?
11:56:59FromDiscord<Rika> what does iota do
11:57:51FromDiscord<Rika> ah okay
11:58:00FromDiscord<konsumlamm> enums have a separate type in Nim, they're not just integer constants
11:58:05FromGitter<acroobat> Nim better change *COVID-19* logo
11:58:16FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=2UZI
11:58:22FromDiscord<konsumlamm> can someone kick acroobat?
11:58:22FromDiscord<Rika> if you use integers
11:58:39FromDiscord<Rika> @dom96 maybe see above?
11:59:56FromDiscord<konsumlamm> (the example still isn't defining integer constant, to be clear, they have the type `a`
11:59:59FromDiscord<konsumlamm> )
12:00:05FromDiscord<Rika> yeah
12:00:12FromDiscord<Rika> sorry about bad naming
12:00:20FromDiscord<Goel> I need to create an Enum with all the keys of a keyboard, and i wanted to create it with a full list of keys, and only initialize the first Key = 0↡and then automatically all the other following keys will be Key2 = 1 Key3 = 2
12:00:21FromDiscord<Rika> but the type is still separate from the value
12:00:29FromDiscord<Rika> yes
12:00:31FromDiscord<Rika> that will happen
12:00:39FromDiscord<Rika> as ive written above
12:01:19FromDiscord<konsumlamm> the `= 0` at the beginning is implicit afaik, so you don't need to specify any values
12:01:37FromDiscord<konsumlamm> to get the value of an enum variant you then use `ord`
12:03:18FromDiscord<Goel> Let's say i need to manutally change my 10th key to something different, so the implicit Nim counting +1 will stop i suppose. What will happen with the 11th key and so on? Does that will be implicitly be +1 again or do i need to do something? Thats why i asked about iota
12:03:30FromDiscord<Goel> (edit) "manutally" => "manually"
12:04:25FromDiscord<Rika> it will add again
12:04:32FromDiscord<Goel> (edit) "something different," => "a different value,"
12:04:46FromDiscord<Rika> so 0, 1, 2, (set here) 11, 12, 13...
12:05:12FromDiscord<Goel> Oh wow, Nim is so smart, good to know, thanks πŸ‘
12:05:41FromDiscord<konsumlamm> ~~more like Go is so dumb~~
12:06:31FromDiscord<Rika> it doesnt make sense to have it just stop all of a sudden...
12:08:25FromGitter<acroobat> Omg Andreas Rumpf is a German guy wiki (https://en.wikipedia.org/wiki/Andreas_Rumpf)
12:09:02FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2UZR
12:09:05FromDiscord<Rika> til
12:09:10FromDiscord<Rika> thats so funky holy shit
12:09:43FromDiscord<haxscramper> I tried to find a way to increase by step other than one, but seems like I need just `<new> = <prevous> + 2`
12:10:05liblq-devi'd make a macro for that
12:10:13FromDiscord<Rika> but that becomes annoying dunnit
12:10:16liblq-devin order to reduce repetition
12:10:20FromDiscord<haxscramper> we would all macro for that
12:10:37FromDiscord<Rika> what if you do `c = c.int + 1` what does that do i wonder
12:10:49liblq-devcompile error i suppose
12:11:04FromDiscord<Rika> yeah good thing at least
12:11:23FromDiscord<haxscramper> sent a code paste, see https://paste.rs/ldF
12:11:27FromDiscord<haxscramper> this might be useful actually in some cases
12:11:40liblq-dev/usercode/in.nim(6, 9) Error: undeclared identifier: 'd'
12:11:55liblq-devwhy the hell are * replaced with Β·
12:11:58liblq-dev@Yardanico
12:12:09liblq-devno it's not Β·
12:12:14liblq-devit's some invalid character
12:12:22liblq-devthe playground displays it as a red Β·
12:12:28liblq-dev
12:12:32liblq-devuh
12:19:22*krux02_ joined #nim
12:26:32FromDiscord<dom96> In reply to @konsumlamm "can someone kick acroobat?": done
12:30:48FromDiscord<clyybber> In reply to @liblq-dev "why the hell are": yeah, it's a weird quirk
12:46:07*krux02__ joined #nim
12:46:41*natrys quit (Ping timeout: 240 seconds)
12:48:17FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2UZZ
12:48:44FromDiscord<haxscramper> Wrap things in `template`
12:49:59FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2V00
12:50:05FromDiscord<haxscramper> And then `l = tryExpr(<expr>, "Hader expected")`
12:50:10FromDiscord<Unaimend> ahh good idea, Havent done any comptime programming in my life
12:50:17FromDiscord<haxscramper> `try` block can be used in expression
12:50:29FromDiscord<Unaimend> thats a really cool idea
12:50:36FromDiscord<haxscramper> https://nim-lang.org/docs/manual.html#exception-handling-try-expression
12:52:15FromDiscord<haxscramper> `{.line: instantiationInfo().}` is needed to get a better backtrace messages (IIRC by default you would get line positions that point in template definition line)
12:53:20FromDiscord<haxscramper> And `except` should probably be narrowed down to more concrete exception
12:55:14FromDiscord<Unaimend> In reply to @haxscramper "And `except` should probably": yeah
13:00:34FromDiscord<Unaimend> can I search for specific strings on git hub repos?
13:09:11*algun quit (Ping timeout: 240 seconds)
13:13:26FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2V0a
13:13:35FromDiscord<Unaimend> (edit)
13:14:29FromDiscord<Rika> reverse the order of the parameters `tryExpr(onFail: string, expr: untyped)` and use this syntax
13:14:54FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=2V0b
13:15:05FromDiscord<Unaimend> ok thx
13:15:29FromDiscord<Rika> or maybe just do `block: l = readLine(gzfs)` in the original format, idk
13:15:37FromDiscord<Rika> not sure on the second one
13:15:42FromDiscord<Rika> so just do the first one i said ig
13:16:22FromDiscord<haxscramper> In reply to @Unaimend "Could you tell me": > And then`l = tryExpr(<expr>, "Hader expected")`
13:16:48*krux02__ quit (Remote host closed the connection)
13:16:48*krux02 quit (Remote host closed the connection)
13:16:57FromDiscord<Unaimend> ahh yeah sry
13:17:07FromDiscord<Unaimend> you meantioned that you can use try as an expression
13:17:18FromDiscord<haxscramper> yes, exactly for this reason
13:17:34FromDiscord<haxscramper> Passing assignment expression will also work, because then `try` will just have
13:17:52FromDiscord<haxscramper> it inside, so nothing special happens here.
13:17:57FromDiscord<Rika> oh i thought you changed the template
13:18:21FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2V0d
13:20:04FromDiscord<dom96> There is no need for `template` here
13:20:13FromDiscord<dom96> remember, use the least powerful construct in Nim
13:20:22FromDiscord<dom96> just create a `safeReadLine` proc
13:20:39FromDiscord<dom96> that checks for exceptions and re-raises them
13:20:54FromDiscord<dom96> (maybe `safe` isn't quite the right name, but you get the idea)
13:23:09FromDiscord<Unaimend> In reply to @haxscramper "> And then`l =": but in your version the except block and the try block have to have the same result type, don't they>
13:23:13FromDiscord<Unaimend> (edit) "they>" => "they?"
13:25:03FromDiscord<haxscramper> They don't have the same return type, `except` contains `raise`, which is `{.noreturn.}` so you eiter have `l = try: <has-type> except: <is-noreturn>` or `try: <no-type> except: <is-noretirn>`
13:25:43FromDiscord<haxscramper> also i guess you might really wrap things in separate proc
13:25:45FromDiscord<haxscramper> instead of a template
13:26:03FromDiscord<Unaimend> In reply to @dom96 "remember, use the least": but but fancy features 😒 but yeah you're right
13:28:16*phatnael[m] joined #nim
13:49:47*algun joined #nim
13:53:15FromDiscord<Unaimend> Is there so good piece of documentation on how to port libraries to nim, I am always complaining about missing visualization and ui stuff maybe I shoud try to work on it myself
13:53:41FromDiscord<haxscramper> You want to wrap C/C++ library?
13:54:45FromDiscord<haxscramper> The best resource is probably a manual https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-importcpp-pragma
13:56:19*D_ quit (Ping timeout: 252 seconds)
13:57:32FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2V0o
13:57:57FromDiscord<haxscramper> For wrapping C++ operators/methods you use `importcpp`, for C API you need `importc`
13:57:57*D_ joined #nim
13:58:48*waleee-cl joined #nim
13:59:07FromDiscord<Unaimend> In reply to @haxscramper "You want to wrap": Maybe I could try to work on the ui library a little bit, not sure if thats feasible
14:00:33FromDiscord<haxscramper> https://github.com/haxscramper/hcparse/blob/master/src/hcparse/hc_typeconv.nim#L255 I might convert it into more human-readable form, but this is the core mapping between C++ and nim types
14:00:45FromDiscord<Unaimend> but its all so daunting, I have to idea were to start 😒
14:02:03FromDiscord<haxscramper> you can try using `c2nim` but in my experience it dies on every second slighly complicated C/C++ syntax construct
14:02:08FromDiscord<haxscramper> There is also nimterop
14:02:19FromDiscord<haxscramper> https://github.com/nimterop/nimterop
14:02:45FromDiscord<Unaimend> I would think that this would fail pretty hard on gui libraries and stuff like that
14:02:57FromDiscord<haxscramper> They are OOP-heavy?
14:04:07FromDiscord<Unaimend> not sure, gtk for example is only c as far as I know
14:05:15FromDiscord<haxscramper> no, I mean the library you are trying to wrap is OOP-heavy? c2nim and nimterop were designed to work on C code I think
14:05:30FromDiscord<haxscramper> > I think
14:05:40FromDiscord<nailuj29> In reply to @leorize "nowadays I think --os:any": I also tried the version that supposedly works on updated Mom, but I get the same error
14:05:55FromDiscord<haxscramper> But wrapping C++ classes very annoying, you need to do something like https://github.com/haxscramper/nimqt5/blob/7718c2f976253c68a715d042eb63fbc47ec91992/src/nimqt5/qt_quick_test/quicktest.nim#L15
14:06:04FromDiscord<Unaimend> In reply to @haxscramper "no, I mean the": yeah, I would try to wrap gtk
14:06:19FromDiscord<haxscramper> https://github.com/StefanSalewski/gintro
14:06:22FromDiscord<haxscramper> Have you seen ^
14:06:28FromDiscord<Unaimend> nope
14:07:21FromDiscord<Unaimend> In reply to @haxscramper "https://github.com/StefanSalewski/gintro": This seems promising, thanks for the tip
14:07:21FromDiscord<haxscramper> https://github.com/xflywind/awesome-nim#gui
14:08:02FromDiscord<haxscramper> wrong link. This one - https://github.com/nim-lang/Nim/wiki/Curated-Packages#gui is more up-to-date I think
14:08:31FromDiscord<Unaimend> Yeah already look an NiGui and Fidget
14:10:47FromDiscord<Unaimend> Webgui is not maintained anymore
15:21:17*krux02 joined #nim
15:21:53saemSup
15:35:30ForumUpdaterBotNew thread by Kobi: Object variants and field names, see https://forum.nim-lang.org/t/7744
15:42:52*Vladar quit (Quit: Leaving)
15:48:40FromDiscord<brainproxy> on Windows, in a context that supports ANSI colors (e.g. msys2 terminal), the compiler still doesn't give me colored output when I specify `--colors:on`
15:49:42FromDiscord<brainproxy> otoh, I do see the expected colors from code I'm compiling that makes use of the ANSI colors when writing to stdout
15:49:53FromDiscord<brainproxy> so it's just the compiler's output that isn't colored
15:56:09algunbrainproxy! Christ has risen from the dead! Bless you :)
15:57:46FromDiscord<brainproxy> Christus Resurrexit! Resurrexit Vere!
15:58:15FromDiscord<brainproxy> Χριστὸς ἀνέστη! – αΌˆΞ»Ξ·ΞΈαΏΆΟ‚ ἀνέστη!
15:58:26FromDiscord<brainproxy> In reply to @algun "brainproxy! Christ has risen": Bless you too πŸ™‚
15:59:11FromDiscord<brainproxy> (edit) "Christus Resurrexit! Resurrexit Vere! ... " added "Alleluia!"
16:00:06*drbixx[m] quit (Quit: Idle for 30+ days)
16:00:37algunCristus vincit, Cristus regnat, Cristus imperat. Amen, halleluyah.
16:00:48algun*ch
16:03:55algunbrainproxy: I'd ask you about your being here (I came here yesterday), but I think I'm just gonna bask in King's glory today, maybe some other time :)
16:04:34FromDiscord<DavidKunz> Hi, I'm trying to have a `case` statement in my macro, one of the cases should call `error` . The problem is that it doesn't satisfy the result of the case statement, is there some `unreachable` trick to overcome this problem? Minimal example: https://play.nim-lang.org/#ix=2V1d
16:05:24FromDiscord<brainproxy> In reply to @algun "<@383034029135364096>: I'd ask you": For the last ~year have been working on projects that involve Nim. Glad to explain more another time. I work for https://status.im/
16:07:17algunπŸ‘
16:08:56FromDiscord<haxscramper> In reply to @DavidKunz "Hi, I'm trying to": you need to use `{.noreturn.}` expression, like `raise`, `return`, `quit`
16:09:40FromDiscord<DavidKunz> Thank you very much, @haxscramper!
16:14:23*algun quit (Ping timeout: 260 seconds)
16:20:54*a_chou joined #nim
16:34:14*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
16:35:23*ehmry joined #nim
16:59:42*ozzz quit (Quit: Bye)
16:59:58*ozzz joined #nim
17:04:44*arecaceae quit (Remote host closed the connection)
17:08:24*arecaceae joined #nim
17:10:05FromDiscord<TurtleP> hi, so I'm trying to use this functionality in nim: <https://nim-lang.org/docs/endians.html#littleEndian32%2Cpointer%2Cpointer> but I've not used pointers before, so I'm confused how it's supposed to work. The code I'm working on is the following: <https://pastebin.com/MTmiVvgv>
17:12:47*xet7 quit (Quit: Leaving)
17:13:17*xet7 joined #nim
17:16:55*a_chou quit (Quit: a_chou)
17:17:23*a_chou joined #nim
17:30:06FromDiscord<Unaimend> In reply to @TurtleP "hi, so I'm trying": Figured it out by now?
17:30:22FromDiscord<TurtleP> no, I haven't
17:31:08FromDiscord<Unaimend> whats the problem exactly
17:37:46Oddmongeri don't understand the difference between Β« proc Β» and Β« method Β»
17:38:34Oddmongerproc : static dispatch, method : dynamic dispatch , says the manuel
17:38:40Oddmongerwhat is it ?
17:40:09FromDiscord<TurtleP> In reply to @Unaimend "whats the problem exactly": trying to understand how to use the function -- it requires pointers
17:43:08haxscramperOddmonger: if you have multiple `proc` defined with varying first arguments and then write `yourProc(<argument-1>)`, you need to determine which one will be called.
17:43:08haxscramperSo if you have `proc(a: int)` and proc(b: string)` and `a(1)` you will call first one
17:43:18haxscramperThis decision is made at compile-time
17:43:24haxscramperI.e. this is static dipatch
17:43:58haxscramperIf you have `method(o: Object1)` and `method(o: Object2)` where both objects are derived from the same base class
17:44:21haxscramperDecitions which particular `method` is called will be made at runtime
17:44:29haxscramperI.e. this is a dynamic dispatch
17:44:49Oddmongerah, it's useful when you don't know the type in advance
17:45:09haxscramperNot exactly but you can say that
17:45:32haxscramperTo be more precise - you need to use methods when you don't know which particular *subtype* the object is
17:46:01FromDiscord<konsumlamm> `method` dispatches based on the runtime type, `proc` based on the compiletime type
17:46:06haxscramperYou can call method using static dispatch too (when you need to call a method of superclass for example)
17:46:11haxscramperUsing `procCall`
17:46:59Oddmongeri get the idea
17:47:24Oddmongerthank you (i have seen that in the sample for using godot with nim)
17:49:02*a_chou quit (Quit: a_chou)
17:52:07Oddmongeri didn't find reference in the Picheta's book (at least in the index), but i've found explanations in Salewski's : http://ssalewski.de/nimprogramming.html#_object_orientated_programming_and_inheritance
17:52:27FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2V1A
17:52:39FromDiscord<TurtleP> I know how pointers in C work
17:52:50FromDiscord<TurtleP> the issue is this is in nim
17:56:23Oddmongerbut wouldn't proc with differents signature work ?
17:58:17Oddmongerok i will cogitate on that later :) Bon appΓ©tit :)’
17:59:30FromDiscord<haxscramper> In reply to @TurtleP "trying to understand how": From what I can tell it just swaps first and second arguments https://github.com/nim-lang/Nim/blob/598d9f84026400acb5cf51dd58aa7f19f50d34fa/lib/pure/endians.nim#L49, or things pointed to by arguments
17:59:44FromDiscord<haxscramper> Or something along those lines
18:00:00FromDiscord<TurtleP> I mean I'm having trouble understanding how to call the function
18:01:32FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2V1F
18:01:39FromDiscord<haxscramper> Almost like you would do it in C, except for different syntax
18:02:01FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=2V1G
18:05:43FromDiscord<TurtleP> ah
18:06:15*D_ quit (Quit: πŸ’¨)
18:08:17FromDiscord<TurtleP> although, actually.. I'm changing the endianness of a number it seems
18:08:23FromDiscord<TurtleP> not something like a pointer
18:08:27FromDiscord<TurtleP> that's what I want
18:11:53*D_ joined #nim
18:11:56FromDiscord<TurtleP> yeah, the C code is doing `local_bswap16(a)`
18:17:20*Gustavo6046 quit (Quit: ZNC 1.8.2 - https://znc.in)
18:17:53*Gustavo6046 joined #nim
18:24:05*xet7 quit (Remote host closed the connection)
18:39:07*beshr quit (Ping timeout: 268 seconds)
18:40:07*beshr joined #nim
18:47:35*krux02_ quit (Remote host closed the connection)
18:55:16*xet7 joined #nim
18:57:45FromDiscord<Yardanico> In reply to @TurtleP "although, actually.. I'm changing": you can also check out https://github.com/status-im/nim-stew/blob/master/stew/endians2.nim and https://github.com/treeform/flatty/blob/master/src/flatty/binny.nim#L110-L138
18:58:27FromDiscord<TurtleP> oh sweet, thank you @Yardanico πŸ˜„
19:14:34*algun joined #nim
19:15:41FromDiscord<TurtleP> do you know how to check the endianness of the host, by the way? seems the swap is only done on big endian machines @Yardanico
19:15:51FromDiscord<Yardanico> https://nim-lang.org/docs/system.html#cpuEndian
19:26:01FromDiscord<konsumlamm> is there any documentation on whether or not it's intended that `int8(255)` fails and `let a = 255); assert int8(a) == -1` works? or should i use `cast[int8](a)` to be sure?
19:27:21FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2V23
19:28:06FromDiscord<konsumlamm> `proc(_: string): string`
19:28:19FromDiscord<konsumlamm> or `string -> string` if you wanna import `std/sugar`
19:29:06FromDiscord<Unaimend> thx
19:37:43FromDiscord<Yardanico> In reply to @konsumlamm "`proc(_: string): string`": doesn't have to be _ though
19:37:46FromDiscord<Yardanico> can be any argument name
19:38:18FromDiscord<konsumlamm> ye, but most of the time, you don't want to explicitly name the argument
19:38:25FromDiscord<Yardanico> it doesn't matter really
19:38:32FromDiscord<Yardanico> since Nim will match all procs with same argument and return types
19:38:36FromDiscord<Yardanico> argument names don't matter
19:38:57FromDiscord<Yardanico> so it can actually be more descriptive to provide argument names even for proc types
19:39:02FromDiscord<Kiloneie> not sure if upvoting helps but, i posted on hackernews for some more traffic on my video series.↡↡https://news.ycombinator.com/item?id=26691933
19:39:07FromDiscord<Yardanico> In reply to @Kiloneie "not sure if upvoting": never link HN directly!
19:39:12FromDiscord<Kiloneie> huh ?
19:39:18FromDiscord<Yardanico> the upvotes from a direct link won't count
19:39:33FromDiscord<Recruit_main707> f
19:39:54FromDiscord<Yardanico> generally you should go to the post from HN's top or new list, and then upvote
19:40:08FromDiscord<Kiloneie> okay
19:40:22FromDiscord<Kiloneie> anyways, if upvoting helps, pretty please upvote D:
19:40:29FromDiscord<Yardanico> also you could've directly linked the youtube series
19:40:36FromDiscord<Yardanico> instead of adding it in the description
19:40:46FromDiscord<Yardanico> https://media.discordapp.net/attachments/371759389889003532/828353418422517823/unknown.png
19:40:51FromDiscord<Kiloneie> i put it in the text
19:40:58FromDiscord<Yardanico> yes, but that's a bit worse
19:41:08FromDiscord<Yardanico> it's better to link stuff directly
19:41:15FromDiscord<Kiloneie> okay
19:41:22FromDiscord<Yardanico> because if people click on the name of the post they'll be taken directly to your link
19:41:31FromDiscord<Yardanico> and to get into HN comments they'll have to press "discuss"
19:41:57FromDiscord<Kiloneie> can't edit that now it seems
19:41:59FromDiscord<Kiloneie> oh well
19:42:02FromDiscord<Kiloneie> next time
19:43:02*haxscramper quit (Remote host closed the connection)
19:44:44FromDiscord<Yardanico> also youtube links are pretty rare on HN, they prefer articles much more :)
19:45:03FromDiscord<Yardanico> or direct link to the projects/etc
19:45:07FromDiscord<Kiloneie> D: im not a blogger yet
19:45:28FromDiscord<Kiloneie> idk just tried some more advertisement
19:45:28saemd'oh, broke the vscode extension for multi-root projects it seems. :/
19:47:07FromDiscord<Kiloneie> Also put my first video on Nim on Vimeo to see if it gets any views at all, or gets people onto my channel on youtube
19:47:27FromDiscord<Kiloneie> i don't feel like adding more till i see any worth in it
19:47:36FromDiscord<Kiloneie> doesn't take much time, but still
19:48:52FromDiscord<konsumlamm> if your main goal is getting views, rather than teaching Nim, you should perhaps consider making different videos
19:49:14FromDiscord<Kiloneie> im fine with this
19:49:24FromDiscord<Kiloneie> i will experiment in due time
19:49:46FromDiscord<Kiloneie> i don't wanna enter a flooded/crowded place
19:49:55FromDiscord<Kiloneie> and i will not do clickbait
19:50:01FromDiscord<Yardanico> but you should understand that programming tutorial vids aren't exactly popular
19:50:11FromDiscord<Kiloneie> they can be
19:50:17FromDiscord<Yardanico> not really
19:50:18FromDiscord<Kiloneie> i've seen tons with millions of views
19:50:23FromDiscord<Yardanico> these are quite different
19:50:27FromDiscord<Yardanico> from normal programming tutorials
19:50:29FromDiscord<Solitude> because it was some clickbait for python
19:51:01FromDiscord<Kiloneie> no i've seen from thenewboston over a decade ago his videos are pretty crappy it's just he put them on when youtube was still young
19:51:04FromDiscord<Kiloneie> i missed that ship
19:56:00FromDiscord<Kiloneie> I do need to make more interesting videos though, not all, but some
19:58:53FromDiscord<Conifer> Actually it was @Kiloneies Nim tutorial that I randomly got from YT Algo that made me aware of Nim
20:00:32FromDiscord<Conifer> So frankly speaking, "popular" or not I don't think it matters. What should matter is the fact they exist which allows newcomers to get accustomed with the language and not be gatekeep'ed into some language for "professional programmers" or however you want to call it.
20:01:25FromDiscord<Conifer> (edit) "So frankly speaking, "popular" or not I don't think it matters. What should matter is the fact they exist which allows newcomers to get accustomed with the language and not be gatekeep'ed into some language for "professional programmers" or however you want to call it. ... " added "Any kind of publicity is a good publicity imo."
20:07:12*Gustavo6046 quit (Ping timeout: 246 seconds)
20:13:47FromDiscord<Kiloneie> Yeh, thats my goal
20:31:48*Gustavo6046 joined #nim
20:36:11*teal joined #nim
20:36:28FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2V2B
20:36:50FromDiscord<Yardanico> In reply to @Unaimend "So when I use": first of all, you don't need to wrap readdir yourself
20:36:58FromDiscord<Yardanico> https://nim-lang.org/docs/posix.html#readdir%2Cptr.DIR
20:37:07FromDiscord<Unaimend> (edit) "https://play.nim-lang.org/#ix=2V2B" => "https://paste.rs/4PG"
20:37:07FromDiscord<Yardanico> and then you generally read the docs for the C function - e.g. https://man7.org/linux/man-pages/man3/readdir.3.html
20:37:31FromDiscord<Yardanico> On success, readdir() returns a pointer to a dirent structure. (This structure may be statically allocated; do not attempt to free(3) it.)
20:37:33FromDiscord<Unaimend> In reply to @Yardanico "https://nim-lang.org/docs/posix.html#readdir%2Cptr.": thats what I am using
20:37:59FromDiscord<Unaimend> In reply to @Yardanico "**On success, readdir() returns": hmm thx, how would I free it if I had to?
20:38:08FromDiscord<Yardanico> free(x)
20:38:15FromDiscord<Yardanico> I mean, it depends
20:38:32FromDiscord<Yardanico> there's nothing special about "freeing" stuff from the C side
20:38:52FromDiscord<Yardanico> you either use specialized functions for freeing some structures (if the C side provides them), or just `free`
20:38:57FromDiscord<Yardanico> but read the docs for the C function first of course
20:39:22FromDiscord<Unaimend> In reply to @Yardanico "but read the docs": Ok, thanks
20:40:26*teal quit (Client Quit)
20:49:40*teal joined #nim
20:49:59FromDiscord<Unaimend> So printing a char array via echo seems to not stop at \0, any ideas how to fix this
20:50:46FromDiscord<Yardanico> In reply to @Unaimend "So printing a char": can you show the code?
20:51:18FromDiscord<Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2V3h
20:51:52FromDiscord<Yardanico> well because it's an array, ofc :P
20:52:03*shmorgle joined #nim
20:52:29FromDiscord<Yardanico> this works fine
20:52:35FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2V3l
20:52:52FromDiscord<Unaimend> ahh i had to take the address
20:52:55FromDiscord<Yardanico> when echoing the array of course all its elements will be printed
20:53:08FromDiscord<Unaimend> i tried converting in to a cstring directly which did not work
20:53:37*PMunch joined #nim
20:53:58FromDiscord<Unaimend> thank you very much, doing low level stuff in nim is pretty new stuff for me
20:54:16FromDiscord<Yardanico> the C way would be using printf's %s
20:54:19FromDiscord<Yardanico> e.g. https://stackoverflow.com/questions/51906202/reading-current-directory-printing-results-based-on-file-attributes
20:54:24FromDiscord<Unaimend> You a witnessing the rise of Shitty Shell πŸ™‚
20:54:29FromDiscord<Yardanico> you can always do that yourself of course, by using sprintf
20:54:30FromDiscord<Unaimend> (edit) "a" => "are"
20:55:42FromDiscord<mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2V3w
20:57:34FromDiscord<mattrb> Am I doing something obviously dumb?
20:57:44FromDiscord<Yardanico> yes, with UFCS you need to use : for generic types
20:57:46FromDiscord<Yardanico> word = bus.read[:uint32](index)
20:57:49FromDiscord<Yardanico> try this
20:58:08FromDiscord<Yardanico> https://nim-lang.org/docs/manual.html#procedures-method-call-syntax
20:58:37FromDiscord<Yardanico> and yeah, you don't need the type here at all actually
20:58:45FromDiscord<Yardanico> ah, wait, you do, right, it's a return type
20:58:58FromDiscord<Yardanico> so you either do bus.read[:uint32](index) or read[uint32](bus, index)
21:02:45FromDiscord<mattrb> Hmm I'm getting some other errors now, but I'll play around with that. Thank you! How would I case over the generic T type?
21:04:02FromDiscord<mattrb> sent a code paste, see https://play.nim-lang.org/#ix=2V3U
21:05:35PMunchYeah I don't think there exists a compile-time case unfortunately
21:06:52FromDiscord<mattrb> Okay, I'll just stick with the `when` for now. Thanks
21:08:51PMunchJust ordered a couple Raspberry Pi Picos by the way, will be fun to try and get them to run Nim @ElegantBeef
21:23:51FromDiscord<mattrb> In reply to @Yardanico "so you either do": Do you know if I could make this work by replacing `read` with ``[]``? No biggie if not, but it doesn't seem to be working when I try that
21:24:05FromDiscord<Yardanico> In reply to @mattrb "Do you know if": not sure I understand
21:24:11FromDiscord<Yardanico> how would you provide the generic type with []?
21:24:20FromDiscord<Yardanico> like bus.[:uint32]`[]` ?
21:24:22FromDiscord<Yardanico> (edit) "bus.[:uint32]`[]`" => "bus.[:uint32]``[]``"
21:24:22FromDiscord<mattrb> `bus[:uint8][address]`
21:24:30FromDiscord<Yardanico> that won't work I think
21:24:58FromDiscord<mattrb> Okay that's what I was observing too, just wasn't sure if I was missing something
21:25:30FromDiscord<mattrb> Is it related to not being able to generics and `[]` or something, or some other reason?
21:25:32FromDiscord<mattrb> Do you know?
21:26:41FromDiscord<Yardanico> btw, in this case you use typedescs instead of the generic type
21:26:53FromDiscord<Yardanico> or create different functions like readUint8
21:26:57FromDiscord<Yardanico> i mean with read
21:27:06FromDiscord<Yardanico> bus.read(uint8, idx)
21:28:07FromDiscord<mattrb> I actually had different functions before and I'm intentionally collapsing them into one so that there aren't any issues with inconsistencies cropping up between the different accessors
21:29:23FromDiscord<mattrb> How does nim handle generic types at compile-time? I was under the impression that it created different concrete procs with each possible type? If I did that like `bus.read(uint8, idx)`, I'd end up with the comparisons happening at runtime?
21:29:38FromDiscord<Yardanico> no, it'd create different procs anyway
21:29:43FromDiscord<Yardanico> typedescs are compile-time only of course
21:31:12FromDiscord<mattrb> What's the benefit over generics?
21:31:36FromDiscord<Yardanico> some prefer one over the other
21:32:21FromDiscord<mattrb> Ahh, so the emitted code is likely the same and it's just a matter of preference on the syntax?
21:32:30FromDiscord<Yardanico> yes
21:32:34FromDiscord<Yardanico> they also have different bugs :P
21:33:25FromDiscord<mattrb> In theory if I wanted to use `[]` rather than `read`, I imagine I could probably do that with typedescs
21:33:27FromDiscord<mattrb> Interesting
21:33:39FromDiscord<mattrb> I already have this working at this point, but good to know there are options at least
21:33:42FromDiscord<mattrb> Thanks for all the info
21:38:30ForumUpdaterBotNew thread by DavidKunz: Learning Nim: Creating a Query Macro [video], see https://forum.nim-lang.org/t/7745
21:40:00ForumUpdaterBotNew post on r/nim by David-Kunz: Learning Nim: Creating a Query Macro, see https://reddit.com/r/nim/comments/mk5hv9/learning_nim_creating_a_query_macro/
21:43:16*teal quit (Quit: WeeChat 3.1)
21:48:43FromDiscord<ElegantBeef> pmunch, no dont say that, someone testing my code will make issues! πŸ˜›
21:49:24PMunchHaha, I'll try to not only make issues :P
21:50:17FromDiscord<ElegantBeef> I still have to figure out the tinyusb stuff, it's just there and whenever i see embedded i cry a bit πŸ˜„
21:50:30PMunchTinyUSB?
21:50:52FromDiscord<ElegantBeef> It's the library the pico uses to become a usb device
21:55:44PMunchAh so if you want it to behave as a keyboard or something
21:56:13FromDiscord<ElegantBeef> yea
21:57:05FromDiscord<Conifer> Have a little question because I'm getting confused with arrays in Nim.
21:57:13PMunchFire away :)
21:57:25FromDiscord<Conifer> ah one sec... Pain in the ass to get code block on discord with macOS
21:57:36FromDiscord<ElegantBeef> The answer is they're statically sized and that size needs to be known at compile time πŸ˜„
21:57:58PMunchHaha, most likely :P
21:58:17PMunch@Conifer, you can share code snippets on play.nim-lang.org as well
21:59:26FromDiscord<ElegantBeef> So far if interested i've wrote bindiings for a bunch of the tusb code, just having issues on linking so i guess i messed something up
21:59:36FromDiscord<Conifer> sent a code paste, see https://play.nim-lang.org/#ix=2V4f
21:59:40FromDiscord<Conifer> In reply to @PMunch "<@215264612185145344>, you can share": Thanks I will keep that in mind till I get new keyboard.
22:00:04FromDiscord<ElegantBeef> arrays are indexed starting at 0
22:00:29FromDiscord<ElegantBeef> atleast that type of array
22:00:39PMunchAnd 0*10 would still be 0
22:00:45FromDiscord<ElegantBeef> you can change it to be `array[1..10]`
22:00:53FromDiscord<ElegantBeef> (edit) "`array[1..10]`" => "`array[1..10, int]`"
22:01:12FromDiscord<ElegantBeef> But just remember it's indexed at 0 and that the python code would be the same
22:01:14FromDiscord<Conifer> In reply to @ElegantBeef "you can change it": perf that worked
22:01:22PMunchYou can either do `var firstArr: array[1..10, int]` or do `firstArr[i-1] = i*10` and loop over `1..10`
22:01:42FromDiscord<Conifer> Yeah I wasnt aware I can do 1..10 in array declaration
22:01:44FromDiscord<Conifer> that makes more sense
22:01:56PMunchWell, then you're index is 1-indexed
22:01:59FromDiscord<ElegantBeef> or the inverse of that and iterate over `0..<10` and `arr[i] = (i + 1) 10`
22:02:04PMunchWhich many programmers find weird :P
22:02:23FromDiscord<Conifer> Thanks for that guys. I will put that down on my notes
22:02:57PMunchNim is one of the few languages I know of that allows you to give arbitrary ranges for arrays
22:03:00FromDiscord<ElegantBeef> Yea 0 indexed is life
22:03:06FromDiscord<ElegantBeef> We even allow enums
22:03:12FromDiscord<Conifer> Lua spoiled me with 1 :wryboi:
22:03:23FromDiscord<ElegantBeef> I mean it's dumb to index at 1
22:03:31PMunchOh yeah, enums as array indices is great :)
22:03:48PMunchOh no :(
22:03:51FromDiscord<Conifer> The more you use the language you forget most... actually all don't do that so your brain does become a bit fucky when you touch something else.
22:04:38PMunchApparently freenode is going down for maintenance in 5 minutes
22:04:46PMunchSo I'll drop out in a second
22:05:00FromDiscord<ElegantBeef> Damn
22:05:06FromDiscord<ElegantBeef> Was nice knowing you
22:05:10FromDiscord<ElegantBeef> Rest in piece
22:05:10PMunchHaha :P
22:05:19PMunchI mean I could just fire up Discord..
22:05:29FromDiscord<ElegantBeef> Or you know your favourite matrix client
22:07:02PMunchWell, then I'd have to install a Matrix client..
22:07:23FromDiscord<ElegantBeef> better matrix than discord πŸ˜›
22:08:07PMunchFor sure
22:08:16federico3+1
22:08:26PMunchBut that still means I have to install a Matrix client..
22:08:32FromDiscord<ElegantBeef> true
22:08:36federico3or use the web thingy
22:08:41PMunchTrue
22:08:55FromDiscord<ElegantBeef> Truthfully i'll be the first to be on matrix if they standardize channelled voip
22:09:09PMunchNot even sure I have another user than the one I used for FOSDEM
22:09:36FromDiscord<PMunch> Hello πŸ™‚ Just in case Freenode suddenly drops out
22:09:46FromDiscord<ElegantBeef> This is an imposter
22:09:54PMunchDon't trust him!
22:09:59FromDiscord<PMunch> Shhh, trust me
22:10:09ForumUpdaterBotNew post on r/nim by LongCovSuperSpreader: Does this minor issue annoy you?, see https://reddit.com/r/nim/comments/mk62nk/does_this_minor_issue_annoy_you/
22:11:02FromDiscord<Yardanico> what
22:11:07FromDiscord<ElegantBeef> huh?
22:11:19PMunchNever had Nim do that when compiling..
22:11:25FromDiscord<ElegantBeef> That makes multiple of us
22:11:35FromDiscord<ElegantBeef> Isnt that on the shell to newline after a process terminates?
22:11:49FromDiscord<PMunch> Not really
22:12:05FromDiscord<PMunch> But some shells will do it for you just in case
22:16:24*vicfred joined #nim
22:18:48*l1x quit (Quit: Connection closed for inactivity)
22:29:17*tane quit (Quit: Leaving)
22:36:12*algun quit (Ping timeout: 265 seconds)
22:36:31FromDiscord<dom96> guess it happens when --verbosity is set to a low number?
22:41:40*wtl joined #nim
22:42:36*wtl quit (Client Quit)
22:51:00*krux02 quit (Remote host closed the connection)
23:10:59FromDiscord<ajusa> this is a pretty trivial question, but is there a built in way to pad a seq to a certain length?
23:11:23FromDiscord<Yardanico> In reply to @ajusa "this is a pretty": setLen
23:11:32FromDiscord<Yardanico> or what do you mean by "pad"?
23:11:43FromDiscord<Yardanico> pad before the elements or after them?
23:12:19FromDiscord<ajusa> wait seriously setLen works? my bad, I didn't make the connection
23:12:34FromDiscord<Yardanico> setLen changes the length of the seq to the specified value
23:12:37FromDiscord<ajusa> yeah I wanted to ensure a sequence is of a certain size by filling it with zeros, that should work for me!
23:12:53FromDiscord<Yardanico> when you're initializing the sequence you can also just use newSeq btw
23:13:01FromDiscord<Yardanico> but after it's initialized you can use setLen, yes
23:13:46FromDiscord<ajusa> yeah I'm turning a string into a sequence and then I need to pad it to a certain length, so setLen is perfect for me
23:14:13FromDiscord<Yardanico> @ajusa you can do this more efficiently by initializing the sequence first, no?
23:14:48hshhi, is anyone using Nim + sourcehut? I could use with a `.build.yml` example, having some trouble setting it up.
23:15:10FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2V4t
23:15:43FromDiscord<ajusa> I could but setLen is more explicit and requires less code. This doesn't need to be super fast either
23:16:01FromDiscord<Yardanico> well setLen is not really "more explicit" than this code :)
23:16:32FromDiscord<Yardanico> @ajusa also, you can pad the string itself with setLen, and string->seq[char] is really cheap
23:17:04FromDiscord<Yardanico> e.g. https://github.com/status-im/nim-stew/blob/master/stew/byteutils.nim#L142 does it to make a seq[byte] out of a string but it's the same for seq[char]
23:17:08FromDiscord<ajusa> what does it pad it with? \0?
23:17:19FromDiscord<Yardanico> In reply to @ajusa "what does it pad": of course
23:17:24FromDiscord<Yardanico> nim strings aren't really null terminated, they're pascal strings
23:17:28FromDiscord<ElegantBeef> Nim auto zeros memory
23:17:40FromDiscord<ajusa> hm... it's a bit weird since I'm also converting the string to utf-16
23:17:42FromDiscord<Yardanico> nim strings have the length (and capacity) before the actual data
23:17:49FromDiscord<Yardanico> In reply to @ajusa "hm... it's a bit": wait, why do you need seq[char] then?
23:18:08FromDiscord<ajusa> I don't, I'm actually using seq[int8] after converting it to UTF16
23:18:17FromDiscord<Yardanico> https://github.com/treeform/encode has `toUTF16LE`
23:18:34FromDiscord<ajusa> nim encodings also has a proc for that so I used it
23:18:48FromDiscord<Yardanico> yes but it requires iconv and encode is pure-nim :P
23:19:21FromDiscord<ajusa> good point to be honest, I was also having to slice the seq to get rid of the first two BOM bytes, I see that treeform has a better way of doing it
23:19:48saemhsh: the nim compiler itself uses sourcehut: https://github.com/nim-lang/Nim/blob/devel/.builds/freebsd.yml
23:20:36hsh@saem
23:20:47FromDiscord<Yardanico> πŸ€”
23:21:04hsh@saem thanks! I was looking for an example of a nim project rather than Nim itself ;)
23:21:21saemthe compiler itself is a nim project. :D
23:21:22ddevaultis there something in particular about the build manifests that are confusing to you?
23:21:39hsh@saem something using `choosenim` I should say, then ;)
23:22:18hsh@ddevault ah well, now I have to be careful with criticism of sourcehut XD
23:22:35ddevaultdon't be shy
23:23:10hsh@ddevault not really, just more the way `choosenim` installs, more than the manifest format itself
23:23:16ddevaultgotcha
23:23:57FromDiscord<Yardanico> you can just look at how "raw" github actions ci scripts use choosenim
23:24:02FromDiscord<Yardanico> i don't think it'd be that different
23:24:16FromDiscord<Yardanico> https://github.com/nim-lang/Nim/wiki/BuildServices#github-actions-using-choosenim
23:24:22FromDiscord<Yardanico> not sure about if sourcehut offers a cache
23:24:33FromDiscord<ElegantBeef> Is your name a coincidence ddevault or is it who i think it is?
23:24:41ddevaultin general we would recommend that you install something like nim from the package manager for your distribution of choice
23:24:42FromDiscord<Yardanico> In reply to @ElegantBeef "Is your name a": it's not a coincidence
23:24:48FromDiscord<Yardanico> it's the creator of sourcehut :)
23:25:00FromDiscord<ElegantBeef> Didnt think so
23:25:08FromDiscord<Yardanico> also creator of sway
23:25:30ddevaultalso the creator of this delcious lasagna
23:25:36FromDiscord<Yardanico> lol
23:25:39FromDiscord<ElegantBeef> and the oddly similar harelang πŸ˜›
23:25:49voidpiddevault: thanks for sr.ht
23:25:54ddevault:)
23:29:06PMunchMan, optimising things for program memory size is such a random game
23:30:54FromDiscord<ElegantBeef> Just glue on more ram
23:31:08FromDiscord<ElegantBeef> That's what people that use electron suggest atleast πŸ˜›
23:31:08PMunchHaha, well I certainly could
23:31:13PMunchBut where's the fun in that :P
23:31:14ddevaultis nim garbage collected?
23:31:20PMunchWell, yes
23:31:24PMunchBy default anyways
23:31:36FromDiscord<ElegantBeef> It's got a GC, scoped memory management or manual memory management
23:32:06FromDiscord<ElegantBeef> A gc is sort of a lie since it has the choice of like 4 different GCs πŸ˜„
23:32:10federico3oh hi ddevault, pity you are not on mastodon anymore but nice to have you here
23:33:02PMunchI mean I want to show people how good Nim is for microcontrollers, and making super tiny programs that still manage to look high-level is part of that
23:33:29FromDiscord<ElegantBeef> Oh yea it's like my templates for those `attribute ((weak))` functions
23:34:34PMunchI mean my keyboard firmware is currently 1/10th of a typical QMK build and has almost all the features you'd expect from keyboard firmware
23:35:31PMunch(Well, all the keyboard related stuff at least, I don't support RGB LED stuff at the moment)
23:35:38FromDiscord<ElegantBeef> Good dont support it
23:35:49PMunchI think the next step is to rewrite the USB stuff in Nim
23:35:55ddevaulthttps://xkcd.com/801/
23:37:25PMunchWho's Wolf Blitzer?
23:37:31FromDiscord<ElegantBeef> A news reporter
23:37:37saemCNN personality/new anchor
23:37:48PMunchBut the rest of that XKCD strip sounds about right :P
23:38:05ddevaultjokes aside, something like a keyboard firmware is indeed a good way to prove the utility of a language for embedded programming
23:38:10PMunchI mean I got that from a quick Google search, but how is it relevant to the comic?
23:38:29ddevaultit's a non sequitur
23:38:43PMunchAh right, just black-hat-man being himself then :P
23:39:01FromDiscord<ElegantBeef> https://explainxkcd.com/wiki/index.php/801:_Golden_Hammer there you go
23:39:08PMunchDoes his characters have "official" names by the way?
23:39:13hshhey, fixed it. nothing like a good session of RTFM.
23:39:20FromDiscord<ElegantBeef> RTFM is for people that can read
23:39:24ddevaultone is called megan
23:40:40FromDiscord<ElegantBeef> Though the joke sorta misses here since Nim goes to C and has scoped based memory management which is perfect for embedded πŸ˜›
23:40:58hshand yes, sourcehut is great.
23:41:13FromDiscord<ElegantBeef> But i'm only slightly biased cause i've bashed my head into the rpi pico-sdk for a few hours
23:42:35PMunch@ElegantBeef, well rewriting the USB part in Nim is similar-ish to porting the JVM
23:42:59PMunchObviously no-where on the same scale of an undertaking, but still it's pretty frivolous
23:43:18ddevaultI don't envy you
23:43:22PMunchAlthough the C code is deprecated in favour of the Arduino based solution, which I don't want to wrap
23:43:25ddevaulthave you had a gander at the USB spec yet
23:43:37PMunchI've had a glance at it
23:43:45PMunchI mean I'm not going to implement the whole spec
23:44:00PMunchPretty much just rewrite the ~600 lines of C code into Nim
23:44:04ddevaultfair enough
23:44:20PMunchMaybe give it a bit better type-safety
23:44:30PMunchOr other fun stuff like that
23:48:17PMunchDamn it.. Now I'm trapped in an XKCD loop
23:49:23ddevaultI can fix that, click this instead: https://tvtropes.org/pmwiki/pmwiki.php/Webcomic/Xkcd
23:54:41PMunchHmm, started looking at this years April 1st thing
23:54:46PMunchThe checkbox one
23:55:57*lritter quit (Ping timeout: 265 seconds)