00:00:12 | FromDiscord | <Elegantbeef> Atleast cabboose has cabboose on his profile |
00:01:13 | FromDiscord | <ajusa> at least with Elegantbeef -> beef331 it's related, leorize and alaviss just have the letters i and l in common. |
00:01:50 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3LP2 |
00:01:59 | FromDiscord | <leorize> lol |
00:02:03 | FromDiscord | <Elegantbeef> ajusa using hashsets |
00:02:10 | FromDiscord | <Elegantbeef> What an amateur |
00:02:19 | FromDiscord | <ajusa> what's the better way of doing this? |
00:02:21 | FromDiscord | <congusbongus> you should use lexicographical distance |
00:02:55 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LP3 |
00:02:59 | FromDiscord | <Elegantbeef> or `echo l a` |
00:03:11 | FromDiscord | <ajusa> huh setutils is a thing, didn't know that |
00:03:29 | FromDiscord | <Elegantbeef> You're welcome |
00:10:39 | * | krux02 quit (Remote host closed the connection) |
00:18:04 | NimEventer | New 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:03 | FromDiscord | <auxym> hm, `{.completeStruct.}` doesn't have any docs. anyone have info? Nim is telling me I need it for `sizeof` to work |
01:00:50 | FromDiscord | <Elegantbeef> You're attempting to use `sizeof` on a `incompleteStruct` |
01:03:18 | FromDiscord | <auxym> what's an incompleteStruct? |
01:03:28 | FromDiscord | <auxym> I mean it's complete enough for me;) |
01:03:32 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-incompletestruct-pragma |
01:04:56 | FromDiscord | <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:22 | FromDiscord | <Elegantbeef> https://docs.microsoft.com/en-us/cpp/c-language/incomplete-types?view=msvc-170 i think this might help |
01:06:02 | FromDiscord | <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:25 | FromDiscord | <auxym> I see, thanks. My C knowledge is somewhat barebones |
01:07:57 | adigitoleo | evoalg: Thanks, I thought about it some more and what I really want is probably some cleverer unpacking, hence the forum post. |
01:09:47 | FromDiscord | <Elegantbeef> https://github.com/haxscramper/hmatching supports unpacking |
01:10:16 | FromDiscord | <Elegantbeef> Unpacking in the compiler would be nicer, but we have packages so use them is my view |
01:11:43 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LPh |
01:12:13 | FromDiscord | <Elegantbeef> That relies on runtime values |
01:12:13 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LPh" => "https://play.nim-lang.org/#ix=3LPj" |
01:12:15 | FromDiscord | <Elegantbeef> Like i said it'll not be possible |
01:12:44 | FromDiscord | <leorize> you can't magically assign a variable like that unfortunately |
01:12:50 | FromDiscord | <Patitotective> hmm |
01:12:52 | FromDiscord | <leorize> do you have a sample code that you want to achieve? |
01:13:02 | FromDiscord | <Patitotective> Yes, wait a sec |
01:13:18 | FromDiscord | <Elegantbeef> That's how you should do it |
01:13:18 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPk |
01:13:30 | FromDiscord | <Elegantbeef> Wait union does have unpack now cant remember if that was a fever dream |
01:13:45 | FromDiscord | <Patitotective> In reply to @Elegantbeef "Wait union does have": yes, they have |
01:15:28 | FromDiscord | <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:45 | FromDiscord | <Patitotective> (edit) "`PTableTypes`," => "`PTableTypes` (a union)," |
01:15:56 | FromDiscord | <Patitotective> (edit) "`talbe[key]" => "`table[key]" | "tyoe`" => "type`" |
01:16:45 | FromDiscord | <Patitotective> Should I share my code? |
01:17:34 | FromDiscord | <leorize> sure |
01:22:06 | FromDiscord | <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:21 | FromDiscord | <leorize> there are several ways, all depending on the context that you want to achieve this |
01:23:49 | FromDiscord | <Patitotective> https://play.nim-lang.org/#ix=3LPm |
01:24:12 | FromDiscord | <Patitotective> What would you recommend then? I cannot stop thinking on python hehe |
01:25:56 | nrds | <Prestige99> I recommend stop thinking of python :P |
01:26:21 | FromDiscord | <leorize> wow I didn't know that union could do self-referencing types |
01:26:57 | FromDiscord | <Patitotective> In reply to @leorize "wow I didn't know": not sure if thats good or not |
01:27:07 | FromDiscord | <Patitotective> In reply to @nrds "<Prestige> I recommend stop": intersting |
01:27:10 | FromDiscord | <Patitotective> (edit) "intersting" => "interesting" |
01:27:15 | FromDiscord | <Elegantbeef> I'm surprised it even works |
01:27:41 | FromDiscord | <Elegantbeef> That means `PTableTypes` is typed? |
01:27:48 | FromDiscord | <leorize> it is kind of a piece of art |
01:28:30 | FromDiscord | <leorize> yea, it is possible to refer to self within the type declaration context |
01:28:52 | FromDiscord | <Patitotective> https://tenor.com/view/interesting-gif-21942309 |
01:29:16 | FromDiscord | <leorize> so from what I can tell you are trying to create a configuration table, right? |
01:29:28 | FromDiscord | <Patitotective> yes |
01:29:58 | FromDiscord | <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:48 | FromDiscord | <leorize> your first problem is that your code is wrong \:p |
01:30:55 | FromDiscord | <Patitotective> where? |
01:31:14 | FromDiscord | <leorize> your `%` operator |
01:31:20 | FromDiscord | <leorize> it doesn't create a table |
01:31:30 | FromDiscord | <Patitotective> yeaa.... |
01:31:46 | FromDiscord | <Patitotective> let me try to fix it |
01:31:47 | FromDiscord | <Patitotective> hehe |
01:31:48 | FromDiscord | <Patitotective> why is there no _hehe_ sticker? |
01:31:53 | FromDiscord | <Patitotective> (edit) "why is there no ... _hehe_" added "a" |
01:33:50 | FromDiscord | <Patitotective> https://play.nim-lang.org/#ix=3LPo |
01:34:16 | FromDiscord | <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:13 | FromDiscord | <leorize> at the moment you'll have to make do with this then\: https://play.nim-lang.org/#ix=3LPp |
01:41:15 | FromDiscord | <leorize> the reason is simply that unions are not mutation-friendly |
01:41:45 | FromDiscord | <leorize> esp when placed in a container, because I can't make Nim infer mutation condition for them |
01:42:41 | FromDiscord | <Patitotective> hmm, maybe nim is not ready for _NiPrefs_ (probably im the one thats not) |
01:42:47 | FromDiscord | <Patitotective> thanks anyways |
01:42:48 | FromDiscord | <Patitotective> 🙃 |
01:44:18 | FromDiscord | <leorize> JsonNode is much better for the kind of work you are doing here |
01:45:07 | FromDiscord | <leorize> mainly because it is packed with utility for container situations (and it is a container as well) |
01:45:44 | FromDiscord | <Elegantbeef> JsonNode style data structures handle stuff like this much easier |
01:45:57 | FromDiscord | <Elegantbeef> You can make your own version with more types to support what you need |
01:46:12 | FromDiscord | <Elegantbeef> But it seems like jsonNode is fine |
01:46:28 | FromDiscord | <Elegantbeef> Oh and leorize i have a PR for that static typedef issue 😀 |
01:46:29 | FromDiscord | <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:48 | FromDiscord | <Patitotective> (edit) "`table[key].getInt`," => "`table[key].getType`," |
01:46:51 | FromDiscord | <leorize> it's not like union will let you get away with that |
01:46:53 | FromDiscord | <Elegantbeef> I mean Nim is statically typed you'll need something like that regardless |
01:47:18 | FromDiscord | <Elegantbeef> you cannot just magically make a variable set to the internal of a variable that depends on runtime information |
01:47:37 | FromDiscord | <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:50 | FromDiscord | <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:46 | FromDiscord | <Elegantbeef> Make your own type based off the json file that saves on modification |
01:49:50 | FromDiscord | <leorize> jsonnode is just a data structure |
01:49:56 | FromDiscord | <leorize> how you use that structure is up to you |
01:50:11 | FromDiscord | <leorize> you can `distinct` it, too |
01:50:48 | FromDiscord | <Elegantbeef> Possibly better to distinct it |
01:52:02 | FromDiscord | <leorize> though I'll say that this data structure wastes a lot of memory |
01:52:27 | FromDiscord | <Patitotective> In reply to @leorize "though I'll say that": any recommendation? |
01:52:48 | FromDiscord | <Patitotective> i'm reading about distinct, but seems like the same problem, i gotta define all procedures for the types |
01:53:23 | FromDiscord | <leorize> you can use converter to basically borrow everything |
01:54:13 | FromDiscord | <Patitotective> could you share a minimal code to start from? i'm a bit lost he he |
01:55:35 | FromDiscord | <leorize> https://play.nim-lang.org/#ix=3LPr |
01:56:05 | FromDiscord | <leorize> with this you have access to all JsonNode stuff, but JsonNode stuff can't go the reverse way |
02:03:50 | FromDiscord | <leorize> you'd have to figure out the access pattern of your structure and optimize for that, pretty much↵(@Patitotective) |
02:03:56 | FromDiscord | <leorize> there is an entire book about it\: https://dataorienteddesign.com/dodbook/ |
02:04:06 | FromDiscord | <leorize> but if you are lazy like me, use this\: https://github.com/araq/packedjson \:P |
02:08:21 | adigitoleo | Any tips on how to get a string into a File, so I can use it as a small mock for testing? |
02:08:43 | FromDiscord | <leorize> `writeFile`? |
02:20:44 | adigitoleo | can't get it directly into `File` without hitting disk? Just curious |
02:21:06 | FromDiscord | <Elegantbeef> You could use a memorymapped file from `std/memfiles` |
02:21:24 | FromDiscord | <Elegantbeef> Normal files propagate to disk, memorymapped files are in memory |
02:21:37 | adigitoleo | noice |
02:28:03 | * | neurocyte09175 joined #nim |
02:28:13 | FromDiscord | <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:02 | FromDiscord | <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:41 | FromDiscord | <Elegantbeef> In what way? |
02:42:57 | FromDiscord | <Elegantbeef> Can you use openArray as a value inside one? Not without views |
02:43:07 | FromDiscord | <Elegantbeef> Capturing `openArray` is unsafe |
02:43:22 | FromDiscord | <IsaacPaul> Ah ok |
02:45:00 | FromDiscord | <Elegantbeef> you can use `ref T` |
02:50:22 | FromDiscord | <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:45 | FromDiscord | <Elegantbeef> You can use memfiles for inter process communication |
02:50:57 | FromDiscord | <Elegantbeef> Where your OS thinks it's a file but it's just in memory |
02:51:00 | FromDiscord | <evoalg> ohhhhhh! |
02:53:51 | FromDiscord | <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:59 | FromDiscord | <IsaacPaul> sent a code paste, see https://play.nim-lang.org/#ix=3LPG |
02:56:39 | FromDiscord | <IsaacPaul> hmm that seems iffy tho.. |
03:01:02 | FromDiscord | <Elegantbeef> What's iffy about it? |
03:01:03 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPJ |
03:01:23 | FromDiscord | <Elegantbeef> Or even `type StringRef = distinct ref string` so you are the function that makes them |
03:02:13 | FromDiscord | <Elegantbeef> The former probably is fine though |
03:02:57 | FromDiscord | <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:31 | FromDiscord | <Elegantbeef> As long as the ref string isnt nil it's basically identical to what you're doing with normal strings |
03:08:56 | FromDiscord | <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:27 | FromDiscord | <Elegantbeef> You use the hash for the string |
03:10:45 | FromDiscord | <Elegantbeef> so `proc hash(x: StringRef): Hash = hash(x[])` |
03:11:30 | FromDiscord | <Elegantbeef> Which means you might need to make a generic disinct table that's `Table[hash, T]` |
03:12:55 | FromDiscord | <Elegantbeef> There is also https://nim-lang.org/docs/strtabs.html though it's probably not memory efficient |
03:13:09 | FromDiscord | <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:14 | FromDiscord | <Elegantbeef> So it's a non allocating operation |
03:14:12 | adigitoleo | how do I use private procs from my package when I'm testing? Is there some alternate import syntax for that? |
03:14:34 | adigitoleo | by testing I mean unit tests in tests/foo.nim |
03:14:38 | FromDiscord | <Elegantbeef> The first thing is "you should test non public API" but the second thing is `import myModule{.all.}` |
03:14:48 | FromDiscord | <Elegantbeef> "you shouldnt test non public API"\ |
03:15:04 | FromDiscord | <IsaacPaul> I did not know about strtabs and about orc/arc 😮 |
03:15:12 | FromDiscord | <IsaacPaul> (edit) "and about" => "or" |
03:15:16 | adigitoleo | I see, maybe I need to rethink the approach, I'm new to unit testing. Thanks |
03:15:34 | FromDiscord | <Elegantbeef> So i mean you can test it but generally it's bad form |
03:16:00 | FromDiscord | <Elegantbeef> Yea Isaac anywhere you see `sink` means "If we dont need to copy we will not" |
03:16:44 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPL |
03:17:10 | FromDiscord | <IsaacPaul> good to know |
03:17:23 | FromDiscord | <Elegantbeef> That only works with Nim's Orc/Arc though |
03:17:27 | FromDiscord | <Elegantbeef> if using refc it'll copy afaik |
03:17:58 | FromDiscord | <IsaacPaul> I'm currently using arc, it seems appropriate for a game. |
03:18:06 | FromDiscord | <Elegantbeef> So just by doing `--gc:orc` you can reduce memory footprint |
03:18:40 | FromDiscord | <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:14 | FromDiscord | <IsaacPaul> I'm used to dealing with cycles since I work in swift/objc for my day job. |
03:19:26 | FromDiscord | <IsaacPaul> So figure I'm fine without it |
03:19:49 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPN |
03:23:13 | FromDiscord | <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:23 | termer | hey, is there any way to set an object property as mutable or immutable? |
04:42:51 | FromDiscord | <Elegantbeef> You cannot set object fields to immutable or mutable you can make properties though |
04:43:00 | termer | I'm getting "<...> cannot be assigned to" |
04:43:32 | termer | how would I go about doing that |
04:43:50 | termer | my object is pretty simple and I don't see what I'm doing that's making its fields immutable |
04:44:32 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LPY |
04:45:17 | termer | interesting |
04:45:35 | termer | well right now I'm not sure why I can't change any of my object fields |
04:45:37 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LQ0 |
04:45:46 | FromDiscord | <Elegantbeef> You declared it with `let` |
04:45:50 | FromDiscord | <Elegantbeef> `let` is immutable `var` is mutable |
04:46:06 | FromDiscord | <Elegantbeef> If you're ina proc you passed it without `var` |
04:46:21 | termer | https://play.nim-lang.org/#ix=3LQ1 |
04:46:23 | termer | this is my object |
04:46:34 | termer | all of the fields seem to be immutable |
04:46:56 | FromDiscord | <Elegantbeef> How do you declare the variable? |
04:47:20 | FromDiscord | <Elegantbeef> I have a feeling you do `let myVar = Server()` |
04:47:54 | termer | https://play.nim-lang.org/#ix=3LQ2 |
04:47:58 | termer | OH |
04:48:01 | termer | you're right |
04:48:08 | FromDiscord | <Elegantbeef> `server: var Server` |
04:48:10 | termer | wait no |
04:48:15 | termer | Oh I see |
04:48:29 | termer | so it's implicitley let then? |
04:48:32 | FromDiscord | <Elegantbeef> If you want to mutate a parameter you have to say `var` |
04:48:43 | FromDiscord | <Elegantbeef> Parameters are implicitly immutable yes |
04:48:53 | termer | I didn't realize that args params were implicitely let |
04:48:59 | termer | thanks so much |
04:49:02 | termer | I was so confused |
04:49:26 | FromDiscord | <Elegantbeef> I did answer a completely unrelated question 😀 |
04:49:51 | termer | a very important one lol |
04:50:06 | FromDiscord | <Elegantbeef> Also because of how mutability works in Nim `ref object` fields are mutable |
04:50:40 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LQ4 |
04:55:11 | adigitoleo | is there a method for getting all field names of an object? |
04:55:32 | FromDiscord | <Elegantbeef> `for name, _ in object.fieldPairs: echo name` |
04:55:53 | FromDiscord | <Elegantbeef> As long as it's not a variant object it'll work |
04:56:53 | adigitoleo | Oh crap I meant getting the field list for a typedesc |
04:57:16 | FromDiscord | <Elegantbeef> `for name, _ in typeDesc().fieldPairs: ...` 😀 |
04:57:24 | adigitoleo | lol |
04:57:50 | FromDiscord | <Elegantbeef> Types can be instantiated from typedescs so yea it's comically not different |
04:58:06 | FromDiscord | <Elegantbeef> Ideally a macro could be made to make this more tame |
04:58:40 | adigitoleo | meh it's fine, I just didn't grok it |
04:59:22 | FromDiscord | <Elegantbeef> What are you after anywho, somewhat of an odd thing to want |
05:00:24 | adigitoleo | Oh 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:55 | FromDiscord | <Elegantbeef> Ah |
05:01:12 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#Exception |
05:03:48 | FromDiscord | <Elegantbeef> Though i guess a general purpose solution is easier than navigating |
05:04:25 | FromDiscord | <Elegantbeef> you could put a variable inside the `_` block and then do `echo "name: ", name, " type: ", typeof(field)` |
05:20:00 | NimEventer | New thread by Niminem: How to import all identifiers from module, see https://forum.nim-lang.org/t/8794 |
05:30:39 | termer | so now I've got a new issue with vars |
05:30:55 | FromDiscord | <Rika> Which is |
05:31:08 | termer | using 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:28 | termer | searching online didn't do much for me since it mostly talks about closures |
05:31:30 | FromDiscord | <Elegantbeef> You're attempting to use a closure with a `var T` |
05:31:33 | FromDiscord | <Elegantbeef> That's unsafe |
05:31:33 | FromDiscord | <Rika> Async I assume |
05:31:36 | termer | async |
05:31:43 | FromDiscord | <Rika> Yup, no can do |
05:32:01 | termer | so can mutable objects not be passed to async procs at all? |
05:32:10 | FromDiscord | <Rika> Either use a ref or redesign I would say |
05:32:42 | termer | switching var Server to ref Server causes random errors everywhere that make no sense |
05:32:55 | termer | is that a syntax error or something |
05:33:05 | termer | Looks like I need to look more into refs |
05:33:49 | FromDiscord | <congusbongus> why not refactor the code so that it returns a result instead of mutating its inputs |
05:34:26 | termer | there is server state that needs to be modified |
05:34:43 | FromDiscord | <Rika> The errors are likely because you have other procs still using var |
05:34:44 | FromDiscord | <congusbongus> yeah so... return the new server state, and have the caller modify the server state |
05:34:44 | termer | like whether it is accepting connections or not, which can change based on events received asynchronously |
05:35:47 | FromDiscord | <Rika> Yeah use a ref then |
05:36:17 | termer | all right |
05:36:36 | termer | I read that's unsafe, is that because I can modify it regardless of whether it was declared as var or let? |
05:36:44 | termer | or are there more pressing concerns |
05:37:05 | FromDiscord | <Rika> I don’t know maybe nil safety |
05:38:30 | termer | how does one get a ref of an existing object |
05:38:42 | FromDiscord | <Elegantbeef> `new Type` |
05:38:55 | FromDiscord | <Elegantbeef> You cannot make a normal object a ref object |
05:39:25 | FromDiscord | <Elegantbeef> Normal objects are conventionally stored on the stack which means you cannot make a ref to it |
05:39:35 | termer | how does that work with constructors then |
05:39:44 | termer | does that mean I will have to write special ref constructors |
05:39:49 | termer | I guess it does |
05:39:57 | FromDiscord | <Elegantbeef> `Server()` does heap allocate |
05:40:13 | FromDiscord | <Elegantbeef> If it's a `ref object` i should add |
05:40:30 | FromDiscord | <Rika> `(ref Server)()` also works |
05:40:52 | termer | all right |
05:41:02 | termer | thanks |
05:55:55 | adigitoleo | ^^ got me thinking about stack vs heap (I'm from python so my square brain don't understand this very well) |
05:56:09 | adigitoleo | I wonder if someone could annotate this to help me out? |
05:56:10 | adigitoleo | https://play.nim-lang.org/#ix=3LQr |
05:56:53 | adigitoleo | Does that all play out on the stack? |
05:57:09 | FromDiscord | <Rika> Yes |
05:57:12 | FromDiscord | <Rika> Except strings |
05:57:25 | FromDiscord | <Rika> Strings in this case are heap |
05:58:18 | adigitoleo | Oh yeah Nim strings are mutable, right |
06:02:00 | FromDiscord | <Rika> That’s not why, it’s that they have variable size |
06:02:45 | FromDiscord | <Elegantbeef> Yea even immutable are heap allocated |
06:02:46 | adigitoleo | Right because you can .add() |
06:03:09 | FromDiscord | <Elegantbeef> Immutable strings are also heap allocated since they're dynamic size |
06:03:14 | FromDiscord | <Elegantbeef> They're not statically known |
06:03:29 | FromDiscord | <Elegantbeef> Plus many immutable strings could easily crash your program if they were not |
06:03:32 | FromDiscord | <Elegantbeef> Stack is relatively small |
06:03:42 | adigitoleo | Ah |
06:03:55 | FromDiscord | <Rika> And alloca() is evil |
07:09:48 | * | PMunch joined #nim |
07:17:47 | szahid | Hello :) |
07:18:20 | FromDiscord | <Elegantbeef> Hello |
07:18:52 | PMunch | Hi |
07:19:04 | FromDiscord | <Elegantbeef> No you! |
07:19:47 | szahid | Is nim ready for production? |
07:20:00 | FromDiscord | <Elegantbeef> People are using it as such |
07:20:06 | PMunch | Well we use it in production at work |
07:20:12 | PMunch | So I'd say so |
07:27:05 | FromDiscord | <Rika> What does “ready for production” mean for you |
07:27:22 | FromDiscord | <Rika> What do you expect out of Nim basically |
08:06:48 | adigitoleo | Compiler 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:03 | adigitoleo | Want it for `expect` statement in tests |
08:07:27 | FromDiscord | <Elegantbeef> Mismatches are not exceptions |
08:07:33 | FromDiscord | <Elegantbeef> They're compiler errors |
08:07:47 | adigitoleo | Oof, can I expect them in unittest somehow? |
08:07:49 | * | Gustavo6046 quit (Quit: Leaving) |
08:08:04 | FromDiscord | <Elegantbeef> No they're compiler errores |
08:08:38 | FromDiscord | <Elegantbeef> I assume you're from python? |
08:08:43 | adigitoleo | yep |
08:08:57 | FromDiscord | <Elegantbeef> Ah type mismatches are no goes |
08:09:43 | FromDiscord | <Elegantbeef> Meaning if they appear it's user error 😛 |
08:10:57 | FromDiscord | <Elegantbeef> Nim is statically typed which means types are known and error at compile time at mismatches |
08:11:21 | adigitoleo | use case is parsing command line, if user gives -f:2.4 then I want to fail because I need integers |
08:11:57 | FromDiscord | <Elegantbeef> well that's a `except ValueError` or w/e `parseInt` returns |
08:12:00 | FromDiscord | <Rika> That’s something else from a type mismatch |
08:12:04 | adigitoleo | so I guess it's a parse error |
08:12:07 | adigitoleo | yeah |
08:12:08 | FromDiscord | <Rika> Yes |
08:51:58 | * | jjido joined #nim |
08:58:25 | NimEventer | New 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:01 | FromDiscord | <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:28 | FromDiscord | <Elegantbeef> Is it mostly just talking about move semantics based RC? |
09:14:47 | * | neurocyte0917 joined #nim |
09:18:59 | FromDiscord | <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:44 | FromDiscord | <Elegantbeef> Unrelated but have you played with nimscripter yet? (I seen the forum post 😛 ) |
09:29:51 | FromDiscord | <Rika> What |
09:29:54 | FromDiscord | <Rika> Where is that from |
09:30:34 | FromDiscord | <Elegantbeef> Huh? |
09:33:23 | FromDiscord | <Rika> The nim scripter plug |
09:33:28 | FromDiscord | <Rika> Why suddenly |
09:33:43 | FromDiscord | <Elegantbeef> Cause he mentioned it in a forum post |
09:34:02 | FromDiscord | <Rika> Eeh which |
09:34:19 | FromDiscord | <Elegantbeef> We also talked about it beefore |
09:35:24 | FromDiscord | <Elegantbeef> https://forum.nim-lang.org/t/8777 this one |
09:40:30 | FromDiscord | <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:11 | FromDiscord | <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:24 | FromDiscord | <Elegantbeef> No |
09:41:34 | FromDiscord | <Elegantbeef> Always was snake |
09:42:26 | FromDiscord | <pietroppeter> but was it already playable? I remember seeing a video, not something I can interact with |
09:42:44 | FromDiscord | <pietroppeter> (btw I realized now it is snake... 🤦♂️ ) |
09:43:19 | FromDiscord | <Elegantbeef> That link has always been a scriptable snake |
09:43:19 | FromDiscord | <Rika> 0/10 not the mathematical game Nim |
09:43:44 | PMunch | Has anyone done Nim in Nim yet? |
09:43:59 | FromDiscord | <Rika> Sounds like a meme idea |
09:44:50 | FromDiscord | <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:02 | FromDiscord | <Elegantbeef> I've shared videos before |
09:45:24 | FromDiscord | <pietroppeter> ok, I'll settle for that then and stop thinking I was crazy 😄 |
09:45:44 | FromDiscord | <Elegantbeef> That code is not public due to using forked Nico |
09:46:21 | FromDiscord | <Elegantbeef> Though i dont recall if it's needed since i think impbox may have removed the procs |
09:48:32 | FromDiscord | <Elegantbeef> I say required but i was just being lazy |
09:48:38 | FromDiscord | <Elegantbeef> And wanted to use my macro instead of manuall wrapping |
09:53:35 | FromDiscord | <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:20 | FromDiscord | <Elegantbeef> I probably should make a few examples |
10:04:27 | FromDiscord | <Elegantbeef> I do have a silly macro inspector example |
10:04:51 | FromDiscord | <Elegantbeef> https://streamable.com/c6farb this thing |
10:11:58 | adigitoleo | is 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:29 | adigitoleo | maybe `exec` from nimscript? |
10:14:23 | adigitoleo | Ah nevermind docs tell me about `gorgeEx` from system |
10:48:05 | FromDiscord | <Benjamin> sent a code paste, see https://play.nim-lang.org/#ix=3LRU |
10:48:20 | FromDiscord | <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:58 | FromDiscord | <Elegantbeef> You've created code the Nim compiler doesnt like |
10:51:06 | FromDiscord | <Elegantbeef> I assume it's the async stuffs + route macro |
10:51:37 | FromDiscord | <Elegantbeef> Yep |
10:51:52 | FromDiscord | <Elegantbeef> The usage of async inside one the macros is the issue |
10:51:52 | FromDiscord | <Benjamin> I had another example where it worked inside routes but without case...of. I'll see if I can replicate it. |
10:52:03 | FromDiscord | <Elegantbeef> It might be with the case |
10:52:18 | FromDiscord | <Elegantbeef> Something is creating AST that the compiler doesnt like |
10:52:54 | FromDiscord | <Benjamin> Yeah, it works if I remove the case or routes |
10:53:02 | FromDiscord | <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:10 | FromDiscord | <Elegantbeef> Yes |
10:53:19 | FromDiscord | <evoalg> thx you |
10:53:23 | FromDiscord | <Elegantbeef> Anything that is dynamic tends to be heap allocated |
10:53:38 | FromDiscord | <Elegantbeef> Yea benjamin sorry cant help, create an issue on jester, i'm going to bed |
10:53:38 | FromDiscord | <Benjamin> I guess I'll use if-else as a workaround for now |
10:54:15 | adigitoleo | syntax for tuple type declaration? is it possible? |
10:54:17 | FromDiscord | <Benjamin> Thanks anyway! Goodnight \:) |
10:54:56 | FromDiscord | <Rika> Same syntax as object except you put tuple instead |
10:55:08 | FromDiscord | <Rika> And you can’t declare fields as exported |
10:55:14 | FromDiscord | <Rika> (They’re exported by default) |
10:55:22 | adigitoleo | thanks |
11:10:38 | FromDiscord | <Benjamin> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/930413958697984020): Yeah, it works if I remove the case |
11:18:35 | FromDiscord | <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:05 | PMunch | I think it's just VSCode |
11:27:44 | FromDiscord | <pietroppeter> I use VS code but I do have different icons though: https://media.discordapp.net/attachments/371759389889003532/930422724642349066/unknown.png |
11:31:23 | FromDiscord | <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:14 | FromDiscord | <Tanguy> sent a code paste, see https://play.nim-lang.org/#ix=3LS7 |
11:34:49 | FromDiscord | <Tanguy> (edit) "https://play.nim-lang.org/#ix=3LS7" => "https://play.nim-lang.org/#ix=3LS8" |
11:35:47 | FromDiscord | <Tanguy> Oh, `template hoy: var int = hey` works, nvm |
11:40:03 | PMunch | You could also do `untype`, `typed`, or even `auto` if you'd like |
11:43:13 | szahid | How i can parse JArrar to Array of Structures? |
11:51:15 | * | jjido joined #nim |
12:06:47 | FromDiscord | <pietroppeter> In reply to @pointystick "If you search the": thanks! |
12:09:12 | adigitoleo | if tuples are fixed size, why can't I len() them? |
12:09:21 | FromDiscord | <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:34 | FromDiscord | <Rika> In reply to @adigitoleo "if tuples are fixed": https://nim-lang.org/docs/typetraits.html#tupleLen%2Ctypedesc%5B%5D |
12:16:36 | adigitoleo | rika: thanks, although I'd still prefer len() ;) Anyway I should probably take a break. |
12:20:03 | FromDiscord | <Rika> Can just alias the function if you want |
12:21:14 | adigitoleo | yeah it's just getting my pea brain to remember haha |
12:33:43 | FromDiscord | <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:38 | PMunch | @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:47 | PMunch | This is what I do in my keyboard firmware |
13:05:07 | FromDiscord | <Michal Maršálek> And if it is assigned to let but never used it stays? |
13:05:18 | FromDiscord | <Michal Maršálek> (edit) "let" => "var" |
13:05:28 | FromDiscord | <Yardanico> if it's just a direct assignment I don't think it'll stay if it's not used |
13:05:33 | FromDiscord | <Yardanico> But why have it in the first place then? |
13:09:58 | FromDiscord | <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:56 | FromDiscord | <Rika> If it’s assigned to a var in a macro it’s fine |
13:16:02 | FromDiscord | <Michal Maršálek> No it's a global that is used my more macros |
13:26:56 | PMunch | What I do in my code is that I save my objects as const |
13:27:37 | PMunch | Then 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:58 | PMunch | So none of the compile-time objects are ever stored in memory during runtime |
13:28:32 | PMunch | Although as you can see I use the objects around in my code: https://github.com/PMunch/badger/blob/master/badger.nim |
13:28:42 | PMunch | But I always pass them to macros |
13:28:52 | PMunch | One 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:13 | PMunch | Originally 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:13 | PMunch | and the reader now just returns the right one. |
13:33:22 | PMunch | This is the `withPinAs` macro |
14:47:00 | * | arkurious joined #nim |
14:58:03 | termer | What would be the best way to convert 2 uint8 into 1 uint16? |
14:58:18 | termer | I'm not familiar with nim's bitshifting interface or whether it uses big endian or little endian |
14:58:36 | termer | or how to find out the platform's endianness if it's platform-dependent |
15:03:43 | FromDiscord | <el__maco> `a shl 8 + b` basically |
15:04:02 | FromDiscord | <el__maco> endianness matters only if you read a and b from some memory location |
15:08:21 | FromDiscord | <Michal Maršálek> Is xor and + the same speed? |
15:08:51 | FromDiscord | <Michal Maršálek> (edit) "xor" => "(x)or" |
15:09:28 | FromDiscord | <Michal Maršálek> (edit) "(x)or" => "`(x)or`" | "+" => "`+`" |
15:09:55 | FromDiscord | <el__maco> you mean `a shl 8 or b`? Yes I don't think there's any difference |
15:13:53 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/vSZ |
15:17:04 | termer | thanks |
15:20:21 | * | covoid19 joined #nim |
15:21:20 | * | jjido joined #nim |
15:24:06 | FromDiscord | <Michal Maršálek> Use the JsonNode constructor or create an init proc. |
15:25:34 | FromDiscord | <Michal Maršálek> And I don't think you need converters to convert between distincts. |
15:27:13 | FromDiscord | <Michal Maršálek> @Patitotective |
15:27:31 | arkanoid | is there a way to generate autmatically .h for exported nim function for C++ / Nim(C) interop? |
15:27:55 | FromDiscord | <Patitotective> In reply to @Michal58 "Use the JsonNode constructor": Thanks, I'm going to create a proc 🙃 |
15:30:15 | FromDiscord | <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:02 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LTm |
15:39:47 | FromDiscord | <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:39 | FromDiscord | <Rika> not that i know of, use regular if/else |
15:41:47 | FromDiscord | <Patitotective> k |
15:42:07 | FromDiscord | <Rika> i mean when/else |
15:42:10 | FromDiscord | <Rika> types require when |
15:42:56 | FromDiscord | <Patitotective> and `is`, right? |
15:46:52 | FromDiscord | <Patitotective> What is the problem here? https://play.nim-lang.org/#ix=3LTq |
15:47:14 | FromDiscord | <Patitotective> Not sure if `get`'s template is correct |
15:49:34 | FromDiscord | <Patitotective> Oh, it seems like the return type has to be the same always |
15:50:41 | FromDiscord | <Patitotective> I thought templates weren't procedures (?) Like, the just replaced some piece of code |
16:05:14 | FromDiscord | <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:29 | FromDiscord | <Patitotective> Is that even possible? |
16:05:47 | FromDiscord | <Patitotective> Cause in json, `JArray` is a sequence, not an array |
16:09:31 | FromDiscord | <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:32 | FromDiscord | <Rika> yeah youre not gonna be able to make a "get" proc like that no |
16:12:00 | FromDiscord | <Rika> In reply to @Patitotective "Cause in json, `JArray`": a "sequence" and an "array" are both lists of objects |
16:12:15 | FromDiscord | <Rika> in JSON, "array" means more of list of objects than literal array |
16:12:24 | FromDiscord | <Rika> so yes dont worry and use a sequence |
16:13:07 | FromDiscord | <Patitotective> In reply to @Rika "so yes dont worry": Thanks 🙃 |
16:13:56 | FromDiscord | <Rika> minor changes i made https://play.nim-lang.org/#ix=3LTB |
16:14:24 | FromDiscord | <Rika> ah i just saw the array and seq thing |
16:14:43 | FromDiscord | <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:57 | FromDiscord | <Patitotective> 👍 |
16:38:03 | FromDiscord | <Patitotective> Also, why does json creates `JsonNodeObj` and then a ref to it called `JsonNode`? |
16:38:13 | FromDiscord | <Patitotective> I copied it, but I do not understand it hehe |
16:44:02 | FromDiscord | <Elegantbeef> https://nim-lang.org/docs/system.html#hostCPU |
16:59:32 | FromDiscord | <iffy (Matt Haggard)> ah, perfect... though I wish it were a tuple instead of a string |
17:02:35 | FromDiscord | <Elegantbeef> well if you need to know the arch size you should be able to do `sizeof(pointer)` |
17:10:59 | FromDiscord | <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:58 | FromDiscord | <Rika> i dont follow |
17:20:12 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LTV |
17:21:39 | FromDiscord | <Elegantbeef> The latter is easier to extend |
17:21:57 | FromDiscord | <Elegantbeef> Plus supports other options in case you need them |
17:22:04 | FromDiscord | <Patitotective> Ok 🙃 |
17:27:01 | FromDiscord | <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:13 | FromDiscord | <Rika> no |
17:27:19 | FromDiscord | <Rika> since your type is distinct |
17:27:33 | FromDiscord | <Rika> that means the json procs are "not compatible" with your type and viceversa |
17:28:11 | FromDiscord | <Elegantbeef> remember Rika %\ are operators that work on anything |
17:28:18 | FromDiscord | <Elegantbeef> So yes you'd have to cause it's ambiguous |
17:28:29 | FromDiscord | <Rika> eh are they |
17:28:33 | FromDiscord | <Rika> i dont recall |
17:28:42 | FromDiscord | <Rika> ah is this the % that works on tuple seqs |
17:28:43 | FromDiscord | <Alea> Is there a way to get the key of the current item while iterating over a table? |
17:28:48 | FromDiscord | <Elegantbeef> `%` is the dumb "toJson" operator |
17:28:50 | FromDiscord | <Patitotective> In reply to @Elegantbeef "So yes you'd have": uh |
17:28:50 | FromDiscord | <Rika> then yeah you would need to disambiguate |
17:29:02 | FromDiscord | <Rika> also i wouldnt recommend it |
17:29:08 | FromDiscord | <Rika> i'd prolly name it something else |
17:29:16 | FromDiscord | <Rika> its both ambiguous and ambiguous |
17:29:18 | FromDiscord | <Elegantbeef> `for key, val in table.pairs`↵(@Alea) |
17:29:26 | FromDiscord | <Alea> Thanks! |
17:29:41 | FromDiscord | <Elegantbeef> `%` is just purposely cryptic |
17:30:02 | FromDiscord | <Rika> not a purpose i would deem worthy for making it cryptic |
17:30:04 | FromDiscord | <Elegantbeef> Name your macro `toNipref` or something not purposely obtuse |
17:30:38 | FromDiscord | <Rika> or a to[T] generic constrained to your type xd |
17:31:20 | FromDiscord | <Patitotective> what about `¬`and `¬`? |
17:31:22 | FromDiscord | <Patitotective> prank |
17:32:22 | FromDiscord | <Rika> your choice |
17:32:48 | FromDiscord | <Patitotective> can a macro be used like `macro{key: val, ...}`? |
17:32:51 | FromDiscord | <Patitotective> without spacing |
17:32:53 | FromDiscord | <Patitotective> (edit) "spacing" => "spacing?" |
17:33:24 | FromDiscord | <Rika> not sure, probably |
17:33:35 | FromDiscord | <Rika> actually depends on the name i guess |
17:33:54 | FromDiscord | <Patitotective> In reply to @Rika "actually depends on the": wdym |
17:34:11 | FromDiscord | <Rika> if its an operator yes, if not im not sure |
17:34:46 | FromDiscord | <Elegantbeef> No it cannot |
17:34:48 | FromDiscord | <Elegantbeef> having a space \> using cryptic operators |
17:34:49 | FromDiscord | <Elegantbeef> Doing `doThing {'a', 'b', 'c', 'd'}` is better than `&$&% {'a', 'b', 'c', 'd'}` |
17:34:52 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LU0 |
17:34:56 | FromDiscord | <Elegantbeef> If you want that operator make an untyped template you use, but dont include it in the library |
17:35:06 | FromDiscord | <Elegantbeef> make the library have `toNipref` |
17:35:17 | FromDiscord | <Elegantbeef> Assuming this is a library that's going to be released |
17:35:32 | FromDiscord | <Elegantbeef> If it's not then do whatever you want |
17:36:10 | FromDiscord | <Patitotective> In reply to @Elegantbeef "make the library have": `toPrefs` -_- lmao |
17:36:12 | FromDiscord | <Patitotective> thanks 🙃 |
17:36:27 | FromDiscord | <Elegantbeef> Anyway it's better than an operator for 99.9% of people |
17:36:36 | FromDiscord | <Elegantbeef> If they want an operator templates exist |
17:36:57 | FromDiscord | <Patitotective> so json's 👎 |
17:37:00 | FromDiscord | <Patitotective> (edit) "so json's 👎 ... " added "hehe" |
17:37:06 | FromDiscord | <Elegantbeef> Yea it's fucking stupid |
17:37:24 | PMunch | JSON is stupid? |
17:37:34 | FromDiscord | <Elegantbeef> Json's `%` operator |
17:38:01 | PMunch | Ah, I kinda like it.. |
17:38:10 | FromDiscord | <Patitotective> how lucky i am that there's a elegant beef to help me (and a rika, but rika is not beef) |
17:38:20 | FromDiscord | <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:35 | FromDiscord | <Elegantbeef> See pmunch you can like it but it shouldnt be in the library |
17:38:56 | FromDiscord | <Elegantbeef> If you want `%` you should have to implement it yourself as a template to `toJson` |
17:39:05 | PMunch | That's tedious |
17:39:18 | FromDiscord | <Elegantbeef> It's an ugly operator that is untinutive |
17:39:23 | PMunch | You can make the same argument that if you don't want it you can `import json except `%`` |
17:39:35 | FromDiscord | <Elegantbeef> It's like the bitwise operators for C++'s streams |
17:39:38 | FromDiscord | <Elegantbeef> They have 0 reason to being there |
17:39:41 | FromDiscord | <Elegantbeef> Sure that works to |
17:39:58 | FromDiscord | <Elegantbeef> Eitherway it should be a named macro |
17:40:33 | FromDiscord | <Hamid_Bluri> it's not that bad really |
17:40:40 | PMunch | I agree that `toJson` should also exist |
17:40:50 | FromDiscord | <Elegantbeef> It's purposely obtuse imo |
17:40:58 | PMunch | And `%*` just be a template to `toJson` or something like that |
17:41:01 | FromDiscord | <Elegantbeef> It does not show intent, it's just a funky operator |
17:41:13 | FromDiscord | <Rika> purposely? no, more like unnecessarily |
17:41:23 | PMunch | Well with JSON I don't think it's too bad, since the rest of the JSON syntax is there |
17:41:37 | FromDiscord | <Elegantbeef> But you can use it on normal objects |
17:41:59 | FromDiscord | <Elegantbeef> So you're capable of doing `var a = % MyObject(a: 100, b: 20, c: @[10, 2, 30])` |
17:42:02 | PMunch | If 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:20 | PMunch | Well of course, but that's just silly |
17:42:28 | FromDiscord | <Rika> is it |
17:42:30 | FromDiscord | <Elegantbeef> I've seen it |
17:42:41 | PMunch | Building an object just to immediately jsonize it? |
17:42:52 | FromDiscord | <Elegantbeef> It's just like the stream operators in C++'s streams |
17:42:52 | PMunch | I've seen `let x = %myObj` |
17:42:58 | FromDiscord | <Elegantbeef> They dont make it easyto read |
17:44:15 | PMunch | Well, 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:29 | FromDiscord | <Rika> is it? |
17:44:44 | FromDiscord | <Rika> if you have "mixed code" say handling json and doing a bunch of other stuff in the same proc |
17:44:48 | FromDiscord | <Rika> is it still obvious |
17:45:03 | PMunch | The 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:27 | FromDiscord | <Elegantbeef> It's putting operators where they dont belong imo |
17:45:33 | PMunch | @Rika, maybe not, and as I said I would've liked to see a `toJson` proc as well |
17:45:46 | PMunch | If 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:47 | arkanoid | once I have finished "nimble develop"ing a package and I want to go back to normal package handling, what should I do? |
17:48:20 | arkanoid | I mean, I wanted to test a little change in existing package, and now I want to return to normal "nimble install" condition |
17:48:57 | FromDiscord | <Rika> uninstall the developed package? |
17:49:16 | arkanoid | do you mean "nimble uninstall" or remove the local folder |
17:49:22 | FromDiscord | <Rika> nimble uninstall xxx@#head |
17:49:54 | arkanoid | how does nimble know if the deleted version should be the locally installed one or the one in ~/.nimble |
17:50:09 | FromDiscord | <Rika> the one locally installed is usually versioned #head |
17:50:27 | FromDiscord | <Rika> unless your global install is also head |
17:54:12 | FromDiscord | <Patitotective> ~~nothing feels better than copying and pasting json's code~~ |
17:56:26 | FromDiscord | <Michal Maršálek> I guess this is the proper way? @Yardanico https://nim-lang.org/docs/manual.html#pragmas-compiletime-pragma |
17:59:14 | FromDiscord | <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:03 | FromDiscord | <Elegantbeef> And yea it's just vscode |
18:06:46 | FromDiscord | <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:50 | arkanoid | is it possible to make a variant object that is also a "ref object of AnotherObject"? |
18:07:11 | FromDiscord | <Elegantbeef> Actually that shouldnt be supported |
18:07:37 | arkanoid | ok, np, I can wrap the variant one into the ref one |
18:07:45 | FromDiscord | <Patitotective> In reply to @Michal58 "I created an issue:": 👍 |
18:08:22 | FromDiscord | <Elegantbeef> Can you not just make a variant object inside a inheriting object? |
18:08:31 | FromDiscord | <Elegantbeef> But michal that shouldnt be supported |
18:08:33 | arkanoid | exactly |
18:08:54 | FromDiscord | <Michal Maršálek> In reply to @Elegantbeef "But michal that shouldnt": Sorry for spamming the github than :/ why not? |
18:09:03 | arkanoid | btw I'm experimenting with nimqml and I'm having quite good results! |
18:09:04 | FromDiscord | <Michal Maršálek> (edit) "than" => "then" |
18:09:23 | FromDiscord | <Elegantbeef> I atleast dont think it should, since distinct should always be converted from the "base" to validate the type |
18:09:30 | arkanoid | I think there should be more interest in this package, it enables one of the most used gui library in industry |
18:09:37 | FromDiscord | <Elegantbeef> When you can create a value directly you cannot get the same validations |
18:10:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LU9 |
18:10:02 | FromDiscord | <Elegantbeef> But only when you borrow `.` operators |
18:10:10 | FromDiscord | <Elegantbeef> Otherwise distinct doesnt make much sense |
18:10:46 | FromDiscord | <Michal Maršálek> Hmm, I'm not sure I understand, the proposition is just a syntactic sugar |
18:10:52 | FromDiscord | <Michal Maršálek> It shouldn't break anything |
18:11:23 | FromDiscord | <Elegantbeef> It's more than syntax if you dont borrow `.` |
18:12:31 | FromDiscord | <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:12 | FromDiscord | <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:49 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUc |
18:14:08 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/Jkm |
18:14:35 | FromDiscord | <Michal Maršálek> Hmm |
18:15:25 | FromDiscord | <Michal Maršálek> In reply to @Elegantbeef "Say you have someone": Can you restructure this sentence please? |
18:22:03 | FromDiscord | <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:30 | FromDiscord | <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:30 | FromDiscord | <Elegantbeef> Bar should not be the same as if you copy Foo since one big usage of distincts is to validate data |
18:22:31 | FromDiscord | <Elegantbeef> Atleast those are my thoughts |
18:23:17 | * | jjido joined #nim |
18:23:47 | FromDiscord | <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:16 | FromDiscord | <Elegantbeef> For a distinct to have purpose everything but assignment should be explicitly added to the object |
18:24:54 | FromDiscord | <Elegantbeef> that and conversion from/to base of course |
18:28:23 | FromDiscord | <Michal Maršálek> I see |
18:28:45 | FromDiscord | <Michal Maršálek> Thank you again. 🙂 |
18:30:06 | FromDiscord | <Michal Maršálek> I updated the issue |
18:30:20 | FromDiscord | <Elegantbeef> Comically a fair bit of people get annoyed with distinct's strictness but that's the entire point |
18:32:15 | FromDiscord | <Smarc> How would you check for an existing file if it is empty? |
18:37:02 | FromDiscord | <Elegantbeef> There is `getFileSize` |
18:37:04 | FromDiscord | <Elegantbeef> Both in `io` and `os` |
18:41:57 | * | Gustavo6046 joined #nim |
18:42:07 | FromDiscord | <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:13 | FromDiscord | <Elegantbeef> Yes it's supported |
18:43:33 | FromDiscord | <Ksr> Thx :). Is this mentioned somewhere in the docu? |
18:43:35 | * | perro left #nim (WeeChat 3.0.1) |
18:44:23 | FromDiscord | <Elegantbeef> I do not know, but it is certainly supported |
18:44:51 | FromDiscord | <Ksr> thank you. |
18:52:23 | FromDiscord | <Michal Maršálek> What is the canonical way do singletons? |
18:52:36 | FromDiscord | <Michal Maršálek> (edit) "What is the canonical way ... do" added "to" |
18:53:23 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUm |
18:53:23 | FromDiscord | <Elegantbeef> Not that singletons are really needed in Nim but yea that's basically how |
18:56:17 | PMunch | I 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:43 | PMunch | This idea of writing code and not really knowing when stuff is instantiated and how often is a bit alien to me.. |
18:57:05 | FromDiscord | <Elegantbeef> Singletons are common in OOP just due to the nature of the language |
18:57:16 | FromDiscord | <Elegantbeef> C# + Unity has a lot of people using them due to the editor |
18:57:21 | PMunch | Yeah I know, and I use them in our C# code at work |
18:57:43 | PMunch | But it feels like a band aid on a broken arm.. |
18:58:09 | nrds | <Prestige99> I use the singleton pattern in my game engine for the "global" input handler, seems fine to me |
18:58:20 | nrds | <Prestige99> Not something needed very often though |
18:58:46 | FromDiscord | <Elegantbeef> Nim has the added benefit of modules |
18:59:28 | FromDiscord | <Elegantbeef> You can have top level logic run and have a singleton without having to expose that you even instantiated state |
18:59:47 | nrds | <Prestige99> Yeah that's the best way to do it imo |
19:12:06 | FromDiscord | <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:36 | FromDiscord | <pietroppeter> @ElegantBeef |
19:12:51 | FromDiscord | <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:51 | FromDiscord | <Elegantbeef> I'll throw it on git right now so you can have a look around |
19:15:09 | FromDiscord | <Elegantbeef> https://github.com/beef331/nimscripter/blob/master/examples/macrorepl/macrorepl.nim here |
19:16:11 | FromDiscord | <Elegantbeef> macrorepl is just a program you can point at a nimscript file and it'll evaluate it |
19:16:34 | FromDiscord | <Elegantbeef> The two macros inside `macrosports` are how I talk to the binary |
19:19:18 | FromDiscord | <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:42 | FromDiscord | <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:58 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUu |
19:22:05 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUu" => "https://play.nim-lang.org/#ix=3LUv" |
19:22:11 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUv" => "https://play.nim-lang.org/#ix=3LUw" |
19:22:18 | FromDiscord | <Patitotective> without having to define it |
19:22:50 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUx |
19:23:17 | FromDiscord | <Elegantbeef> Damn people like pestering the bridge |
19:24:51 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LUA |
19:25:26 | FromDiscord | <Elegantbeef> If you want to make multiple parameters defaulted the only way to do so is use a macro or manually |
19:25:32 | FromDiscord | <Patitotective> 😉 |
19:25:34 | FromDiscord | <Patitotective> Thanks |
19:27:12 | * | noeontheend joined #nim |
19:28:14 | * | krux02 joined #nim |
19:46:17 | FromDiscord | <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:48 | FromDiscord | <Elegantbeef> As long as it's not in a call, of course |
19:47:10 | FromDiscord | <Elegantbeef> Assuming you have some form of static information you can |
19:47:33 | FromDiscord | <Elegantbeef> so if you want the first 3 values as variables you can |
19:47:40 | FromDiscord | <hmmm> hmm I'd like to use it exactly to pass the bunch of variables to another proc that has maybe varargs |
19:47:43 | FromDiscord | <Elegantbeef> if you want the first 2 and remainder in a collection you can |
19:48:00 | FromDiscord | <Elegantbeef> If the proc has varargs pass the seq |
19:48:08 | FromDiscord | <Elegantbeef> varargs accepts seq/array |
19:48:11 | FromDiscord | <hmmm> oh |
19:48:16 | FromDiscord | <hmmm> that is comfy |
19:48:20 | FromDiscord | <hmmm> u sure? |
19:49:15 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3LUM |
19:49:15 | FromDiscord | <Elegantbeef> Yes |
19:49:31 | FromDiscord | <Elegantbeef> If you're attempting to do `doThing(10, @[10 ,20])` it will not work for obvious reasons |
19:49:32 | FromDiscord | <hmmm> In reply to @Elegantbeef "so if you want": hmm nu it should work on a seq of any lenght |
19:49:47 | FromDiscord | <Elegantbeef> You cannot unpack a seq dynamically |
19:49:53 | FromDiscord | <Elegantbeef> nim operates on static information |
19:49:59 | FromDiscord | <hmmm> I see |
19:50:08 | FromDiscord | <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:07 | FromDiscord | <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:05 | Amun-Ra | btw. 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:32 | FromDiscord | <Elegantbeef> One can be reasoned unsound statically |
19:54:34 | Amun-Ra | should I start adding "and 0xff" when converting to byte? |
19:54:36 | FromDiscord | <Elegantbeef> The other cannot |
19:54:39 | FromDiscord | <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:08 | FromDiscord | <Elegantbeef> They're unchecked integers so i think it's "safe" |
19:55:56 | Amun-Ra | it wraps around in C/C++, I wonder if this will change on "nim level" |
19:59:38 | FromDiscord | <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:39 | FromDiscord | <konsumlamm> In reply to @Amun-Ra "should I start adding": yeah, using `and 0xff` is the "correct" way |
20:00:47 | FromDiscord | <konsumlamm> also, why use `byte` instead of `uint8`? |
20:01:37 | Amun-Ra | konsumlamm: one character less ;) |
20:01:52 | Amun-Ra | and it's easier to type so it's win win for me |
20:08:28 | arkanoid | I 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:33 | PMunch | Implementing some new stuff for microcontroller programming in preparation for my talk |
20:22:22 | PMunch | I'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:40 | PMunch | Now the entire keyboard firmware is 2468 bytes |
20:24:21 | FromDiscord | <el__maco> you wrote your keyboard's firmware? |
20:24:24 | arkanoid | PMunch, 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:38 | PMunch | For comparison the "hello world" of microcontrollers, blinking the onboard LED, takes 2422 bytes when written in Arduino |
20:25:02 | PMunch | @el__maco, I built and programmed my own keyboard, yes |
20:25:29 | FromDiscord | <el__maco> I guess I should ask if its in Nim |
20:25:47 | PMunch | arkanoid, 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:55 | PMunch | @el__maco, of course it is :P |
20:25:56 | FromDiscord | <el__maco> probably not if its 2368 bytes 🤔 |
20:26:07 | FromDiscord | <el__maco> it is? dang |
20:26:09 | PMunch | https://github.com/PMunch/badger |
20:26:19 | arkanoid | PMunch: oh! sad, I was going to try same for esp32 |
20:26:31 | PMunch | @el__maco, or rather: https://github.com/PMunch/badger/tree/final |
20:26:55 | PMunch | I haven't pushed my latest changes though, so the size of that is 3750 bytes |
20:27:05 | arkanoid | is the honey badger the nim mascot? really? |
20:27:31 | PMunch | Haha, it was, but it hasn't been used for many many years now |
20:28:06 | PMunch | arkanoid, 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:51 | PMunch | Closest you'll get now is to sponsor me on GitHub, then I can go and buy some beer myself :D |
20:29:06 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LUZ |
20:29:41 | FromDiscord | <Patitotective> (edit) "https://play.nim-lang.org/#ix=3LUZ" => "https://play.nim-lang.org/#ix=3LV0" |
20:30:11 | PMunch | @Patitotective, that is the default behaviour |
20:30:21 | PMunch | You have to use `distinct` to make it not behave like that |
20:31:24 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV1 |
20:32:43 | FromDiscord | <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:24 | arkanoid | PMunch: I'll wait for the possibility to reach FOSDEM, otherwhy happy to sponsor |
20:33:38 | PMunch | @huantian, It's build for a Teensy 2.0 which runs the atmega32u4, so it should be as easy as `make upload` |
20:34:15 | PMunch | @Patitotective, yes, like that it will be it's own type and you can't use any of OrderedTables procedures on it |
20:34:21 | FromDiscord | <huantian> oh I didn't realize that↵might check it out in a bit then |
20:34:25 | arkanoid | if 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:49 | FromDiscord | <huantian> you can do `for (a, b) in myseq` or `for a, b in myseq.items` I believe |
20:35:10 | PMunch | @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:28 | FromDiscord | <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:41 | PMunch | But should be super easy, only file you should have to edit is badger.nim |
20:35:50 | FromDiscord | <huantian> hm ok |
20:35:55 | FromDiscord | <huantian> is there rotary encoder support? |
20:35:57 | PMunch | @Patitotective, then don't put `distinct` there |
20:36:03 | PMunch | @huantian, not yet |
20:36:23 | PMunch | It's really bare bones, just scanning a matrix and outputting keys over USB |
20:36:39 | PMunch | I wrote it all live on stream, so I focused on just getting everything to work |
20:37:27 | FromDiscord | <huantian> mm makes sense, seems like a pretty cool project though |
20:37:54 | FromDiscord | <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:06 | arkanoid | thanks |
20:38:14 | PMunch | Oh 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:34 | PMunch | @Patitotective, do you import the tables module where you're using your type? |
20:39:04 | PMunch | If you have that definition in one module and use it from another module that other module still needs to import tables |
20:39:29 | PMunch | You can of course put `import tables; export tables` in the file where you create that type alias though |
20:41:18 | FromDiscord | <Patitotective> sent a code paste, see https://paste.rs/hLI |
20:42:25 | FromDiscord | <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:30 | PMunch | Well of course |
20:42:39 | FromDiscord | <Elegantbeef> `export tables` |
20:42:49 | PMunch | Your second argument is a string, not a PrefsNode |
20:42:53 | FromDiscord | <Elegantbeef> You dont have the tables module exported so you cannot `table.objectV["lang"] = "es"` |
20:43:28 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LV4 |
20:43:39 | FromDiscord | <Patitotective> In reply to @Elegantbeef "You dont have the": all occurs in a same file |
20:43:49 | FromDiscord | <Patitotective> In reply to @PMunch "Your second argument is": hehe that was it thanks 🙃 |
20:43:53 | FromDiscord | <Elegantbeef> As an ex C# programmer i default to byte↵(@konsumlamm) |
20:44:11 | FromDiscord | <Patitotective> (edit) "In reply to @PMunch "Your second argument is": hehe ... that" added "it was" | removed "was it" |
20:44:22 | PMunch | I use byte if I want to use a byte, and I use uint8 if I want a number. |
20:44:36 | PMunch | Well, I try to. I'm not very good at it |
20:44:55 | FromDiscord | <Elegantbeef> Yea i either go `u8` or `byte` |
20:45:02 | FromDiscord | <Elegantbeef> I just dont think about `uint8` |
20:47:32 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV5 |
20:49:36 | arkanoid | when should I prefer "proc `myattribute=`" instead of "proc getMyAttribute" ? |
20:49:40 | PMunch | Hmm, is there a way to create a byte literal? |
20:49:42 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LV7 |
20:49:51 | PMunch | I like to use 0xff'u8 for example |
20:49:56 | FromDiscord | <huantian> isn't byte just an alias for uint8? |
20:50:13 | PMunch | arkanoid, well one is a getter and the other is a setter? |
20:50:23 | PMunch | @huantian, I think so, yes |
20:51:02 | arkanoid | PMunch: getter would be "proc myattribute"? |
20:51:15 | PMunch | You should be able to overload `[]=` for string, string @Patitotective |
20:51:30 | PMunch | arkanoid, sure, that's what I usually do |
20:51:47 | PMunch | Oh well, I'm off to take a shower and go to bed |
20:51:48 | * | PMunch quit (Quit: leaving) |
20:51:59 | FromDiscord | <Patitotective> In reply to @PMunch "You should be able": hmmm, quite long but thanks hehe 🙃 |
20:52:16 | FromDiscord | <Elegantbeef> Buh bye |
20:52:24 | FromDiscord | <huantian> In reply to @Patitotective "hmmm, quite long but": I mean it's just like 1-2 lines of code |
20:52:33 | FromDiscord | <huantian> In reply to @PMunch "Oh well, I'm off": good sleeps |
20:52:49 | arkanoid | PMunch, interesting approach, thanks |
20:52:52 | arkanoid | oh, he's gone |
20:53:20 | FromDiscord | <Elegantbeef> Bunch of overloads means more↵(@huantian) |
20:54:06 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LV8 |
20:55:24 | FromDiscord | <Patitotective> why there are two `=`? |
20:55:27 | FromDiscord | <Patitotective> (edit) "why there are two `=`? ... " added "what does that mean" |
20:55:29 | FromDiscord | <Patitotective> (edit) "mean" => "mean?" |
20:55:36 | FromDiscord | <huantian> the first one is part of the proc definition |
20:55:41 | FromDiscord | <huantian> the second one is the actual assignment |
20:55:51 | FromDiscord | <Elegantbeef> What huantian said |
20:55:58 | FromDiscord | <Elegantbeef> It's just a single lined proc |
20:56:09 | FromDiscord | <Patitotective> In reply to @huantian "the first one is": what the first means, the return type? |
20:56:22 | FromDiscord | <Patitotective> (edit) "In reply to @huantian "the first one is": what ... themean," added "does" | "means," => "mean," |
20:56:33 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3LVa |
20:56:39 | FromDiscord | <Patitotective> oh lol |
20:56:42 | FromDiscord | <Elegantbeef> There is nothing fancy going on nim uses `=` for proc bodies |
20:56:54 | FromDiscord | <Patitotective> let me try |
20:58:17 | FromDiscord | <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:26 | FromDiscord | <Elegantbeef> I'm using some low level logic to reset now but i dont know if it's safe |
20:59:29 | FromDiscord | <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:00 | FromDiscord | <Elegantbeef> Nice, it passes my tests but i dont know if it's "right" on complex types |
21:00:19 | FromDiscord | <Elegantbeef> But yea we're at relatively cheap peek only 64bytes are copied |
21:00:45 | FromDiscord | <Patitotective> sent a code paste, see https://play.nim-lang.org/#ix=3LVf |
21:01:08 | FromDiscord | <Patitotective> and if i remove the convert part, infinit recursion |
21:01:32 | FromDiscord | <Elegantbeef> `T: not NiPref` |
21:01:35 | FromDiscord | <Elegantbeef> Or whatever the node is |
21:01:46 | FromDiscord | <Elegantbeef> Generic type constraints are magic |
21:08:17 | FromDiscord | <Elegantbeef> replace `NiPref` for whatever the `toPref` returns |
21:12:55 | FromDiscord | <ajusa> Works perfectly, thanks mr beef |
21:13:23 | FromDiscord | <Elegantbeef> Nice if you have any odd behaviour shoot me a message of course 😀 |
21:13:32 | FromDiscord | <ajusa> sent a code paste, see https://play.nim-lang.org/#ix=3LVm |
21:14:00 | FromDiscord | <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 |