<< 11-01-2022 >>

00:00:12FromDiscord<Elegantbeef> Atleast cabboose has cabboose on his profile
00:01:13FromDiscord<ajusa> at least with Elegantbeef -> beef331 it's related, leorize and alaviss just have the letters i and l in common.
00:01:50FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3LP2
00:01:59FromDiscord<leorize> lol
00:02:03FromDiscord<Elegantbeef> ajusa using hashsets
00:02:10FromDiscord<Elegantbeef> What an amateur
00:02:19FromDiscord<ajusa> what's the better way of doing this?
00:02:21FromDiscord<congusbongus> you should use lexicographical distance
00:02:55FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LP3
00:02:59FromDiscord<Elegantbeef> or `echo l a`
00:03:11FromDiscord<ajusa> huh setutils is a thing, didn't know that
00:03:29FromDiscord<Elegantbeef> You're welcome
00:10:39*krux02 quit (Remote host closed the connection)
00:18:04NimEventerNew thread by Adigitoleo: Can I haz splat operator, see https://forum.nim-lang.org/t/8793
00:39:37*Figworm joined #nim
00:42:37*noeontheend quit (Ping timeout: 240 seconds)
00:59:03FromDiscord<auxym> hm, `{.completeStruct.}` doesn't have any docs. anyone have info? Nim is telling me I need it for `sizeof` to work
01:00:50FromDiscord<Elegantbeef> You're attempting to use `sizeof` on a `incompleteStruct`
01:03:18FromDiscord<auxym> what's an incompleteStruct?
01:03:28FromDiscord<auxym> I mean it's complete enough for me;)
01:03:32FromDiscord<Elegantbeef> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-incompletestruct-pragma
01:04:56FromDiscord<auxym> ok... but... why? Why would we not want the underlying c struct's size? And if not that, what does it use instead?
01:05:22FromDiscord<Elegantbeef> https://docs.microsoft.com/en-us/cpp/c-language/incomplete-types?view=msvc-170 i think this might help
01:06:02FromDiscord<evoalg> In reply to @adigitoleo "Is there a quick": From what I know there isn't a quick way (not like `toSeq` for seq's), as that question has been asked a few times. Since arrays have to be defined at compile time, it means that seq has to be known at compile time too, and so some guru's have given code snippets (eg a template) to convert a static seq to an array at compile time
01:06:25FromDiscord<auxym> I see, thanks. My C knowledge is somewhat barebones
01:07:57adigitoleoevoalg: Thanks, I thought about it some more and what I really want is probably some cleverer unpacking, hence the forum post.
01:09:47FromDiscord<Elegantbeef> https://github.com/haxscramper/hmatching supports unpacking
01:10:16FromDiscord<Elegantbeef> Unpacking in the compiler would be nicer, but we have packages so use them is my view
01:11:43FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LPh
01:12:13FromDiscord<Elegantbeef> That relies on runtime values
01:12:13FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3LPh" => "https://play.nim-lang.org/#ix=3LPj"
01:12:15FromDiscord<Elegantbeef> Like i said it'll not be possible
01:12:44FromDiscord<leorize> you can't magically assign a variable like that unfortunately
01:12:50FromDiscord<Patitotective> hmm
01:12:52FromDiscord<leorize> do you have a sample code that you want to achieve?
01:13:02FromDiscord<Patitotective> Yes, wait a sec
01:13:18FromDiscord<Elegantbeef> That's how you should do it
01:13:18FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPk
01:13:30FromDiscord<Elegantbeef> Wait union does have unpack now cant remember if that was a fever dream
01:13:45FromDiscord<Patitotective> In reply to @Elegantbeef "Wait union does have": yes, they have
01:15:28FromDiscord<Patitotective> In reply to @leorize "do you have a": The thing is that I have a `OrderedTable[string, PTableTypes]` and when I access a certain key, it's type is `PTableTypes`, which means all of it's defined procedures won't work, so I'm not sure what should I do, because it would be a pain if you needed to write `talbe[key] as tyoe`
01:15:45FromDiscord<Patitotective> (edit) "`PTableTypes`," => "`PTableTypes` (a union),"
01:15:56FromDiscord<Patitotective> (edit) "`talbe[key]" => "`table[key]" | "tyoe`" => "type`"
01:16:45FromDiscord<Patitotective> Should I share my code?
01:17:34FromDiscord<leorize> sure
01:22:06FromDiscord<leorize> not that what you are asking is impossible, but more that it is not very... nice to do, nor will it be very efficient
01:22:21FromDiscord<leorize> there are several ways, all depending on the context that you want to achieve this
01:23:49FromDiscord<Patitotective> https://play.nim-lang.org/#ix=3LPm
01:24:12FromDiscord<Patitotective> What would you recommend then? I cannot stop thinking on python hehe
01:25:56nrds<Prestige99> I recommend stop thinking of python :P
01:26:21FromDiscord<leorize> wow I didn't know that union could do self-referencing types
01:26:57FromDiscord<Patitotective> In reply to @leorize "wow I didn't know": not sure if thats good or not
01:27:07FromDiscord<Patitotective> In reply to @nrds "<Prestige> I recommend stop": intersting
01:27:10FromDiscord<Patitotective> (edit) "intersting" => "interesting"
01:27:15FromDiscord<Elegantbeef> I'm surprised it even works
01:27:41FromDiscord<Elegantbeef> That means `PTableTypes` is typed?
01:27:48FromDiscord<leorize> it is kind of a piece of art
01:28:30FromDiscord<leorize> yea, it is possible to refer to self within the type declaration context
01:28:52FromDiscord<Patitotective> https://tenor.com/view/interesting-gif-21942309
01:29:16FromDiscord<leorize> so from what I can tell you are trying to create a configuration table, right?
01:29:28FromDiscord<Patitotective> yes
01:29:58FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LPn
01:30:15*vicecea quit (Remote host closed the connection)
01:30:45*vicecea joined #nim
01:30:48FromDiscord<leorize> your first problem is that your code is wrong \:p
01:30:55FromDiscord<Patitotective> where?
01:31:14FromDiscord<leorize> your `%` operator
01:31:20FromDiscord<leorize> it doesn't create a table
01:31:30FromDiscord<Patitotective> yeaa....
01:31:46FromDiscord<Patitotective> let me try to fix it
01:31:47FromDiscord<Patitotective> hehe
01:31:48FromDiscord<Patitotective> why is there no _hehe_ sticker?
01:31:53FromDiscord<Patitotective> (edit) "why is there no ... _hehe_" added "a"
01:33:50FromDiscord<Patitotective> https://play.nim-lang.org/#ix=3LPo
01:34:16FromDiscord<Patitotective> Now it does create a table if a table constructor is found, otherwise returns a `PTableTypes` union
01:39:29*noeontheend joined #nim
01:40:13FromDiscord<leorize> at the moment you'll have to make do with this then\: https://play.nim-lang.org/#ix=3LPp
01:41:15FromDiscord<leorize> the reason is simply that unions are not mutation-friendly
01:41:45FromDiscord<leorize> esp when placed in a container, because I can't make Nim infer mutation condition for them
01:42:41FromDiscord<Patitotective> hmm, maybe nim is not ready for _NiPrefs_ (probably im the one thats not)
01:42:47FromDiscord<Patitotective> thanks anyways
01:42:48FromDiscord<Patitotective> 🙃
01:44:18FromDiscord<leorize> JsonNode is much better for the kind of work you are doing here
01:45:07FromDiscord<leorize> mainly because it is packed with utility for container situations (and it is a container as well)
01:45:44FromDiscord<Elegantbeef> JsonNode style data structures handle stuff like this much easier
01:45:57FromDiscord<Elegantbeef> You can make your own version with more types to support what you need
01:46:12FromDiscord<Elegantbeef> But it seems like jsonNode is fine
01:46:28FromDiscord<Elegantbeef> Oh and leorize i have a PR for that static typedef issue 😀
01:46:29FromDiscord<Patitotective> I saw json's code, but it looked like you needed to do `table[key].getInt`, which seems disgusting to me↵but i will try it too lol
01:46:48FromDiscord<Patitotective> (edit) "`table[key].getInt`," => "`table[key].getType`,"
01:46:51FromDiscord<leorize> it's not like union will let you get away with that
01:46:53FromDiscord<Elegantbeef> I mean Nim is statically typed you'll need something like that regardless
01:47:18FromDiscord<Elegantbeef> you cannot just magically make a variable set to the internal of a variable that depends on runtime information
01:47:37FromDiscord<Elegantbeef> You can simulate it with macros, but you cannot evet just do `var a = table[key]` and expect `a` to be a variable type
01:48:50FromDiscord<Patitotective> the problem is that json does only reads and writes (i think), niprefs is supposed to offer a dynamic table interface (updates the file in real time)
01:49:46FromDiscord<Elegantbeef> Make your own type based off the json file that saves on modification
01:49:50FromDiscord<leorize> jsonnode is just a data structure
01:49:56FromDiscord<leorize> how you use that structure is up to you
01:50:11FromDiscord<leorize> you can `distinct` it, too
01:50:48FromDiscord<Elegantbeef> Possibly better to distinct it
01:52:02FromDiscord<leorize> though I'll say that this data structure wastes a lot of memory
01:52:27FromDiscord<Patitotective> In reply to @leorize "though I'll say that": any recommendation?
01:52:48FromDiscord<Patitotective> i'm reading about distinct, but seems like the same problem, i gotta define all procedures for the types
01:53:23FromDiscord<leorize> you can use converter to basically borrow everything
01:54:13FromDiscord<Patitotective> could you share a minimal code to start from? i'm a bit lost he he
01:55:35FromDiscord<leorize> https://play.nim-lang.org/#ix=3LPr
01:56:05FromDiscord<leorize> with this you have access to all JsonNode stuff, but JsonNode stuff can't go the reverse way
02:03:50FromDiscord<leorize> you'd have to figure out the access pattern of your structure and optimize for that, pretty much↵(@Patitotective)
02:03:56FromDiscord<leorize> there is an entire book about it\: https://dataorienteddesign.com/dodbook/
02:04:06FromDiscord<leorize> but if you are lazy like me, use this\: https://github.com/araq/packedjson \:P
02:08:21adigitoleoAny tips on how to get a string into a File, so I can use it as a small mock for testing?
02:08:43FromDiscord<leorize> `writeFile`?
02:20:44adigitoleocan't get it directly into `File` without hitting disk? Just curious
02:21:06FromDiscord<Elegantbeef> You could use a memorymapped file from `std/memfiles`
02:21:24FromDiscord<Elegantbeef> Normal files propagate to disk, memorymapped files are in memory
02:21:37adigitoleonoice
02:28:03*neurocyte09175 joined #nim
02:28:13FromDiscord<Elegantbeef> Depending on what you're doing a `Stream` might be a better general purpose
02:30:15*neurocyte0917 quit (Ping timeout: 256 seconds)
02:30:15*neurocyte09175 is now known as neurocyte0917
02:42:02FromDiscord<IsaacPaul> Anyone know if tables/hashsets work well with open arrays ? I wanna try to avoid copying some of these strings, but also provided lookup tables.
02:42:41FromDiscord<Elegantbeef> In what way?
02:42:57FromDiscord<Elegantbeef> Can you use openArray as a value inside one? Not without views
02:43:07FromDiscord<Elegantbeef> Capturing `openArray` is unsafe
02:43:22FromDiscord<IsaacPaul> Ah ok
02:45:00FromDiscord<Elegantbeef> you can use `ref T`
02:50:22FromDiscord<evoalg> In reply to @Elegantbeef "You could use a": just curious ... what are these used for? If I want data in mem I'd have them in the usual containers ... why would I want it to act like a file?
02:50:45FromDiscord<Elegantbeef> You can use memfiles for inter process communication
02:50:57FromDiscord<Elegantbeef> Where your OS thinks it's a file but it's just in memory
02:51:00FromDiscord<evoalg> ohhhhhh!
02:53:51FromDiscord<IsaacPaul> In reply to @Elegantbeef "you can use `ref": I'm just writing some helper classes to save me a few keystrokes.↵https://gist.github.com/izackp/984899f956b8dda6709d8d187be99beb I was kinda (overly) concerned about memory usage with the additional indexes.
02:54:59FromDiscord<IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3LPG
02:56:39FromDiscord<IsaacPaul> hmm that seems iffy tho..
03:01:02FromDiscord<Elegantbeef> What's iffy about it?
03:01:03FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPJ
03:01:23FromDiscord<Elegantbeef> Or even `type StringRef = distinct ref string` so you are the function that makes them
03:02:13FromDiscord<Elegantbeef> The former probably is fine though
03:02:57FromDiscord<Elegantbeef> You can make a `proc asRef(s: sink string): ref string = new result; result[] = s` to make life easier so you can do `asRef"Hello"` or `s.asRef`
03:04:31FromDiscord<Elegantbeef> As long as the ref string isnt nil it's basically identical to what you're doing with normal strings
03:08:56FromDiscord<IsaacPaul> I think the iffy part is that I don't know how to make string == StringByRef so lookup tables work correctly with both lol.
03:10:27FromDiscord<Elegantbeef> You use the hash for the string
03:10:45FromDiscord<Elegantbeef> so `proc hash(x: StringRef): Hash = hash(x[])`
03:11:30FromDiscord<Elegantbeef> Which means you might need to make a generic disinct table that's `Table[hash, T]`
03:12:55FromDiscord<Elegantbeef> There is also https://nim-lang.org/docs/strtabs.html though it's probably not memory efficient
03:13:09FromDiscord<Elegantbeef> By the way you do know with `orc/arc` if you dont use the string after adding it to a table it's moved and not copied?
03:13:14FromDiscord<Elegantbeef> So it's a non allocating operation
03:14:12adigitoleohow do I use private procs from my package when I'm testing? Is there some alternate import syntax for that?
03:14:34adigitoleoby testing I mean unit tests in tests/foo.nim
03:14:38FromDiscord<Elegantbeef> The first thing is "you should test non public API" but the second thing is `import myModule{.all.}`
03:14:48FromDiscord<Elegantbeef> "you shouldnt test non public API"\
03:15:04FromDiscord<IsaacPaul> I did not know about strtabs and about orc/arc 😮
03:15:12FromDiscord<IsaacPaul> (edit) "and about" => "or"
03:15:16adigitoleoI see, maybe I need to rethink the approach, I'm new to unit testing. Thanks
03:15:34FromDiscord<Elegantbeef> So i mean you can test it but generally it's bad form
03:16:00FromDiscord<Elegantbeef> Yea Isaac anywhere you see `sink` means "If we dont need to copy we will not"
03:16:44FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPL
03:17:10FromDiscord<IsaacPaul> good to know
03:17:23FromDiscord<Elegantbeef> That only works with Nim's Orc/Arc though
03:17:27FromDiscord<Elegantbeef> if using refc it'll copy afaik
03:17:58FromDiscord<IsaacPaul> I'm currently using arc, it seems appropriate for a game.
03:18:06FromDiscord<Elegantbeef> So just by doing `--gc:orc` you can reduce memory footprint
03:18:40FromDiscord<Elegantbeef> Using orc is fine it'll only worry about places where cycles are and if you dont have any it doesnt matter
03:19:14FromDiscord<IsaacPaul> I'm used to dealing with cycles since I work in swift/objc for my day job.
03:19:26FromDiscord<IsaacPaul> So figure I'm fine without it
03:19:49FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPN
03:23:13FromDiscord<Elegantbeef> Well you do you
04:00:37*noeontheend quit (Ping timeout: 240 seconds)
04:05:27*arkurious quit (Quit: Leaving)
04:39:16*rockcavera quit (Remote host closed the connection)
04:41:53*termer joined #nim
04:42:23termerhey, is there any way to set an object property as mutable or immutable?
04:42:51FromDiscord<Elegantbeef> You cannot set object fields to immutable or mutable you can make properties though
04:43:00termerI'm getting "<...> cannot be assigned to"
04:43:32termerhow would I go about doing that
04:43:50termermy object is pretty simple and I don't see what I'm doing that's making its fields immutable
04:44:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPY
04:45:17termerinteresting
04:45:35termerwell right now I'm not sure why I can't change any of my object fields
04:45:37FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LQ0
04:45:46FromDiscord<Elegantbeef> You declared it with `let`
04:45:50FromDiscord<Elegantbeef> `let` is immutable `var` is mutable
04:46:06FromDiscord<Elegantbeef> If you're ina proc you passed it without `var`
04:46:21termerhttps://play.nim-lang.org/#ix=3LQ1
04:46:23termerthis is my object
04:46:34termerall of the fields seem to be immutable
04:46:56FromDiscord<Elegantbeef> How do you declare the variable?
04:47:20FromDiscord<Elegantbeef> I have a feeling you do `let myVar = Server()`
04:47:54termerhttps://play.nim-lang.org/#ix=3LQ2
04:47:58termerOH
04:48:01termeryou're right
04:48:08FromDiscord<Elegantbeef> `server: var Server`
04:48:10termerwait no
04:48:15termerOh I see
04:48:29termerso it's implicitley let then?
04:48:32FromDiscord<Elegantbeef> If you want to mutate a parameter you have to say `var`
04:48:43FromDiscord<Elegantbeef> Parameters are implicitly immutable yes
04:48:53termerI didn't realize that args params were implicitely let
04:48:59termerthanks so much
04:49:02termerI was so confused
04:49:26FromDiscord<Elegantbeef> I did answer a completely unrelated question 😀
04:49:51termera very important one lol
04:50:06FromDiscord<Elegantbeef> Also because of how mutability works in Nim `ref object` fields are mutable
04:50:40FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LQ4
04:55:11adigitoleois there a method for getting all field names of an object?
04:55:32FromDiscord<Elegantbeef> `for name, _ in object.fieldPairs: echo name`
04:55:53FromDiscord<Elegantbeef> As long as it's not a variant object it'll work
04:56:53adigitoleoOh crap I meant getting the field list for a typedesc
04:57:16FromDiscord<Elegantbeef> `for name, _ in typeDesc().fieldPairs: ...` 😀
04:57:24adigitoleolol
04:57:50FromDiscord<Elegantbeef> Types can be instantiated from typedescs so yea it's comically not different
04:58:06FromDiscord<Elegantbeef> Ideally a macro could be made to make this more tame
04:58:40adigitoleomeh it's fine, I just didn't grok it
04:59:22FromDiscord<Elegantbeef> What are you after anywho, somewhat of an odd thing to want
05:00:24adigitoleoOh it's not for proper code, just to check stuff in playground, when I can't remember the fields of a type like CatchableError
05:00:55FromDiscord<Elegantbeef> Ah
05:01:12FromDiscord<Elegantbeef> https://nim-lang.org/docs/system.html#Exception
05:03:48FromDiscord<Elegantbeef> Though i guess a general purpose solution is easier than navigating
05:04:25FromDiscord<Elegantbeef> you could put a variable inside the `_` block and then do `echo "name: ", name, " type: ", typeof(field)`
05:20:00NimEventerNew thread by Niminem: How to import all identifiers from module, see https://forum.nim-lang.org/t/8794
05:30:39termerso now I've got a new issue with vars
05:30:55FromDiscord<Rika> Which is
05:31:08termerusing var Server as a parameter yields a compiler error: server' is of type <var Server> which cannot be captured as it would violate memory safety
05:31:28termersearching online didn't do much for me since it mostly talks about closures
05:31:30FromDiscord<Elegantbeef> You're attempting to use a closure with a `var T`
05:31:33FromDiscord<Elegantbeef> That's unsafe
05:31:33FromDiscord<Rika> Async I assume
05:31:36termerasync
05:31:43FromDiscord<Rika> Yup, no can do
05:32:01termerso can mutable objects not be passed to async procs at all?
05:32:10FromDiscord<Rika> Either use a ref or redesign I would say
05:32:42termerswitching var Server to ref Server causes random errors everywhere that make no sense
05:32:55termeris that a syntax error or something
05:33:05termerLooks like I need to look more into refs
05:33:49FromDiscord<congusbongus> why not refactor the code so that it returns a result instead of mutating its inputs
05:34:26termerthere is server state that needs to be modified
05:34:43FromDiscord<Rika> The errors are likely because you have other procs still using var
05:34:44FromDiscord<congusbongus> yeah so... return the new server state, and have the caller modify the server state
05:34:44termerlike whether it is accepting connections or not, which can change based on events received asynchronously
05:35:47FromDiscord<Rika> Yeah use a ref then
05:36:17termerall right
05:36:36termerI read that's unsafe, is that because I can modify it regardless of whether it was declared as var or let?
05:36:44termeror are there more pressing concerns
05:37:05FromDiscord<Rika> I don’t know maybe nil safety
05:38:30termerhow does one get a ref of an existing object
05:38:42FromDiscord<Elegantbeef> `new Type`
05:38:55FromDiscord<Elegantbeef> You cannot make a normal object a ref object
05:39:25FromDiscord<Elegantbeef> Normal objects are conventionally stored on the stack which means you cannot make a ref to it
05:39:35termerhow does that work with constructors then
05:39:44termerdoes that mean I will have to write special ref constructors
05:39:49termerI guess it does
05:39:57FromDiscord<Elegantbeef> `Server()` does heap allocate
05:40:13FromDiscord<Elegantbeef> If it's a `ref object` i should add
05:40:30FromDiscord<Rika> `(ref Server)()` also works
05:40:52termerall right
05:41:02termerthanks
05:55:55adigitoleo^^ got me thinking about stack vs heap (I'm from python so my square brain don't understand this very well)
05:56:09adigitoleoI wonder if someone could annotate this to help me out?
05:56:10adigitoleohttps://play.nim-lang.org/#ix=3LQr
05:56:53adigitoleoDoes that all play out on the stack?
05:57:09FromDiscord<Rika> Yes
05:57:12FromDiscord<Rika> Except strings
05:57:25FromDiscord<Rika> Strings in this case are heap
05:58:18adigitoleoOh yeah Nim strings are mutable, right
06:02:00FromDiscord<Rika> That’s not why, it’s that they have variable size
06:02:45FromDiscord<Elegantbeef> Yea even immutable are heap allocated
06:02:46adigitoleoRight because you can .add()
06:03:09FromDiscord<Elegantbeef> Immutable strings are also heap allocated since they're dynamic size
06:03:14FromDiscord<Elegantbeef> They're not statically known
06:03:29FromDiscord<Elegantbeef> Plus many immutable strings could easily crash your program if they were not
06:03:32FromDiscord<Elegantbeef> Stack is relatively small
06:03:42adigitoleoAh
06:03:55FromDiscord<Rika> And alloca() is evil
07:09:48*PMunch joined #nim
07:17:47szahidHello :)
07:18:20FromDiscord<Elegantbeef> Hello
07:18:52PMunchHi
07:19:04FromDiscord<Elegantbeef> No you!
07:19:47szahidIs nim ready for production?
07:20:00FromDiscord<Elegantbeef> People are using it as such
07:20:06PMunchWell we use it in production at work
07:20:12PMunchSo I'd say so
07:27:05FromDiscord<Rika> What does “ready for production” mean for you
07:27:22FromDiscord<Rika> What do you expect out of Nim basically
08:06:48adigitoleoCompiler says "Error: type mismatch: ...", and I know how to fix it, but in general how do I figure out the typedesc of an error?
08:07:03adigitoleoWant it for `expect` statement in tests
08:07:27FromDiscord<Elegantbeef> Mismatches are not exceptions
08:07:33FromDiscord<Elegantbeef> They're compiler errors
08:07:47adigitoleoOof, can I expect them in unittest somehow?
08:07:49*Gustavo6046 quit (Quit: Leaving)
08:08:04FromDiscord<Elegantbeef> No they're compiler errores
08:08:38FromDiscord<Elegantbeef> I assume you're from python?
08:08:43adigitoleoyep
08:08:57FromDiscord<Elegantbeef> Ah type mismatches are no goes
08:09:43FromDiscord<Elegantbeef> Meaning if they appear it's user error 😛
08:10:57FromDiscord<Elegantbeef> Nim is statically typed which means types are known and error at compile time at mismatches
08:11:21adigitoleouse case is parsing command line, if user gives -f:2.4 then I want to fail because I need integers
08:11:57FromDiscord<Elegantbeef> well that's a `except ValueError` or w/e `parseInt` returns
08:12:00FromDiscord<Rika> That’s something else from a type mismatch
08:12:04adigitoleoso I guess it's a parse error
08:12:07adigitoleoyeah
08:12:08FromDiscord<Rika> Yes
08:51:58*jjido joined #nim
08:58:25NimEventerNew post on r/nim by PrettySeriousUser: connect_the_dotfiles - A (dot)file organizer in Nim, see https://reddit.com/r/nim/comments/s18lw0/connect_the_dotfiles_a_dotfile_organizer_in_nim/
09:02:01FromDiscord<pietroppeter> interesting article (actually a podcast but there is the transcript) on memory management with author of jq (many remarks on Rust and OCaml). https://signalsandthreads.com/memory-management/ Wish I could understand it 🙂
09:12:06*neurocyte0917 quit (Quit: The Lounge - https://thelounge.chat)
09:13:48*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
09:14:28FromDiscord<Elegantbeef> Is it mostly just talking about move semantics based RC?
09:14:47*neurocyte0917 joined #nim
09:18:59FromDiscord<pietroppeter> mmh, not really it actually starts from the very basic (it is long, have not read fully). the interviewee (Stephen Dolen) now works on OCaml so it talks a lot about that but it really is rather general about stack vs heap, tracing vs ref counting (at least the first part). it is very well written (well it is actually spoken)
09:26:44FromDiscord<Elegantbeef> Unrelated but have you played with nimscripter yet? (I seen the forum post 😛 )
09:29:51FromDiscord<Rika> What
09:29:54FromDiscord<Rika> Where is that from
09:30:34FromDiscord<Elegantbeef> Huh?
09:33:23FromDiscord<Rika> The nim scripter plug
09:33:28FromDiscord<Rika> Why suddenly
09:33:43FromDiscord<Elegantbeef> Cause he mentioned it in a forum post
09:34:02FromDiscord<Rika> Eeh which
09:34:19FromDiscord<Elegantbeef> We also talked about it beefore
09:35:24FromDiscord<Elegantbeef> https://forum.nim-lang.org/t/8777 this one
09:40:30FromDiscord<pietroppeter> In reply to @Elegantbeef "Unrelated but have you": no not yet! I guess until FOSDEM I will likely not have time (unless I manage to talk about it for FOSDEM talk, I think I will mention it anyway)
09:41:11FromDiscord<pietroppeter> btw, when I did the Made in Nim forum post I was surprised by the link which gave the interactive application, did it change with respect to when you first shared it?
09:41:24FromDiscord<Elegantbeef> No
09:41:34FromDiscord<Elegantbeef> Always was snake
09:42:26FromDiscord<pietroppeter> but was it already playable? I remember seeing a video, not something I can interact with
09:42:44FromDiscord<pietroppeter> (btw I realized now it is snake... 🤦‍♂️ )
09:43:19FromDiscord<Elegantbeef> That link has always been a scriptable snake
09:43:19FromDiscord<Rika> 0/10 not the mathematical game Nim
09:43:44PMunchHas anyone done Nim in Nim yet?
09:43:59FromDiscord<Rika> Sounds like a meme idea
09:44:50FromDiscord<pietroppeter> In reply to @Elegantbeef "That link has always": then I am really bad at internet... did you share a video in the chat? well, for anotehr more productive question. the code/build instruction to (re)produce what comes up at that link is available?
09:45:02FromDiscord<Elegantbeef> I've shared videos before
09:45:24FromDiscord<pietroppeter> ok, I'll settle for that then and stop thinking I was crazy 😄
09:45:44FromDiscord<Elegantbeef> That code is not public due to using forked Nico
09:46:21FromDiscord<Elegantbeef> Though i dont recall if it's needed since i think impbox may have removed the procs
09:48:32FromDiscord<Elegantbeef> I say required but i was just being lazy
09:48:38FromDiscord<Elegantbeef> And wanted to use my macro instead of manuall wrapping
09:53:35FromDiscord<pietroppeter> ok, if you happen to make it public let me know. anyway I checked and experiment it with nimscripter is in my potential task list for FOSDEM presentation (but I expect a small subset of those to be done for the presentation): https://github.com/pietroppeter/soscin22/blob/main/README.md#tasks
10:04:20FromDiscord<Elegantbeef> I probably should make a few examples
10:04:27FromDiscord<Elegantbeef> I do have a silly macro inspector example
10:04:51FromDiscord<Elegantbeef> https://streamable.com/c6farb this thing
10:11:58adigitoleois there a way to capture stdout or output of `echo` in a unit test? I prefer to stick with std/unittest if possible
10:13:29adigitoleomaybe `exec` from nimscript?
10:14:23adigitoleoAh nevermind docs tell me about `gorgeEx` from system
10:48:05FromDiscord<Benjamin> sent a code paste, see https://play.nim-lang.org/#ix=3LRU
10:48:20FromDiscord<Benjamin> ^ What am I doing wrong? I get this error\: `Error: internal error: /home/runner/work/nightlies/nightlies/nim-1.6.2/compiler/ccgstmts.nim(1597, 18)`
10:49:58FromDiscord<Elegantbeef> You've created code the Nim compiler doesnt like
10:51:06FromDiscord<Elegantbeef> I assume it's the async stuffs + route macro
10:51:37FromDiscord<Elegantbeef> Yep
10:51:52FromDiscord<Elegantbeef> The usage of async inside one the macros is the issue
10:51:52FromDiscord<Benjamin> I had another example where it worked inside routes but without case...of. I'll see if I can replicate it.
10:52:03FromDiscord<Elegantbeef> It might be with the case
10:52:18FromDiscord<Elegantbeef> Something is creating AST that the compiler doesnt like
10:52:54FromDiscord<Benjamin> Yeah, it works if I remove the case or routes
10:53:02FromDiscord<evoalg> In reply to @Rika "That’s not why, it’s": So if strings are on the heap because of variable size, does that mean seq's are also on the heap?
10:53:10FromDiscord<Elegantbeef> Yes
10:53:19FromDiscord<evoalg> thx you
10:53:23FromDiscord<Elegantbeef> Anything that is dynamic tends to be heap allocated
10:53:38FromDiscord<Elegantbeef> Yea benjamin sorry cant help, create an issue on jester, i'm going to bed
10:53:38FromDiscord<Benjamin> I guess I'll use if-else as a workaround for now
10:54:15adigitoleosyntax for tuple type declaration? is it possible?
10:54:17FromDiscord<Benjamin> Thanks anyway! Goodnight \:)
10:54:56FromDiscord<Rika> Same syntax as object except you put tuple instead
10:55:08FromDiscord<Rika> And you can’t declare fields as exported
10:55:14FromDiscord<Rika> (They’re exported by default)
10:55:22adigitoleothanks
11:10:38FromDiscord<Benjamin> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/930413958697984020): Yeah, it works if I remove the case
11:18:35FromDiscord<pietroppeter> In reply to @Elegantbeef "https://streamable.com/c6farb this thing": this also looks very nice and also weird (setRenderSettings does not seem valid nimscript code, is the magic happening through some IDE plugin? which IDE is with those nice crowns?)
11:26:05PMunchI think it's just VSCode
11:27:44FromDiscord<pietroppeter> I use VS code but I do have different icons though: https://media.discordapp.net/attachments/371759389889003532/930422724642349066/unknown.png
11:31:23FromDiscord<pointystick> If you search the VS Code extensions for "file icon theme", there are lots of examples. The first one seems to have that icon (I've not tried it to confirm): https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme
11:34:14FromDiscord<Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=3LS7
11:34:49FromDiscord<Tanguy> (edit) "https://play.nim-lang.org/#ix=3LS7" => "https://play.nim-lang.org/#ix=3LS8"
11:35:47FromDiscord<Tanguy> Oh, `template hoy: var int = hey` works, nvm
11:40:03PMunchYou could also do `untype`, `typed`, or even `auto` if you'd like
11:43:13szahidHow i can parse JArrar to Array of Structures?
11:51:15*jjido joined #nim
12:06:47FromDiscord<pietroppeter> In reply to @pointystick "If you search the": thanks!
12:09:12adigitoleoif tuples are fixed size, why can't I len() them?
12:09:21FromDiscord<Michal Maršálek> If a large const seq is only used at compile time, is that a guarantee that it will not be present in the binary?
12:11:34FromDiscord<Rika> In reply to @adigitoleo "if tuples are fixed": https://nim-lang.org/docs/typetraits.html#tupleLen%2Ctypedesc%5B%5D
12:16:36adigitoleorika: thanks, although I'd still prefer len() ;) Anyway I should probably take a break.
12:20:03FromDiscord<Rika> Can just alias the function if you want
12:21:14adigitoleoyeah it's just getting my pea brain to remember haha
12:33:43FromDiscord<Yardanico> In reply to @Michal58 "If a large const": yes, since Nim always has DCE enabled
12:54:24*rockcavera joined #nim
12:54:24*rockcavera quit (Changing host)
12:54:24*rockcavera joined #nim
12:59:38PMunch@Michal_Maršálek, you can even have objects that you pass around from call to call, as long as the object itself is never assigned to a let or a var you're good
12:59:47PMunchThis is what I do in my keyboard firmware
13:05:07FromDiscord<Michal Maršálek> And if it is assigned to let but never used it stays?
13:05:18FromDiscord<Michal Maršálek> (edit) "let" => "var"
13:05:28FromDiscord<Yardanico> if it's just a direct assignment I don't think it'll stay if it's not used
13:05:33FromDiscord<Yardanico> But why have it in the first place then?
13:09:58FromDiscord<Michal Maršálek> Not sure I understand the question. My macros need some data to work with which is not needed at runtime.
13:11:56FromDiscord<Rika> If it’s assigned to a var in a macro it’s fine
13:16:02FromDiscord<Michal Maršálek> No it's a global that is used my more macros
13:26:56PMunchWhat I do in my code is that I save my objects as const
13:27:37PMunchThen I have macros like `high`, `low`, `output`, `pullup`, etc. that unpacks the fields from the static object on compile-time and rewrites that to the efficient runtime code.
13:27:58PMunchSo none of the compile-time objects are ever stored in memory during runtime
13:28:32PMunchAlthough as you can see I use the objects around in my code: https://github.com/PMunch/badger/blob/master/badger.nim
13:28:42PMunchBut I always pass them to macros
13:28:52PMunchOne slightly challenging thing was to make loops work in a good way
13:29:29*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
13:33:13PMunchOriginally I just unrolled the loop on compile-time, but that created really big code. So my later approach was to loop over the range of the collection (e.g. `for i in myPins.low..myPins.high`) and then I have a dummy object assigned to the iterator variable with a template to read that dummy type. In the template I have a case statement that selects the correct action based on the value. So the case statement contains all the unpacked versions of my objects,
13:33:13PMunchand the reader now just returns the right one.
13:33:22PMunchThis is the `withPinAs` macro
14:47:00*arkurious joined #nim
14:58:03termerWhat would be the best way to convert 2 uint8 into 1 uint16?
14:58:18termerI'm not familiar with nim's bitshifting interface or whether it uses big endian or little endian
14:58:36termeror how to find out the platform's endianness if it's platform-dependent
15:03:43FromDiscord<el__maco> `a shl 8 + b` basically
15:04:02FromDiscord<el__maco> endianness matters only if you read a and b from some memory location
15:08:21FromDiscord<Michal Maršálek> Is xor and + the same speed?
15:08:51FromDiscord<Michal Maršálek> (edit) "xor" => "(x)or"
15:09:28FromDiscord<Michal Maršálek> (edit) "(x)or" => "`(x)or`" | "+" => "`+`"
15:09:55FromDiscord<el__maco> you mean `a shl 8 or b`? Yes I don't think there's any difference
15:13:53FromDiscord<Patitotective> sent a code paste, see https://paste.rs/vSZ
15:17:04termerthanks
15:20:21*covoid19 joined #nim
15:21:20*jjido joined #nim
15:24:06FromDiscord<Michal Maršálek> Use the JsonNode constructor or create an init proc.
15:25:34FromDiscord<Michal Maršálek> And I don't think you need converters to convert between distincts.
15:27:13FromDiscord<Michal Maršálek> @Patitotective
15:27:31arkanoidis there a way to generate autmatically .h for exported nim function for C++ / Nim(C) interop?
15:27:55FromDiscord<Patitotective> In reply to @Michal58 "Use the JsonNode constructor": Thanks, I'm going to create a proc 🙃
15:30:15FromDiscord<Michal Maršálek> In reply to @Patitotective "Thanks, I'm going to": But I feel like what you wrote should be allowed.
15:31:55*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
15:39:02FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LTm
15:39:47FromDiscord<Patitotective> I'm trying to create a procedure to create new prefs node automatically, so depending on the type of the object you pass to it, it instances a differend kind of prefs node but it is saying that `Error: selector must be of an ordinal type, float or string`
15:40:39FromDiscord<Rika> not that i know of, use regular if/else
15:41:47FromDiscord<Patitotective> k
15:42:07FromDiscord<Rika> i mean when/else
15:42:10FromDiscord<Rika> types require when
15:42:56FromDiscord<Patitotective> and `is`, right?
15:46:52FromDiscord<Patitotective> What is the problem here? https://play.nim-lang.org/#ix=3LTq
15:47:14FromDiscord<Patitotective> Not sure if `get`'s template is correct
15:49:34FromDiscord<Patitotective> Oh, it seems like the return type has to be the same always
15:50:41FromDiscord<Patitotective> I thought templates weren't procedures (?) Like, the just replaced some piece of code
16:05:14FromDiscord<Patitotective> Also, in here https://play.nim-lang.org/#ix=3LTw↵It seems like `openArray[PrefsNode]` is not valid (?), what would be the proper way for specifying a unknown length array
16:05:29FromDiscord<Patitotective> Is that even possible?
16:05:47FromDiscord<Patitotective> Cause in json, `JArray` is a sequence, not an array
16:09:31FromDiscord<iffy (Matt Haggard)> How do I get the current system's CPU architecture from within my nim program? e.g. x86, x86\_64, arm64, etc...
16:11:32FromDiscord<Rika> yeah youre not gonna be able to make a "get" proc like that no
16:12:00FromDiscord<Rika> In reply to @Patitotective "Cause in json, `JArray`": a "sequence" and an "array" are both lists of objects
16:12:15FromDiscord<Rika> in JSON, "array" means more of list of objects than literal array
16:12:24FromDiscord<Rika> so yes dont worry and use a sequence
16:13:07FromDiscord<Patitotective> In reply to @Rika "so yes dont worry": Thanks 🙃
16:13:56FromDiscord<Rika> minor changes i made https://play.nim-lang.org/#ix=3LTB
16:14:24FromDiscord<Rika> ah i just saw the array and seq thing
16:14:43FromDiscord<Rika> remove the array thing and maybe change PSeq to PList to be more explicit that you dont care if its an arr/seq
16:15:57FromDiscord<Patitotective> 👍
16:38:03FromDiscord<Patitotective> Also, why does json creates `JsonNodeObj` and then a ref to it called `JsonNode`?
16:38:13FromDiscord<Patitotective> I copied it, but I do not understand it hehe
16:44:02FromDiscord<Elegantbeef> https://nim-lang.org/docs/system.html#hostCPU
16:59:32FromDiscord<iffy (Matt Haggard)> ah, perfect... though I wish it were a tuple instead of a string
17:02:35FromDiscord<Elegantbeef> well if you need to know the arch size you should be able to do `sizeof(pointer)`
17:10:59FromDiscord<Patitotective> Also, @Rika , Do you think is better to have a template `newPrefsNode` to convert the given type into a `PrefsNode` or multiple procs for each type?
17:18:58FromDiscord<Rika> i dont follow
17:20:12FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LTV
17:21:39FromDiscord<Elegantbeef> The latter is easier to extend
17:21:57FromDiscord<Elegantbeef> Plus supports other options in case you need them
17:22:04FromDiscord<Patitotective> Ok 🙃
17:27:01FromDiscord<Patitotective> What happens if I define the `%` and `%` macros in niprefs and you import json? would you need to do `niprefs.%` or `json.%`?
17:27:13FromDiscord<Rika> no
17:27:19FromDiscord<Rika> since your type is distinct
17:27:33FromDiscord<Rika> that means the json procs are "not compatible" with your type and viceversa
17:28:11FromDiscord<Elegantbeef> remember Rika %\ are operators that work on anything
17:28:18FromDiscord<Elegantbeef> So yes you'd have to cause it's ambiguous
17:28:29FromDiscord<Rika> eh are they
17:28:33FromDiscord<Rika> i dont recall
17:28:42FromDiscord<Rika> ah is this the % that works on tuple seqs
17:28:43FromDiscord<Alea> Is there a way to get the key of the current item while iterating over a table?
17:28:48FromDiscord<Elegantbeef> `%` is the dumb "toJson" operator
17:28:50FromDiscord<Patitotective> In reply to @Elegantbeef "So yes you'd have": uh
17:28:50FromDiscord<Rika> then yeah you would need to disambiguate
17:29:02FromDiscord<Rika> also i wouldnt recommend it
17:29:08FromDiscord<Rika> i'd prolly name it something else
17:29:16FromDiscord<Rika> its both ambiguous and ambiguous
17:29:18FromDiscord<Elegantbeef> `for key, val in table.pairs`↵(@Alea)
17:29:26FromDiscord<Alea> Thanks!
17:29:41FromDiscord<Elegantbeef> `%` is just purposely cryptic
17:30:02FromDiscord<Rika> not a purpose i would deem worthy for making it cryptic
17:30:04FromDiscord<Elegantbeef> Name your macro `toNipref` or something not purposely obtuse
17:30:38FromDiscord<Rika> or a to[T] generic constrained to your type xd
17:31:20FromDiscord<Patitotective> what about `¬`and `¬`?
17:31:22FromDiscord<Patitotective> prank
17:32:22FromDiscord<Rika> your choice
17:32:48FromDiscord<Patitotective> can a macro be used like `macro{key: val, ...}`?
17:32:51FromDiscord<Patitotective> without spacing
17:32:53FromDiscord<Patitotective> (edit) "spacing" => "spacing?"
17:33:24FromDiscord<Rika> not sure, probably
17:33:35FromDiscord<Rika> actually depends on the name i guess
17:33:54FromDiscord<Patitotective> In reply to @Rika "actually depends on the": wdym
17:34:11FromDiscord<Rika> if its an operator yes, if not im not sure
17:34:46FromDiscord<Elegantbeef> No it cannot
17:34:48FromDiscord<Elegantbeef> having a space \> using cryptic operators
17:34:49FromDiscord<Elegantbeef> Doing `doThing {'a', 'b', 'c', 'd'}` is better than `&$&% {'a', 'b', 'c', 'd'}`
17:34:52FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LU0
17:34:56FromDiscord<Elegantbeef> If you want that operator make an untyped template you use, but dont include it in the library
17:35:06FromDiscord<Elegantbeef> make the library have `toNipref`
17:35:17FromDiscord<Elegantbeef> Assuming this is a library that's going to be released
17:35:32FromDiscord<Elegantbeef> If it's not then do whatever you want
17:36:10FromDiscord<Patitotective> In reply to @Elegantbeef "make the library have": `toPrefs` -_- lmao
17:36:12FromDiscord<Patitotective> thanks 🙃
17:36:27FromDiscord<Elegantbeef> Anyway it's better than an operator for 99.9% of people
17:36:36FromDiscord<Elegantbeef> If they want an operator templates exist
17:36:57FromDiscord<Patitotective> so json's 👎
17:37:00FromDiscord<Patitotective> (edit) "so json's 👎 ... " added "hehe"
17:37:06FromDiscord<Elegantbeef> Yea it's fucking stupid
17:37:24PMunchJSON is stupid?
17:37:34FromDiscord<Elegantbeef> Json's `%` operator
17:38:01PMunchAh, I kinda like it..
17:38:10FromDiscord<Patitotective> how lucky i am that there's a elegant beef to help me (and a rika, but rika is not beef)
17:38:20FromDiscord<Elegantbeef> The operator made just to do `toJson` and save 3 characters but looks as intuitive as a knife made out of knifes
17:38:35FromDiscord<Elegantbeef> See pmunch you can like it but it shouldnt be in the library
17:38:56FromDiscord<Elegantbeef> If you want `%` you should have to implement it yourself as a template to `toJson`
17:39:05PMunchThat's tedious
17:39:18FromDiscord<Elegantbeef> It's an ugly operator that is untinutive
17:39:23PMunchYou can make the same argument that if you don't want it you can `import json except `%``
17:39:35FromDiscord<Elegantbeef> It's like the bitwise operators for C++'s streams
17:39:38FromDiscord<Elegantbeef> They have 0 reason to being there
17:39:41FromDiscord<Elegantbeef> Sure that works to
17:39:58FromDiscord<Elegantbeef> Eitherway it should be a named macro
17:40:33FromDiscord<Hamid_Bluri> it's not that bad really
17:40:40PMunchI agree that `toJson` should also exist
17:40:50FromDiscord<Elegantbeef> It's purposely obtuse imo
17:40:58PMunchAnd `%*` just be a template to `toJson` or something like that
17:41:01FromDiscord<Elegantbeef> It does not show intent, it's just a funky operator
17:41:13FromDiscord<Rika> purposely? no, more like unnecessarily
17:41:23PMunchWell with JSON I don't think it's too bad, since the rest of the JSON syntax is there
17:41:37FromDiscord<Elegantbeef> But you can use it on normal objects
17:41:59FromDiscord<Elegantbeef> So you're capable of doing `var a = % MyObject(a: 100, b: 20, c: @[10, 2, 30])`
17:42:02PMunchIf I come across something that looks like json, prefixed with an unknown operator, being passed to something that accepts JSON, I will put 2 and 2 together
17:42:20PMunchWell of course, but that's just silly
17:42:28FromDiscord<Rika> is it
17:42:30FromDiscord<Elegantbeef> I've seen it
17:42:41PMunchBuilding an object just to immediately jsonize it?
17:42:52FromDiscord<Elegantbeef> It's just like the stream operators in C++'s streams
17:42:52PMunchI've seen `let x = %myObj`
17:42:58FromDiscord<Elegantbeef> They dont make it easyto read
17:44:15PMunchWell, it's one less word, and if you're adding JSON in there it should be obvious to anyone reading what you're doing
17:44:29FromDiscord<Rika> is it?
17:44:44FromDiscord<Rika> if you have "mixed code" say handling json and doing a bunch of other stuff in the same proc
17:44:48FromDiscord<Rika> is it still obvious
17:45:03PMunchThe stream operators are a bit wonky in different way. Since you don't necessarily get any extra hints to what the operator is doing it might not be that easy to grok what's going on
17:45:27FromDiscord<Elegantbeef> It's putting operators where they dont belong imo
17:45:33PMunch@Rika, maybe not, and as I said I would've liked to see a `toJson` proc as well
17:45:46PMunchIf you needed to clarity
17:45:48*neurocyte09179 joined #nim
17:45:49*neurocyte0917 quit (Ping timeout: 240 seconds)
17:45:49*neurocyte09179 is now known as neurocyte0917
17:47:47arkanoidonce I have finished "nimble develop"ing a package and I want to go back to normal package handling, what should I do?
17:48:20arkanoidI mean, I wanted to test a little change in existing package, and now I want to return to normal "nimble install" condition
17:48:57FromDiscord<Rika> uninstall the developed package?
17:49:16arkanoiddo you mean "nimble uninstall" or remove the local folder
17:49:22FromDiscord<Rika> nimble uninstall xxx@#head
17:49:54arkanoidhow does nimble know if the deleted version should be the locally installed one or the one in ~/.nimble
17:50:09FromDiscord<Rika> the one locally installed is usually versioned #head
17:50:27FromDiscord<Rika> unless your global install is also head
17:54:12FromDiscord<Patitotective> ~~nothing feels better than copying and pasting json's code~~
17:56:26FromDiscord<Michal Maršálek> I guess this is the proper way? @Yardanico https://nim-lang.org/docs/manual.html#pragmas-compiletime-pragma
17:59:14FromDiscord<Elegantbeef> Since this is running in a program nimsuggest doesnt have the information of what's valid, which is why the error line on `setRenderSettings`↵(@pietroppeter)
18:00:03FromDiscord<Elegantbeef> And yea it's just vscode
18:06:46FromDiscord<Michal Maršálek> In reply to @Patitotective "Thanks, I'm going to": I created an issue: https://github.com/nim-lang/Nim/issues/19367
18:06:50arkanoidis it possible to make a variant object that is also a "ref object of AnotherObject"?
18:07:11FromDiscord<Elegantbeef> Actually that shouldnt be supported
18:07:37arkanoidok, np, I can wrap the variant one into the ref one
18:07:45FromDiscord<Patitotective> In reply to @Michal58 "I created an issue:": 👍
18:08:22FromDiscord<Elegantbeef> Can you not just make a variant object inside a inheriting object?
18:08:31FromDiscord<Elegantbeef> But michal that shouldnt be supported
18:08:33arkanoidexactly
18:08:54FromDiscord<Michal Maršálek> In reply to @Elegantbeef "But michal that shouldnt": Sorry for spamming the github than :/ why not?
18:09:03arkanoidbtw I'm experimenting with nimqml and I'm having quite good results!
18:09:04FromDiscord<Michal Maršálek> (edit) "than" => "then"
18:09:23FromDiscord<Elegantbeef> I atleast dont think it should, since distinct should always be converted from the "base" to validate the type
18:09:30arkanoidI think there should be more interest in this package, it enables one of the most used gui library in industry
18:09:37FromDiscord<Elegantbeef> When you can create a value directly you cannot get the same validations
18:10:00FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LU9
18:10:02FromDiscord<Elegantbeef> But only when you borrow `.` operators
18:10:10FromDiscord<Elegantbeef> Otherwise distinct doesnt make much sense
18:10:46FromDiscord<Michal Maršálek> Hmm, I'm not sure I understand, the proposition is just a syntactic sugar
18:10:52FromDiscord<Michal Maršálek> It shouldn't break anything
18:11:23FromDiscord<Elegantbeef> It's more than syntax if you dont borrow `.`
18:12:31FromDiscord<Elegantbeef> Say you have someone import this module that exports `Bar` and constructs their own `Bar` that's invalid, you now have unsafe/bad data
18:13:12FromDiscord<Elegantbeef> The only type the Object construction syntax should be allowed is when you borrow dots since that means you can access the fields
18:13:49FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUc
18:14:08FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/Jkm
18:14:35FromDiscord<Michal Maršálek> Hmm
18:15:25FromDiscord<Michal Maršálek> In reply to @Elegantbeef "Say you have someone": Can you restructure this sentence please?
18:22:03FromDiscord<ajusa> Is there a library for Nim/Go interop? I think there is one for Rust that status(?) came up with but can't remember.
18:22:30FromDiscord<Elegantbeef> `since I'd expect Bar to behave the same as if I just copied the type definition of Foo.` I think is the reason you think this
18:22:30FromDiscord<Elegantbeef> Bar should not be the same as if you copy Foo since one big usage of distincts is to validate data
18:22:31FromDiscord<Elegantbeef> Atleast those are my thoughts
18:23:17*jjido joined #nim
18:23:47FromDiscord<Elegantbeef> Assuming someone is using `Bar` as a validated `Foo` so the field `data` is known good data, if you can construct `Bar`s the data cannot be considered validated
18:24:16FromDiscord<Elegantbeef> For a distinct to have purpose everything but assignment should be explicitly added to the object
18:24:54FromDiscord<Elegantbeef> that and conversion from/to base of course
18:28:23FromDiscord<Michal Maršálek> I see
18:28:45FromDiscord<Michal Maršálek> Thank you again. 🙂
18:30:06FromDiscord<Michal Maršálek> I updated the issue
18:30:20FromDiscord<Elegantbeef> Comically a fair bit of people get annoyed with distinct's strictness but that's the entire point
18:32:15FromDiscord<Smarc> How would you check for an existing file if it is empty?
18:37:02FromDiscord<Elegantbeef> There is `getFileSize`
18:37:04FromDiscord<Elegantbeef> Both in `io` and `os`
18:41:57*Gustavo6046 joined #nim
18:42:07FromDiscord<Ksr> The doc says:↵> Pragmas are enclosed in the special {. and .} curly brackets.↵I found code that uses `{. }` , dropping the second dot. I also tested it and it works. Is this officially supported? Is there any official info on this?
18:43:13FromDiscord<Elegantbeef> Yes it's supported
18:43:33FromDiscord<Ksr> Thx :). Is this mentioned somewhere in the docu?
18:43:35*perro left #nim (WeeChat 3.0.1)
18:44:23FromDiscord<Elegantbeef> I do not know, but it is certainly supported
18:44:51FromDiscord<Ksr> thank you.
18:52:23FromDiscord<Michal Maršálek> What is the canonical way do singletons?
18:52:36FromDiscord<Michal Maršálek> (edit) "What is the canonical way ... do" added "to"
18:53:23FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUm
18:53:23FromDiscord<Elegantbeef> Not that singletons are really needed in Nim but yea that's basically how
18:56:17PMunchI remember the first time I read about singletons, this special thing that could only be instantiated once. And I remember thinking to myself "why not just not instantiate something multiple times instead of building a complicated system to make sure it doesn't happen"
18:56:43PMunchThis idea of writing code and not really knowing when stuff is instantiated and how often is a bit alien to me..
18:57:05FromDiscord<Elegantbeef> Singletons are common in OOP just due to the nature of the language
18:57:16FromDiscord<Elegantbeef> C# + Unity has a lot of people using them due to the editor
18:57:21PMunchYeah I know, and I use them in our C# code at work
18:57:43PMunchBut it feels like a band aid on a broken arm..
18:58:09nrds<Prestige99> I use the singleton pattern in my game engine for the "global" input handler, seems fine to me
18:58:20nrds<Prestige99> Not something needed very often though
18:58:46FromDiscord<Elegantbeef> Nim has the added benefit of modules
18:59:28FromDiscord<Elegantbeef> You can have top level logic run and have a singleton without having to expose that you even instantiated state
18:59:47nrds<Prestige99> Yeah that's the best way to do it imo
19:12:06FromDiscord<pietroppeter> In reply to @Elegantbeef "Since this is running": Ah actually had not noticed setRenderSetting was marked as error. I meant that all those setXxxx identifiers I do not know where they come from (they are not in system or std/macros and I do not see other imports)
19:12:36FromDiscord<pietroppeter> @ElegantBeef
19:12:51FromDiscord<Elegantbeef> That's all apart of my nimscripter example
19:13:24*jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzz…)
19:13:51FromDiscord<Elegantbeef> I'll throw it on git right now so you can have a look around
19:15:09FromDiscord<Elegantbeef> https://github.com/beef331/nimscripter/blob/master/examples/macrorepl/macrorepl.nim here
19:16:11FromDiscord<Elegantbeef> macrorepl is just a program you can point at a nimscript file and it'll evaluate it
19:16:34FromDiscord<Elegantbeef> The two macros inside `macrosports` are how I talk to the binary
19:19:18FromDiscord<Elegantbeef> All the nimscript stuff to be interested in is https://github.com/beef331/nimscripter/blob/master/examples/macrorepl/macrorepl.nim#L162-L189
19:21:42FromDiscord<Elegantbeef> If it's unclear the API you expose to Nimscript from Nim using nimscripter is auto imported in the main module(and possibly children module havent checked)
19:21:58FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUu
19:22:05FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUu" => "https://play.nim-lang.org/#ix=3LUv"
19:22:11FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUv" => "https://play.nim-lang.org/#ix=3LUw"
19:22:18FromDiscord<Patitotective> without having to define it
19:22:50FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUx
19:23:17FromDiscord<Elegantbeef> Damn people like pestering the bridge
19:24:51FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUA
19:25:26FromDiscord<Elegantbeef> If you want to make multiple parameters defaulted the only way to do so is use a macro or manually
19:25:32FromDiscord<Patitotective> 😉
19:25:34FromDiscord<Patitotective> Thanks
19:27:12*noeontheend joined #nim
19:28:14*krux02 joined #nim
19:46:17FromDiscord<hmmm> beefy I was looking at the splat thread on the forums, would it be possible to make a macro that takes a variable len seq and splats into ordered named variables like a,b,c,.. or a1,a2,a3,... 🤔
19:46:48FromDiscord<Elegantbeef> As long as it's not in a call, of course
19:47:10FromDiscord<Elegantbeef> Assuming you have some form of static information you can
19:47:33FromDiscord<Elegantbeef> so if you want the first 3 values as variables you can
19:47:40FromDiscord<hmmm> hmm I'd like to use it exactly to pass the bunch of variables to another proc that has maybe varargs
19:47:43FromDiscord<Elegantbeef> if you want the first 2 and remainder in a collection you can
19:48:00FromDiscord<Elegantbeef> If the proc has varargs pass the seq
19:48:08FromDiscord<Elegantbeef> varargs accepts seq/array
19:48:11FromDiscord<hmmm> oh
19:48:16FromDiscord<hmmm> that is comfy
19:48:20FromDiscord<hmmm> u sure?
19:49:15FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=3LUM
19:49:15FromDiscord<Elegantbeef> Yes
19:49:31FromDiscord<Elegantbeef> If you're attempting to do `doThing(10, @[10 ,20])` it will not work for obvious reasons
19:49:32FromDiscord<hmmm> In reply to @Elegantbeef "so if you want": hmm nu it should work on a seq of any lenght
19:49:47FromDiscord<Elegantbeef> You cannot unpack a seq dynamically
19:49:53FromDiscord<Elegantbeef> nim operates on static information
19:49:59FromDiscord<hmmm> I see
19:50:08FromDiscord<Elegantbeef> You can only unpack N number of things and then collect the rest or not
19:50:31*adigitoleo quit (Remote host closed the connection)
19:51:07FromDiscord<Elegantbeef> Personally i'd say to do `doThing @[10] & yourSeq` or similar for passing to varargs if you want to pass a a seq and other args
19:51:14*adigitoleo joined #nim
19:53:05Amun-Rabtw. there's some incosistency right now with converting to smaller types, vide: https://play.nim-lang.org/#ix=3LUN will this be fixed and if so, in what direction?
19:54:32FromDiscord<Elegantbeef> One can be reasoned unsound statically
19:54:34Amun-Rashould I start adding "and 0xff" when converting to byte?
19:54:36FromDiscord<Elegantbeef> The other cannot
19:54:39FromDiscord<hmmm> I had the problem of passing simultaneously a variable len seq to a proc like proc(a[1],a[2]...) passing the seq didn't work and obviously couldn't use a loop
19:55:01*noeontheend quit (Ping timeout: 240 seconds)
19:55:08FromDiscord<Elegantbeef> They're unchecked integers so i think it's "safe"
19:55:56Amun-Rait wraps around in C/C++, I wonder if this will change on "nim level"
19:59:38FromDiscord<hmmm> In reply to @Elegantbeef "https://play.nim-lang.org/#ix=3LUM": beefy and how do you write this if you want to echo every single element separately
20:00:39FromDiscord<konsumlamm> In reply to @Amun-Ra "should I start adding": yeah, using `and 0xff` is the "correct" way
20:00:47FromDiscord<konsumlamm> also, why use `byte` instead of `uint8`?
20:01:37Amun-Rakonsumlamm: one character less ;)
20:01:52Amun-Raand it's easier to type so it's win win for me
20:08:28arkanoidI have a sequence of objects each with a kind attribute. I'd like to turn this into a sequence of sequences where "kind" is grouped, is there a std proc for this? I can surely wrap my own, but seems like a split proc
20:18:34*jjido joined #nim
20:21:33PMunchImplementing some new stuff for microcontroller programming in preparation for my talk
20:22:22PMunchI've managed to reduce the latency of my keyboard to less than 1/10th than it used to be, while reducing code size 35%
20:22:39*zacts quit (Ping timeout: 250 seconds)
20:22:40PMunchNow the entire keyboard firmware is 2468 bytes
20:24:21FromDiscord<el__maco> you wrote your keyboard's firmware?
20:24:24arkanoidPMunch, I'm very interested in your microcontroller project. I'm planning to jump on ESP32 + futhark soon! Btw, I keep having success stories with futhark, I own you a beer or whatever
20:24:38PMunchFor comparison the "hello world" of microcontrollers, blinking the onboard LED, takes 2422 bytes when written in Arduino
20:25:02PMunch@el__maco, I built and programmed my own keyboard, yes
20:25:29FromDiscord<el__maco> I guess I should ask if its in Nim
20:25:47PMuncharkanoid, very happy to hear that. Unfortunately I'm not sure Futhark will work on ESP32, I tried to run it on the AVR headers, but they have to be compiled with avr-gcc so clang isn't able to do it :(
20:25:55PMunch@el__maco, of course it is :P
20:25:56FromDiscord<el__maco> probably not if its 2368 bytes 🤔
20:26:07FromDiscord<el__maco> it is? dang
20:26:09PMunchhttps://github.com/PMunch/badger
20:26:19arkanoidPMunch: oh! sad, I was going to try same for esp32
20:26:31PMunch@el__maco, or rather: https://github.com/PMunch/badger/tree/final
20:26:55PMunchI haven't pushed my latest changes though, so the size of that is 3750 bytes
20:27:05arkanoidis the honey badger the nim mascot? really?
20:27:31PMunchHaha, it was, but it hasn't been used for many many years now
20:28:06PMuncharkanoid, and you'll have to meet up at FOSDEM or something once it's back to being physical if you want to buy me a beer :P
20:28:51PMunchClosest you'll get now is to sponsor me on GitHub, then I can go and buy some beer myself :D
20:29:06FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUZ
20:29:41FromDiscord<Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUZ" => "https://play.nim-lang.org/#ix=3LV0"
20:30:11PMunch@Patitotective, that is the default behaviour
20:30:21PMunchYou have to use `distinct` to make it not behave like that
20:31:24FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV1
20:32:43FromDiscord<huantian> In reply to @PMunch "https://github.com/PMunch/badger": hmm maybe one day I'll take a crack at getting this on my atmega32U4 board but that's probably a long way off
20:33:24arkanoidPMunch: I'll wait for the possibility to reach FOSDEM, otherwhy happy to sponsor
20:33:38PMunch@huantian, It's build for a Teensy 2.0 which runs the atmega32u4, so it should be as easy as `make upload`
20:34:15PMunch@Patitotective, yes, like that it will be it's own type and you can't use any of OrderedTables procedures on it
20:34:21FromDiscord<huantian> oh I didn't realize that↵might check it out in a bit then
20:34:25arkanoidif I have a seq[Tuple[string,string]] can I unpack during "for a,b in myseq" iteration? I'm getting the index instead
20:34:49FromDiscord<huantian> you can do `for (a, b) in myseq` or `for a, b in myseq.items` I believe
20:35:10PMunch@huantian, right now it's built for using port expanders over i2c though, so you might have to delete some bits to make it use internal pins
20:35:28FromDiscord<Patitotective> In reply to @PMunch "<@762008715162419261>, yes, like that": huh? i think you misunderstood me, i want to be able to use `OrderedTable` procedures
20:35:41PMunchBut should be super easy, only file you should have to edit is badger.nim
20:35:50FromDiscord<huantian> hm ok
20:35:55FromDiscord<huantian> is there rotary encoder support?
20:35:57PMunch@Patitotective, then don't put `distinct` there
20:36:03PMunch@huantian, not yet
20:36:23PMunchIt's really bare bones, just scanning a matrix and outputting keys over USB
20:36:39PMunchI wrote it all live on stream, so I focused on just getting everything to work
20:37:27FromDiscord<huantian> mm makes sense, seems like a pretty cool project though
20:37:54FromDiscord<Patitotective> In reply to @PMunch "<@762008715162419261>, then don't put": yea, thats the problem, i dont have `distinct` but it doesn't work
20:38:06arkanoidthanks
20:38:14PMunchOh just wait, I'm making it more generic now so that the underlying libraries can be used on more controllers. The plan is to make a super-framework for writing microcontroller applications
20:38:34PMunch@Patitotective, do you import the tables module where you're using your type?
20:39:04PMunchIf you have that definition in one module and use it from another module that other module still needs to import tables
20:39:29PMunchYou can of course put `import tables; export tables` in the file where you create that type alias though
20:41:18FromDiscord<Patitotective> sent a code paste, see https://paste.rs/hLI
20:42:25FromDiscord<Patitotective> I'm trying to implement an object that can have multiple value types (just like json's node), so `objectV` is the field of an `PObjectType`, which is an `OrderedTable[string, PrefsNode]`↵(`PrefsNode` is my object)
20:42:30PMunchWell of course
20:42:39FromDiscord<Elegantbeef> `export tables`
20:42:49PMunchYour second argument is a string, not a PrefsNode
20:42:53FromDiscord<Elegantbeef> You dont have the tables module exported so you cannot `table.objectV["lang"] = "es"`
20:43:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LV4
20:43:39FromDiscord<Patitotective> In reply to @Elegantbeef "You dont have the": all occurs in a same file
20:43:49FromDiscord<Patitotective> In reply to @PMunch "Your second argument is": hehe that was it thanks 🙃
20:43:53FromDiscord<Elegantbeef> As an ex C# programmer i default to byte↵(@konsumlamm)
20:44:11FromDiscord<Patitotective> (edit) "In reply to @PMunch "Your second argument is": hehe ... that" added "it was" | removed "was it"
20:44:22PMunchI use byte if I want to use a byte, and I use uint8 if I want a number.
20:44:36PMunchWell, I try to. I'm not very good at it
20:44:55FromDiscord<Elegantbeef> Yea i either go `u8` or `byte`
20:45:02FromDiscord<Elegantbeef> I just dont think about `uint8`
20:47:32FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV5
20:49:36arkanoidwhen should I prefer "proc `myattribute=`" instead of "proc getMyAttribute" ?
20:49:40PMunchHmm, is there a way to create a byte literal?
20:49:42FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV7
20:49:51PMunchI like to use 0xff'u8 for example
20:49:56FromDiscord<huantian> isn't byte just an alias for uint8?
20:50:13PMuncharkanoid, well one is a getter and the other is a setter?
20:50:23PMunch@huantian, I think so, yes
20:51:02arkanoidPMunch: getter would be "proc myattribute"?
20:51:15PMunchYou should be able to overload `[]=` for string, string @Patitotective
20:51:30PMuncharkanoid, sure, that's what I usually do
20:51:47PMunchOh well, I'm off to take a shower and go to bed
20:51:48*PMunch quit (Quit: leaving)
20:51:59FromDiscord<Patitotective> In reply to @PMunch "You should be able": hmmm, quite long but thanks hehe 🙃
20:52:16FromDiscord<Elegantbeef> Buh bye
20:52:24FromDiscord<huantian> In reply to @Patitotective "hmmm, quite long but": I mean it's just like 1-2 lines of code
20:52:33FromDiscord<huantian> In reply to @PMunch "Oh well, I'm off": good sleeps
20:52:49arkanoidPMunch, interesting approach, thanks
20:52:52arkanoidoh, he's gone
20:53:20FromDiscord<Elegantbeef> Bunch of overloads means more↵(@huantian)
20:54:06FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LV8
20:55:24FromDiscord<Patitotective> why there are two `=`?
20:55:27FromDiscord<Patitotective> (edit) "why there are two `=`? ... " added "what does that mean"
20:55:29FromDiscord<Patitotective> (edit) "mean" => "mean?"
20:55:36FromDiscord<huantian> the first one is part of the proc definition
20:55:41FromDiscord<huantian> the second one is the actual assignment
20:55:51FromDiscord<Elegantbeef> What huantian said
20:55:58FromDiscord<Elegantbeef> It's just a single lined proc
20:56:09FromDiscord<Patitotective> In reply to @huantian "the first one is": what the first means, the return type?
20:56:22FromDiscord<Patitotective> (edit) "In reply to @huantian "the first one is": what ... themean," added "does" | "means," => "mean,"
20:56:33FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LVa
20:56:39FromDiscord<Patitotective> oh lol
20:56:42FromDiscord<Elegantbeef> There is nothing fancy going on nim uses `=` for proc bodies
20:56:54FromDiscord<Patitotective> let me try
20:58:17FromDiscord<Elegantbeef> @ajusa\: if you get a chance to update slicerator and test it with your code with peek/reset that'd be nice
20:58:26FromDiscord<Elegantbeef> I'm using some low level logic to reset now but i dont know if it's safe
20:59:29FromDiscord<ajusa> In reply to @Elegantbeef "<@102899813149855744>\: if you get": Sure, I'll try that! Hadn't actually integrated it yet, was planning on doing it today.
21:00:00FromDiscord<Elegantbeef> Nice, it passes my tests but i dont know if it's "right" on complex types
21:00:19FromDiscord<Elegantbeef> But yea we're at relatively cheap peek only 64bytes are copied
21:00:45FromDiscord<Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LVf
21:01:08FromDiscord<Patitotective> and if i remove the convert part, infinit recursion
21:01:32FromDiscord<Elegantbeef> `T: not NiPref`
21:01:35FromDiscord<Elegantbeef> Or whatever the node is
21:01:46FromDiscord<Elegantbeef> Generic type constraints are magic
21:08:17FromDiscord<Elegantbeef> replace `NiPref` for whatever the `toPref` returns
21:12:55FromDiscord<ajusa> Works perfectly, thanks mr beef
21:13:23FromDiscord<Elegantbeef> Nice if you have any odd behaviour shoot me a message of course 😀
21:13:32FromDiscord<ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3LVm
21:14:00FromDiscord<ajusa> sure! looking forward to this landing on Nimble!
21:28:07*anddam quit (Quit: WeeChat 3.3)
21:28:21*anddam joined #nim
22:39:28*Gustavo6046 quit (Ping timeout: 268 seconds)
23:30:11*adigitoleo quit (Remote host closed the connection)
23:30:54*adigitoleo joined #nim