<< 22-01-2022 >>

00:12:10*vicfred quit (Quit: Leaving)
00:14:27FromDiscord<Patitotective> In reply to @PMunch "Well, now I'm in": I'm already out of that boat :p
00:21:19*Guest8 quit (Quit: Client closed)
00:23:03arkanoidmratsim, so you see anything wrong here? I'm getting "Error cannot borrow from" https://play.nim-lang.org/#ix=3N4E
00:44:19FromDiscord<mratsim> In reply to @arkanoid "<@570268431522201601>, so you see": `slotPosition = offsets[i].addr`↵↵and use {.experimental: "views".}
01:48:02*krux02 quit (Remote host closed the connection)
03:39:05FromDiscord<Bung> @ElegantBeef any news for me ?
03:39:41FromDiscord<Elegantbeef> `ref T` should work and procs are `nil`'d dont recall what you needed
03:41:36FromDiscord<Bung> let me see what happen after new update
03:41:54nrds<Prestige99> Not sure how to word this succinctly https://play.nim-lang.org/#ix=3N5j
03:42:00nrds<Prestige99> Is there a way to do the above?
03:42:19nrds<Prestige99> or do they have to be ref objects
03:42:57FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3N5k not overly safe but if `f` doesnt go out of scope should be fine
03:43:08FromDiscord<Elegantbeef> Alternatively you use `views`
03:43:21nrds<Prestige99> ah that may be just what I need, byaddr
03:43:46nrds<Prestige99> thanks beef
03:44:07FromDiscord<Elegantbeef> Should note it's also unsafe if you mutate the collection
03:44:42nrds<Prestige99> hm okay I'll see how this goes
03:45:54FromDiscord<Elegantbeef> To showcase the issue https://play.nim-lang.org/#ix=3N5l
03:46:23FromDiscord<Elegantbeef> We add another value to `mySeq` which causes it to realloc and move the memory, which means our point is no longer safe
03:46:37nrds<Prestige99> hm why would I be getting an error invalid pragma: byaddr
03:46:51FromDiscord<Elegantbeef> `import std/decls`
03:47:05nrds<Prestige99> ah I totally missed that
03:48:47nrds<Prestige99> still happening 🤔
03:49:07FromDiscord<Elegantbeef> Are you modifying the collection?
03:49:17FromDiscord<Bung> I still get `Error: type mismatch: got 'NimNode' for '↵nil' but expected 'Node = ref Node:ObjectType'`
03:49:29FromDiscord<Elegantbeef> Oh right that error
03:49:37FromDiscord<Elegantbeef> I forgot, can you make an issue with a min reproduction?
03:49:37nrds<Prestige99> not before the object goes out of scope
03:50:47FromDiscord<Elegantbeef> There is also this sort of thing you can do https://play.nim-lang.org/#ix=3N5m
03:51:35nrds<Prestige99> oh fancy
03:51:49nrds<Prestige99> this should still work though eh?
03:51:53FromDiscord<Elegantbeef> Yea i dont know what to say `byaddr` will work properly assuming the collection isnt mutated
03:52:07FromDiscord<Elegantbeef> So unless you're causing the collection to mutate something else is the issue
03:52:39nrds<Prestige99> maybe there's some other issue but I'm getting the wrong compilation error
03:53:33FromDiscord<Elegantbeef> Can you share the code?
03:54:15nrds<Prestige99> yeah let me finish this up and push, few mins
03:55:00FromDiscord<Bung> In reply to @Elegantbeef "I forgot, can you": let me try
03:59:13nrds<Prestige99> https://github.com/avahe-kellenberger/shade/blob/aa70b81849f49d427e7c9f74eac9c0a5499455a2/src/shadepkg/math/collision/aabbtree.nim#L72 @Elegantbeef
03:59:28nrds<Prestige99> aabbtree.nim(72, 16) Error: invalid pragma: byaddr
04:00:04*arkurious quit (Quit: Leaving)
04:02:27FromDiscord<Elegantbeef> Perhaps `byaddr` isnt getting mixed in
04:02:49FromDiscord<Elegantbeef> add `mixin byaddr` to the top
04:03:12nrds<Prestige99> same error
04:03:14FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N5r
04:03:23nrds<Prestige99> could it have to do with the gc?
04:03:41FromDiscord<Elegantbeef> No
04:03:48FromDiscord<Elegantbeef> It's to due with pragmas in generics i think
04:03:56nrds<Prestige99> ah :/
04:04:10FromDiscord<Elegantbeef> `export cdecls` in this module
04:04:31nrds<Prestige99> decls or cdecls
04:04:53FromDiscord<Elegantbeef> `decls`
04:05:00FromDiscord<Elegantbeef> I'm an idiot that for some reason always thinks it's named `cdecls`
04:05:15nrds<Prestige99> same error but a different line, interesting
04:05:43nrds<Prestige99> that means line 72 worked.. but line 173 didn't
04:06:02FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N5s
04:06:06FromDiscord<Elegantbeef> instead of the byaddr
04:06:27nrds<Prestige99> about that, is there overhead?
04:06:30FromDiscord<Elegantbeef> It's what `byaddr` does anyway
04:06:35nrds<Prestige99> ah, ok
04:06:59nrds<Prestige99> thanks for the help
04:07:01FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/std/decls.nim#L15-L19
04:07:07FromDiscord<Elegantbeef> byaddr isnt very complicated
04:13:09FromDiscord<Bung> I dont know which part cause that , you can check this https://github.com/bung87/crown_ui/tree/nimscripter and run nimble buildSite
04:16:53*vicfred joined #nim
04:31:36FromDiscord<Elegantbeef> Uhh it works for me
04:31:57FromDiscord<Elegantbeef> Line 158 you have a `vNode = string` which errors
04:36:47FromDiscord<Bung> which file
04:36:52FromDiscord<Elegantbeef> generator
04:38:02FromDiscord<Elegantbeef> There are so many indention issues in here aswell
04:38:55FromDiscord<Bung> I dont get what you mean `vNode = string` https://media.discordapp.net/attachments/371759389889003532/934306108741394462/Screen_Shot_2022-01-22_at_12.37.37_PM.png
04:39:24FromDiscord<Elegantbeef> `postNode: VNode` `invoke(returnType = string)`
04:39:50FromDiscord<Elegantbeef> You're attempting to assign `postNode` to a `string`
04:40:40FromDiscord<Elegantbeef> `type mismatch: got 'string' for '...' but expected 'VNode = ref VNode:ObjectType`
04:40:49FromDiscord<Bung> `postNode = libTheme.invoke(renderPost,conf, data, contentNode, returnType = VNode)`
04:41:02FromDiscord<Bung> this is what I see
04:41:18FromDiscord<Elegantbeef> https://github.com/bung87/crown_ui/blob/nimscripter/src/crown_ui/generator.nim#L158 that's not the code you have on the repo
04:43:48FromDiscord<Bung> okay , may bad ,updated.
04:49:54FromDiscord<sharpcdf> can i make an anonymous process for a parameter?
04:52:04FromDiscord<Elegantbeef> You mean procedure? Yes
04:52:46FromDiscord<sharpcdf> is it possible to make it not have a body
04:52:52FromDiscord<sharpcdf> just an empty function
04:53:01FromDiscord<Elegantbeef> `proc()= discard`
04:53:09FromDiscord<Elegantbeef> or `nil`
04:53:09FromDiscord<sharpcdf> thanks
04:53:15FromDiscord<Elegantbeef> `proc` is a pointer
04:58:14FromDiscord<Elegantbeef> So interestingly bung the issue is due to the object having 0 fields
04:58:41*rockcavera quit (Remote host closed the connection)
05:03:57FromDiscord<Elegantbeef> 1.0.8 is now up so try that please
05:03:58FromDiscord<Bung> which one , I dont see any type has no fields in this file
05:04:16FromDiscord<Bung> okay, let me try
05:06:11FromDiscord<Elegantbeef> Vnode has `Node`
05:06:22FromDiscord<Elegantbeef> Node when not JS is `Node = ref object`
05:25:21FromDiscord<Bung> oh , it compiles and run but got error `Script Error: (line: 1, col: 13, fileIndex: ...) cannot open file: karax/karaxdsl`
05:25:50*Gustavo6046 joined #nim
05:26:05nrds<Prestige99> @Elegantbeef I attempted writing my own pragma but had the same error, so it's probably some weird issue with generics + concepts + pragmas
05:32:43FromDiscord<Elegantbeef> Yea bung it doesnt have nimble paths
05:33:22FromDiscord<Elegantbeef> You are using it weirdly, so i need to think about how best to support this
05:42:32NimEventerNew thread by Oyster: Usage of OpenMP parallel loop iterator for lazybones?, see https://forum.nim-lang.org/t/8836
05:53:46FromDiscord<Bung> In reply to @Elegantbeef "You are using it": okay
05:54:18FromDiscord<Elegantbeef> You could copy the karax stuff to a folder that is your stdlib, not ideal but yea
05:55:33FromDiscord<Bung> how to apply modules in loadScript ? maybe I can assign nimble modules to this parameter ?
05:57:36FromDiscord<Elegantbeef> There is a search path used which could be added to by user
05:58:04FromDiscord<Bung> oh , found modules is used for preclude module
05:59:05FromDiscord<Elegantbeef> Yea i guess the thing to do is add yet another optional parameter of `searchPaths` which are also used
05:59:56FromDiscord<Bung> yeah, it's single one path now , need to be support sequence of string
06:03:26*joshbaptiste quit (Ping timeout: 250 seconds)
06:24:05*krux02 joined #nim
06:48:33FromDiscord<Mike> Quick question\: I know I can get the number of characters in a string with `myString.len`, but how do I get the number of characters that will actually be displayed if I were to print the string?
06:49:10FromDiscord<Mike> If a string has digraphs in it, the number of characters won't actually represent the length of the string when it's printed out to the terminal
06:49:21FromDiscord<Mike> Is there a way to get that number?
06:49:25FromDiscord<Elegantbeef> `unicode.runeLen`?
06:51:39FromDiscord<Elegantbeef> Or are you talking about non printable characters?
06:51:52FromDiscord<Mike> No that's exactly what I was looking for, thank you!
06:52:03FromDiscord<Mike> Hadn't even looked at the unicode module yet
06:58:13FromDiscord<Elegantbeef> No problem
07:55:38FromDiscord<Phil> I may have designed myself into a not so great situation
07:59:37FromDiscord<Phil> Spontaneous idea, it might not be that impossible afterall, one minute
08:11:04FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3N6f
08:11:50FromDiscord<mratsim> why? you put that template in a tools/utils/helpers file
08:11:55FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=3N6f" => "https://play.nim-lang.org/#ix=3N6g"
08:12:03FromDiscord<mratsim> the let connection can be saved as well
08:13:09FromDiscord<mratsim> sent a code paste, see https://play.nim-lang.org/#ix=3N6h
08:13:34FromDiscord<mratsim> sent a code paste, see https://play.nim-lang.org/#ix=3N6i
08:13:56FromDiscord<mratsim> and you should wrap in a try/finally to ensure recycling on exceptions
08:16:15FromDiscord<Phil> Right, I can just pass in an empty shell of a variable and assign that within the template, while using the variable outside of it. I forgot I can pass uninitialized variables like that.↵That is really neat, thanks mratsim!
08:17:19FromDiscord<mratsim> it's not even a variable you have to declare
08:17:34FromDiscord<mratsim> it's just an identifier, the template will declare it with `let`
08:18:45FromDiscord<Phil> check, identifier is a better word for it than shell, I simply pass an identifier
08:18:49FromDiscord<Elegantbeef> You may want to add a block
08:19:25FromDiscord<mratsim> ah yes for namespacing
08:19:30FromDiscord<mratsim> block and try finally
08:19:50FromDiscord<Elegantbeef> Well with try you dont need the block
08:20:30FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3N6m
08:20:44FromDiscord<Elegantbeef> ah right i'm dumb
08:20:54FromDiscord<Elegantbeef> it's just `block:`
08:21:06FromDiscord<Elegantbeef> Creates a new scope
08:21:36FromDiscord<Elegantbeef> You can optionally do `block name:`
08:21:45FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#statements-and-expressions-block-statement
08:22:18FromDiscord<Phil> That way I can ensure that "connection" isn't accidentally already taken as an identifier?
08:22:34FromDiscord<Phil> No wait, that makes no sense, hmmm
08:22:40FromDiscord<Elegantbeef> Or used after supposedly disposed
08:23:27FromDiscord<Bung> https://github.com/haxscramper/haxdoc/commit/31b80251c09c515027954c5c74b6de6a542c3d1c found hax have written something to find nimble packages
08:25:40FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=3N6n
08:28:38FromDiscord<evoalg> a try/finally is already a block right? ... with its own scope?
08:29:35FromDiscord<Elegantbeef> Yes
08:29:54FromDiscord<Elegantbeef> The only reason block is needed is due to the fact you cannot declare it inside `try` and use it in `finally`
08:30:41FromDiscord<Elegantbeef> blocks without scope only exists for `when`
08:31:12FromDiscord<evoalg> ahhh thanks!
08:31:56FromDiscord<evoalg> hehe I tried a try/finally in python and it's not a separate score (of course)
08:32:43FromDiscord<Elegantbeef> "Why would you want a new scope in what looks like a new scope"
08:32:53FromDiscord<evoalg> lol
08:44:04*l1x quit (Quit: Connection closed for inactivity)
08:48:50FromDiscord<evoalg> So I can think of it like this? ... if I see something ending in ":" (and a newline) has its own scope except for "when:"?
08:49:08FromDiscord<Elegantbeef> In the case of templates not so
08:49:22FromDiscord<evoalg> ahhhh ok!
08:49:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6p
08:50:34FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6q
08:50:42FromDiscord<Elegantbeef> All flow control is properly scoped though
08:51:23FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/LWZ
08:52:07FromDiscord<Elegantbeef> inb4 "Wait you can call procedures like that?!"
08:52:49FromDiscord<Phil> wait, variable assignments within procedure calls?
08:52:57FromDiscord<evoalg> that's nice!
08:53:05FromDiscord<Phil> I'm not sure it is
08:53:14FromDiscord<Elegantbeef> In Nim "everything" can be a expression
08:53:29FromDiscord<Elegantbeef> you can also do `if (let x = 100; x) == 100`
08:54:00FromDiscord<evoalg> lol
08:54:40FromDiscord<Phil> I would like to ~~rage~~ veto!
08:55:23FromDiscord<Elegantbeef> Eh it's more a case of "allowing it is nice, only idiots will miss use it"
08:55:29FromDiscord<Phil> I have watched too many dndstreams that this phrase from one of the more popular streams is so ingrained into me
08:55:37FromDiscord<Phil> (edit) "dndstreams" => "dnd-streams"
08:55:52FromDiscord<evoalg> In reply to @Elegantbeef "you can also do": In this case it has it's own scope
08:56:02FromDiscord<Elegantbeef> Yes it has the `if` scope
08:56:06FromDiscord<Elegantbeef> Which makes sense
08:56:10FromDiscord<evoalg> ahhh yes!
08:56:11FromDiscord<Elegantbeef> since `if` actually makes scope
08:56:19FromDiscord<evoalg> unlike python
08:56:39FromDiscord<Elegantbeef> Unrelated but hey there are more matrix users!
08:56:58FromDiscord<Elegantbeef> Lurkers i tell you 😛
08:57:38FromDiscord<mratsim> Good Matrix client for Linux that isn't yet another web browser (TM°?
08:57:40FromDiscord<mratsim> Nheko?
08:58:15FromDiscord<Elegantbeef> I just use element but i have been meaning to try others
08:59:54FromDiscord<Elegantbeef> I do kinda dumbly want to make one but knowing me it'd end with a 1/20th implemented client
09:00:04FromDiscord<Elegantbeef> Plus i cant even use GTK without my brain imploding
09:00:08FromDiscord<Phil> Sidenote, I am fascinated that supertux exists
09:00:41FromDiscord<Elegantbeef> Super tux kart and super tux party exist aswell 😀
09:01:31FromDiscord<Phil> This is ridiculous and adorable in equal measure
09:01:37FromDiscord<Elegantbeef> I did kinda want to use my technical art skills to contribute to Super Tux Party to make it not god awful looking
09:02:23FromDiscord<Elegantbeef> This water is just so meh
09:02:28FromDiscord<Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/934372430087069726/image.png
09:02:44FromDiscord<Elegantbeef> Anyway where are all the Nim questions! 😛
09:03:13FromDiscord<evoalg> I have a list of questions ... I pull from it when you ask that
09:03:28FromDiscord<Elegantbeef> Jeez a whole list
09:03:57FromDiscord<evoalg> but I'll only ask one ... hang on finishing my "scope" notes 😉
09:04:29FromDiscord<Elegantbeef> These notes sound quite interesting
09:05:04FromDiscord<evoalg> maybe because it's a minor scale ... I dunno
09:06:06FromDiscord<evoalg> I mean I have to keep notes ... "Beef's cunnings"
09:06:52FromDiscord<Elegantbeef> At this point you should just have a github gist so you can link others to your notes 😛
09:07:04FromDiscord<Elegantbeef> "Aw shit i have notes on this topic, look at this!"
09:09:56FromDiscord<evoalg> hehe true
09:10:25FromDiscord<Phil> Huh... strictly speaking that connection pooling thingy may have been the last larger roadblock for my webapp
09:11:19FromDiscord<Phil> Oh wait, no, handling uploading myself in prologue will be another, nevermind
09:11:35FromDiscord<Phil> (edit) "Oh wait, no, handling uploading ... myself" added "files by"
09:12:14FromDiscord<evoalg> sent a code paste, see https://play.nim-lang.org/#ix=3N6x
09:12:33FromDiscord<evoalg> (I saw it and I thought it looks interesting but I don't understand it)
09:12:58FromDiscord<Elegantbeef> Yes it's echoing the address of the first value in the string's data
09:13:38FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6y
09:14:09FromDiscord<Elegantbeef> They point to the same data but arent at the same place 😀
09:14:37FromDiscord<Elegantbeef> So yes it's passed as a reference 😀
09:15:08FromDiscord<Elegantbeef> I mean no
09:15:15FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6z
09:15:40FromDiscord<Elegantbeef> a string is a "small object" it's only a pointer so it's not passed as a reference
09:16:12FromDiscord<evoalg> ahhhh ok ... so now I know how to check, nice!
09:16:24FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/gXg
09:16:40FromDiscord<Elegantbeef> And if you make that `ref object` you get the same thing as a string
09:17:19FromDiscord<evoalg> those a really good examples ... thank you!
09:18:06FromDiscord<evoalg> do you use "unsafeAddr" because strings are on the heap?
09:18:44FromDiscord<Elegantbeef> nah
09:18:49FromDiscord<Elegantbeef> `unsafeaddr` is just a misnomer
09:19:22FromDiscord<Elegantbeef> It's equally as unsafe as `addr` but allows you to take the address of something that is immutable
09:19:34FromDiscord<Elegantbeef> A future Nim will allow `addr` to work in both cases
09:19:59FromDiscord<evoalg> ahhh
09:20:12FromDiscord<evoalg> and why do you cast to ByteAddress ?
09:20:20FromDiscord<Elegantbeef> Just to be more descript
09:20:24FromDiscord<Elegantbeef> It's just an alias of `int`
09:20:44FromDiscord<Elegantbeef> Or do you mean why do i cast atall?
09:20:54FromDiscord<evoalg> both 😉
09:21:06FromDiscord<Elegantbeef> Pointers are just integers that are distinct types to `int` in Nim
09:21:11FromDiscord<Elegantbeef> They do not have a `$` implemented
09:21:29FromDiscord<evoalg> ahhhh
09:21:32FromDiscord<Elegantbeef> Casting to `int` results in us being able to echo out the pointer address
09:21:37FromDiscord<Elegantbeef> you could also do `.repr`
09:21:51FromDiscord<evoalg> gotcha ok
09:21:52FromDiscord<Elegantbeef> repr gives more information
09:23:47FromDiscord<evoalg> why don't cast to `int` if it's shorter?
09:23:59FromDiscord<Elegantbeef> To be more descriptive in the example 😀
09:24:11FromDiscord<Elegantbeef> Types afterall are mainly to make things more readable
09:25:18FromDiscord<evoalg> that's fair
09:25:53FromDiscord<Elegantbeef> I also left out static soundness
09:26:12FromDiscord<Elegantbeef> More questions?!
09:27:15FromDiscord<evoalg> yep ... I can pull another one off the list 😉
09:27:55FromDiscord<evoalg> I see you talking about constructors ... what are they and do I need to learn them at the moment?
09:29:27FromDiscord<evoalg> if it's to do with macro's then I can wait until I learn them
09:31:35FromDiscord<evoalg> in which case I can ask what you meant by "static soundness"
09:33:59FromDiscord<Elegantbeef> Constructors just make objects
09:34:11FromDiscord<Elegantbeef> Static soundness was just in reference of statically typed
09:35:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6F
09:35:53FromDiscord<Elegantbeef> That's a constructor for instance
09:36:12FromDiscord<Elegantbeef> Now i do also have a package named constructor, which is also what i've talked about
09:36:21FromDiscord<evoalg> ohhh
09:36:34FromDiscord<Elegantbeef> It makes it `proc init(_: typedesc[MyObject], a, b: int) : MyObject {.constr.}`
09:38:25FromDiscord<evoalg> without the body?
09:38:38FromDiscord<Elegantbeef> Body is optional
09:39:05FromDiscord<Elegantbeef> https://github.com/beef331/constructor#constructor-1 shows different usages
09:39:09FromDiscord<evoalg> so you constructor saves some (keyboard) typing?
09:39:23FromDiscord<Elegantbeef> Yep
09:41:46FromDiscord<evoalg> ahhh it seems to me there are mainly two types of people coming to nim ... those from C (etc) and those from python ... those from the C side are heavily into objects ... but I'm from python and I naturally don't think about using objects, so it's a bit of a shift in thinking for me, and I'm still confused by a lot of it. That `var a = Myobject.init(10, 20)` ... couldn't I write it like `var a = Myobject.init(a=10, b=20)` and not have that
09:42:07FromDiscord<Elegantbeef> I dont come from C 😀
09:42:49FromDiscord<evoalg> C, C++, C# ... I lump them all into the same thing because I'm from python and I don't know any better
09:42:52FromDiscord<Elegantbeef> The benefit of constructor is when you have long field names and dont want to have to write it out fully
09:43:12FromDiscord<evoalg> ohhh ok
09:43:24FromDiscord<Elegantbeef> I mean most libraries that make you make many objects will have constructors
09:43:30FromDiscord<Elegantbeef> The entire point is to make it easy to do
09:43:32FromDiscord<evoalg> and if you use objects a lot then it makes sense
09:43:50FromDiscord<Elegantbeef> Secondary reason can be to prevent access from internals
09:44:05FromDiscord<Elegantbeef> I mean `newSeq` is a constructor 😛
09:44:45FromDiscord<Elegantbeef> What do you use if not objects?
09:44:53FromDiscord<Elegantbeef> Or are your programs not complex enough to want to have grouped fields? 😀
09:46:34FromDiscord<evoalg> "prevent access from internals" ... what is that? Ahhh I still think like a python programmer (and even then I usually write small things ... I'm not a programmer, and I don't do it as a job). So I just have lots of variables and I end up passing heaps of them to a proc and then it looks confusing
09:47:27FromDiscord<Elegantbeef> Say you have a field that you want intialized but dont want to expose it to the user aside from there
09:47:57FromDiscord<evoalg> ohhhh ok
09:48:58FromDiscord<Elegantbeef> Yea if you're passing a bunch of variables you may consider making objects
09:49:19FromDiscord<evoalg> I guess also it's easy to have containers of mixed types, so I use those like an object I guess
09:50:42FromDiscord<Elegantbeef> Manually doing struct of arrays 😀
09:52:25FromDiscord<evoalg> with objects, are they traps for young players? ... or are they pretty simple?
09:52:56FromDiscord<Elegantbeef> They're dead simple
09:53:13FromDiscord<Elegantbeef> They're 0 intalized databuckets with named fields 😀
09:54:26FromDiscord<evoalg> "0 intalized" means empty for the default type?
09:54:42FromDiscord<Elegantbeef> Just like variables `var a: int` being 0
09:54:50FromDiscord<evoalg> ok gotcha
09:54:57FromDiscord<Elegantbeef> `var a = MyObject()`
09:54:58FromDiscord<Elegantbeef> All fields are 0'd
09:55:11FromDiscord<evoalg> ahhh ok
09:56:57*PMunch joined #nim
10:03:15FromDiscord<evoalg> in a discussion of Nim vs Python, leorize said "oh and there's no such thing as global namespace in nim, everything is module-scoped↵that's a knowledge that will help you avoid the from-import trap that newcomers from python frequently fall into"↵... I'm wondering what this trap is?
10:03:39FromDiscord<Elegantbeef> `from x import y`
10:03:54FromDiscord<Elegantbeef> Or whatever the python import method is
10:04:32FromDiscord<Elegantbeef> Many python users want to have all their modules imported and do `moduleName.procedure`
10:04:52FromDiscord<Elegantbeef> Atleast i think that's what it was
10:05:01FromDiscord<evoalg> Nim allows that, no?
10:05:18FromDiscord<Elegantbeef> Bur it's doesnt compose well with Nim
10:05:24FromDiscord<Elegantbeef> but\
10:06:05FromDiscord<evoalg> doesn't compose well means doesn't look good or it leads to errors?
10:06:22FromDiscord<Elegantbeef> It's tedious to use since all procedures require prefix
10:06:34FromDiscord<Elegantbeef> say you import a module that adds operators for types
10:06:58FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6R
10:07:08FromDiscord<evoalg> ahh
10:07:25FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3N6S
10:07:53FromDiscord<evoalg> ok I see what was meant now
10:08:11FromDiscord<Elegantbeef> I atleast imagine that's what he meant
10:08:31FromDiscord<evoalg> gosh I think I've asked enough tonight, and it's getting late for you ... thank you Beef!
10:08:44FromDiscord<Elegantbeef> How dare you thank me!
10:09:24FromDiscord<evoalg> maybe it's cos I'm kiwi
10:10:12FromDiscord<Elegantbeef> We're the stereotypical most polite countries
10:11:37FromDiscord<Rika> Huh really
10:11:46FromDiscord<evoalg> I remember I was in hospital and the young female doctor checked my prostate, and I said "thank you" ... she gave me such a look
10:12:05FromDiscord<Elegantbeef> "I came in with a cough"
10:12:24FromDiscord<evoalg> yea they don't much around in hospitals
10:12:44*Gustavo6046 quit (Quit: Leaving)
10:13:45FromDiscord<Elegantbeef> Atleast in the english world Canadians/Kiwis are considered "overly polite"
10:14:06FromDiscord<evoalg> yea I've heard comedians joke about that
10:14:33FromDiscord<Rika> I guess
10:14:35FromDiscord<evoalg> a Canadian get's hit by a car, gets up and says "sorry"
10:14:53FromDiscord<evoalg> Kiwis are like that too
10:15:43FromDiscord<Elegantbeef> Yea the most Kiwi thing i've ever seen was a wood carving twitch streamer getting subscriptions bought for watchers and him going "Oh no, how do i give the money back"
10:16:00FromDiscord<evoalg> LOL
10:18:35PMunchHaha, that is so wholesome
10:18:49PMunchAnd by the way, wood carving twitch stream sounds awesome
10:20:38PMunchHmm, maybe Nim should have a `from module import operators` or something like that
10:20:53PMunchTo only import operators
10:21:02PMunchWell it also breaks chaining..
10:21:16PMunchI guess people should just stop being scared of imports :P
10:23:28FromDiscord<Elegantbeef> Indeed
10:38:00FromDiscord<Rika> It’s not gonna ever lead to hidden errors like if you do it in Python lol
10:38:08FromDiscord<Rika> I guess that’s the thing
10:38:22FromDiscord<Rika> They think oh Nim looks like Python i assume the import system does too
10:41:55NimEventerNew thread by Moigagoo: A love letter to SciNim, see https://forum.nim-lang.org/t/8837
10:42:59*jjido joined #nim
11:00:05PMunchHmm, with os:any we don't need a panicoverride, but with os:standalone we do. What is os:any doing with panics?
11:46:37FromDiscord<mratsim> it rings Araq's personal phone
11:47:19FromDiscord<Rika> It melts your processor
11:53:43NimEventerNew post on r/nim by derrpwave: request for input - packaging nimdice, see https://reddit.com/r/nim/comments/sa0xar/request_for_input_packaging_nimdice/
11:58:44*adigitoleo quit (Remote host closed the connection)
11:59:42*jjido quit (Ping timeout: 268 seconds)
12:20:15PMunchHaha, so I can call him by just crashing my microcontroller?
12:25:27FromDiscord<Phil> He will direct disappointed silence at you
12:41:42FromDiscord<auxym> what is panicoverride anyways? I've seen it used in some embedded projects
12:51:45PMunchEssentially when your program "panics" (ie. crashes) Nim tries to output something useful. Since this typically involves some form of echo or other things which might not be supported everywhere it allows you to override the panic behaviour
13:34:36FromDiscord<auxym> ah, so you can redirect the stack trace to uart or a debugger? Sounds useful
14:45:42FromDiscord<Phil> Nim does not have a specific "MissingDirectoryDefect" or something like that, right? I'm not missing that while CTRl+F'ing my way through the exceptions.nim file, correct?
14:46:19FromDiscord<Phil> Want to make sure before I make that Defect myself since I would have assumed such a defect to exist
14:47:09PMunchI guess that would go under a FileNotFound error
14:47:19PMunchSince directories are pretty much the same as files
14:47:39FromDiscord<Phil> Yeh, can't find such an error either
14:48:36FromDiscord<Phil> I basically want to raise one if "dirExists" returns false to me, and want to give it a custom error message
14:56:41PMunchSeems the standard library uses IOError for it
14:57:22FromDiscord<Phil> Custom defects it is then
14:57:56PMunchNim unfortunately doesn't have a lot of pre-defined exceptions for things like this
14:57:57FromDiscord<Phil> Defects are the default to use with nim's exception system right? That's what I understand given that other things appear to be deprecated
14:59:07PMunchNah, you should use CatchableError instead
14:59:35PMunchDefects are for things that can't be recovered from, like div by zero or overflow
15:00:04PMunchBut you probably should make it an `object of IOError`
15:00:33PMunchSince this is a narrower kind of IOError
15:00:52*arkurious joined #nim
15:00:59PMunchSo if someone catches IOErrors then they will get yours as well, which makes sense
15:37:11*noeontheend joined #nim
15:51:13FromDiscord<konsumlamm> in general, the Error suffix denotes a catchable exception, while the Defect suffix means that the exception should not be catched
16:06:34*Guest31 joined #nim
16:06:57*Guest31 quit (Client Quit)
16:23:39FromDiscord<IsaacPaul> In reply to @mratsim "it rings Araq's personal": lmbooo
16:41:52PMunchHmm, designing presentation slides is quite different when making a video presentation from a live one
16:45:50*mahlon quit (Ping timeout: 268 seconds)
17:00:49*luis_ joined #nim
17:01:01luis_Hi all
17:01:15luis_I am getting an error at startup, but I cant read it entirely
17:01:30luis_sorry, wrong channel
17:52:13FromDiscord<Phil> Do we have anything to convert images from png to webp?
17:53:15FromDiscord<Phil> (edit) "webp?" => "webp?↵Edit: nevermind, we do: https://github.com/Tormund/nimwebp"
18:13:23FromDiscord<geekrelief> Is there an way to check if a type if nilable?
18:13:30FromDiscord<geekrelief> (edit) "if" => "is"
18:13:38FromDiscord<geekrelief> (edit) "an" => "a"
18:13:39PMunchis pointer?
18:17:19PMunch@geekrelief, something like this? https://play.nim-lang.org/#ix=3N9M
18:17:31PMunchNabbed that type definitions from the options module
18:18:50FromDiscord<geekrelief> thanks, I was going to do that, but I was hoping for a proc. Appreciate the tip! fyi, I'm working on a macro that will check for nil in a chained dotExpr like ?a.b[1].c
18:24:17*noeontheend quit (Ping timeout: 240 seconds)
18:24:20PMunch@geekrelief, have you checked out optionsutils?
18:24:46PMunchSince nil == Option[pointer](none) it can be used for that (at least with some casting)
18:25:51FromDiscord<geekrelief> I haven't checked out optionsutils
18:27:55FromDiscord<geekrelief> are you getting a 504 for the docs? https://nimble.directory/docs/optionsutils//optionsutils.html
18:32:49*supakeen joined #nim
18:41:17FromDiscord<geekrelief> strange I do a `getType` on a `seq` and check if it's a nilable type and I get `true` in a macro but `false` at runtime.
18:43:51*vicecea quit (Remote host closed the connection)
18:44:21*vicecea joined #nim
18:44:26FromDiscord<geekrelief> oh duh.. `getType` returns NimNode
19:03:28*noeontheend joined #nim
19:26:20*mahlon joined #nim
19:36:14FromDiscord<auxym> there's no direct way to access a C `#define` from Nim right? The only way I can think of is creating a proc that uses `{.emit}` to get value, assuming the header is included in some other way
19:55:05PMunch@auxym, importc?
19:55:13PMunchMaybe throw on a nodecl
19:56:59FromDiscord<auxym> huh, didn't think of that. lemme try it out
20:01:27PMunchShould work fine
20:03:21FromDiscord<auxym> with a let declaration? or var?
20:03:34PMunchDepends on what you're importing
20:04:00FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3Naf
20:04:54PMunchUhm, not quite what I meant
20:05:09PMunchDoes that actually work?
20:05:33FromDiscord<auxym> ah something like this right? https://github.com/PMunch/badger/blob/7add5f680643ce620da06f615bb1dece214c8c45/teensy.nim#L28
20:05:59PMunchHaha, yup, those are #define in the C code
20:06:11PMunchDid you just go searching my GitHub for importc or something?
20:08:26FromDiscord<IsaacPaul> In reply to @PMunch "Does that actually work?": Yea... I think the difference is that I needed a value for when the define didn't exist..
20:09:29FromDiscord<auxym> I read a good part of it when I was figuring out how nim on embedded works a couple months ago. You mentioning it made me remember 🙂
20:09:54PMunch@auxym, I'm actually working on more Nim on embedded stuff right now
20:10:23FromDiscord<auxym> yeah, gathered that, looking forward to the result and your talk!
20:10:47FromDiscord<auxym> I'm working on beef's rp pico library, getting usb and PIO working.
20:11:33PMunchPIO?
20:11:50PMunchOh nice, hopefully we can combine that with what I'm working on :)
20:12:18FromDiscord<auxym> yeah, sort-of mini-CPLDs that are integrated in the rp2040 chip, they are pretty neat!
20:13:12FromDiscord<auxym> they're actually programmed in a small assembly language, but I need to wrap the C SDK functions for loading programs, config, etc
20:13:59FromDiscord<auxym> really tiny though, limited to 32 instructions of program size
20:32:18arkanoidI'm playing with {.experimental: "views".}, but I'm failing even the most trivial example. What's wrong with this code? https://play.nim-lang.org/#ix=3Nas
20:32:36PMunch@auxym, wait what? What would you do with one of those?
20:35:50FromDiscord<auxym> Currently reading their docs to better understand, but some examples they have is implementing a full I2C or UART interface, or driving ws2812 LEDs. Basically anything you'd need to bit-bang, you can get a PIO to do it outside the cpu instead. https://github.com/raspberrypi/pico-examples/tree/master/pio
20:36:54FromDiscord<auxym> you can apparently do a minimal uart rx/tx in 8 instructions total
20:37:51PMunchHoly shit, that's super cool
21:31:37FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3NaO arkanoid the procedure to borrow I think is the issue it doesnt know if it's mutated or captured in there so it's unsafe
21:35:15arkanoidElegantbeef: I've found out that if I do something with the source of the view *after* using the view it works https://play.nim-lang.org/#ix=3NaP
21:35:44arkanoidbut I don't get the point of this, why should I force the user to use the source instead of the view
21:37:05arkanoidactually, it works on my machine but doesn't in play.nim-lang?
21:37:29arkanoidalso, it works in arc, but doesn't in refc
21:37:43arkanoidI find this experimental feature too experimental for general use
21:38:10FromDiscord<Elegantbeef> I mean it's a memory borrow system
21:38:29FromDiscord<Elegantbeef> So even at the best of times it can be confusing
21:39:14arkanoidlet's coin *fighting the nim borrow checker*
21:42:16FromDiscord<mratsim> In reply to @auxym "there's no direct way": I use proc with importc just fine. And for variable I use const and oaste the value
21:57:28arkanoidElegantbeef: I've expanded the experiment, and yeah not sure if "views" are to be considered usable or not https://play.nim-lang.org/#ix=3NaU
22:03:20FromDiscord<Elegantbeef> without strictfuncs i think it doesnt know that it's mutable
22:03:26FromDiscord<Elegantbeef> So i think that makes sense for arc/orc
22:03:50FromDiscord<Elegantbeef> Borrowing is harder with the GC, so i assume that's why the errors exist
22:05:40*vicfred quit (Quit: Leaving)
22:06:25FromDiscord<exelotl> I've never once had success with views :(
22:06:58arkanoidexelotl, I am having success, but I'm trying to consider if it's worth or not accepting the consequences
22:07:25arkanoidI really like turning C buffers into zero-copy openArray
22:13:35*PMunch quit (Quit: leaving)
22:36:45arkanoidexelotl, if you have any question, I'm kinda in the flow of writing functions outputting views. Please ask if you want
22:43:25FromDiscord<exelotl> arkanoid: I think the problem is that my main use case is `const` openarrays which don't seem to be implemented yet
22:44:22FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3Nb1
22:46:14arkanoidexelotl, I'm dropping views on these C structs https://play.nim-lang.org/#ix=3Nb2
22:47:25FromDiscord<exelotl> in my case the data needs to be `const` so that it goes in ROM, but because pointers are involved I can't express that in Nim, so have to resort to outputting C code
22:53:53arkanoidnot sure, seems a specific problem
22:55:29arkanoidexelotl, but I can tell you that these two views do work: https://play.nim-lang.org/#ix=3Nb7
22:56:18arkanoidexelotl, please consider that my experience shows that "--experimental:strictFuncs" is required, not suggested but required
23:02:58arkanoidand also is --gc:arc
23:03:05arkanoidor orc obviously
23:11:09arkanoidthe real puzzle to me is why I'm failing to use any variable in a func returning a view. The top one works, the bottom doesn't, and they are exactly the same https://play.nim-lang.org/#ix=3Nbe
23:15:09FromDiscord<ynfle> Do generics work with macros? I want to run code at compile time to compare at runtime with `unittest`
23:16:17FromDiscord<Phil> It does
23:17:25FromDiscord<Phil> I have a generic proc that uses a macro to turn a list of seq[sometype] into seq[sometype. Field]
23:17:48arkanoidwell, solved my issue. You have to use `result =` and not assign first parameter of toOpenArray: https://play.nim-lang.org/#ix=3Nbi
23:18:36FromDiscord<ynfle> In reply to @Isofruit "I have a generic": Can you share the code? I'm not sure if it's the same as I'm thinking
23:19:13FromDiscord<ynfle> sent a code paste, see https://play.nim-lang.org/#ix=3Nbj
23:20:40FromDiscord<ynfle> sent a code paste, see https://play.nim-lang.org/#ix=3Nbk
23:21:40FromDiscord<ynfle> Where's beef? He's a macro wizard 🧙
23:22:18FromDiscord<Elegantbeef> Where's' he
23:22:29FromDiscord<Phil> Wait, what you want to do is evaluate a test at compile time?
23:22:49FromDiscord<ynfle> In reply to @Isofruit "Wait, what you want": Just generate the output and compare at runtime
23:22:50FromDiscord<Phil> I mean, you could evaluate it into a boolean and assert the boolean in the end
23:23:19FromDiscord<Phil> Ohhh the macro generates your "expected" value and your runtime code generates your "actual" value
23:23:22FromDiscord<ynfle> Ya but that won't give error messages
23:23:57FromDiscord<ynfle> In reply to @Isofruit "Ohhh the macro generates": No. generate actual at compile time and compare at runtime with `unittest`. `unittest` doens't work at compile time because of generics
23:25:06FromDiscord<Phil> I'm... not sure that one's feasible because issues within compile-time-code tend to manifest themselves into "it doesn't compile"
23:25:35FromDiscord<ynfle> In reply to @Isofruit "I'm... not sure that": ? I don't understand
23:25:36FromDiscord<Phil> You can check if something compiles with, what I've been introduced to as "the ultimate hack"
23:27:27FromDiscord<Phil> (edit) "You can check if something compiles with, what I've been introduced to as "the ultimate hack"" => "sent a code paste, see https://play.nim-lang.org/#ix=3Nbl"
23:27:36FromDiscord<ynfle> In reply to @Isofruit "You can check if": I dont understand? What is the relevance?
23:27:57FromDiscord<Phil> In reply to @ynfle "I dont understand? What": I was still wrapping up my earlier response, I do one thing after another before I respond to your most recent answer
23:28:10FromDiscord<ynfle> In reply to @Isofruit "I was still wrapping": Oh ok
23:30:21FromDiscord<ynfle> I'm trying to test `func`s that go from `JsonNode` or other objects to `NimNode` that I then use to generate nim code. So instead of writing a bunch of `NimNode`s I'd much rather define the expected in actualy nim code and see whether the 2 values are equal. Hope this clears things up
23:30:24FromDiscord<Phil> In reply to @ynfle "? I don't understand": I'm not aware why a unit test shouldn't work there, your macro just produces some kind of value that you want to stuff into a variable, which then will, post-compilation, just be a variable assignment instead of a computation as to how to get that variable.↵If your assertion happens at runtime to another value, which means your unittest runs at runtime, everything should be fine. Which means I
23:30:47FromDiscord<ynfle> In reply to @Isofruit "I'm not aware why": `NimNode` doesn't exist at runtime.
23:31:01FromDiscord<ynfle> I'm not testing macros. I'm testing function that produce nimnodes
23:31:26FromDiscord<Phil> Can you cast NimNode's to something that exists at runtime (e.g. strings or hashes) ?
23:32:03FromDiscord<ynfle> In reply to @Isofruit "Can you cast NimNode's": The comparison to see what diff would be confusing, no? What exactly do you mean?
23:32:16*PMunch joined #nim
23:33:38FromDiscord<Elegantbeef> `NimNode.repr` will return a string representation of the code
23:34:11FromDiscord<Phil> I'm not aware of such a thing as a test that runs at compile time.↵So your test runs at runtime.↵Basically if you have data structures that don't exist at runtime, turn them into something that does exist at runtime.
23:34:51FromDiscord<Phil> (edit) "runs" => "must run" | "runtime.↵Basically" => "runtime (which you were already aware of IIRC as that was your opener).↵Basically"
23:35:12FromDiscord<Phil> Which appears to be NimNode.repr
23:45:39FromDiscord<ynfle> My primary issue isn't the transformation of the data. That I have already from a previous project. It's capturing the output function. I can't have a generic macro to "run" the functions at compile time so how do I do that?
23:47:56FromDiscord<Elegantbeef> What do you need?
23:48:31FromDiscord<Elegantbeef> Like code example
23:54:37*adigitoleo joined #nim
23:55:38FromDiscord<Phil> (This can include code that doesn't actually work but would work if things worked as you would anticipate)