00:09:11 | FromDiscord | <Jakraes> Is there a way to return an array in a proc? |
00:09:35 | FromDiscord | <Jakraes> I'm trying to do like, proc x(): [bool, int] |
00:09:57 | FromDiscord | <RattleyCooper> I think the first parameter for arrays is the length |
00:10:03 | FromDiscord | <RattleyCooper> You might need `tables`? |
00:10:10 | FromDiscord | <Jakraes> Oh lemme check that out |
00:13:29 | FromDiscord | <RattleyCooper> Just depends on if you're trying to create an actual array or a set of key/value pairs |
00:15:21 | FromDiscord | <Jakraes> Yeah I just want to return an array with a bool and an int inside |
00:17:14 | FromDiscord | <RattleyCooper> I'm pretty sure I was trying to do something similar at one point and was told to use a custom object/type. There aren't multi-type arrays. You might be able to use something like `Dik` |
00:17:38 | FromDiscord | <RattleyCooper> https://github.com/juancarlospaco/dik |
00:17:40 | fn | <R2D299> itHub: 7"Table implemented as optimized sorted hashed dictionary for heterogeneous values" |
00:17:57 | FromDiscord | <RattleyCooper> Easier to make a custom object/type though |
00:33:00 | FromDiscord | <ElegantBeef> do you want ints or bools or int and bool? |
00:33:39 | FromDiscord | <ElegantBeef> if you want a bool and int together you could do `seq[(bool, int)]` but if it's int or bool best to use an object variant |
01:07:05 | FromDiscord | <dan> @ElegantBeef Didnt you do something with android ndk using the generated c files from nim? |
01:07:15 | FromDiscord | <dan> did that work out? |
01:11:21 | FromDiscord | <ElegantBeef> I mean i used the android.mk file that impbox made for nico, but yea |
01:11:30 | FromDiscord | <ElegantBeef> I've also ran nim on the rpi pico |
01:13:28 | FromDiscord | <dan> is that public? |
01:17:21 | FromDiscord | <ElegantBeef> Which part? |
01:17:39 | FromDiscord | <dan> ah sry, the android.mk |
01:18:13 | FromDiscord | <ElegantBeef> It's really just a "include all c files in X folder" but i can get it for you |
01:18:56 | FromDiscord | <dan> its more of the other stuff thats really interesting to me |
01:19:05 | FromDiscord | <dan> like includes flags etc |
01:19:31 | FromDiscord | <dan> if its parsed from the json or something |
01:19:32 | FromDiscord | <ElegantBeef> Well it's just outputting C to a folder then including it |
01:19:41 | FromDiscord | <ElegantBeef> https://hastebin.com/ehuqemohuj.makefile |
01:19:52 | FromDiscord | <ElegantBeef> That's the important part afaik |
01:21:25 | FromDiscord | <dan> 🤔 i cant quite make sense of how this is working |
01:21:45 | FromDiscord | <ElegantBeef> It's just including the c files to be included |
01:21:51 | FromDiscord | <dan> yes of course |
01:22:02 | FromDiscord | <ElegantBeef> So when ndk-build is called it compiles it as is |
01:22:08 | FromDiscord | <dan> but this does not consider anything that nim spits out about how it needs to be compiled |
01:22:17 | FromDiscord | <ElegantBeef> Cause it doesnt need to |
01:22:30 | FromDiscord | <ElegantBeef> Atleast i dont think so |
01:22:40 | FromDiscord | <dan> i somehow assumed it would |
01:23:11 | FromDiscord | <dan> did you use the nim dump command before? |
01:23:28 | FromDiscord | <ElegantBeef> Nah ` nim c -c --nimcache:android/app/jni/src/arm $(RELEASEOPTS) --cpu:arm --os:android -d:androidNDK --noMain:on --genScript ./src/main.nim` |
01:23:32 | FromDiscord | <ElegantBeef> Is the compile command |
01:24:00 | FromDiscord | <ElegantBeef> Worth noting that nico emits a `sdlMain` procedure which is what's called from the javaa |
01:24:16 | FromDiscord | <dan> what is the genScript for? |
01:26:04 | FromDiscord | <dan> https://tenor.com/view/thinking-interesting-hmmm-emoji-3d-gif-7838382 |
01:26:07 | FromDiscord | <ElegantBeef> Emits a `.sh` for compiling, though dont know if it's used |
01:27:47 | FromDiscord | <dan> you think i should try and pester impbox about how this works? 🤔 |
01:27:53 | FromDiscord | <ElegantBeef> If you want |
01:28:07 | FromDiscord | <ElegantBeef> He knows more than me in this regard i didnt touch it much |
01:28:39 | FromDiscord | <ElegantBeef> The pico work was easier since it had fewer layers of indirection 😄 |
01:32:04 | FromDiscord | <dan> alright 😄 @impbox [ftsf] would you mind me picking your brain about some of the nico stuff? |
01:43:28 | fn | <ForumUpdaterBot99> New post on r/nim by PhotonicBlindness: Question from a C# guy. If anyone here worked with C# , how would you compare the 2., see https://reddit.com/r/nim/comments/ons89i/question_from_a_c_guy_if_anyone_here_worked_with/ |
01:43:58 | * | kayabaNerve_ quit (Remote host closed the connection) |
01:44:23 | * | kayabaNerve_ joined #nim |
01:53:06 | * | kayabaNerve_ quit (Ping timeout: 255 seconds) |
02:00:40 | FromDiscord | <creonico> Hey, so I watched a video saying that rust is memory safe without a garbage collector, and it made me wonder if nim can also be memory safe without a garbage collector |
02:01:36 | FromDiscord | <dan> now that i can answer without knowing too much about nim |
02:02:06 | FromDiscord | <dan> nim does have a garbage collector and any language can be memory safe |
02:02:30 | FromDiscord | <dan> really depends on your code |
02:11:24 | FromDiscord | <ElegantBeef> Well rust uses a similar memory management method to Nim's Arc, which is what they mean by "no GC" afaik |
02:11:52 | FromDiscord | <ElegantBeef> So if you use the strict not nil annotation you can get similar memory safety |
02:12:40 | FromDiscord | <ElegantBeef> Remember that rust doesnt give nil, so just by making sure you cannot have nil you get a fair bit of memory safety |
02:17:39 | FromDiscord | <ElegantBeef> So nil aside you can say using the same definition of GC that rust does that Nim's orc is "memory safe without a garbage collector" 😄 |
02:18:07 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I'm writing a library in Nim. How can I have a file withing the `src` directory echo the name of the library? |
02:18:52 | FromDiscord | <generic linux user> like ehen you launch it? |
02:19:01 | FromDiscord | <generic linux user> confusing question tho |
02:22:17 | FromDiscord | <@bracketmaster-5a708063d73408ce4> well... more when I run a function in the library |
02:22:59 | FromDiscord | <generic linux user> so when someone uses your lib, it will print that this uses your library? |
02:23:13 | FromDiscord | <@bracketmaster-5a708063d73408ce4> yes |
02:23:22 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I know it sounds silly - but I have reasons |
02:23:45 | FromDiscord | <ElegantBeef> Well you could make a macro that inserts a `echo "Using library X"` in the proc statement list |
02:24:25 | FromDiscord | <@bracketmaster-5a708063d73408ce4> yeah - I'm just wondering if there is a library define or something |
02:28:31 | FromDiscord | <ElegantBeef> It's an odd want inserting calls to all procedures from a specific module |
02:30:57 | FromDiscord | <@bracketmaster-5a708063d73408ce4> yeah... don't worry about it - not super important |
02:40:55 | FromDiscord | <Bung> @ElegantBeef have you checked hax's updated exmaple? |
02:41:15 | FromDiscord | <ElegantBeef> Nope |
02:41:31 | FromDiscord | <ElegantBeef> Got a link? |
02:42:02 | FromDiscord | <Bung> https://github.com/haxscramper/hnimast/blob/master/tests/tNimscriptInterop.nim seems ready for use, only pointer type not handled |
02:47:30 | FromDiscord | <ElegantBeef> Seems nice, looks like a worry i had is a non issue |
02:49:40 | FromDiscord | <Bung> I havn't tried yet, reading frontend things . |
02:50:12 | FromDiscord | <ElegantBeef> Well i cannot just paste this into nimscripter thanks to that `std/` issue i atleast experienced |
02:50:49 | FromDiscord | <ElegantBeef> Meaning it relies on any version past that commit 😄 |
02:51:56 | FromDiscord | <Bung> okay, so wait |
03:29:27 | * | arkurious quit (Quit: Leaving) |
03:34:54 | FromDiscord | <impbox [ftsf]> In reply to @dan "alright 😄 <@!309937753699778561> would": sure, what's up? |
03:35:47 | FromDiscord | <impbox [ftsf]> (best to ask your question so i can answer it) |
03:36:11 | FromDiscord | <ElegantBeef> It'll be about the android build process with nim |
03:55:54 | FromDiscord | <offbeat-stuff (offbeat-stuff)> addExitProc doesn't work |
03:56:00 | FromDiscord | <offbeat-stuff (offbeat-stuff)> how do i import it |
03:56:08 | FromDiscord | <ElegantBeef> `import std/exitprocs` |
03:56:26 | FromDiscord | <ElegantBeef> Its how you should be importing stdlib files presently |
03:56:27 | FromDiscord | <offbeat-stuff (offbeat-stuff)> thanks |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:39 | * | supakeen joined #nim |
04:21:18 | * | kayabaNerve joined #nim |
04:21:24 | * | kayabaNerve quit (Remote host closed the connection) |
04:21:48 | * | kayabaNerve joined #nim |
04:35:33 | FromDiscord | <Bung> implement a new backend ,does it need to be in nim repo or plugable ? |
04:44:39 | FromDiscord | <haxscramper> In reply to @Bung "https://github.com/haxscramper/hnimast/blob/master/": I realized toVm for objects is implemented incorrectly - simple fieldPairs is not sufficient, I must also use 'iterateFields' on the object implementation to correctly position all fields |
04:45:01 | FromDiscord | <haxscramper> But that can be easily fixed |
04:52:39 | FromDiscord | <bung87 (Bung)> Okay |
04:58:30 | FromDiscord | <Rika> In reply to @ElegantBeef "So nil aside you": technically only arc, not orc |
05:24:25 | nixfreak_nim[m] | using tables , how do you get back only one key or value |
05:25:43 | FromDiscord | <ElegantBeef> What do you mean? |
05:26:57 | nixfreak_nim[m] | so I iterate over all the keys or values or both but how can I just show one key or one value |
05:27:58 | FromDiscord | <ElegantBeef> do the first then put a break after, can always make a proc to do it for you |
05:29:02 | nixfreak_nim[m] | I can't just echo the int of a value ? |
05:29:15 | FromDiscord | <ElegantBeef> You can |
05:29:32 | nixfreak_nim[m] | echo x["Cat"] |
05:29:32 | nixfreak_nim[m] | 10 |
05:29:42 | nixfreak_nim[m] | echo x(10) ? |
05:30:03 | FromDiscord | <ElegantBeef> Oh you want to get the key from the value? |
05:30:12 | nixfreak_nim[m] | yes |
05:30:20 | nixfreak_nim[m] | sorry had it backwards |
05:30:54 | FromDiscord | <ElegantBeef> You cant really, you can get a list of all keys with that value but not a specific key |
05:31:16 | FromDiscord | <ElegantBeef> So if you just want the first you can just iterate over find the value that's the same and break |
05:32:27 | nixfreak_nim[m] | ahh ok ,I was looking over the tables section and didn't see a way but that makes sense |
05:33:02 | nixfreak_nim[m] | so iterate over all then use an if statement for the first one then break |
05:33:27 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=3tu4 for an example of what i'd do, though preferablly make it a proc instead of course |
05:36:33 | nixfreak_nim[m] | ok how would you do it if you didn't know the key? |
05:36:49 | FromDiscord | <ElegantBeef> That example doesnt know the key |
05:37:09 | nixfreak_nim[m] | ok either one then , the value or the key |
05:37:31 | FromDiscord | <ElegantBeef> I dont follow, if you have the key you can get the value, if you have the value you can only get a possible key |
05:37:40 | FromDiscord | <ElegantBeef> It's only associative key -> value |
05:37:51 | FromDiscord | <ElegantBeef> There is no connection from value to key |
05:38:20 | nixfreak_nim[m] | oh so not like an array , there is no index with key,value |
05:38:39 | FromDiscord | <Rika> Well that’s not how tables work |
05:39:05 | nixfreak_nim[m] | I get it , I didn't think there was just curious |
05:39:12 | FromDiscord | <Rika> In arrays you cannot set arbitrary keys like in tables |
05:39:56 | nixfreak_nim[m] | so not like python dicts then |
05:40:12 | FromDiscord | <Rika> Python dictionaries cannot do what you say either |
05:40:42 | FromDiscord | <Rika> You can always use two tables with the value and key reversed in one of them |
05:41:10 | FromDiscord | <ElegantBeef> The same issue arises though you can have 200 `10`s and have a list of keys |
05:41:11 | FromDiscord | <Rika> That is only if the value is hashable like the key |
05:41:21 | FromDiscord | <Rika> And yes |
05:41:27 | FromDiscord | <Rika> If the value is unique to the key |
05:42:07 | FromDiscord | <Rika> Though Nim tables have an interesting feature where a key can have more than one value |
05:42:08 | nixfreak_nim[m] | d.iterkeys().next() |
05:42:30 | FromDiscord | <Rika> In reply to @nixfreak_nim "d.iterkeys().next()": You’re iterating through the keys still, which is O(n) |
05:42:41 | FromDiscord | <Rika> Accesses for dictionaries are typically constant time |
05:43:25 | FromDiscord | <Rika> You will not have fun trying to search for a key with a certain value in a dictionary with a few hundred thousand or a million entries |
05:43:57 | FromDiscord | <Rika> And the issue of non unique values still exists |
05:44:23 | nixfreak_nim[m] | Sorry element crashed on sway |
05:45:04 | nixfreak_nim[m] | ok I understand , thanks |
05:47:41 | * | max22- joined #nim |
05:47:58 | * | max22- quit (Remote host closed the connection) |
05:48:20 | * | max22- joined #nim |
06:13:42 | FromDiscord | <checkersai> What's the purpose of `lent`? |
06:15:19 | FromDiscord | <checkersai> Oh is it basically like a const reference? |
06:20:36 | FromDiscord | <ElegantBeef> It's an read only borrow |
06:21:36 | FromDiscord | <ElegantBeef> So based off my minute understanding of what a const reference is yea basically, a read only reference |
06:22:03 | FromDiscord | <ElegantBeef> Though i'm uncertain if in Nim it's forced to be read only, in that if you mutate it i believe it's a copy |
06:24:26 | FromDiscord | <impbox [ftsf]> maybe check out the ARC talk |
06:24:39 | FromDiscord | <impbox [ftsf]> https://www.youtube.com/watch?v=yA32Wxl59wo i think? |
06:24:43 | fn | <R2D299> outube: 7"Move semantics for Nim" |
06:25:03 | FromDiscord | <impbox [ftsf]> or https://www.youtube.com/watch?v=aUJcYTnPWCg |
06:25:06 | fn | <R2D299> outube: 7"Andreas Rumpf: Nim ARC/ORC (NimConf 2020)" |
06:25:20 | FromDiscord | <impbox [ftsf]> goes into detail about sink/lent |
06:26:38 | FromDiscord | <checkersai> cool |
06:27:08 | FromDiscord | <checkersai> another question, is there a significant difference between using `SharedPtr` and using `ref` with `--gc:arc`? |
06:28:01 | FromDiscord | <ElegantBeef> Wouldnt a sharedptr just be equivlent to any GC'd method? |
06:28:32 | FromDiscord | <checkersai> Well it's a reference counted pointer so `arc` is the most similar |
06:30:35 | FromDiscord | <ElegantBeef> I'll dumbly say sure then |
06:35:25 | FromDiscord | <Rika> Well I assume it is because arc doesn’t use thread local heaps anymore right? |
06:36:45 | FromDiscord | <ElegantBeef> Probably |
06:37:16 | FromDiscord | <ElegantBeef> My experience with shared ptrs is reading the C++ standard and going "Yep sound about what Nim offers now" |
06:41:29 | * | rockcavera quit (Remote host closed the connection) |
06:42:34 | FromDiscord | <Rika> Why would you read the C++ standard willingly |
06:51:11 | FromDiscord | <ElegantBeef> Elaborate explanation of what it's supposed to do 😄 |
06:54:03 | * | max22- quit (Remote host closed the connection) |
06:55:54 | * | Vladar joined #nim |
06:56:31 | * | max22- joined #nim |
07:09:02 | fn | <ForumUpdaterBot99> New post on r/nim by unquietwiki: Nim in DevOps?, see https://reddit.com/r/nim/comments/onx0z3/nim_in_devops/ |
07:15:34 | * | botenkhamen|2 joined #nim |
07:25:15 | * | botenkhamen|2 left #nim (No boundaries on the net!) |
07:32:21 | * | max22- quit (Remote host closed the connection) |
07:33:25 | * | max22- joined #nim |
07:43:19 | * | TakinOver joined #nim |
07:47:15 | fn | <ForumUpdaterBot99> New post on r/nim by rangerelf: json / nimongo data exchange?, see https://reddit.com/r/nim/comments/onxhd5/json_nimongo_data_exchange/ |
08:21:57 | * | icebattle quit (Ping timeout: 268 seconds) |
08:22:56 | * | krux02 joined #nim |
08:28:15 | * | icebattle joined #nim |
09:06:09 | * | pro joined #nim |
09:10:07 | fn | <ForumUpdaterBot99> New thread by Stefan_Salewski: Templates as aliases, see https://forum.nim-lang.org/t/8252 |
09:10:10 | FromDiscord | <planetis> one can be shared across threads, the other is not atomic. arc actually stands for automatic.↵(@checkersai) |
09:15:04 | * | pro quit (Quit: WeeChat 3.2) |
09:18:03 | * | pro joined #nim |
09:37:42 | FromDiscord | <System64 ~ Flandre Scarlet> Is it normal I have that? https://media.discordapp.net/attachments/371759389889003532/866977153714618368/unknown.png |
09:38:12 | FromDiscord | <haxscramper> yes, you need to provide an implementation for a procedure |
09:38:27 | * | pro quit (Ping timeout: 265 seconds) |
09:38:33 | FromDiscord | <System64 ~ Flandre Scarlet> wdym? |
09:39:26 | FromDiscord | <haxscramper> I mean you need to provide implementation for a procedure |
09:39:26 | FromDiscord | <Rika> you need to have a body for the procedure |
09:39:36 | FromDiscord | <Rika> you cannot export an unimplemented procedure; how would you call it? |
09:39:47 | FromDiscord | <haxscramper> Or forward-declare it, but still provide an implementation |
09:40:10 | FromDiscord | <haxscramper> Or `.importc.` it from somewhere |
09:40:41 | FromDiscord | <System64 ~ Flandre Scarlet> I should importc then |
09:42:00 | * | max22- quit (Remote host closed the connection) |
09:42:48 | * | max22- joined #nim |
09:44:10 | FromDiscord | <System64 ~ Flandre Scarlet> When I do that, should I cdecl? https://media.discordapp.net/attachments/371759389889003532/866978782682415114/unknown.png |
09:44:34 | FromDiscord | <generic linux user> i am SysV |
10:05:31 | * | max22- quit (Ping timeout: 246 seconds) |
10:40:08 | * | xet7 quit (Remote host closed the connection) |
10:40:24 | * | SebastianM joined #nim |
10:41:11 | * | SebastianM quit (Client Quit) |
10:41:44 | * | xet7 joined #nim |
10:44:31 | * | max22- joined #nim |
10:47:13 | * | xet7 quit (Remote host closed the connection) |
11:09:54 | * | pro joined #nim |
11:10:27 | * | pro quit (Client Quit) |
11:14:14 | * | max22- quit (Remote host closed the connection) |
11:14:32 | * | pro joined #nim |
11:20:55 | * | vsantana joined #nim |
11:21:12 | * | max22- joined #nim |
11:36:29 | * | vsantana quit (Ping timeout: 255 seconds) |
11:50:35 | * | pro quit (Quit: WeeChat 3.2) |
11:52:44 | * | vsantana joined #nim |
12:02:00 | * | max22- quit (Ping timeout: 265 seconds) |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:37 | * | supakeen joined #nim |
12:15:22 | * | kayabaNerve quit (Remote host closed the connection) |
12:18:37 | * | kayabaNerve joined #nim |
12:28:27 | * | sagax quit (Ping timeout: 258 seconds) |
12:43:49 | FromDiscord | <Justaus3r (Justaus3r)> sent a code paste, see https://paste.rs/5Fi |
12:45:48 | FromDiscord | <Justaus3r (Justaus3r)> sent a code paste, see https://play.nim-lang.org/#ix=3tvx |
12:49:04 | FromDiscord | <haxscramper> yes, you need to declare type of procedure argument. And by the way, `var1` in `var var1: int` and the argument are not related |
12:49:18 | FromDiscord | <haxscramper> You defined variable and procedure separately, they just happened to have the same name |
12:49:49 | FromDiscord | <fajjida> sent a code paste, see https://paste.rs/e17 |
12:50:17 | FromDiscord | <fajjida> sent a code paste, see https://play.nim-lang.org/#ix=3tvA |
12:50:20 | FromDiscord | <fajjida> sent a code paste, see https://play.nim-lang.org/#ix=3tvA |
12:51:12 | FromDiscord | <fajjida> sent a code paste, see https://play.nim-lang.org/#ix=3tvC |
12:51:16 | FromDiscord | <fajjida> sent a code paste, see https://paste.rs/KN9 |
12:51:26 | FromDiscord | <fajjida> sent a code paste, see https://play.nim-lang.org/#ix=3tvD |
12:52:09 | FromDiscord | <haxscramper> Can't reproduce the issue |
12:52:15 | FromDiscord | <Rika> do you mind checking for issues before sending your message instead of editing, because the bridge does not work well with edits |
12:52:48 | FromDiscord | <haxscramper> yes, that looks horrible on the discord side |
12:54:28 | FromDiscord | <haxscramper> How do you run the code? `./script.nims` and `nim script.nims` both produce correct results |
12:58:22 | FromDiscord | <fajjida> I suddenly can't reproduce it either? I tried fixing this for 20 minutes and resetarted code and such?? Thanks for trying to help... |
12:59:10 | FromDiscord | <Justaus3r (Justaus3r)> sent a code paste, see https://play.nim-lang.org/#ix=3tvE |
13:01:26 | FromDiscord | <Justaus3r (Justaus3r)> Also is it necessary for me to set a return type,i mean if my code is returning values of different types then what should i do?. |
13:01:29 | FromDiscord | <haxscramper> Yes, that is correct |
13:01:52 | FromDiscord | <Justaus3r (Justaus3r)> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/867028425016082432): Also is it necessary for me to set a return type,i mean if my code is returning values of different types depending on the condition then what should i do?. |
13:02:02 | FromDiscord | <haxscramper> If your code returns values of different type you have seveal options depending on what you do |
13:02:31 | FromDiscord | <haxscramper> If return type is based on the argument types you can create an overloaded or generic proc |
13:03:11 | FromDiscord | <haxscramper> If return type is based on some internal logic you can use object variants |
13:03:11 | FromDiscord | <haxscramper> You can also use inheritance, but that is usually unnecessary |
13:03:48 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tvH |
13:05:24 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tvI |
13:06:01 | FromDiscord | <haxscramper> Last one should be just `proc calc(arg: int): Res =` |
13:08:18 | FromDiscord | <planetis> anyone knows what's the story with =deepcopy in arc/orc? |
13:08:20 | FromDiscord | <planetis> is it implemented? |
13:11:35 | * | arkurious joined #nim |
13:14:50 | fn | <ForumUpdaterBot99> New thread by Jasonfi: Building JSON objects with JsonNode?, see https://forum.nim-lang.org/t/8253 |
13:14:51 | FromDiscord | <planetis> doesn't seem to work, I get\: "Error\: signature for 'deepCopy' must be proc[T\: ptr\|ref](x\: T)\: T" |
13:17:26 | FromDiscord | <planetis> that signature doesn't help me, I would expect the same as =copy |
13:19:55 | FromDiscord | <deech> Is this expected behavior? Running `import options; var c : cstring: echo c.option` results in a segfault. I see `option` is overloaded on `ptr` and `pointer` types so I expected it to print `none()`. |
13:23:18 | FromDiscord | <Justaus3r (Justaus3r)> sent a code paste, see https://play.nim-lang.org/#ix=3tvO |
13:23:47 | FromDiscord | <Rika> deech cstring doesnt actually match ptr/pointer/ref |
13:23:49 | FromDiscord | <Rika> i dont think |
13:25:00 | FromDiscord | <Rika> !eval echo cstring is SomePointer |
13:25:02 | NimBot | Compile failed: /usercode/in.nim(1, 17) Error: undeclared identifier: 'SomePointer' |
13:25:23 | FromDiscord | <Justaus3r (Justaus3r)> sent a code paste, see https://play.nim-lang.org/#ix=3tvP |
13:25:28 | FromDiscord | <Rika> !eval echo cstring is (ref | ptr | pointer | proc) |
13:25:30 | NimBot | false |
13:25:42 | FromDiscord | <Rika> yeah so thats why it's broken |
13:25:43 | FromDiscord | <haxscramper> cstring is magic |
13:26:06 | FromDiscord | <deech> That is unfortunate |
13:26:31 | FromDiscord | <haxscramper> you can overload `isSome()` for `cstring` |
13:26:31 | FromDiscord | <haxscramper> This might work |
13:27:12 | FromDiscord | <haxscramper> Object variants are not related to OOP. You can say it is quite the opposite - they allow you to move from object inhertance to just putting all variants of data in a single structure |
13:27:16 | FromDiscord | <haxscramper> [Justaus3r (Justaus3r)](https://matrix.to/#/@justaus3r-601fefa16da03739846156cd:gitter.im)\: |
13:27:33 | FromDiscord | <haxscramper> In other programming languages it is called 'tagged union' or 'sum type" |
13:27:34 | FromDiscord | <deech> Oh wow, apparently the `c` in `cstring` doesn't stand for `C` but `compatible`: `cstring {.magic: Cstring.} ## Built-in cstring (compatible string) type.` |
13:27:49 | FromDiscord | <haxscramper> https://nim-lang.org/docs/tut2.html#object-oriented-programming-object-variants tutorial has a section on object variants |
13:28:14 | * | max22- joined #nim |
13:28:48 | FromDiscord | <haxscramper> Also, for your speific use case you can either return `Option[float]`, or use one of the `Result` packages to return `Result[float, string]` |
13:30:48 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tvS |
13:31:07 | FromDiscord | <haxscramper> `assert false` is not the best choice, but IIRC there is no `ArgumentError` or `LogicError` exceptions in the stdlib |
13:31:54 | FromDiscord | <Justaus3r (Justaus3r)> Thanks alot for the help |
13:32:51 | FromDiscord | <Justaus3r (Justaus3r)> so this is an alternative to C's switch-case statement? |
13:33:46 | * | vsantana quit (Remote host closed the connection) |
13:34:34 | FromDiscord | <haxscramper> Yes, but it does not require `break` on each clause and can be used as expression |
13:34:41 | FromDiscord | <haxscramper> see I have no `return` anywhere |
13:36:20 | FromDiscord | <Justaus3r (Justaus3r)> Oh i see,pretty handy! |
13:37:55 | * | vsantana joined #nim |
13:41:18 | * | rockcavera joined #nim |
13:41:18 | * | rockcavera quit (Changing host) |
13:41:18 | * | rockcavera joined #nim |
13:51:43 | * | max22- quit (Ping timeout: 265 seconds) |
13:54:27 | FromDiscord | <deech> It's so odd that this also segfaults: `var c: cstring; assert c[0] == '\0'`. I would expect the default `cstring` to at least be a null terminator. |
13:57:23 | FromDiscord | <deech> More shenanigans: `var c: cstring; echo c.len; assert c[0] == '\0';` outputs `0` and segfaults, `var c: cstring = ""; echo c.len; assert c[0] == '\0';` outputs `0` and doesn't segfault. Yeah this is just broken. |
13:57:36 | FromDiscord | <haxscramper> no, default `cstring` is `NULL` in C |
13:57:47 | FromDiscord | <haxscramper> So why should it have null terminator |
13:58:29 | FromDiscord | <haxscramper> If you init it with `""` then it has null terminator |
13:58:48 | FromDiscord | <haxscramper> And it makes perfect sense, since you default-init pointer with an expression |
13:58:48 | FromDiscord | <deech> `len` of a default `NULL` cstring and `len` with empty cstring have the same value, `0`. |
13:59:05 | FromDiscord | <haxscramper> I bet `strlen` does the same |
13:59:23 | FromDiscord | <deech> And if the default value is `NULL` like in C it should behave like `char` in other cases too (like `option`). |
14:00:39 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/8ccde68f132be4dba330eb6ec50f4679e564efac/lib/system/memory.nim#L45 |
14:00:50 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/4ec2f74246158759735149e3dd087f373fd787b2/compiler/ccgexprs.nim#L1750 |
14:00:58 | FromDiscord | <haxscramper> It is defined to be that way explicitly |
14:01:21 | FromDiscord | <haxscramper> `($1 ? #nimCStrLen($1) : 0)` |
14:19:04 | FromDiscord | <Rika> In reply to @deech "And if the default": the option issue is an oversight |
14:19:13 | FromDiscord | <Rika> a bug if you want |
14:52:21 | * | springb0k joined #nim |
14:58:20 | * | max22- joined #nim |
15:51:32 | * | max22- quit (Remote host closed the connection) |
15:58:17 | * | max22- joined #nim |
16:00:23 | FromDiscord | <emmа> <@&371760044473319454> can you ban `Max567#1483`? they DMed me trying a steam account scam. https://media.discordapp.net/attachments/371759389889003532/867073462564552714/unknown.png |
16:02:03 | FromDiscord | <Zachary Carter> In reply to @emmа "<@&371760044473319454> can you ban": They're not a member of this server |
16:02:07 | FromDiscord | <alehander42> /ban Max567#1483 |
16:02:17 | FromDiscord | <Zachary Carter> So they can't be banned from here |
16:02:17 | FromDiscord | <alehander42> 😄 |
16:02:19 | FromDiscord | <Zachary Carter> You can block them though |
16:02:28 | FromDiscord | <alehander42> maybe already banned |
16:02:28 | FromDiscord | <emmа> oh, they mustve left after i sent that |
16:02:33 | FromDiscord | <emmа> they were a minute ago |
16:03:00 | * | vsantana quit (Remote host closed the connection) |
16:11:11 | * | vsantana joined #nim |
16:14:41 | * | springb0k quit (Quit: KVIrc 5.0.0 Aria http://www.kvirc.net/) |
16:16:04 | * | springb0k joined #nim |
16:36:07 | FromDiscord | <haxscramper> what can be the reason for `nim doc` to hang infinitely in the CI? |
16:36:30 | FromDiscord | <haxscramper> I run the same documentation generator command locally and in CI, and it randomly breaks there |
16:50:57 | FromDiscord | <treeform> [macros] Any on know how to get a name of nnkEnumTy ? |
18:03:27 | * | sagax joined #nim |
18:05:56 | * | max22- quit (Ping timeout: 268 seconds) |
18:15:43 | FromDiscord | <checkersai> I'm a little bit confused, is `lent T` necessary when large `T`'s are already converted to pointers? |
18:15:55 | FromDiscord | <checkersai> Or am I misunderstanding something |
18:19:25 | FromDiscord | <haxscramper> `lent` is an immutable view, so if your data is already in form of a pointer (which is also can be considered a view) then you probably don't need this |
18:23:45 | FromDiscord | <arnetheduck> In reply to @deech "More shenanigans: `var c:": there's lots of fun you can do with cstring: https://play.nim-lang.org/#ix=3txx - gotta love that implicit conversion |
18:33:31 | FromDiscord | <zidsal> sent a code paste, see https://play.nim-lang.org/#ix=3txz |
18:39:27 | * | max22- joined #nim |
18:50:07 | FromDiscord | <deech> In reply to @arnetheduck "there's lots of fun": This is discouraging. 🙂 |
19:06:29 | FromDiscord | <haxscramper> why do you use cstring in the first place? |
19:06:56 | FromDiscord | <haxscramper> I mean wrapping it in `Option` etc. |
19:06:58 | arkanoid | just compiler nim from source for the first time. Everything went fine, I'm just curious about the steps. What is "https://github.com/nim-lang/csources_v1", what is the meaning of iteration 1 2 and 3? |
19:07:18 | FromDiscord | <leorize> i think the point is that cstring is too magical while being unsafe |
19:07:48 | FromDiscord | <leorize> but that probably won't change until @Araq finally figured out how views should work |
19:07:57 | FromDiscord | <haxscramper> to me `cstring` is approximately in the same area as `pointer` |
19:08:05 | FromDiscord | <haxscramper> stuff for interop, don't touch otherwise |
19:08:20 | FromDiscord | <leorize> it's not getting that support from the compiler |
19:08:37 | FromDiscord | <leorize> the compiler treats it as perfectly safe and that's where trouble lies |
19:09:11 | FromDiscord | <carmysilna> In reply to @arkanoid "just compiler nim from": I think the three iterations are meant to check that compiling nim with number 0 (before change version of nim compiler) produces the same executable as compiling nim with the compiled version (number 1) and so on. |
19:10:02 | FromDiscord | <carmysilna> nim1 is the compiler compiled with nim0, nim2 is the compiler compiled with nim1, and nim3 is the compiler compiled with nim3, and the script checks to make sure each executable is the same |
19:10:20 | FromDiscord | <leorize> iirc that check was removed |
19:10:24 | FromDiscord | <leorize> did it return? |
19:10:56 | arkanoid | well, I got "executables are equal: SUCCESS!" at the end of third iteration |
19:11:36 | arkanoid | how is possible that the binary produced by nim < 1.0 is equal to latest nim? It it mean logically equivalent and not binary equivalent? |
19:11:56 | FromDiscord | <leorize> it's only comparing iteration #2 and #3 |
19:13:06 | arkanoid | ok |
19:14:31 | arkanoid | I was expecting nimlint https://github.com/nim-dev/nimlint , is this project available? |
19:14:34 | fn | <R2D299> itHub: 7"nimlint makes developing softer." |
19:51:14 | FromDiscord | <RattleyCooper> I was going to post on nim lang forum but it says I have to confirm my email. I never got a confirmation email and I don't have an option to resend it. Anybody know how to fix that? Should I try making a new account? |
19:53:49 | FromDiscord | <zidsal> whatever you do don't delete the account or you're boned |
19:57:14 | FromDiscord | <RattleyCooper> Lol, ok |
19:57:54 | FromDiscord | <treeform> Its very touchy |
20:02:06 | FromDiscord | <RattleyCooper> I'll try making a new account tomorrow |
20:28:44 | * | vsantana quit (Ping timeout: 252 seconds) |
20:36:26 | * | beshr quit (Ping timeout: 252 seconds) |
20:39:03 | * | beshr joined #nim |
20:39:03 | * | beshr quit (Changing host) |
20:39:03 | * | beshr joined #nim |
20:39:50 | * | xet7 joined #nim |
20:42:09 | * | max22- quit (Remote host closed the connection) |
21:12:26 | FromDiscord | <checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3tyi |
21:14:32 | FromDiscord | <dom96> In reply to @RattleyCooper "I was going to": I can confirm your account |
21:14:37 | FromDiscord | <dom96> just tell me what the nickname is 🙂 |
21:19:21 | FromDiscord | <InventorMatt> sent a code paste, see https://play.nim-lang.org/#ix=3tyj |
21:22:28 | FromDiscord | <checkersai> In reply to @InventorMatt "you can do this": I don't want to change the variable outside the scope, I just want a local mutable variable |
21:23:51 | FromDiscord | <InventorMatt> in that case I don't think there is a better way to do that |
21:23:51 | FromDiscord | <RattleyCooper> In reply to @dom96 "just tell me what": It's RattleyCooper 😛 |
21:24:20 | FromDiscord | <RattleyCooper> In reply to @dom96 "I can confirm your": And thank you!!! |
21:26:04 | FromDiscord | <dom96> done |
21:40:24 | FromDiscord | <theangryepicbanana> In reply to @InventorMatt "in that case I": wait, parameters in nim are immutable? |
21:40:37 | FromDiscord | <theangryepicbanana> I don't recall the docs ever mentioning that |
21:41:50 | FromDiscord | <dom96> depends on the parameter's type |
21:42:14 | FromDiscord | <theangryepicbanana> In reply to @dom96 "depends on the parameter's": besides var types |
21:42:22 | FromDiscord | <theangryepicbanana> just like regular types |
21:44:12 | FromDiscord | <dom96> and ref types |
21:45:10 | FromDiscord | <theangryepicbanana> sent a code paste, see https://play.nim-lang.org/#ix=3tyr |
21:49:21 | FromDiscord | <checkersai> sent a code paste, see https://play.nim-lang.org/#ix=3tys |
21:50:18 | FromDiscord | <theangryepicbanana> In reply to @checkersai "yeah you can't do": why though? not even a pragma for it? |
21:50:30 | FromDiscord | <theangryepicbanana> (edit) "In reply to @checkersai "yeah you can't do": why though? not even a pragma for it? ... " added "(without macros!)" |
21:51:19 | FromDiscord | <Hi02Hi> In reply to @theangryepicbanana "wait, parameters in nim": ^ |
21:51:39 | FromDiscord | <carmysilna> Because just like Rust, mutability is explicit. if you don't say something is `var` or `ref`, you can't mutate it |
21:51:48 | FromDiscord | <theangryepicbanana> not in the slightest |
21:52:08 | FromDiscord | <theangryepicbanana> nim has explicit keywords for both mutable and immutable variables |
21:52:32 | FromDiscord | <theangryepicbanana> in that case, I don't see why something like `proc thing(var a: int): int` couldn't be allowed |
21:52:46 | FromDiscord | <carmysilna> It is allowed |
21:52:55 | FromDiscord | <carmysilna> but written `a: var int` |
21:53:03 | FromDiscord | <theangryepicbanana> that's still a different thing |
21:53:17 | FromDiscord | <carmysilna> it returns an immutable int, though. |
21:53:41 | FromDiscord | <theangryepicbanana> `var a: int` would allow `a` to be mutated locally, and not mutate its argument |
21:54:23 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tyt |
21:54:30 | FromDiscord | <carmysilna> In reply to @theangryepicbanana "`var a: int` would": I'd assume the idiom for this is a local var shadow, like Rust |
21:54:31 | FromDiscord | <theangryepicbanana> that's not what I'm wanting bruh |
21:55:13 | FromDiscord | <theangryepicbanana> sent a code paste, see https://play.nim-lang.org/#ix=3tyu |
21:56:06 | FromDiscord | <carmysilna> sent a code paste, see https://play.nim-lang.org/#ix=3tyv |
21:56:13 | FromDiscord | <theangryepicbanana> did you not see the first thing I said about how that's dumb |
21:56:44 | FromDiscord | <theangryepicbanana> I don't even understand why parameters would be immutable by default in the first place if nothing else behaves like that |
21:57:51 | FromDiscord | <ElegantBeef> "if nothing else behaves like that"? |
22:00:37 | FromDiscord | <ElegantBeef> If you can mutate parameters dont you have to pass them by copy every time regardless of size? |
22:00:45 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef ""if nothing else behaves": last time I checked, fields on objects(/tuples?) aren't immutable by default, with no way to specify otherwise |
22:01:24 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "If you can mutate": by mutable parameters, I mean parameters that can be modified locally without affecting the original argument |
22:01:33 | FromDiscord | <ElegantBeef> Exactly, which means you have to copy it |
22:02:01 | FromDiscord | <theangryepicbanana> I'm again saying that there should be a default syntax for it rather than a workaround |
22:03:50 | FromDiscord | <ElegantBeef> The issue is going to be this is super easy to do in a macro so there isnt going to much reason to support it in compiler |
22:04:58 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "The issue is going": I don't see how that's possible if you'd have to redefine the semantics of proc, func, iterator, method, and converter |
22:05:12 | FromDiscord | <theangryepicbanana> or rather, I don't see how it's convenient |
22:05:16 | FromDiscord | <ElegantBeef> To do what? |
22:05:31 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "The issue is going": to do this |
22:05:46 | FromDiscord | <ElegantBeef> It's really not that hard |
22:07:23 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "It's really not that": last time I checked, `var` sections don't stop after a semicolon. even if they didn't that wouldn't match nim's parameter syntax because parameters can also be delimited on commas |
22:07:35 | FromDiscord | <theangryepicbanana> (edit) "on" => "by" |
22:08:15 | FromDiscord | <theangryepicbanana> so something like `proc thing(var a: int, b: string)` either wouldn't do what you'd expect, or `proc thing(var a: int; b: string)` wouldn't work at all |
22:08:40 | FromDiscord | <theangryepicbanana> (edit) "so something like `proc thing(var a: int, b: string)` either wouldn't do what you'd expect, or `proc thing(var a: int; b: string)` wouldn't work at all ... " added "(or it'd just make the impl a lot harder)" |
22:09:14 | FromDiscord | <konsumlamm> propose it then, if you really think it's important |
22:09:30 | FromDiscord | <ElegantBeef> There we did it we shadowed it https://play.nim-lang.org/#ix=3tyA |
22:09:40 | FromDiscord | <theangryepicbanana> not that I think it's super important, I just don't see why a workaround is accepted as a solution |
22:10:38 | FromDiscord | <konsumlamm> a situation where you need something like that rarely ever happens in the first place |
22:10:39 | FromDiscord | <ElegantBeef> removed the wrong code |
22:10:40 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=3tyB |
22:11:08 | FromDiscord | <ElegantBeef> And you could support the code your propsed with a macro |
22:11:21 | FromDiscord | <leorize> parameters are immutable by default because that's what people want 90% of the time |
22:11:24 | FromDiscord | <theangryepicbanana> In reply to @konsumlamm "a situation where you": I've seen it happen in langs with similar macro capabilities as nim (e.g haxe, ocaml, crystal) and they all end up never getting QoL features because it's either not important (sometimes understandable) or "it can be done with a macro" |
22:11:49 | FromDiscord | <theangryepicbanana> In reply to @leorize "parameters are immutable by": what about the other 10% of the time lol |
22:11:59 | FromDiscord | <ElegantBeef> you shadow the specific variable you want |
22:12:12 | FromDiscord | <leorize> you either create a local variable or you just use the built-in result |
22:12:24 | FromDiscord | <konsumlamm> OCaml doesn't even have (normal) mutable variables lol |
22:12:30 | FromDiscord | <theangryepicbanana> like I can see why they're immutable by default and that's fine, but not having a builtin keyword or pragma to change that is a bit annoying |
22:12:33 | FromDiscord | <ElegantBeef> Exactly in this example result is what you' want |
22:12:37 | * | sagax quit (Ping timeout: 245 seconds) |
22:12:40 | FromDiscord | <ElegantBeef> (edit) "you'" => "you'd" |
22:12:54 | FromDiscord | <ElegantBeef> `result = a 3` is a proper solution |
22:12:59 | FromDiscord | <theangryepicbanana> (edit) "like I can see why they're immutable by default and that's fine, but not having a builtin keyword or pragma to change that ... is" added "for a variable" |
22:13:04 | FromDiscord | <theangryepicbanana> but that doesn't always work |
22:13:12 | FromDiscord | <ElegantBeef> My shadow macro does |
22:13:13 | FromDiscord | <theangryepicbanana> what if you want to change a parameter and then keep using it |
22:13:20 | FromDiscord | <konsumlamm> In reply to @theangryepicbanana "like I can see": again, make an RFC if you think that matters |
22:13:32 | FromDiscord | <theangryepicbanana> like sure macros yay, but it's just a bit irritating is all |
22:13:52 | FromDiscord | <leorize> well sink is there but the mutability is kind of a side-effect... |
22:14:14 | FromDiscord | <ElegantBeef> You could always implement the syntax you want but yes you'd have to annotate it with some pragma |
22:14:33 | FromDiscord | <theangryepicbanana> In reply to @leorize "well sink is there": lol isn't mutability supposed to be a side effect though? |
22:14:50 | FromDiscord | <theangryepicbanana> (anyways sink seems dangerous, staying away from it for now) |
22:14:51 | FromDiscord | <dom96> writing `var a = a` isn't a workaround |
22:14:59 | FromDiscord | <dom96> it works very well |
22:15:05 | FromDiscord | <dom96> there is no need for the syntax sugar here |
22:15:07 | FromDiscord | <leorize> sink is perfectly safe btw↵(@theangryepicbanana) |
22:15:16 | FromDiscord | <ElegantBeef> Sink will copy if it cannot move |
22:15:21 | FromDiscord | <theangryepicbanana> isn't it still in the experimental docs though |
22:15:26 | FromDiscord | <ElegantBeef> Nope |
22:15:31 | FromDiscord | <ElegantBeef> It's in the destructor docs |
22:15:35 | FromDiscord | <theangryepicbanana> huh |
22:15:48 | FromDiscord | <ElegantBeef> https://media.discordapp.net/attachments/371759389889003532/867167938863955978/unknown.png |
22:15:53 | FromDiscord | <leorize> side effect is that it's not to express that you want the parameter to be proc-mutable-only |
22:16:04 | FromDiscord | <theangryepicbanana> well anyways I suppose a pragma could be fine |
22:16:36 | FromDiscord | <theangryepicbanana> @ElegantBeef in your example, would there be a way to just annotate the parameter to shadow with the pragma? |
22:16:44 | FromDiscord | <leorize> the mutability comes from the ownership transfer |
22:17:14 | FromDiscord | <ElegantBeef> Ah shame you cannot write `var a: t` |
22:17:37 | FromDiscord | <theangryepicbanana> oh are var sections not considered expressions |
22:17:40 | FromDiscord | <leorize> you can attach a pragma to the parameter though |
22:17:55 | FromDiscord | <ElegantBeef> or do `i: mut int` like a sadist |
22:17:56 | FromDiscord | <theangryepicbanana> well sure, but I'm not sure if that'd give me access to the proc as well |
22:18:05 | FromDiscord | <ElegantBeef> well the pragma on the proc would |
22:18:12 | FromDiscord | <theangryepicbanana> yes but what if it's on the param instead |
22:18:21 | FromDiscord | <ElegantBeef> You'd also need one on the proc |
22:18:26 | FromDiscord | <theangryepicbanana> :/ |
22:18:36 | FromDiscord | <leorize> `i: copy int` or `i {.copy.}: int` |
22:18:53 | FromDiscord | <leorize> both of which can be transformed by the macro |
22:19:15 | FromDiscord | <theangryepicbanana> yeah but I don't really want a pragma attached to the proc as well |
22:19:25 | FromDiscord | <ElegantBeef> Well then you cannot do this |
22:19:36 | FromDiscord | <ElegantBeef> You need a pragma attached to the proc to insert the shadow calls |
22:19:54 | FromDiscord | <ElegantBeef> Only a macro operating on the procdef can change it's contents |
22:20:20 | FromDiscord | <ElegantBeef> So then you need to make an RFC detailing what you want and why a macro doesnt suffice |
22:20:52 | FromDiscord | <theangryepicbanana> yeah that makes sense ig. it's definitely nitpick-y, but I'm not a fan of using macros where stuff could easily be builtin |
22:21:24 | FromDiscord | <konsumlamm> most uses of macros could be replaced by something builtin |
22:21:29 | FromDiscord | <ElegantBeef> all |
22:21:38 | FromDiscord | <konsumlamm> but that doesn't necessarily make it s good idea to do so |
22:21:41 | FromDiscord | <theangryepicbanana> well yes but that's not the point |
22:21:43 | FromDiscord | <konsumlamm> (edit) "s" => "a" |
22:22:19 | FromDiscord | <leorize> the rfc process is always there for adding new features to the language |
22:22:19 | FromDiscord | <dom96> Nim's philosophy is explicitly to implement a small core language that's extensible via macros |
22:22:33 | FromDiscord | <dom96> and in fact we've got too much implemented in the compiler |
22:22:42 | FromDiscord | <leorize> not all can be done like that tbf |
22:24:00 | FromDiscord | <theangryepicbanana> again I don't really need to propose it because I don't think it matters all too much, but allowing var sections as an expression (for use in macros) might actually be a decent idea |
22:24:40 | FromDiscord | <leorize> it's not about expression, unfortunately |
22:25:01 | FromDiscord | <theangryepicbanana> why else wouldn't it be able to work? |
22:25:22 | FromDiscord | <leorize> it's about what the compiler considers well-formed ast |
22:25:32 | FromDiscord | <ElegantBeef> The semantic pass on the keyword var has an explicit path to valid code |
22:25:41 | FromDiscord | <theangryepicbanana> oh that makes sense |
22:26:08 | FromDiscord | <ElegantBeef> not to say you cannot use macros with var statements they're just pragmas on the ident like so `var a {.byaddr.} = c` |
22:26:24 | FromDiscord | <theangryepicbanana> so `var` will otherwise be an actual invalid token, and not just parsed a function call or something? |
22:27:14 | FromDiscord | <ElegantBeef> Interestingly there is an explict error for that syntax you proposed 😄 `Error: the syntax is 'parameter: var T', not 'var parameter: T'` |
22:27:19 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "not to say you": yeah I mean the other way around, like `myMacro(var thing = 1)` |
22:27:29 | FromDiscord | <theangryepicbanana> lmao that's what I was thinking |
22:27:45 | FromDiscord | <ElegantBeef> That's valid since the entire statement is inside the macro, and is a valid statement |
22:28:17 | FromDiscord | <theangryepicbanana> would `myMacro(a: int, var b: string)` also be valid or no? |
22:28:21 | FromDiscord | <ElegantBeef> For these experiments i highly suggest playing around with dumptree to see what chooches like so https://play.nim-lang.org/#ix=3tyC |
22:28:29 | FromDiscord | <theangryepicbanana> 👍 |
22:28:49 | FromDiscord | <leorize> the ast goes more or less like this\: ProcDef(..., FormalParams(Sym, IdentDefs...), ...) |
22:28:49 | FromDiscord | <theangryepicbanana> thanks for the help |
22:28:55 | FromDiscord | <theangryepicbanana> hmm |
22:29:18 | FromDiscord | <theangryepicbanana> that reminds me (completely different topic ik), will nim support pattern matching on ast nodes/syntax? |
22:29:23 | FromDiscord | <leorize> the params is the FormalParams part and VarSection is not a valid child for it |
22:30:00 | FromDiscord | <leorize> see fusion/matching↵(@theangryepicbanana) |
22:30:15 | FromDiscord | <theangryepicbanana> haxe has this really cool thing where you can do something like `case macro thing($a + $b):` to match the expr `thing(<anything> + <anything>)` |
22:30:51 | FromDiscord | <ElegantBeef> Nim already does |
22:30:51 | FromDiscord | <dom96> !eval import macros; const s = parseStmt("myMacro(var x=1)").treeRepr; echo s |
22:30:53 | NimBot | StmtList↵ Call↵ Ident "myMacro"↵ ExprEqExpr↵ VarTy↵ Ident "x"↵ IntLit 1 |
22:31:15 | FromDiscord | <ElegantBeef> https://nim-lang.org/docs/manual_experimental.html#term-rewriting-macros-pattern-operators |
22:31:17 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "Nim already does": oh? like, actual pattern matching? |
22:31:19 | FromDiscord | <dom96> heh, best do it in play.nim-lang.org |
22:31:24 | FromDiscord | <theangryepicbanana> oh yeah that thing |
22:31:38 | FromDiscord | <theangryepicbanana> I meant like inside a macro as a statement or something (like in case...of) |
22:31:49 | FromDiscord | <ElegantBeef> Ah there is a matching macro package in `fusion` |
22:31:55 | FromDiscord | <ElegantBeef> https://nim-lang.github.io/fusion/src/fusion/matching.html |
22:32:28 | FromDiscord | <theangryepicbanana> yeah I've seen that, but I'm not sure if it supports direct matching on syntax like I described |
22:32:39 | FromDiscord | <theangryepicbanana> like on NimNode, etc |
22:33:01 | * | lain quit (Quit: brb!) |
22:33:02 | FromDiscord | <ElegantBeef> Nah it'd have to be on the `infix(ident"+", a, b)` if that's even possible |
22:33:12 | FromDiscord | <theangryepicbanana> oof |
22:33:15 | FromDiscord | <hugogranstrom> The `quote do` of pattern matching would be lit |
22:33:32 | FromDiscord | <ElegantBeef> I generally dont follow pattern matching, so i dont actually know |
22:34:16 | FromDiscord | <theangryepicbanana> here's an example of where I've actually used it btw <https://github.com/ALANVF/star/blob/master/src/Util.hx#L59-L76> |
22:34:26 | FromDiscord | <theangryepicbanana> (in haxe) |
22:35:04 | FromDiscord | <ElegantBeef> It could be done by parsingExpr the given nimnode and doing string compare i guess, though might be dangerous to do that way |
22:35:52 | FromDiscord | <theangryepicbanana> that sounds kinda hacky |
22:36:02 | FromDiscord | <ElegantBeef> Well reading pattern matching seems hacky to me 😛 |
22:36:53 | * | Vladar quit (Quit: Leaving) |
22:37:05 | FromDiscord | <theangryepicbanana> eh |
22:37:09 | FromDiscord | <theangryepicbanana> I quite like it |
22:37:09 | * | lain joined #nim |
22:37:17 | FromDiscord | <theangryepicbanana> it tunes down the verbosity of the rest of the code |
22:38:21 | FromDiscord | <ElegantBeef> Hey i'm a numpty no one needs to defend their views to me |
22:40:45 | FromDiscord | <theangryepicbanana> In reply to @ElegantBeef "Hey i'm a numpty": no I'm just saying it makes the code a lot cleaner is all |
23:00:33 | * | xet7 quit (Remote host closed the connection) |
23:05:23 | FromDiscord | <Ayy Lmao> I'm making an extension .dll for a program, and when I do something bad like try to call a function that is nil, it crashes my program silently. Is there a way to stop that and somehow display an error message? I know about `globalRaiseHook` but I'm not sure what to do there. |
23:13:42 | FromDiscord | <demotomohiro> try statement doesn't catch such err? |
23:17:20 | FromDiscord | <Ayy Lmao> I will test that out |
23:20:29 | FromDiscord | <Ayy Lmao> Yeah it's still crashing my program inside the try statement |
23:21:20 | FromDiscord | <Ayy Lmao> It's because it involves window messages I guess. |
23:29:31 | FromDiscord | <theangryepicbanana> In reply to @Ayy Lmao "I'm making an extension": try checking it for nil manually? |
23:34:09 | FromDiscord | <Ayy Lmao> @theangryepicbanana My problem isn't that I can't get the code to run. If I check for nil manually the code runs. My problem is that I forgot to check for nil and it took me a long time to figure out what was wrong because the program crashes silently. I'm wondering if there is a way to get the program to give some feedback if I forget to check for nil. |
23:34:32 | FromDiscord | <theangryepicbanana> In reply to @Ayy Lmao "<@!356108561232953344> My problem isn't": the `notNil` pragma might help |
23:34:41 | FromDiscord | <theangryepicbanana> (edit) "In reply to @Ayy Lmao "<@!356108561232953344> My problem isn't": the `notNil` ... pragma" added "experimental" |
23:36:01 | FromDiscord | <Ayy Lmao> In reply to @theangryepicbanana "the `notNil` experimental pragma": I'll look into it, thanks for the tip |
23:50:51 | * | krux02 quit (Remote host closed the connection) |