00:03:33 | madprops | https://madprops.github.io/numberstring/ |
00:05:48 | FromDiscord | <Elegantbeef> Want a code review? |
00:06:52 | madprops | if you want to do that, sure |
00:08:45 | madprops | just so you know there are some bash scripts to run and test |
00:08:55 | FromDiscord | <Elegantbeef> Yea i seen the useless scripts |
00:09:13 | madprops | how are they useless? |
00:09:17 | FromDiscord | <Elegantbeef> nimble has a built in `nimble test` which will run all files with `t.nim` |
00:09:50 | FromDiscord | <Elegantbeef> so if you just named `intergration` `tintergration` you'd have it apart of the test suite |
00:10:09 | madprops | ah |
00:10:13 | madprops | good to know |
00:10:26 | madprops | t_integration |
00:10:31 | FromDiscord | <Elegantbeef> the run is pointless since there is no code ran in the main file |
00:10:54 | madprops | i think it's mostly so the binary gets placed in /bin |
00:11:26 | FromDiscord | <Elegantbeef> So then make a `config.nims` dont use bash π |
00:21:57 | madprops | got an example of a config.nims ? |
00:23:09 | madprops | ok think i found an example |
00:25:18 | madprops | switch("out", "bin/debug") won't cut it |
00:25:26 | madprops | Error: command expects a filename |
00:25:51 | madprops | oh nvm |
00:27:39 | madprops | i guess there's no way in avoiding adding: src/numberstring.nim as an argument to the command |
00:30:12 | madprops | also wondering if the config in config.nims affects both debug and release binaries |
00:31:32 | FromDiscord | <Elegantbeef> Well here is my quick review https://github.com/beef331/numberstring/commit/db60d293436fccb46dfb56d3a1c6bdcd7310bb7e#diff-a607b90233afd98462387f44deda392986bec82aab75db20ce1b161e904d0a65 removed stuff that isnt overly sensible and comment for stuff that felt needed an explanation |
00:33:07 | madprops | the constants file wasn't supposed to be there |
00:33:10 | madprops | forgot to delete it |
00:33:31 | madprops | lets see |
00:34:20 | FromDiscord | <Elegantbeef> config.nims is passed to the compiler as a config file so yes |
00:36:21 | FromDiscord | <Elegantbeef> Feel free to ask any questions of course |
00:37:14 | madprops | the idea of the ns_x vars was because they were going to be exported |
00:37:17 | madprops | and didn't want to pollute ns |
00:37:20 | madprops | namespace |
00:37:27 | FromDiscord | <Elegantbeef> Well that's silly |
00:37:35 | FromDiscord | <Elegantbeef> yes i have abrasive views |
00:39:01 | madprops | why though |
00:39:11 | madprops | names like "vowels" could cause problems |
00:39:13 | FromDiscord | <Elegantbeef> It's not an issue at least in my view, cause there are vehicles to get around it |
00:39:27 | FromDiscord | <Elegantbeef> It could cause problems and the compiler will tell you when it does |
00:41:40 | madprops | "No reason to parse int here, there are cheaper methods of getting leading digit" |
00:41:48 | FromDiscord | <Elegantbeef> let's look at the difference between your version and and mine when if there is ambiguity `ns_vowels` vs. `numberstring.Vowels` we did the exact same thing but my way is optional |
00:42:08 | FromDiscord | <Elegantbeef> This isnt C so i dont get the C style approach, but YMMV |
00:42:29 | FromDiscord | <Elegantbeef> Nothing states you have to accept my view, so live life the way you want to |
00:42:46 | madprops | the randomize thing was interesting |
00:42:56 | madprops | didn't realize it could change the program itself |
00:42:59 | madprops | which can cause problems |
00:45:13 | madprops | oh you changed the timeago output lol |
00:45:42 | madprops | it was meant to be used like on internet posts "posted 1 hour ago" |
00:45:48 | madprops | so it carried less information |
00:48:06 | FromDiscord | <Elegantbeef> Ah was unclear by the name and description |
00:48:22 | madprops | yeah i should have described it better |
00:48:53 | FromDiscord | <Elegantbeef> Well calling randomize inside the main body is certain to cause issues if anyone has a randomized state, when dealing with random you should have a lazy one that uses global state and a non lazy one which takes a `Rand` |
00:49:03 | FromDiscord | <Elegantbeef> This way you dont change the seed unless the programmer doesnt care |
00:54:49 | madprops | so I should be adding runnableExamples to each proc |
00:55:02 | madprops | how is it actually runnable? |
00:55:07 | FromDiscord | <Elegantbeef> It's a second layer of testing and gives a code example |
00:55:12 | FromDiscord | <Elegantbeef> It runs on doc gen |
00:57:48 | madprops | ok so Digits and digits is not the same var, I thought it would, so the namespacing makes less sense now |
00:58:30 | madprops | since this_cat == thisCat i wasn't sure |
00:58:50 | FromDiscord | <Elegantbeef> Ah first character is case sensitive |
01:21:44 | madprops | how can I pass arguments to nimble test? |
01:21:51 | madprops | i mean arguments for the test itself |
01:21:53 | madprops | not to nimble |
01:23:18 | FromDiscord | <Elegantbeef> Dont know if you can |
01:24:17 | madprops | yeah probably doesn't make sense |
01:24:28 | FromDiscord | <impbox [ftsf]> they should be self-contained ideally |
01:24:47 | FromDiscord | <impbox [ftsf]> if you need to test multiple arguments, just make more checks |
01:24:56 | FromDiscord | <impbox [ftsf]> and test them all |
01:26:44 | * | tiorock joined #nim |
01:26:44 | * | tiorock quit (Changing host) |
01:26:44 | * | tiorock joined #nim |
01:26:44 | * | rockcavera is now known as Guest1210 |
01:26:44 | * | tiorock is now known as rockcavera |
01:29:40 | * | Guest1210 quit (Ping timeout: 240 seconds) |
01:33:04 | FromDiscord | <NumLock> hello |
01:33:20 | FromDiscord | <Elegantbeef> Hello |
01:33:43 | FromDiscord | <NumLock> Why is the main conversation in this server taken up by bots |
01:35:00 | FromDiscord | <JSONBash> Not actual bots |
01:35:16 | FromDiscord | <JSONBash> Itβs a way to distinguish people who are bridged over from other platform |
01:35:23 | FromDiscord | <JSONBash> ElegentBeef is on matrix |
01:35:29 | FromDiscord | <NumLock> Ok |
01:35:32 | FromDiscord | <JSONBash> Other are on IRC |
01:35:38 | FromDiscord | <JSONBash> But I am on discord |
01:35:57 | FromDiscord | <JSONBash> Hello btw! π |
01:36:04 | FromDiscord | <NumLock> Hello\ |
01:36:05 | FromDiscord | <NumLock> hru |
01:37:17 | madprops | beep boop |
01:37:42 | FromDiscord | <ββ> design discussion: |
01:37:52 | FromDiscord | <ββ> file path joining with the `/` operator should be removed |
01:38:08 | FromDiscord | <ββ> or atleast written that its not reccomended |
01:38:14 | FromDiscord | <Elegantbeef> Why? |
01:38:31 | FromDiscord | <ββ> because i find i extremely confusing |
01:38:39 | FromDiscord | <ββ> its dividing a path |
01:38:47 | FromDiscord | <Elegantbeef> It's an operator |
01:38:55 | FromDiscord | <ββ> really they use `/` cause theyre used to filesystem that uses `/` to seperate paths |
01:39:20 | FromDiscord | <Elegantbeef> Yes, so what's the issue |
01:39:28 | FromDiscord | <ββ> its confusing |
01:39:33 | FromDiscord | <ββ> compared to a function call which is not |
01:39:41 | FromDiscord | <Elegantbeef> So then use the function |
01:39:51 | FromDiscord | <ββ> i would |
01:40:02 | FromDiscord | <Elegantbeef> So then what's the issue |
01:40:03 | FromDiscord | <ββ> but i want to discourage the use of `/` or remove it all together |
01:40:06 | FromDiscord | <ββ> like i said |
01:40:14 | FromDiscord | <Elegantbeef> Not going to happen it's fantastic |
01:40:32 | FromDiscord | <ββ> why ? |
01:40:52 | FromDiscord | <ββ> i do not like using operators in ways like this |
01:41:09 | FromDiscord | <ββ> i expect `/` to divide something |
01:41:18 | FromDiscord | <Elegantbeef> Cause it's more ergonomic than `"dir".joinPath("subDir").joinPath("subSubDir")` `"dir" / "subDir" / "subSubDir"` |
01:41:29 | FromDiscord | <Elegantbeef> Well i like operators to do operations, so it's fine |
01:41:56 | FromDiscord | <ββ> `joinPath("a", "b", "c")` |
01:42:14 | FromDiscord | <ββ> also |
01:42:21 | FromDiscord | <Elegantbeef> Ah didnt realize there was a vararg version |
01:42:25 | FromDiscord | <ββ> thats already so confusing |
01:42:33 | FromDiscord | <ββ> it looks like youre dividing a string |
01:42:51 | FromDiscord | <ββ> c++ uses `/` too but atleast there it has to clearly be with a file path object |
01:42:54 | FromDiscord | <Elegantbeef> No it looks like i'm calling `/("dir", "subDir")` |
01:43:19 | madprops | since you can't divide strings, it makes sense to me. Also python does the same thing with Path |
01:43:21 | FromDiscord | <Elegantbeef> So then what should `{10u8} {20u8}` do? |
01:43:46 | FromDiscord | <Elegantbeef> or `"hello $#" % 100` |
01:45:04 | FromDiscord | <ββ> if you wrote `divide("a", "b", "c")` it would be confusing, so using `/` is also confusing because you expect this to be for division, so now the programmer is expected to put it in his mind that `/` can also mean file path seperator (his operating system might not even use `/` for it too) |
01:45:41 | FromDiscord | <Elegantbeef> but that isnt `divide` that is the `/` operator |
01:46:17 | FromDiscord | <ββ> if you want to start using operators arbitrarily instead of functions thats gonna be very confusing in my opinion |
01:46:29 | FromDiscord | <ββ> now `+` or `/` no longer mean roughly the same thing |
01:46:35 | FromDiscord | <Elegantbeef> And nim encourages ergonomics by enabling the above |
01:46:42 | FromDiscord | <Elegantbeef> So i dont see the issue |
01:46:56 | FromDiscord | <Elegantbeef> It's more ergonomic/readable, if you dont like it dont use it |
01:47:09 | madprops | ergonomics ... if that was so strings would be concatenated with + instead of & |
01:47:21 | madprops | but i got used to it eventually |
01:47:34 | FromDiscord | <Elegantbeef> If you dont know what the operator is doing you can always goto definition |
01:47:43 | FromDiscord | <ββ> i dont think thats a valid response to this problem, its in the standard library, people are going to use `/`, i might be reading the code of people who use it |
01:48:05 | FromDiscord | <Elegantbeef> image.png https://media.discordapp.net/attachments/371759389889003532/878092994073489438/image.png |
01:48:06 | FromDiscord | <Elegantbeef> Or even just hover it |
01:48:28 | FromDiscord | <Elegantbeef> yes i realize my code here is dumb, dont question it |
01:48:51 | FromDiscord | <ββ> reducing operators to just arbitrary symbols is not something i would do |
01:48:55 | FromDiscord | <ββ> i want `+` to add |
01:48:58 | FromDiscord | <ββ> `-` to substract |
01:48:59 | FromDiscord | <ββ> etc |
01:51:18 | madprops | I think it's easy to get the concepts after some thought though |
01:51:27 | madprops | context based operators |
01:51:38 | madprops | but i do get what you're saying |
01:53:04 | madprops | most languages at least use + for addition and string concat |
01:53:43 | madprops | well at least some do |
01:55:25 | FromDiscord | <Elegantbeef> i dont buy the "i dont like it so it must be removed" make an RFC so people can either agree or disagree, instead of complaining here |
01:59:26 | FromDiscord | <exelotl> I like `/` for paths, its readable and unambiguous in all the situations I've ever seen it |
02:01:38 | FromDiscord | <exelotl> I think we have our share of questionable operators (why is there a json operator lol) but / isn't one of them |
02:03:50 | FromDiscord | <impbox [ftsf]> I also like `/` for path joining |
02:04:04 | FromDiscord | <impbox [ftsf]> but what about `\\` ? ;) |
02:04:20 | FromDiscord | <Elegantbeef> Lol impbox |
02:04:50 | FromDiscord | <ββ> since paths seem to just be strings i think that makes `/` even worse than it normally would be |
02:05:08 | FromDiscord | <ββ> string now have an operator specifically for using the paths api |
02:05:18 | FromDiscord | <impbox [ftsf]> have you encountered a place where it's problematic and confusing? |
02:05:26 | FromDiscord | <ββ> yes |
02:05:31 | FromDiscord | <Elegantbeef> Oh noes, when you `import std/os` you get code that it exports! |
02:05:47 | FromDiscord | <impbox [ftsf]> you don't get std divided by os? |
02:05:50 | FromDiscord | <Elegantbeef> Wait until you learn about distinct types |
02:06:17 | FromDiscord | <Elegantbeef> Impbox that is the most evil question i've seen today |
02:06:17 | FromDiscord | <ββ> those are nice |
02:06:36 | FromDiscord | <ββ> why arent paths a distinct type |
02:07:29 | FromDiscord | <Elegantbeef> There are probably answers to that question on github, the forums or irclogs |
02:08:02 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/compiler/pathutils.html |
02:08:18 | FromDiscord | <impbox [ftsf]> they are |
02:08:32 | FromDiscord | <ββ> well the joinPath function dosent seem to use those |
02:09:26 | FromDiscord | <ββ> this makes me even more confused |
02:09:34 | FromDiscord | <ββ> do i use this or the other library? |
02:10:46 | FromDiscord | <impbox [ftsf]> what are you trying to do? |
02:11:20 | FromDiscord | <ββ> work with file paths |
02:11:42 | FromDiscord | <impbox [ftsf]> i'd just use strings and `/` |
02:12:15 | FromDiscord | <impbox [ftsf]> but if you want to add extra security you could add your own version that only takes a distinct type |
02:12:46 | FromDiscord | <impbox [ftsf]> what kind of work are you doing with file paths? |
02:13:11 | FromDiscord | <ββ> what pathJoin or `/` do |
02:13:30 | FromDiscord | <ββ> well even if i use this distinct library |
02:13:38 | FromDiscord | <ββ> my strings will still have `/` if i import os |
02:13:39 | FromDiscord | <impbox [ftsf]> if your application is just joining paths, sounds like you should use `/` since it works |
02:14:07 | FromDiscord | <Elegantbeef> so then do \`\`\`import std/os except \`/\`\`\`\` |
02:14:15 | FromDiscord | <impbox [ftsf]> yep |
02:14:37 | FromDiscord | <Elegantbeef> I fucked that formatting up but anywho |
02:14:59 | FromDiscord | <impbox [ftsf]> sent a code paste, see https://paste.rs/y7W |
02:20:21 | FromDiscord | <Elegantbeef> and mad seems `&` was copied from ada, if interested why it's not `+` |
02:20:30 | madprops | ah |
02:21:21 | madprops | i would prefer + but whatevs |
02:21:35 | FromDiscord | <Elegantbeef> well you can alias it, so you can have what you want |
02:21:39 | FromDiscord | <impbox [ftsf]> yeah, i wouldn't mind it being +, you can always add it i guess |
02:21:47 | FromDiscord | <impbox [ftsf]> is aliasing a thing now? |
02:22:07 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=3wvh |
02:22:10 | FromDiscord | <Elegantbeef> I consider that aliasing |
02:23:24 | madprops | & has the advantage that you know for sure that your'e dealing with strings |
02:24:18 | madprops | which can be their own realm |
02:27:04 | FromDiscord | <JohnAD (John Dupuy)> The mathemetician in me dislikes using `+` for strings since ("a" + "b") != ("b" + "a"). That is, you cannot really add strings since they do not follow the communitive property. |
02:28:31 | FromDiscord | <JohnAD (John Dupuy)> Unless, of course, the plus sign represents some kind of rolling cipher operation. "abc" + "foo" == "foo" + "abc" == "e8\\" |
02:29:44 | FromDiscord | <JohnAD (John Dupuy)> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/878102810963632158): The mathemetician in me dislikes using `+` for strings since ("a" + "b") != ("b" + "a"). That is, you cannot really add strings since they do not follow the communative property. |
02:30:02 | FromDiscord | <Elegantbeef> Quick someone get the nerd beating stick π |
02:30:45 | FromDiscord | <Elegantbeef> I'm pretty in different about `+` vs. `&` since it's just an operator and not overly messy either way |
02:31:17 | FromDiscord | <Elegantbeef> It's not like we're doing `a +&%#@ b` π |
02:31:25 | madprops | + is faster to type with my hands though |
02:31:42 | madprops | muscle memory etc |
02:32:27 | madprops | but it's almost the same |
02:33:37 | FromDiscord | <Elegantbeef> Dont make me suggest we should only use `a` for everything to make it so we have the easiest language to type |
02:34:51 | FromDiscord | <Elegantbeef> Yes i have no control over my hyperbolic comments they just appear after i think them, quite odd |
02:35:20 | madprops | even brainfuck uses + |
02:35:45 | madprops | ++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++. |
02:35:45 | madprops | <<+++++++++++++++.>.+++.ββ.βββ.>+.>. |
02:35:51 | madprops | haha |
02:52:57 | madprops | i decided to not put runnableExamples |
02:53:05 | madprops | theres' already an integration test |
02:53:09 | madprops | and the comments get too bloated |
02:53:23 | FromDiscord | <Elegantbeef> The examples are for showing examples |
02:53:30 | FromDiscord | <Elegantbeef> So what your comments already do |
02:54:42 | madprops | except comments don'pt need to be compilable |
02:54:57 | madprops | so i can freely explain with some sentences |
02:55:10 | madprops | i do like showing examples but it feels bloated |
02:55:12 | FromDiscord | <Elegantbeef> Which is a problem imo |
02:55:12 | FromDiscord | <Elegantbeef> Sure but do a doc comment then throw the example in |
02:56:05 | FromDiscord | <Elegantbeef> Yea idk it's not that bloated https://nim-lang.org/docs/strutils.html#allCharsInSet%2Cstring%2Cset%5Bchar%5D |
02:56:39 | madprops | it looks great on the doc |
02:56:42 | madprops | but i mean in the src itself |
02:57:38 | madprops | but yeah probably worth it |
02:58:28 | FromDiscord | <impbox [ftsf]> the doAssert in the docs looks odd |
02:58:40 | FromDiscord | <impbox [ftsf]> since that's now how you'd use it in practice |
02:58:44 | FromDiscord | <Elegantbeef> old docs should be `assert` |
02:58:48 | FromDiscord | <impbox [ftsf]> which is what an example should be |
02:59:04 | FromDiscord | <Elegantbeef> Oh that's what you mean \:D |
02:59:44 | FromDiscord | <impbox [ftsf]> yep |
03:00:07 | FromDiscord | <Elegantbeef> Idk for documenting procedures it seems fine to me, for explaining things more advanced you can always write more elaborate RST |
03:05:54 | FromDiscord | <gogolxdong (liuxiaodong)> Is there any yaml library is Nim? |
03:08:18 | nrds | <Prestige99> I see https://nimble.directory/pkg/yaml |
03:08:44 | nrds | <Prestige99> oh a whole site - https://nimyaml.org/ |
03:11:24 | * | rockcavera quit (Remote host closed the connection) |
03:14:14 | * | arkurious quit (Quit: Leaving) |
03:19:51 | madprops | decided to add the runnableExamples |
03:35:05 | FromDiscord | <creonico> Is it possible to view the compiled c version of my nim code? |
03:35:14 | FromDiscord | <creonico> and if so, how? |
03:37:25 | * | vicfred joined #nim |
03:37:52 | nrds | <Prestige99> I believe there's a cache somewhere, but I don't recall where |
03:38:11 | FromDiscord | <Elegantbeef> the output C is thrown in a temp folder, you can tell it to output it somewhere else with `--nimCache:somePath` |
03:38:22 | FromDiscord | <impbox [ftsf]> @creonico yep, it's stored in "nimcache", but you can specify with --nimCache:dirname |
03:38:24 | FromDiscord | <Elegantbeef> It's in `.cache/nim/projectname` on linux |
03:38:25 | FromDiscord | <impbox [ftsf]> damn beef |
03:38:40 | FromDiscord | <Elegantbeef> It's ok imp you'll be faster next time |
03:38:56 | FromDiscord | <impbox [ftsf]> nah, my RSI means i'll never be able to compete |
03:39:15 | FromDiscord | <impbox [ftsf]> https://nim-lang.org/docs/nimc.html#compiler-usage-generated-c-code-directory |
03:49:08 | madprops | doc generation always trigger a git diff becuse it uses a timestamp |
03:49:26 | madprops | is there a way to just check the doc runnableExamples without generating ? |
04:06:01 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:30 | * | supakeen joined #nim |
04:16:35 | madprops | what's the equivalent of: import std/[os, parseopt, strformat, strutils] |
04:16:38 | madprops | for local modules? |
04:16:49 | madprops | should I use pkg? |
04:18:28 | madprops | ok nvm I just comma separate it |
04:20:22 | madprops | weird thing is, if I import the modules like: import types, utils, types |
04:20:29 | madprops | then I get an error about something being undefined |
04:20:46 | madprops | wait why is types twice there.. |
04:20:59 | madprops | oh that was an export |
04:21:08 | madprops | nvm |
04:43:28 | * | flynn quit (Read error: Connection reset by peer) |
04:44:35 | * | flynn joined #nim |
05:03:21 | * | nrds quit (Remote host closed the connection) |
05:26:57 | * | kayabaNerve quit (Remote host closed the connection) |
05:27:16 | * | kayabaNerve joined #nim |
06:51:06 | * | PMunch joined #nim |
06:55:01 | * | Vladar joined #nim |
06:59:15 | FromDiscord | <j-james> What is the C type `dev_t`'s equivalent in Nim? |
06:59:23 | FromDiscord | <j-james> I've found things saying both `int32` and `culong`, depending on where I look |
07:01:11 | FromDiscord | <Rika> https://nim-lang.org/docs/posix.html#Dev |
07:01:27 | * | jjido joined #nim |
07:07:37 | FromDiscord | <j-james> Fantastic, thank you |
07:20:02 | FromDiscord | <j-james> Do you know what `ssize_t` is? |
07:22:28 | * | jjido quit (Ping timeout: 250 seconds) |
07:23:38 | FromDiscord | <Rika> https://jameshfisher.com/2017/02/22/ssize_t/ |
07:34:08 | * | max22- joined #nim |
07:43:08 | * | max22- quit (Quit: Leaving) |
07:49:35 | * | jjido joined #nim |
08:08:37 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
08:38:42 | * | vicfred quit (Quit: Leaving) |
08:39:13 | * | xxov joined #nim |
08:51:55 | FromDiscord | <moein> what array of object in js would be in a nim app? objects have fixed keys and value types |
08:54:17 | FromDiscord | <moein> sent a long message, see http://ix.io/3ww8 |
08:54:27 | FromDiscord | <moein> what i wrote so far but it has some issues. |
08:55:06 | FromDiscord | <moein> how can i specify return proc is array of CaloriesMap? am i adding object to calories array in right way? |
08:59:56 | * | jjido joined #nim |
09:02:46 | FromDiscord | <Elegantbeef> seems fine, though wouldnt call it a map |
09:02:47 | FromDiscord | <Elegantbeef> remove square braces |
09:02:52 | FromDiscord | <Elegantbeef> just `: CaloriesMap` |
09:06:42 | FromDiscord | <Rika> I think he wants an array and not a single value |
09:06:44 | FromDiscord | <moein> yeah table is right name i guess. shouldn't it be array[1,CaloriesMap]? since i'm want to return array of CaloriesMap |
09:06:57 | FromDiscord | <moein> (edit) "i'm" => "i" |
09:07:12 | FromDiscord | <Elegantbeef> `seq[CaloriesMap]` possibly since you're adding |
09:07:21 | FromDiscord | <Elegantbeef> Arrays are fixed size in Nim they have to be known at compile time |
09:11:44 | FromDiscord | <moein> so I can initiate empty sequence like var calories = @[] ? |
09:11:55 | FromDiscord | <moein> and how to add to it? |
09:13:26 | FromDiscord | <moein> what i tried |
09:13:29 | FromDiscord | <moein> var calories = seq[CaloriesMap]β΅ calories.add(CaloriesMap(calorie:1000,difficulty:"hard",suitable:false)) |
09:14:00 | FromDiscord | <Elegantbeef> you need to do `var calories: seq[CalorieMap]` then just `calories.add` |
09:15:25 | FromDiscord | <moein> thank you |
09:16:43 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
09:24:20 | NimEventer | New post on r/nim by tobiasbarco666: How to get files from a directory?, see https://reddit.com/r/nim/comments/p81nza/how_to_get_files_from_a_directory/ |
09:35:23 | FromDiscord | <moein> do people use nim to create rest apis? |
09:36:42 | FromDiscord | <moein> right now i'm learning new languages simply to increase my knowledge about more languages and their differences |
09:37:08 | FromDiscord | <moein> for what purposes nim is a good choice? |
09:37:49 | FromDiscord | <enthus1ast> sureβ΅(@moein) |
09:40:07 | FromDiscord | <haxscramper> CLI tooling, compiler development, working with C libraries from a saner languageβ΅(@moein) |
09:44:53 | FromDiscord | <enthus1ast> @moein\: i honestly think you can use nim for mostly everything (and i do) |
09:45:18 | * | max22- joined #nim |
09:45:36 | FromDiscord | <xflywind> > Good for everything, from shell scripting to web front and backend, to machine learning, high-performance computing (HPC), and embedded. |
09:46:51 | FromDiscord | <enthus1ast> you will of course find rough edges here and there, but if more people start using it, finding bugs, and contributing it gets better and better (and it got a LOT better since i used nim) |
09:47:21 | FromDiscord | <moein> is it right to say writing rest apis in let's say something like nodejs is easier in terms of libraries and development speed comparing to nim? |
09:48:26 | NimEventer | New post on r/nim by hotmilki: Is nim good for my use case?, see https://reddit.com/r/nim/comments/p82026/is_nim_good_for_my_use_case/ |
09:48:29 | FromDiscord | <haxscramper> Js has more libraries, but development speed depends on what you used to |
09:49:39 | FromDiscord | <haxscramper> It is possible hack together semi-working js code pretty quickly, from what I can tell, nim requires a little more forethought, being statically typed language and all |
09:49:54 | FromDiscord | <moein> In reply to @moein "is it right to": but in other hand nim offers better type checking and performance (I guess) |
09:49:57 | FromDiscord | <haxscramper> And it has more built-in features that you would need to learn |
09:50:26 | FromDiscord | <haxscramper> Like macros |
10:09:14 | * | max22- quit (Remote host closed the connection) |
10:13:06 | * | jjido joined #nim |
10:50:21 | * | PMunch quit (Read error: Connection reset by peer) |
10:51:14 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
10:51:56 | * | PMunch joined #nim |
10:54:54 | * | max22- joined #nim |
10:58:35 | PMunch | @moein, I've used Nim to set up REST APIs before, and I've never been able to do it more easily than with Nim. Performance will be good, but since performance of web stuff is mostly down to handling HW interactions and async behaviour you won't see as great a boost with Nim as you do in more computationally heavy areas when compared to e.g. Node. |
11:17:36 | * | PMunch quit (Quit: Leaving) |
11:19:23 | * | PMunch joined #nim |
11:27:21 | FromDiscord | <moein> In reply to @PMunch "<@368734642679054338>, I've used Nim": do you recommend any tutorial or library to write rest api? |
11:29:28 | FromDiscord | <moein> jester looks a decent tool |
11:29:34 | FromDiscord | <moein> (edit) "jester looks ... a" added "like" |
11:29:40 | PMunch | Yeah I was using Jester |
11:30:17 | PMunch | Didn't really use any tutorials for it though, it's pretty straight forward to use |
11:36:58 | * | pro joined #nim |
11:48:24 | NimEventer | New thread by Chat_noir: [termux pkg] nim:SSL routines:tls_process_server_certificate:certificate verify failed [SslError], see https://forum.nim-lang.org/t/8345 |
11:51:43 | FromDiscord | <moein> how can i convert array of sequence to json? |
11:51:57 | FromDiscord | <moein> routes:β΅ get "/":β΅ resp result |
11:52:18 | FromDiscord | <moein> result variable is an array of sequence |
11:52:18 | FromDiscord | <enthus1ast> does `% ` work? |
11:52:41 | FromDiscord | <enthus1ast> resp %\ result |
11:53:44 | FromDiscord | <moein> no compiler says Error: undeclared identifier: '%' |
11:53:51 | FromDiscord | <enthus1ast> import json |
11:54:49 | FromDiscord | <moein> i did that before, didn't find anything in docs |
11:55:30 | FromDiscord | <enthus1ast> https://nim-lang.org/docs/json.html#%25%2A.m%2Cuntyped |
11:56:01 | FromDiscord | <moein> In reply to @moein "var calories = seq[CaloriesMap]": it's related to this. the calories is what i want to convert to json |
11:56:26 | PMunch | What is a CaloriesMap? |
11:56:45 | FromDiscord | <moein> it's an object |
11:56:53 | FromDiscord | <moein> sent a long message, see http://ix.io/3wwX |
11:58:17 | PMunch | Seems to work fine: https://play.nim-lang.org/#ix=3wwZ |
11:59:39 | * | pro quit (Quit: WeeChat 3.2) |
12:00:43 | * | xxov quit (Ping timeout: 246 seconds) |
12:01:39 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3wx3 |
12:03:01 | FromDiscord | <enthus1ast> https://play.nim-lang.org/#ix=3wx4 |
12:03:33 | * | xxov joined #nim |
12:04:08 | FromDiscord | <moein> sent a code paste, see https://play.nim-lang.org/#ix=3wx5 |
12:04:11 | FromDiscord | <moein> sent a long message, see https://paste.rs/iKx |
12:04:24 | FromDiscord | <enthus1ast> you can only return string |
12:04:34 | * | max22- quit (Ping timeout: 250 seconds) |
12:04:34 | FromDiscord | <enthus1ast> so `$ % ` should be it |
12:04:59 | FromDiscord | <enthus1ast> %\ transforms your input to JsonNode |
12:05:25 | FromDiscord | <enthus1ast> but jester wants strings \:) |
12:05:55 | PMunch | So you need to use $ to turn the JSON into a string :) |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:24 | PMunch | Like so: https://play.nim-lang.org/#ix=3wx7 |
12:06:30 | * | supakeen joined #nim |
12:08:21 | FromDiscord | <moein> oddly neither of those works |
12:08:31 | * | Vladar quit (Quit: Leaving) |
12:10:06 | PMunch | Could you share your full snippet? Or a minimal version? |
12:10:18 | PMunch | Much easier to test when you actually have the code |
12:11:55 | FromDiscord | <moein> sent a code paste, see https://paste.rs/y81 |
12:12:19 | FromDiscord | <moein> it's just a simple exercise for me to get familiar with nim |
12:12:45 | FromDiscord | <enthus1ast> result |
12:12:49 | FromDiscord | <enthus1ast> ist the issue |
12:12:54 | FromDiscord | <enthus1ast> call it something else |
12:12:59 | FromDiscord | <enthus1ast> seems like a bug |
12:13:14 | FromDiscord | <enthus1ast> sent a code paste, see https://play.nim-lang.org/#ix=3wxa |
12:13:40 | FromDiscord | <enthus1ast> maybe worth an issue at jesters repo |
12:14:19 | PMunch | By the way, you don't need float64, float is by default 64 bits |
12:14:40 | FromDiscord | <moein> In reply to @enthus1ast "call it something else": oh ok. thank you for helping |
12:14:58 | FromDiscord | <moein> In reply to @PMunch "By the way, you": nice. I didn't know that |
12:15:57 | PMunch | That was my suspicion as well, but I wanted to try it out myself |
12:16:19 | PMunch | Basically `result` is a special variable in Nim, it's automatically declared to be the same type as your return type |
12:16:55 | PMunch | So in your nearestCalorie procedure for example you can drop the `var nearest = 0` part and simply use result instead |
12:17:09 | PMunch | It will default to binary zero for whatever your type is, so for an int it would be zero |
12:21:56 | FromDiscord | <moein> In reply to @PMunch "So in your nearestCalorie": like this? var nearest = result |
12:23:18 | FromDiscord | <haxscramper> Like this |
12:23:22 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wxc |
12:24:03 | PMunch | Nope, simple remove `var nearest = 0` and then use `result` instead of `nearest`, like this: https://play.nim-lang.org/#ix=3wxe |
12:24:21 | PMunch | `result` is automatically returned at the end of the procedure |
12:24:41 | PMunch | @haxscramper, you missed one on line 7 |
12:26:16 | FromDiscord | <moein> nice this really makes it cleaner |
12:27:28 | PMunch | Nim has a couple of neat features like that |
12:27:53 | PMunch | Here you can read more about implicit return and result: https://peterme.net/tips-and-tricks-with-implicit-return-in-nim.html |
12:29:23 | FromDiscord | <moein> since you read my code would you give me feedback about usage of array and object and sequences i used in my app? I mean did i use proper methods for those data or there is better approach? I'm coming from javascript and we use array and object for everything π |
12:34:05 | PMunch | Hmm, well in calcCaloriesToLose I would return a tuple instead |
12:34:11 | PMunch | Much faster than building a hash table |
12:35:36 | PMunch | Hmm, well that might be hard with the other stuff you're doing. It's a bit hard to tell what the goal here is |
12:37:00 | PMunch | You can use result in calcCaloriesToLoseMap by the way |
12:37:09 | PMunch | The default value of a seq is an empty sequence |
12:38:08 | FromDiscord | <moein> sent a code paste, see https://paste.rs/RBA |
12:39:08 | PMunch | Right.. |
12:40:15 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wxl |
12:40:41 | FromDiscord | <haxscramper> You can use enum instead of magical strings like "medium", and nim allows you to index into `array` using enums as well |
12:41:40 | PMunch | Makes it a bit more work to turn it into that JSON output though |
12:41:50 | PMunch | Definitely a balance to be struck here |
12:43:18 | * | rockcavera joined #nim |
12:43:18 | * | rockcavera quit (Changing host) |
12:43:18 | * | rockcavera joined #nim |
12:51:05 | PMunch | I'd probably do something like this: http://ix.io/3wxn/ |
12:51:12 | * | arkurious joined #nim |
12:53:00 | PMunch | A bit dependent on what that "activity" thing actually is |
12:53:18 | PMunch | But I assume it might come from the request, and as such is a string |
12:53:54 | PMunch | But you could do that as an enum/array combination as well, and use parseEnum to convert it |
12:54:09 | PMunch | @moein ^ |
12:54:44 | * | Jjp137 quit (Read error: Connection reset by peer) |
12:57:32 | FromDiscord | <moein> yeah exactly activity could be an enum since it values are specific. |
12:58:03 | FromDiscord | <moein> so this changes also affect to performance? |
12:58:13 | FromDiscord | <moein> (edit) "affect to" => "affects" |
12:58:19 | PMunch | Yes, this will be more performant than your version |
12:59:25 | PMunch | A table is a full hash table with buckets and room to grow (all of which involves using the GC both for the string keys but also for the buckets themselves). An array[Difficulty, int] is simply three integers crammed together in memory and might even be passed directly on the stack. |
13:00:40 | PMunch | Since we're using the result variable it's also possible that they are written to directly on the callers stack and not even copied from one place to another. Or the whole procedure might even be inlined because it's not trivially simple. |
13:06:41 | FromDiscord | <haxscramper> If we are talking about microoptimizations like inlining you can also use `toJson(calMap)` from https://github.com/treeform/jsony instead of `$(%(calMap))`. jsony converts directly to string, avoiding lots of intermediate allocations that std/json does |
13:08:02 | FromDiscord | <haxscramper> On the sequence of four CaloriesMaps difference is about five times (faster) |
13:08:09 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wxr |
13:16:39 | * | Vladar joined #nim |
13:34:10 | * | xxov quit (Ping timeout: 246 seconds) |
13:37:14 | * | max22- joined #nim |
13:37:14 | arkanoid | how bad is the idea to automatically convert nil of T in none(T) of Option[T] |
13:38:56 | FromDiscord | <Rika> if you wrap a ref type in an option that is automatically done i believe |
13:39:09 | PMunch | Not any longer I believe |
13:39:12 | FromDiscord | <Rika> or do you mean a converter of T to Option[T]? |
13:39:27 | PMunch | It was supposed to be an optimisation, but it turns out that it was a silly idea |
13:39:34 | FromDiscord | <Rika> oh really? huh |
13:39:41 | arkanoid | not sure yet how to implement it, but I was just thinking if it was worth it |
13:40:04 | arkanoid | yeah, I also smell that it might be a silly idea |
13:41:25 | FromDiscord | <konsumlamm> it's still done, because changing the behaviour would be a breaking change |
13:41:30 | PMunch | The problem is that you suddenly have no way of having Option[pointer] that makes any sense |
13:41:32 | FromDiscord | <konsumlamm> but it is a silly idea, ye |
13:41:47 | FromDiscord | <konsumlamm> see https://github.com/nim-lang/Nim/pull/18401 |
13:42:01 | PMunch | You could just use a normal pointer and have it take special value nil, but if you need more than that there simply would be no way to do it |
13:42:13 | PMunch | Well, there would be a way, just not a very practical one |
13:43:01 | FromDiscord | <konsumlamm> In reply to @arkanoid "not sure yet how": are you aware that stdlib already has an `Option[T]` type? |
13:43:28 | PMunch | Ah, so it still has this behaviour.. |
13:47:15 | arkanoid | konsumlamm, sure, but I didn't know that it was automatically doing the nil to none thing |
13:54:04 | * | flynn quit (Read error: Connection reset by peer) |
13:55:11 | * | flynn joined #nim |
13:55:39 | FromDiscord | <moein> In reply to @PMunch "But you could do": why array? why not an object? |
13:56:09 | FromDiscord | <moein> (edit) "In reply to @PMunch "But you could do": why array? why not an object?" => "sent a code paste, see https://play.nim-lang.org/#ix=3wxF" |
13:57:00 | * | max22- quit (Quit: Leaving) |
13:59:59 | FromDiscord | <moein> In reply to @moein "why array? why not": I'm asking this because i need to get value by key name if that's possible with array I'm good to go |
14:00:07 | FromDiscord | <ββ> in relation to the previous conversation |
14:00:13 | FromDiscord | <ββ> i dont think `+` should be used for strings |
14:00:29 | FromDiscord | <ββ> basically for the same reasons why i dont think `/` should be used |
14:01:39 | PMunch | @moein, array because you can use parseEnum to get an enum that can index an array. But you can't (easily) parse a string into a field to access from the object. |
14:02:13 | * | xet7 quit (Remote host closed the connection) |
14:02:22 | PMunch | Anyways, I'm off |
14:02:25 | * | PMunch quit (Quit: Leaving) |
14:03:25 | * | xet7 joined #nim |
14:04:55 | * | max22- joined #nim |
14:05:41 | arkanoid | how can I declare aliases for generic procs? |
14:13:56 | FromDiscord | <moein> can i set enum values while defining enum in first place? |
14:15:06 | FromDiscord | <moein> sent a code paste, see https://paste.rs/Av1 |
14:15:10 | FromDiscord | <moein> but i get: Error: ordinal type expected; given: float |
14:29:03 | NimEventer | New thread by Doctor: Read command-line arguments, see https://forum.nim-lang.org/t/8346 |
14:29:12 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
14:29:23 | FromDiscord | <moein> sent a code paste, see https://play.nim-lang.org/#ix=3wxP |
14:30:04 | FromDiscord | <moein> those values are always the same, is there better way to initial them? |
14:33:12 | arkanoid | is there any convenience in replacing all equal string literals with a const? |
14:33:17 | FromDiscord | <ynfle (ynfle)> parseEnum needs a string |
14:33:28 | arkanoid | I mean, they should be const anyway, right? |
14:34:14 | FromDiscord | <Rika> In reply to @moein "ok i changed my": what's the last line supposed to do? |
14:34:25 | FromDiscord | <ynfle (ynfle)> They aren't const, strings are imutable |
14:34:30 | FromDiscord | <ynfle (ynfle)> \mutable |
14:34:38 | FromDiscord | <Rika> you can probably do `var ... = [1.2, 1.37, 1.55, 1.72, 1.9]` |
14:34:47 | FromDiscord | <moein> In reply to @Rika "what's the last line": returns 1.37 |
14:35:07 | FromDiscord | <Rika> `paParams[light]` |
14:35:18 | FromDiscord | <ynfle (ynfle)> @moein, `Activity` isn't an enum |
14:35:26 | arkanoid | ynfle, but literal strings? compiler should know if they are actually changed or not |
14:36:28 | FromDiscord | <ynfle (ynfle)> You mean as an optimization? Maybe. You'd have to check the c code and assembler |
14:38:22 | arkanoid | k, I think I will leave them as string literals |
14:38:33 | FromDiscord | <moein> sent a long message, see http://ix.io/3wxR |
14:39:53 | FromDiscord | <ynfle (ynfle)> You can have an object type and access the fields like pa.light. |
14:41:12 | FromDiscord | <ynfle (ynfle)> sent a code paste, see https://paste.rs/vV7 |
14:42:44 | FromDiscord | <Ondrejoda> sent a code paste, see https://paste.rs/Azw |
14:42:59 | FromDiscord | <ynfle (ynfle)> No |
14:43:11 | FromDiscord | <ynfle (ynfle)> you need to do var rect = new Rect |
14:43:24 | FromDiscord | <Ondrejoda> π€¦ββοΈ |
14:43:31 | FromDiscord | <ynfle (ynfle)> There is probably a wrapper proc for it |
14:43:44 | FromDiscord | <Ondrejoda> i was trying `var rect = Rect.new()` |
14:43:56 | FromDiscord | <Rika> that should work too |
14:45:00 | FromDiscord | <Ondrejoda> well it doesn't seem to |
14:45:26 | * | jjido joined #nim |
14:46:04 | FromDiscord | <Rika> what error are you getting |
14:55:09 | * | Jjp137 joined #nim |
15:09:32 | FromDiscord | <Yardanico> In reply to @Ondrejoda "i have a small": with sdl2 or sdl2_nim ? |
15:10:29 | FromDiscord | <Yardanico> in sdl2 Rect is a tuple |
15:10:37 | FromDiscord | <Yardanico> so you do it likeβ΅β΅`var rect = (x, y, 50, 50)` |
15:10:47 | FromDiscord | <Yardanico> or, if you like specifying the type explicitly, `var rect: Rect = (x, y, 50, 50)` |
15:12:45 | FromDiscord | <Yardanico> there's also a helper `rect` proc in sdl2 so you can create a rect like `rect(x, y, 50, 50)` |
15:13:15 | FromDiscord | <Yardanico> that said, sdl2_nim has Rect as a Nim object |
15:14:33 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
15:15:27 | * | xxov joined #nim |
15:21:19 | * | jjido joined #nim |
15:27:14 | * | robertmeta quit (Read error: Connection reset by peer) |
15:31:55 | * | robertmeta joined #nim |
15:45:03 | FromDiscord | <Ondrejoda> how do i convert int to cint? |
15:45:26 | FromDiscord | <enthus1ast> 123.cint |
15:45:32 | FromDiscord | <Ondrejoda> oh |
15:45:40 | FromDiscord | <Ondrejoda> so int(my_variable).cint? |
15:46:55 | FromDiscord | <Ondrejoda> yeah that works |
15:47:02 | FromDiscord | <Rika> no need for int() |
15:48:22 | FromDiscord | <Yardanico> also sdl2_nim doesn't require such conversions :P |
15:48:55 | FromDiscord | <enthus1ast> my\_variable.cint should also work |
15:52:30 | * | max22- quit (Remote host closed the connection) |
15:53:19 | * | max22- joined #nim |
15:53:48 | FromDiscord | <marceneiro> sent a long message, see https://paste.rs/Z3u |
15:54:31 | FromDiscord | <marceneiro> (edit) "long message," => "code paste," | "http://ix.io/3wyK" => "https://paste.rs/L7a" |
15:55:17 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wyM |
15:55:26 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#statements-and-expressions-case-statement |
15:56:48 | FromDiscord | <Rika> `'+'` not`"+"` |
15:57:19 | FromDiscord | <Yardanico> In reply to @Rika "`'+'` not`"+"`": huh? |
15:57:32 | FromDiscord | <Yardanico> why char instead of string? marceniero asked about matching strings |
15:57:50 | FromDiscord | <Yardanico> in rust strings are double quotes, chars are single quotes |
15:57:56 | FromDiscord | <Rika> yes but doesnt regular case not allow for matching strings |
15:57:59 | FromDiscord | <Yardanico> it does |
15:58:02 | FromDiscord | <Yardanico> there's no problem with that |
15:58:03 | FromDiscord | <Rika> it does? |
15:58:06 | FromDiscord | <Yardanico> yes lol |
15:58:12 | FromDiscord | <Yardanico> it always did :P |
15:58:17 | FromDiscord | <Rika> i probably forgot over time |
16:00:25 | FromDiscord | <Yardanico> you can't have runtime strings in of branches, maybe that's what you remembered |
16:00:32 | FromDiscord | <Yardanico> but literal strings are fine |
16:00:36 | FromDiscord | <Yardanico> (or const ones) |
16:01:45 | FromDiscord | <Rika> no i dont know im probably mixing some other language |
16:04:10 | FromDiscord | <marceneiro> Thanks @Rika and @Yardanico , that worked |
16:04:21 | FromDiscord | <Rika> dont forget hax lol |
16:05:10 | FromDiscord | <marceneiro> Oh, god. Sorry mate @haxscramper , much appreciated |
16:28:20 | * | rockcavera quit (Remote host closed the connection) |
16:34:49 | arkanoid | whoever invented xml and decided to build a schema around it, must be a kind of evil man |
16:42:44 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
16:42:49 | FromDiscord | <ββ> how do i make the automatic name changing thing an error |
16:42:50 | FromDiscord | <ββ> so like |
16:43:01 | FromDiscord | <ββ> `parse_file` instead of `parseFile` |
16:43:04 | FromDiscord | <ββ> how do i make that an error |
16:47:43 | FromDiscord | <Rika> cannot |
16:47:53 | FromDiscord | <Rika> you can make `parse_file` an error but not the reverse |
16:49:17 | FromDiscord | <Rika> oh, apparently `--styleCheck:usages` exists now, not sure when but i assume only in devel |
16:49:38 | FromDiscord | <haxscramper> 1.4.8 has it |
16:49:58 | FromDiscord | <Rika> i assume this emits errors, right? |
16:52:08 | FromDiscord | <ββ> it dosent seem to emit errors or warnings |
16:52:12 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wyQ |
16:52:16 | FromDiscord | <ββ> ^ |
16:53:03 | FromDiscord | <Rika> maybe requires a prior --styleCheck:error |
16:53:24 | FromDiscord | <haxscramper> `command line(1, 2) Error: 'on' or 'off' expected, but 'error' found` |
16:53:44 | FromDiscord | <haxscramper> `--styleCheck:off|hint|error` literally in fullhelp |
16:53:47 | FromDiscord | <haxscramper> wtf |
16:53:47 | FromDiscord | <Rika> `echo -e "proc aaa_q() = discard\naaaQ()" | nim r --styleCheck:error --styleCheck:usages` |
16:53:50 | FromDiscord | <Rika> (edit) "--styleCheck:usages`" => "--styleCheck:usages -`" |
16:53:58 | FromDiscord | <Rika> doesnt work either |
16:54:26 | FromDiscord | <Rika> yeah i dont think it works at all |
16:55:19 | FromDiscord | <haxscramper> https://github.com/nim-lang/fusion/issues/82 it works when someone is concerned with stray capital S at least |
16:57:15 | FromDiscord | <ββ> so i cant do it? |
16:59:00 | FromDiscord | <Rika> could if the issue is fixed |
16:59:23 | FromDiscord | <Sorrow> Hello. Is it possible to build a single executable? Looked at the documentation and couldn't see a way. |
16:59:39 | FromDiscord | <Sorrow> With all the required dlls etc packed in. |
16:59:56 | FromDiscord | <Rika> what dynamic libraries are you using |
17:00:13 | FromDiscord | <Sorrow> I mean Nim's own dlls. |
17:00:18 | FromDiscord | <ββ> do you really want ALL the required things? |
17:00:29 | FromDiscord | <ββ> probably you will have to use a alternative libc |
17:00:59 | FromDiscord | <Rika> i dont know for windows sorry |
17:01:25 | FromDiscord | <Rika> maybe just a --passL:-static would work |
17:01:56 | FromDiscord | <Sorrow> I'll try that later, thanks. Go's my main lang, but wanna start using Nim, too. |
17:02:00 | FromDiscord | <Rika> what dynlibs does nim even use on windows? |
17:02:09 | FromDiscord | <Sorrow> Quite a few. |
17:02:27 | FromDiscord | <ββ> how do you check |
17:02:33 | FromDiscord | <Sorrow> (edit) "Nim," => "Nim again," |
17:02:34 | FromDiscord | <Rika> i asked what, not how many |
17:02:47 | FromDiscord | <Sorrow> Idk, not at pc. |
17:02:50 | FromDiscord | <Rika> okay |
17:03:00 | FromDiscord | <Rika> anyone who can check> |
17:03:00 | FromDiscord | <ββ> im using windows and at my pc |
17:03:04 | FromDiscord | <ββ> so just tell me how to check |
17:03:10 | FromDiscord | <ββ> quickly though im going soon |
17:06:19 | FromDiscord | <ββ> i found KERNEL32 and msvcrt |
17:06:31 | FromDiscord | <Rika> `dumpbin /imports` |
17:06:32 | FromDiscord | <Rika> ? |
17:06:42 | FromDiscord | <ββ> i dont have that |
17:06:47 | FromDiscord | <Sorrow> https://media.discordapp.net/attachments/371759389889003532/878324195581366343/Untitled.png |
17:07:21 | FromDiscord | <Rika> only needed for certain modules |
17:10:15 | FromDiscord | <Sorrow> Didn't work unfortunately. |
17:10:30 | FromDiscord | <Sorrow> (edit) "Didn't work unfortunately. ... " added "`could not load: (libcrypto-1_1-x64|libeay64).dll`" |
17:15:23 | FromDiscord | <Rika> well what did the code you compiled look like |
17:15:56 | FromDiscord | <Sorrow> Just a basic script using json and httpclient. |
17:16:14 | FromDiscord | <Rika> theres the module |
17:16:20 | FromDiscord | <Rika> httpclient requires that dll |
17:16:28 | FromDiscord | <Rika> (of course, SSL) |
17:16:50 | FromDiscord | <Sorrow> I wanna include that in the compilation. |
17:17:32 | FromDiscord | <Rika> yes im looking into it |
17:18:32 | FromDiscord | <Rika> https://github.com/nim-lang/Nim/issues/15220 |
17:20:05 | FromDiscord | <Sorrow> Thanks. |
17:21:02 | FromDiscord | <Rika> not sure if it helps, actually |
17:26:24 | * | pro joined #nim |
17:37:16 | FromDiscord | <JSONBash> I am in the process of making a website (https://www.nim.wiki/) that gives people with nim related GitHub Pages websites a domain name (https://demo.nim.wiki/). I could use a couple people going through thr process and giving feedback if that is something people would be willing to do |
17:55:34 | FromDiscord | <RattleyCooper> How can I add something to the event loop with `asyncdispatch`? I'm trying to make a discord bot with `dimscord` and need to check an outside api for something then post a message depending on the result, but I can't figure out how to add something to the event loop. It seems that I can either `runForever` or `waitFor`. What am I missing here? |
18:02:10 | FromDiscord | <Yardanico> In reply to @RattleyCooper "How can I add": I don't exactly understand, do you mean that you want to periodically check for something and then send a discord message if that check is successful? |
18:02:22 | FromDiscord | <RattleyCooper> Correct |
18:02:56 | FromDiscord | <Yardanico> you can just create a proc with a infinite loop (+ await sleepAsync) and call it with asyncCheck proc() |
18:03:02 | FromDiscord | <Yardanico> and do whatever checking you need inside the loop's body |
18:03:44 | FromDiscord | <RattleyCooper> Ok cool, do you know if `poll` is also required? |
18:03:52 | FromDiscord | <Yardanico> no |
18:03:56 | FromDiscord | <RattleyCooper> sent a code paste, see https://paste.rs/CXj |
18:03:57 | FromDiscord | <Yardanico> no, you misunderstood me |
18:03:58 | FromDiscord | <RattleyCooper> Ok |
18:04:06 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3wz2 |
18:04:10 | FromDiscord | <Yardanico> then call that with "asyncCheck" somewhere at the start of your program once |
18:04:16 | FromDiscord | <Yardanico> asyncCheck waitForEvent() |
18:04:45 | FromDiscord | <Yardanico> there's also another way |
18:13:15 | FromDiscord | <Rika> In reply to @Yardanico "then call that with": And then at the end you call run forever right? |
18:13:26 | FromDiscord | <Yardanico> In reply to @Rika "And then at the": well, that depends on how your async app works generally |
18:13:36 | FromDiscord | <Yardanico> i assumed he already had that set up so didn't mention it |
18:13:40 | FromDiscord | <Rika> As long as something calls poll at the end |
18:14:02 | FromDiscord | <RattleyCooper> Yeah, ngl I'm pretty lost bc the docs don't really explain it |
18:14:11 | FromDiscord | <Yardanico> well, what's your issue exactly? |
18:14:16 | FromDiscord | <Yardanico> dimscord has plenty of examples |
18:14:22 | FromDiscord | <RattleyCooper> It's not running anything in while true: |
18:14:30 | FromDiscord | <Rika> Basically, by merely calling an async proc, it is put in the event loop |
18:14:41 | FromDiscord | <RattleyCooper> I'm not having issues with dimscord though |
18:14:42 | FromDiscord | <Rika> As far as I know, at least |
18:14:48 | FromDiscord | <Yardanico> In reply to @RattleyCooper "It's not running anything": well, that was a code example, you're supposed to add your own checking for whatever api you need instead of # ... |
18:14:50 | FromDiscord | <RattleyCooper> I need to add a simple while loop to the event loop |
18:15:01 | FromDiscord | <Yardanico> In reply to @RattleyCooper "I need to add": as I said, write a proc like that and add it with asyncCheck |
18:16:47 | FromDiscord | <RattleyCooper> In reply to @Yardanico "as I said, write": I got you, looks like it did need `runForever` |
18:16:55 | FromDiscord | <Yardanico> well, but you do that for dimscord usually |
18:17:03 | FromDiscord | <Yardanico> e.g. `waitFor discord.startSession()` for dimscord |
18:17:05 | FromDiscord | <RattleyCooper> Here is what works for me |
18:17:22 | FromDiscord | <RattleyCooper> sent a code paste, see https://play.nim-lang.org/#ix=3wz4 |
18:17:25 | FromDiscord | <Yardanico> nonono |
18:17:52 | FromDiscord | <RattleyCooper> Don't need runForever |
18:17:54 | FromDiscord | <RattleyCooper> Gotcha |
18:17:54 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=3wz5 |
18:17:55 | FromDiscord | <Yardanico> that's all you need |
18:17:58 | FromDiscord | <RattleyCooper> Ok cool |
18:18:09 | FromDiscord | <RattleyCooper> Thanks for the help π |
18:26:05 | * | nrds joined #nim |
18:30:44 | nrds | <Prestige99> I feel like the async system could have better docs, it's always a bit confusing to me |
18:31:28 | FromDiscord | <Yardanico> well, idk, nim's default async seems pretty natural to me |
18:31:33 | FromDiscord | <Yardanico> and similar to e.g. python's async |
18:32:14 | nrds | <Prestige99> The different keywords throw me off, I need to learn it in-depth. Feel like I'm missing something |
18:32:47 | FromDiscord | <Yardanico> well, not sure I can relate, never had a problem with them :P |
18:33:35 | FromDiscord | <Yardanico> asyncCheck - start a future, don't wait for completion, waitFor - start and wait for the future to complete |
18:33:39 | FromDiscord | <Yardanico> runForever - run the event loop forever |
18:33:48 | FromDiscord | <Jakraes> Does nim have a perlin noise library? |
18:33:54 | FromDiscord | <Yardanico> waitFor is the "await" for non async procs |
18:33:58 | FromDiscord | <Yardanico> or for global-level code |
18:34:23 | nrds | <Prestige99> I would think all non-async procs would be blocking |
18:34:25 | FromDiscord | <Yardanico> In reply to @Jakraes "Does nim have a": check https://github.com/search?q=language%3Anim+perlin+noise maybe there's something that suits your needs |
18:34:36 | FromDiscord | <Yardanico> @Prestige in what sense? |
18:34:58 | nrds | <Prestige99> like if I call foo() I would expect execution to not continue, until foo has finished |
18:35:04 | nrds | <Prestige99> unless foo were async |
18:35:11 | FromDiscord | <Yardanico> yes, that is true for all non-sync procs |
18:35:16 | FromDiscord | <Yardanico> non-async |
18:35:47 | nrds | <Prestige99> the sentence "waitFor is the "await" for non async procs" didn't make sense to me |
18:36:30 | FromDiscord | <Yardanico> I meant that waitFor is when you need to wait for future's completion and get a result, but you're not in an async context |
18:36:42 | FromDiscord | <Yardanico> so usually global code or the proc where you start your main async proc |
18:37:08 | FromDiscord | <Yardanico> and waitFor itself does block (since it waits till the future completes) |
18:37:41 | nrds | <Prestige99> oh I see. Interesting |
18:38:07 | FromDiscord | <Yardanico> also don't be scared by async stuff in the stdlib, it has pretty readable source code as well :P |
18:38:31 | FromDiscord | <Yardanico> e.g. waitFor is just 3 lines https://github.com/nim-lang/Nim/blob/devel/lib/pure/asyncdispatch.nim#L1932 |
18:38:35 | nrds | <Prestige99> My knee-jerk reaction tells me it'd make more sense if it was still "await" instead of "waitFor", and it just handled things differently in different contexts |
18:38:58 | FromDiscord | <Yardanico> well, I think that'd be even more confusing - the same thing will be doing different stuff based on the context it's in |
18:39:07 | nrds | <Prestige99> true |
18:39:25 | FromDiscord | <Yardanico> you don't use waitFor a lot anyway |
18:39:39 | FromDiscord | <Yardanico> it's mainly used to start some main async loop or something similar |
18:39:41 | nrds | <Prestige99> I guess the part that confuses me is that the proc names aren't super descriptive but that'd be really hard to pull off |
18:43:42 | nrds | <Prestige99> Probably just need to work on more async stuff in Nim π |
18:44:38 | * | max22- quit (Ping timeout: 256 seconds) |
18:53:12 | * | jjido joined #nim |
19:10:09 | madprops | Nim is the most powerful programming language! |
19:15:37 | * | max22- joined #nim |
19:17:10 | FromDiscord | <ββ> how do i make `join_path` instead of `joinPath` a compile error then |
19:19:56 | FromDiscord | <haxscramper> I don't think nim compiler has a way to enforce identifiers that don't conform to the official style guide |
19:21:00 | FromDiscord | <haxscramper> And IIRC `styleCheck:usage` is supposed to make it possible to use library with "incorrect" identifiers in your code together with `--styleCheck:error` |
19:21:38 | FromDiscord | <ββ> :( |
19:24:17 | FromDiscord | <haxscramper> Ah, sorry I read your question backwards, though second part still applies ... and styleCheck is like supposed to work, but maybe I don't know what exactly triggers it |
19:24:30 | FromDiscord | <tandy> \`Error\: unhandled exception\: assignment to discriminant changes object branch; compile with -d\:nimOldCaseObjects for a transition period [FieldDefect]\` |
19:24:36 | FromDiscord | <tandy> what does this mean? |
19:27:53 | FromDiscord | <haxscramper> You can't assign to discriminant fields |
19:28:02 | FromDiscord | <haxscramper> case kind\: |
19:29:00 | FromDiscord | <tandy> oh |
19:29:10 | FromDiscord | <ββ> nim syntax |
19:29:25 | FromDiscord | <ββ> sent a code paste, see https://paste.rs/c2W |
19:29:37 | FromDiscord | <haxscramper> do you need to switch object branch or this just happened accidentally? |
19:29:37 | FromDiscord | <ββ> sent a code paste, see https://paste.rs/NCD |
19:29:40 | FromDiscord | <ββ> you have to watch out for spaces |
19:29:53 | FromDiscord | <haxscramper> I.e there a ways to work around this if you need |
19:30:02 | FromDiscord | <tandy> im trying to create a func to create a new object which has discriminant fields |
19:30:03 | FromDiscord | <ββ> maybe that should be a compile error or warning |
19:30:26 | FromDiscord | <carpal> sent a code paste, see https://play.nim-lang.org/#ix=3wA1 |
19:30:44 | FromDiscord | <haxscramper> okay, so in simple constructor you just need to assign when creating object `result = Obj(kind: <input>)` |
19:30:50 | FromDiscord | <carpal> something:β΅xxxx |
19:30:52 | FromDiscord | <carpal> xxxx |
19:30:59 | FromDiscord | <Yardanico> In reply to @carpal "xxxx": it's different |
19:31:01 | FromDiscord | <haxscramper> this ia a language feature called MCSβ΅(@ββ) |
19:31:03 | FromDiscord | <Yardanico> spaces before f vs no spaces |
19:31:09 | FromDiscord | <carpal> In reply to @Yardanico "it's different": yes |
19:31:24 | FromDiscord | <carpal> but it was a bit funny to see |
19:31:45 | FromDiscord | <Yardanico> In reply to @haxscramper "this ia a language": is it in this case? he's talking about how f without a space binds stronger than f with a space |
19:32:17 | FromDiscord | <haxscramper> whatever this bs is called, mcs/ufcs |
19:32:20 | FromDiscord | <haxscramper> command syntax |
19:32:22 | FromDiscord | <haxscramper> method call syntax |
19:32:27 | FromDiscord | <haxscramper> regular proc call syntax |
19:32:50 | FromDiscord | <haxscramper> command call syntax yes |
19:32:55 | FromDiscord | <ββ> i would want the nim compiler to detect cases like the one i showed |
19:33:18 | FromDiscord | <haxscramper> it is not possible to do since it is not a "case" that can be detected |
19:33:20 | FromDiscord | <haxscramper> both are valid usages |
19:33:36 | FromDiscord | <haxscramper> `echo (12, 2)` is just as justified as `echo(12, 2)` |
19:33:47 | FromDiscord | <haxscramper> or whatewher infix operator you might have added in |
19:34:06 | FromDiscord | <ββ> is that a tuple? |
19:34:09 | FromDiscord | <ββ> vs normal call |
19:34:14 | FromDiscord | <haxscramper> yes |
19:34:30 | FromDiscord | <ββ> so its even more confusing than i thought |
19:34:40 | FromDiscord | <Yardanico> it's more consistent :) |
19:34:46 | FromDiscord | <haxscramper> has space - tupleβ΅no space - call |
19:35:00 | FromDiscord | <ββ> ok what about this |
19:35:07 | FromDiscord | <ββ> `f (1+2) + 3` |
19:35:12 | FromDiscord | <ββ> is that a tuple with 3 in it |
19:35:25 | FromDiscord | <ββ> or the math `()~ |
19:35:26 | FromDiscord | <ββ> (edit) "`()~" => "`()`" |
19:36:33 | FromDiscord | <konsumlamm> that's `f` applied to `(1+2) + 3` |
19:36:57 | FromDiscord | <konsumlamm> command syntax doesn't magically turn everything into tuples |
19:37:15 | FromDiscord | <konsumlamm> but `(a, b)` happens to be the syntax for tuples |
19:37:21 | FromDiscord | <Yardanico> @ββ have you read https://nim-lang.org/docs/manual.html#procedures-command-invocation-syntax ? |
19:37:31 | FromDiscord | <ββ> i think nim should have it syntax reworked |
19:37:53 | FromDiscord | <konsumlamm> command syntax is very unlikely to change |
19:37:56 | FromDiscord | <Yardanico> In reply to @ββ "i think nim should": create a forum thread, see if other people agree with you |
19:37:59 | FromDiscord | <Yardanico> (edit) "In reply to @ββ "i think nim should": create a forum thread, see if other people agree with you ... " added "or not" |
19:38:16 | FromDiscord | <haxscramper> I think command syntax is one of the best things in nim |
19:38:20 | pro | evening lads |
19:38:25 | FromDiscord | <haxscramper> no break-the-language-by-making-print-an-operator |
19:38:39 | FromDiscord | <haxscramper> aka python |
19:38:46 | FromDiscord | <haxscramper> eveything is consistent and can be used uniformly |
19:38:49 | FromDiscord | <Yardanico> also await |
19:38:54 | FromDiscord | <haxscramper> echo |
19:39:00 | FromDiscord | <Yardanico> they had to make it a keyword as well |
19:39:30 | FromDiscord | <haxscramper> In reply to @Yardanico "also await": yes, things like await & other stuff that looks and feels like a keyword but does not have to have a special language support |
19:40:43 | FromDiscord | <konsumlamm> ~~and also works worse than if it was builtin, from what i've heard~~ |
19:40:49 | FromDiscord | <Yardanico> how so? |
19:41:40 | FromDiscord | <haxscramper> In reply to @konsumlamm "~~and also works worse": it is related to the internal implementation and not syntax but yeah, there were some talks about making async not a macro transform |
19:41:50 | FromDiscord | <haxscramper> but a built-in language feature |
19:42:03 | FromDiscord | <haxscramper> but there are like trillion opinons on that one |
19:42:04 | FromDiscord | <dain> doesnt async pose problems for the garbage collector |
19:42:16 | FromDiscord | <Yardanico> no |
19:42:19 | FromDiscord | <haxscramper> IIRC it creates lots of cycles? |
19:42:27 | FromDiscord | <haxscramper> but that's as far as it goes |
19:42:30 | FromDiscord | <Yardanico> well yes, but i don't think this can be considered a real "problem" |
19:42:40 | FromDiscord | <Yardanico> In reply to @dain "doesnt async pose problems": maybe you read that from people talking about async + orc |
19:42:46 | FromDiscord | <Yardanico> this has been already fixed |
19:42:49 | FromDiscord | <tandy> just if statement? |
19:42:50 | FromDiscord | <tandy> depending on the kind I need to pass in different input though, how would i do that? |
19:42:50 | FromDiscord | <dain> yeah that must have been it |
19:42:50 | FromDiscord | <Yardanico> async doesn't leak with orc |
19:43:41 | FromDiscord | <dain> i want to use nim in something bc it seems so comfy but none of the stuff i work on would benefit from it :S |
19:43:46 | FromDiscord | <enthus1ast> do you know of a ready to use parseStr that parses a nim str but respects simple escaping like\: " |
19:43:53 | FromDiscord | <enthus1ast> \\" |
19:44:00 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3wAC |
19:44:12 | FromDiscord | <tandy> ahh |
19:44:12 | FromDiscord | <dain> i just do simple scripting that is almost entirely IO bound, so the extra speed vs python means nothing |
19:44:52 | FromDiscord | <haxscramper> You want to parse simple string literal, or this is related to nim code parsing? |
19:46:40 | FromDiscord | <enthus1ast> i must rewrite the nimja lexer, and it uses constructs like {% extends "fooBaaBaz" %} or {{ """ }} |
19:46:59 | FromDiscord | <enthus1ast> but it should follow the same rules nim uses |
19:47:15 | FromDiscord | <enthus1ast> [Edit](https://discord.com/channels/371759389889003530/371759389889003532/878364434035245057): i must rewrite the nimja lexer, and it uses constructs like {% extends "fooBaaBaz" %} or {{ "\\"" }} |
19:47:34 | FromDiscord | <enthus1ast> at least "foo \\"baa\\" baz" |
19:47:51 | FromDiscord | <enthus1ast> before i roll my own i though i ask you guys \:) |
19:47:58 | FromDiscord | <haxscramper> You can copy one from `compiler/lexer.getStr():~757` |
19:48:22 | FromDiscord | <haxscramper> but I'm not aware of any built-in stdlib implementation that does the same |
19:48:52 | FromDiscord | <haxscramper> I think copying nim lexer part would be the best idea, since you want to reproduce it anyway |
19:49:02 | FromDiscord | <enthus1ast> yeah i must have written 4 or 5 of them all are half assed |
19:49:59 | FromDiscord | <enthus1ast> yeah |
19:50:16 | FromDiscord | <tandy> https://pastebin.com/NqsKFfj8 |
19:50:24 | FromDiscord | <tandy> \`Error\: unhandled exception\: 'apiKey' is not accessible using discriminant 'service' of type 'ServiceUser' [FieldDefect]\` |
19:50:35 | FromDiscord | <tandy> i get this error \:( |
19:51:54 | FromDiscord | <Yardanico> show the code? |
19:52:28 | FromDiscord | <tandy> i sent it in the pastebin https://pastebin.com/NqsKFfj8β΅(@Yardanico) |
19:52:33 | FromDiscord | <tandy> didnt wanna spam chat |
19:53:02 | FromDiscord | <Yardanico> that should work just fine |
19:53:51 | FromDiscord | <Yardanico> and your pastebin example does indeed compile fine for me |
19:53:53 | FromDiscord | <tandy> strange |
19:54:09 | FromDiscord | <tandy> maybe its somewhere else, il take a look |
19:54:48 | FromDiscord | <Yardanico> you are probably assigning to .apiKey somewhere else without checking if the branch is correct |
19:55:05 | FromDiscord | <Yardanico> well, not assigning, just accessing |
19:55:13 | FromDiscord | <Yardanico> try to search for ".apiKey" in your codebase |
19:56:21 | FromDiscord | <tandy> \`newUser(services = [lastFmUser, listenBrainzUser]).services[lastFm].apiKey\` |
19:56:37 | FromDiscord | <Yardanico> eh what does .services[lastFm] even mean? |
19:56:50 | FromDiscord | <tandy> i missed out some other code |
19:57:04 | * | xxov quit (Ping timeout: 246 seconds) |
19:57:23 | FromDiscord | <tandy> \`\`\` User\ = ref object services\\: array[Service, ServiceUser] playingNow\\: Option[Track] listenHistory\\: seq[Track] func newUser\( services\: array[Service, ServiceUser], playingNow\: Option[Track] = none(Track), listenHistory\: seq[Track] = @[])\: User = ## Create new User object new(result) result.services = services result.playingNow = playingNow result.listenHistory = listenHistory \`\`\` |
19:58:02 | FromDiscord | <tandy> https://pastebin.com/vkKfVh2E |
19:59:08 | FromDiscord | <Yardanico> uhh, do your Users always have both services? |
19:59:16 | FromDiscord | <tandy> \`listenBrainzUser = newServiceUser(service = listenBrainz, username = "tandy1000")\` |
20:00:32 | FromDiscord | <Yardanico> but your newUser proc from that pastebin doesn't take a services array |
20:00:44 | FromDiscord | <Yardanico> can you post more code, I'm still quite confused |
20:00:54 | FromDiscord | <Yardanico> i understand that you want to have a single user with one or more ServiceUsers attached to it |
20:10:00 | FromDiscord | <tandy> im post the github repoβ΅(@Yardanico) |
20:11:05 | FromDiscord | <tandy> https://github.com/Listen2gether/website |
20:11:08 | nrds | <prestigebot99> itHub: 7"Sync your listens on Last.fm and ListenBrainz with other people." |
20:11:30 | FromDiscord | <tandy> \`nim c -r src/listentogether.nim\` |
20:11:43 | FromDiscord | <tandy> oh shit leme push actualy |
20:13:43 | * | pro quit (Quit: WeeChat 3.2) |
20:14:44 | FromDiscord | <Yardanico> have you pushed yet? |
20:16:53 | FromDiscord | <tandy> doneβ΅(@Yardanico) |
20:17:36 | FromDiscord | <Yardanico> and where does the error happen? |
20:18:17 | FromDiscord | <Yardanico> i mean file and line |
20:18:24 | FromDiscord | <tandy> \`nim c -r src/listentogether.nim\`β΅(@Yardanico) |
20:20:10 | * | flynn quit (Read error: Connection reset by peer) |
20:20:26 | FromDiscord | <Yardanico> newUser(services = [listenBrainzUser]) |
20:21:13 | FromDiscord | <Yardanico> you have array[Service, ServiceUser] argument in your newUser which means that it can only accepts an array with two values both at the same time |
20:21:18 | * | flynn joined #nim |
20:21:23 | FromDiscord | <Yardanico> you can't pass an array with only one value to it |
20:21:35 | FromDiscord | <tandy> oh |
20:21:47 | FromDiscord | <Yardanico> you can for example make it a seq instead of an array |
20:22:10 | FromDiscord | <Yardanico> also, do you only need two of these services or plan to expand it to more services later on? |
20:22:47 | FromDiscord | <tandy> oh it somehow started compiling |
20:23:20 | FromDiscord | <tandy> this, i dont think i will need to, because there arent really other services, but i want to design it to be expandableβ΅(@Yardanico) |
20:23:38 | FromDiscord | <Yardanico> ah okay, then you can just keep it as a seq |
20:23:43 | FromDiscord | <Yardanico> is this spam or not? π€ https://media.discordapp.net/attachments/371759389889003532/878373753661308968/unknown.png |
20:23:45 | FromDiscord | <Yardanico> seems like it's not |
20:24:23 | FromDiscord | <tandy> but then i cant index it by serviceβ΅(@Yardanico) |
20:25:25 | FromDiscord | <tandy> wait the error is back |
20:25:35 | FromDiscord | <tandy> its the indexing issue, i pushed it |
20:28:22 | FromDiscord | <Yardanico> because you're missing an argument |
20:28:31 | FromDiscord | <Yardanico> newSyncLastFM expects two string arguments at minimum, you're only passing one |
20:29:12 | FromDiscord | <tandy> this is the error though \`Error\: unhandled exception\: 'apiKey' is not accessible using discriminant 'service' of type 'ServiceUser' [FieldDefect]\` |
20:29:53 | FromDiscord | <tandy> also, the other args are optionalβ΅(@Yardanico) |
20:29:57 | FromDiscord | <Yardanico> no |
20:30:03 | FromDiscord | <Yardanico> your first two are required |
20:30:16 | FromDiscord | <tandy> oh you might need to update to head |
20:30:16 | FromDiscord | <Yardanico> apiKey, apiSecret: string; sessionKey: string = "" means that first two are required |
20:30:24 | FromDiscord | <Yardanico> as to your issue, you actually don't create the array correctly |
20:30:55 | FromDiscord | <tandy> ohh |
20:31:02 | FromDiscord | <tandy> il look into that |
20:32:07 | FromDiscord | <Yardanico> @tandy in mirroredUser you should pass services as [listenBrainz: listenBrainzUser, lastFm: lastFmUser] |
20:32:39 | FromDiscord | <Yardanico> and IMO a "cleaner" way would be to have newUser accept services as a seq and then add them to an array inside of a loop with a case, but that's not needed in your case since I doubt you'll be actually calling newUser in a lot of places |
20:33:09 | FromDiscord | <Yardanico> array[Service, ServiceUser] means that your array is indexed by Service, and the first value here is listenBrainz |
20:33:36 | FromDiscord | <Yardanico> so when you did services[lastFm] before you actually accessed the listenBrain'z ServiceUser since you had [lastFmUser, listenBrainzUser] |
20:35:21 | FromDiscord | <tandy> oh thats a good ideaβ΅(@Yardanico) |
20:35:38 | * | max22- quit (Quit: Leaving) |
20:35:42 | FromDiscord | <Yardanico> but as I said, that'll be be cleanliness for the sake of cleanliness :) |
20:36:09 | FromDiscord | <Yardanico> since your listen2gether isn't a library so you'll only have it a few times in the code at max |
20:36:17 | FromDiscord | <tandy> true |
20:36:56 | FromDiscord | <tandy> thanks for your help |
20:46:23 | FromDiscord | <tandy> i wish a library like https://github.com/gruns/icecream for nim |
20:46:26 | nrds | <prestigebot99> itHub: 7"π¦ Never use print() to debug again." |
20:46:35 | FromDiscord | <tandy> i wish there was\ |
20:48:41 | nrds | <Prestige99> You could make it ;) |
20:49:18 | FromDiscord | <InventorMatt> That would be pretty trivial to implement in nim with a macro |
20:49:30 | nrds | <Prestige99> ^^^ |
20:49:33 | FromDiscord | <Elegantbeef> Seems like a lot of work for something that exists |
20:49:34 | nrds | <Prestige99> Looks neat, too |
20:49:40 | FromDiscord | <Elegantbeef> https://github.com/treeform/print |
20:49:43 | nrds | <prestigebot99> itHub: 7"Print is a set of pretty print macros, useful for print-debugging." |
20:51:26 | FromDiscord | <tandy> looks good, does it support json pretty printing? |
20:52:42 | FromDiscord | <Elegantbeef> I dont know i'm not a jsonologis |
20:53:17 | FromDiscord | <tandy> lol |
20:53:26 | FromDiscord | <tandy> it doesnt sadly |
20:53:44 | FromDiscord | <Yardanico> In reply to @tandy "looks good, does it": nim's json module can pretty-format json |
20:53:58 | FromDiscord | <Yardanico> https://nim-lang.org/docs/json.html#pretty%2CJsonNode%2Cint |
21:11:43 | * | max22- joined #nim |
21:14:07 | * | max22- quit (Client Quit) |
21:23:09 | * | max22- joined #nim |
21:29:17 | * | max22- quit (Quit: Leaving) |
21:30:26 | FromDiscord | <rishavs (Rishav Sharan)> @treeform does https://github.com/treeform/pg being maintained? |
21:30:28 | nrds | <prestigebot99> itHub: 7"Very simple PostgreSQL async api for nim." |
21:40:36 | * | max22- joined #nim |
21:41:45 | FromDiscord | <tandy> how can i test if my jsony hooks are working? |
21:41:59 | * | max22- quit (Client Quit) |
21:42:15 | FromDiscord | <tandy> some object in object json isnt being parsed |
21:48:48 | * | Vladar quit (Quit: Leaving) |
21:55:36 | FromDiscord | <Fractal> @Fractal happy Bday |
21:57:54 | FromDiscord | <Yardanico> wat |
22:00:59 | * | jjido quit (Quit: My MacBook Air has gone to sleep. ZZZzzzβ¦) |
22:02:36 | madprops | is creating procs inside a proc a bad idea, performance wise? |
22:03:31 | FromDiscord | <Elegantbeef> Should be the same regardless |
22:04:14 | madprops | I just have a short one like |
22:04:17 | madprops | proc cs(s: string): string = capitalizer(s, string_mode) |
22:04:42 | madprops | but it's inside a proc that could be called a lot |
22:05:22 | madprops | so I'm just wondering if the process of building procs is expensive |
22:05:25 | madprops | but I guess not |
22:07:42 | FromDiscord | <Elegantbeef> Well you may want to add `{.inline.}` to that proc definition to increase the likelyhood of being inlined, or even make it a `template` instead |
22:10:29 | * | max22- joined #nim |
22:48:40 | * | cyraxjoe quit (Quit: No Ping reply in 210 seconds.) |
22:50:01 | * | cyraxjoe joined #nim |
23:02:13 | * | flynn quit (Read error: Connection reset by peer) |
23:03:20 | * | flynn joined #nim |
23:11:53 | * | max22- quit (Remote host closed the connection) |