00:03:55 | * | PMunch quit (Quit: leaving) |
00:23:43 | * | NimBot joined #nim |
00:41:26 | FromDiscord | <XxDiCaprioxX> is there a way to parse the digit a char contains? like, there is the proc `char.isDigit()`, but is there a way to access the exact digit a char is |
00:44:42 | * | Sembei quit (Quit: WeeChat 3.0) |
00:52:33 | FromDiscord | <XxDiCaprioxX> nevermind |
00:57:42 | FromDiscord | <XxDiCaprioxX> Is there in iterator similar to `string.mitems()` that doesn't require the string to be a `var string` but can also be immutable? |
00:59:04 | FromDiscord | <ElegantBeef> you mean `string.items`? |
01:00:46 | FromDiscord | <XxDiCaprioxX> Oh |
01:00:55 | FromDiscord | <XxDiCaprioxX> How didn't I see that in the docs |
01:01:06 | FromDiscord | <XxDiCaprioxX> That's awkward. But thanks |
01:01:18 | FromDiscord | <ElegantBeef> btw did you know `for x in y` will automagically get `y.items` |
01:01:49 | FromDiscord | <XxDiCaprioxX> Oh really? So I can say `for char in string`? Cool! |
01:02:46 | * | grobe0ba quit (Quit: ZNC 1.7.5 - https://znc.in) |
01:03:29 | FromDiscord | <ElegantBeef> Yep |
01:10:21 | FromDiscord | <Anonymous Poet> whats the recommended way to do stdio tests in nim? |
01:10:30 | FromDiscord | <Anonymous Poet> it seems like most things suggest using nimble? |
01:11:18 | FromDiscord | <ElegantBeef> You can checkout the `unittest` module in the stdlib |
01:11:39 | FromDiscord | <ElegantBeef> `nimble test` just runs all files inside `tests/` that start with "t" |
01:12:06 | FromDiscord | <Anonymous Poet> unless im blind, the docs for that dont have anything on io :/ |
01:12:33 | FromDiscord | <ElegantBeef> I dont know what you mean |
01:12:59 | FromDiscord | <Anonymous Poet> im writing a lambda expr evaluator |
01:13:08 | FromDiscord | <Anonymous Poet> it needs to take values from stdin, or write to stdout |
01:13:24 | FromDiscord | <ElegantBeef> I mean shouldnt it just take a string and return a string? |
01:13:30 | FromDiscord | <Anonymous Poet> sadly no :/ |
01:13:42 | * | krux02 quit (Remote host closed the connection) |
01:13:57 | FromDiscord | <Anonymous Poet> in addition to that, it needs to have side effects |
01:14:19 | FromDiscord | <Anonymous Poet> i can restructure my code to do it properly, but i need to end up rewriting it (as is now) in another language, so id rather not |
01:14:41 | FromDiscord | <ElegantBeef> Well i dont have a clue |
01:15:18 | FromDiscord | <Anonymous Poet> tragic |
01:22:06 | * | grobe0ba joined #nim |
01:23:55 | * | njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
01:24:15 | * | njoseph joined #nim |
01:29:40 | FromDiscord | <Rika> IO will be an effect, no way past that unless you want to go unsafe route |
01:30:27 | FromDiscord | <Rika> Do you need to test input and output? Can’t you emulate that instead |
01:30:57 | FromDiscord | <Anonymous Poet> i decided to just do it right and pass in the io |
01:31:18 | FromDiscord | <Anonymous Poet> i was going to use streams but not sure if thats actually correct |
01:31:31 | FromDiscord | <Anonymous Poet> since `stdin` and `stdout` are typed as Files |
01:33:19 | FromDiscord | <Rika> They also have stream versions I believe |
01:33:41 | FromDiscord | <Rika> Underneath they are file descriptors so a lot of things can encapsulate them |
01:34:15 | FromDiscord | <Anonymous Poet> yeah, i was worried what would happen if i did something like `ioIn: Stream = newFileStream(stdin)` |
01:34:33 | FromDiscord | <Anonymous Poet> because i was calling the function with the default multiple times, but everything seems good |
01:36:04 | * | Fish-Face quit (Ping timeout: 240 seconds) |
01:41:36 | * | vicfred quit (Ping timeout: 265 seconds) |
01:50:53 | FromDiscord | <Pixtum> is there way to call a proc before you give it's definition in a file? |
01:51:38 | FromDiscord | <Pixtum> kinda like how in C you can define a functions type name & params but have the actual implementation later in the file |
01:57:19 | * | fredrikhr quit (Quit: Client Disconnecting) |
02:00:10 | FromDiscord | <konsumlamm> ye, you can do a forward declaration |
02:00:35 | FromDiscord | <Hi02Hi> sent a code paste, see https://play.nim-lang.org/#ix=2R8T |
02:00:37 | FromDiscord | <Yardanico> yep :) |
02:00:41 | FromDiscord | <Pixtum> cool thanks |
02:00:45 | FromDiscord | <Hi02Hi> np |
02:42:51 | FromDiscord | <Pixtum> does forward declaration not work in nimscript files? |
03:00:27 | FromDiscord | <Hi02Hi> never tried it |
03:18:59 | * | theelous3 quit (Read error: Connection reset by peer) |
03:27:19 | FromDiscord | <Hi02Hi> tried the example above, it worked, can you show code? |
03:28:51 | * | muffindrake quit (Ping timeout: 272 seconds) |
03:30:12 | * | muffindrake joined #nim |
03:39:37 | * | Gustavo6046 quit (Ping timeout: 272 seconds) |
03:42:10 | * | asdflkj quit (Ping timeout: 276 seconds) |
03:44:54 | FromDiscord | <treeform> Is there a way to make lib set the `-d:ssl` flag? I want to `import mylib` and it just sets the `-d:ssl` flag from my lib's `config.nims` so that users of my lib do not have to know about it? |
03:53:27 | FromDiscord | <Yardanico> @treeform sadly no, the best you could do is to error out if -d:ssl is not defined |
04:17:36 | FromDiscord | <juan_carlos> `switch("define", "ssl")` ?. |
04:25:37 | FromDiscord | <Rika> Only works in Nim script I believe |
04:27:36 | * | spiderstew_ joined #nim |
04:29:57 | * | spiderstew quit (Ping timeout: 264 seconds) |
04:35:15 | Prestige | Is there an int version of Inf and NegInf? |
04:36:23 | FromDiscord | <juan_carlos> I hope not. |
04:37:08 | FromDiscord | <juan_carlos> Theres no NegInf, is -Inf in Nim. |
04:37:23 | FromDiscord | <ElegantBeef> `int.low` and `int.high` 😛 |
04:37:26 | FromDiscord | <ElegantBeef> Int's dont have infinity |
04:38:23 | Prestige | NegInf exists btw |
04:39:22 | FromDiscord | <Rika> -Inf != NegInf I believe... |
04:39:29 | Prestige | Beef thanks for reminding me about int.low |
05:13:57 | FromDiscord | <PizzaFox> does nim have a way to format a number to a string like `123,456,789`? |
05:19:34 | Prestige | Hm I feel like there should be, but I'm not finding anything in the docs |
05:20:59 | FromDiscord | <PizzaFox> yeah i see some stuff in `strformat` for aligning numbers but nothing of the pretty printing sort |
05:21:05 | FromDiscord | <Rika> $? Or do you mean more specifically with commas |
05:21:10 | FromDiscord | <PizzaFox> with commas |
05:21:41 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2R9Y |
05:21:58 | FromDiscord | <Rika> https://nim-lang.org/docs/strutils.html#insertSep%2Cstring%2Cchar%2Cint |
05:22:35 | FromDiscord | <PizzaFox> oh nice |
05:23:02 | Prestige | Nice |
05:23:15 | FromDiscord | <PizzaFox> ok new question |
05:23:52 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2R9Z |
05:24:59 | FromDiscord | <InventorMatt> you can overload a proc so that one has no parameters and the other one has a boolean in your case for the parameter |
05:25:08 | FromDiscord | <PizzaFox> yeah |
05:25:23 | FromDiscord | <PizzaFox> can i enforce that the parameter is never `false` at compile time? |
05:26:17 | FromDiscord | <InventorMatt> if you have is as a static bool then you can have a when statement that errors out is set to false |
05:26:44 | FromDiscord | <ElegantBeef> you can do it in a single procedure, but it's weird 😄 |
05:27:18 | FromDiscord | <PizzaFox> i am coming from my beloved typescript |
05:27:27 | FromDiscord | <PizzaFox> where i can just write |
05:27:32 | FromDiscord | <ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=2Ra2 |
05:27:34 | FromDiscord | <PizzaFox> `param: true` |
05:27:45 | FromDiscord | <PizzaFox> In reply to @ElegantBeef "```nim proc myFn(a: static": this is cursed |
05:27:46 | FromDiscord | <ElegantBeef> The single proc weirdness |
05:27:48 | FromDiscord | <PizzaFox> i'm just going to have |
05:27:51 | FromDiscord | <PizzaFox> `myFn` |
05:28:02 | FromDiscord | <PizzaFox> `myFnFormatted` |
05:28:11 | FromDiscord | <PizzaFox> er |
05:28:12 | FromDiscord | <ElegantBeef> I'm tried and didnt use the proper variable in the when 😄 |
05:28:17 | FromDiscord | <ElegantBeef> (edit) "tried" => "tired" |
05:28:36 | FromDiscord | <PizzaFox> In reply to @InventorMatt "you can overload a": i'll do this and just have an `assert` that param is `false` |
05:28:44 | FromDiscord | <XeroOl> just make it so that `myFn(formatted = false)` does the same thing as `myFn()` |
05:28:54 | FromDiscord | <XeroOl> if you want to just have an optional argument |
05:29:03 | FromDiscord | <PizzaFox> yeah |
05:29:08 | FromDiscord | <PizzaFox> well |
05:29:12 | FromDiscord | <PizzaFox> then the return types wouldn't be valid |
05:29:31 | FromDiscord | <XeroOl> then two procs is probably the way to go |
05:29:49 | FromDiscord | <XeroOl> dynamic return types like that may be okay in typescript, but in nim, it's a bit cursed |
05:30:04 | FromDiscord | <XeroOl> (edit) "a bit" => "~~a bit~~ very" |
05:30:10 | FromDiscord | <PizzaFox> yeah |
05:30:24 | FromDiscord | <PizzaFox> tbh this is just me wanting the compiler to do more than is reasonable sometimes |
05:30:37 | FromDiscord | <XeroOl> you can overload if you want |
05:30:40 | FromDiscord | <PizzaFox> overload sounds good |
05:31:07 | FromDiscord | <XeroOl> sent a code paste, see https://paste.rs/Op2 |
05:31:10 | FromDiscord | <XeroOl> (edit) |
05:31:37 | FromDiscord | <XeroOl> this only makes sense if there are actually different parameters that you need for each version |
05:31:37 | FromDiscord | <ElegantBeef> Well it's a static bool, so it's known at compile time what's going to happen |
05:32:09 | FromDiscord | <XeroOl> if you actually want them to take the same parameters, it's better to have two functions than to have overloaded functions with a hacky optional argument thing |
05:50:01 | FromDiscord | <PizzaFox> if the param is `false` it returns type `A`↵if the param is `true` it returns type `B` |
05:51:04 | FromDiscord | <Rika> In reply to @ElegantBeef "```nim proc myFn(a: static": i dont see how this is cursed ngl |
05:51:08 | FromDiscord | <ElegantBeef> Me either |
05:51:44 | FromDiscord | <ElegantBeef> It's known at compile time and you specify either explicitly or implictly through omission |
05:52:09 | FromDiscord | <ElegantBeef> It's sorta like saying inferred generics are cursed 😄 |
05:55:21 | FromDiscord | <PizzaFox> the auto typing |
05:55:40 | FromDiscord | <PizzaFox> compiler features that are slightly advanced |
05:56:43 | FromDiscord | <Rika> not reallyh |
05:56:44 | FromDiscord | <ElegantBeef> I mean it's just "figure out the type for me" |
05:57:05 | FromDiscord | <Rika> i dont think you can represent that without auto tho |
05:57:24 | FromDiscord | <ElegantBeef> Nope dont think you can |
05:57:27 | FromDiscord | <treeform> In reply to @Yardanico "<@107140179025735680> sadly no, the": thanks! |
05:57:35 | FromDiscord | <ElegantBeef> oh actually |
05:57:42 | FromDiscord | <ElegantBeef> you can do `int or float32` |
05:57:48 | FromDiscord | <Rika> ya sure? |
05:57:52 | FromDiscord | <ElegantBeef> Just tested |
05:58:06 | FromDiscord | <Rika> ok |
05:58:49 | FromDiscord | <ElegantBeef> So is this less cursed pizza? `proc myFn(a: static bool = false): int or float32 =` |
06:01:09 | FromDiscord | <PizzaFox> uh |
06:01:48 | FromDiscord | <PizzaFox> sent a code paste, see https://paste.rs/ZOK |
06:02:04 | FromDiscord | <ElegantBeef> That doesnt really change anything 😄 |
06:02:19 | FromDiscord | <PizzaFox> wouldn't i have to write code to check if the result is A or B |
06:02:51 | FromDiscord | <ElegantBeef> The code i showed earlier worked with the above name change |
06:03:01 | FromDiscord | <ElegantBeef> It returns a single value |
06:03:23 | FromDiscord | <ElegantBeef> When passing true it returned a int, otherwise a float32 |
06:05:32 | FromDiscord | <ElegantBeef> In your case you could probably just say `Stats` as the type itself has the limitation |
06:07:51 | FromDiscord | <ElegantBeef> I was wrong |
06:07:59 | FromDiscord | <ElegantBeef> But here is an example https://play.nim-lang.org/#ix=2Rab |
06:09:55 | FromDiscord | <ElegantBeef> It works the exact same as your double proc idea, but has no "what if you pass the wrong value" |
06:10:32 | FromDiscord | <PizzaFox> is there any downside to your solution |
06:10:48 | FromDiscord | <PizzaFox> it seems good |
06:11:40 | FromDiscord | <ElegantBeef> I mean you're getting a intialized version of the type you want, not any possible down sides afaik |
06:14:23 | FromDiscord | <hamidb80> does minGW-32 makes problem on 64bit windows? |
06:14:57 | FromDiscord | <hamidb80> nim can't compile some of external libraries |
06:15:46 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/815467257102598144/unknown.png |
07:01:49 | FromDiscord | <dponyatov> Is Nim lang suitable for persistent object database engine development, that works over Intel's `libpmem` persistent layer over NVRAM/SSD storage? |
07:02:25 | FromDiscord | <Rika> if its doable in C it should be doable in Nim |
07:03:42 | * | waleee-cl quit (Quit: Connection closed for inactivity) |
07:03:48 | FromDiscord | <dponyatov> What scares me there is garbage collection over persistent memory is critical to faults in its algorithm, as NVRAM will not be cleared on process restart, and any memory leakage or dangling references will corrupt the whole data volume. |
07:04:53 | FromDiscord | <dponyatov> As I know, Nim authors are mad about GC hacking, so are any experiments were done on moving Nim to a huge virtual memory image works over libpmem? |
07:05:21 | FromDiscord | <dponyatov> https://pmem.io/ |
07:07:33 | FromDiscord | <ElegantBeef> It kills a majority of the stdlib but you could do manual memory management |
07:07:44 | FromDiscord | <dponyatov> I can point on the GemStone/S64 system, which runs Smalltalk runtime in huge virtual memory, so for the user and programmer, the system looks like a huge image of RAM, something about 10Tb RAM for an object store. |
07:08:56 | FromDiscord | <dponyatov> (edit) "I can point on the GemStone/S64 system, which runs Smalltalk runtime in huge virtual memory, so for the user and programmer, the system looks like a huge image of RAM, something about 10Tb RAM for an object store. ... " added "Maybe Nim runtime can be run in a such way? Some sort of live object database with its internal language mixes data with processing code." |
07:43:03 | FromDiscord | <hamidb80> In reply to @hamidb80 "": i think i should build mingw-w64 by myself 😕 |
07:54:07 | * | haxscramper joined #nim |
08:07:12 | * | krux02 joined #nim |
08:11:03 | FromDiscord | <PizzaFox> sent a code paste, see https://paste.rs/AFe |
08:13:52 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2Rav |
08:32:25 | FromDiscord | <hamidb80> In reply to @hamidb80 "": does anyone have idea why `handleapi.h` is missing? |
08:32:32 | FromDiscord | <hamidb80> (edit) "In reply to @hamidb80 "": does anyone have ... idea" added "any" |
08:33:20 | FromDiscord | <haxscramper> Ii is not in `includepath` maybe? `--passC:-I<director-with-handleapi.h>` |
08:33:51 | FromDiscord | <hamidb80> In reply to @haxscramper "Ii is not in": no |
08:33:53 | FromDiscord | <haxscramper> Or `--passC:-v` if you are using GCC/clang to make it compile in verbose mode - it will also show al directories |
08:37:23 | FromDiscord | <hamidb80> `handleapi.h` is missing |
08:37:41 | FromDiscord | <hamidb80> i can't find it in mingw directory |
08:38:02 | FromDiscord | <hamidb80> (edit) "mingw" => "`mingw`" |
08:39:00 | FromDiscord | <hamidb80> it must be in `mingw/include` |
08:42:23 | FromDiscord | <hamidb80> do you think it's better to build `mingw` by myself? |
08:54:51 | FromDiscord | <PizzaFox> nim compiler says my custom exception doesn't have a `body` field https://zws.im/↵but it does, which i can verify from logging https://zws.im/ |
08:56:26 | FromDiscord | <haxscramper> > nim compiler says ↵But your code runs correctly? Y just showed `repr` output |
08:56:42 | FromDiscord | <PizzaFox> the second screenshot is the output of `repr(exception` |
08:56:43 | FromDiscord | <PizzaFox> (edit) "`repr(exception`" => "`repr(exception)`" |
08:56:45 | FromDiscord | <Rika> that's nimsuggest saying so |
08:56:48 | FromDiscord | <Rika> not the nim compiler |
08:56:53 | FromDiscord | <PizzaFox> it's also the nim compiler |
08:56:57 | FromDiscord | <PizzaFox> Error: undeclared field: 'body' |
08:57:22 | FromDiscord | <haxscramper> Does your code compile or not? nimsuggest might error out sometimes |
08:57:26 | FromDiscord | <PizzaFox> it doesn't compile |
08:57:40 | FromDiscord | <Rika> what is `echo typeof exception` and `echo exception of CustomException`? |
08:57:45 | FromDiscord | <Rika> eh |
08:57:51 | FromDiscord | <Rika> whats the code then |
08:57:55 | FromDiscord | <ElegantBeef> Did you change your ApiException to a `ref object of HttpRequestError`? |
08:58:17 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2RaB |
08:58:28 | FromDiscord | <Rika> ref |
08:58:30 | FromDiscord | <Rika> needs to be a ref |
08:58:49 | FromDiscord | <ElegantBeef> Inheritance should always use ref unless you wear protection and know how to do it |
08:59:08 | FromDiscord | <PizzaFox> man what |
08:59:20 | FromDiscord | <ElegantBeef> `type ApiException = ref object of HttpRequestError` |
08:59:39 | FromDiscord | <ElegantBeef> Inheritance should always use `ref` unless you know what you're doing |
08:59:39 | FromDiscord | <PizzaFox> Error: raised object of type ref ApiException does not inherit from Exception |
08:59:41 | FromDiscord | <PizzaFox> sad! |
09:00:20 | FromDiscord | <ElegantBeef> Well the issue is it's making a ref due to you not properly handling it 😄 |
09:00:48 | FromDiscord | <PizzaFox> let me review nim exceptions docs |
09:01:02 | FromDiscord | <ElegantBeef> Wait... errors dont inherit using ref |
09:01:09 | FromDiscord | <ElegantBeef> Weird.... behaviour |
09:01:11 | FromDiscord | <PizzaFox> fantastic https://zws.im/ |
09:02:48 | FromDiscord | <PizzaFox> so what am i supposed to do here |
09:02:57 | FromDiscord | <PizzaFox> i just want to attach some metadata to the exception |
09:03:25 | * | krux02` joined #nim |
09:05:30 | FromDiscord | <haxscramper> idk, https://play.nim-lang.org/#ix=2RaE |
09:06:01 | FromDiscord | <haxscramper> `ApiException = ref object of HttpRequestError`, `raise ApiException()` worked perfectly fine |
09:07:30 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2RaI |
09:08:17 | FromDiscord | <Rika> try exporting body |
09:08:28 | FromDiscord | <PizzaFox> good idea |
09:08:37 | FromDiscord | <PizzaFox> same compiler error |
09:09:02 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2RaJ |
09:09:34 | FromDiscord | <haxscramper> Can you just give full code via playground instead of type definition and random pieces |
09:09:46 | FromDiscord | <PizzaFox> yeah let me make a full snippet |
09:09:57 | FromDiscord | <ElegantBeef> Whenever i put puzzles together i always pin the tail on the head |
09:11:35 | FromDiscord | <PizzaFox> https://play.nim-lang.org/#ix=2RaK |
09:12:34 | FromDiscord | <ElegantBeef> ref to a ref |
09:13:01 | FromDiscord | <ElegantBeef> https://play.nim-lang.org/#ix=2RaL |
09:13:24 | FromDiscord | <PizzaFox> idk what a ref even is 🤷♂️ |
09:13:36 | FromDiscord | <ElegantBeef> it's a managed pointer |
09:13:42 | FromDiscord | <ElegantBeef> a reference |
09:14:03 | FromDiscord | <ElegantBeef> you had a pointer pointing to a pointer |
09:14:27 | FromDiscord | <PizzaFox> nice |
09:15:11 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2RaM |
09:15:18 | FromDiscord | <ElegantBeef> For constructors you use `:` |
09:15:45 | FromDiscord | <PizzaFox> a |
09:15:49 | FromDiscord | <PizzaFox> (edit) "https://play.nim-lang.org/#ix=2RaM" => "https://play.nim-lang.org/#ix=2RaN" |
09:17:00 | FromDiscord | <PizzaFox> nimsuggest loses again |
09:17:11 | * | blackpawn_ joined #nim |
09:17:33 | FromDiscord | <PizzaFox> nice it works |
09:17:37 | FromDiscord | <PizzaFox> thanks @ElegantBeef @haxscramper |
09:18:27 | * | blackpawn quit (Ping timeout: 272 seconds) |
09:18:55 | FromDiscord | <haxscramper> Ye. Just minor nitpicking - [i think] it is usually better to send working example at once, even if it is not particularly minimized |
09:19:01 | FromDiscord | <ElegantBeef> I wonder if all the errors couldnt be upgraded to `ref`s, simply cause you can only raise refs, so i imagine all of them have a redundant `new` somewhere |
09:19:36 | FromDiscord | <haxscramper> Working == I can run it and get the same errorr as you |
09:19:51 | FromDiscord | <ElegantBeef> A small reproducible example 😄 |
09:20:01 | FromDiscord | <PizzaFox> yeah idk why i didn't do that initially lol |
09:20:12 | FromDiscord | <PizzaFox> i'm usually better at this |
09:23:41 | * | haxscramper quit (Remote host closed the connection) |
10:05:55 | * | carkh quit (Read error: Connection reset by peer) |
10:18:56 | FromDiscord | <Kiloneie> 230 views on thursday, 359 right now on last video, sharing works 😛 |
10:32:27 | * | fosred joined #nim |
10:36:40 | FromDiscord | <PizzaFox> anyone know of a nim or C library that does something like asciichart https://github.com/kroitor/asciichart |
10:37:07 | FromDiscord | <PizzaFox> trying to turn a list of timestamps into a pretty line chart |
10:38:19 | * | fosred quit (Quit: Leaving) |
11:08:27 | * | tane joined #nim |
11:11:04 | FromDiscord | <haxscramper> IIRC no, but it should not be particularly difficult to write using seq[seq[Rune]] that you use as a canvas for drawing |
11:11:18 | FromDiscord | <Unaimend> So is there some place where copying semantics and stuff like that is explained |
11:12:57 | FromDiscord | <Unaimend> so for example if I want to create a sequence on the heap and return a reference to it from a function, how would I do that |
11:15:43 | * | haxscramper joined #nim |
11:16:05 | FromDiscord | <Unaimend> Or even better a list of all usefull nim documents to become proficient in the language 🙂 |
11:16:09 | FromDiscord | <haxscramper> You use `s: ref seq[T]`, then create s with `new(s)` and then assign something to it, like `s[] = @[1,2,3]` |
11:16:44 | FromDiscord | <haxscramper> In reply to @Unaimend "Or even better a": There is a manual of course, but I'm not sure if there is a concise list with all memory-related things |
11:16:55 | FromDiscord | <Unaimend> And the return type of the function would be `ref seq[T]` ? |
11:17:01 | FromDiscord | <haxscramper> correct |
11:18:20 | FromDiscord | <haxscramper> `seq` and `string` have value semantics, (even though their content is allocated on heap), so in order to get reference semantics you'd need to do something like that |
11:19:49 | FromDiscord | <Unaimend> thx 🙂 |
11:37:38 | FromDiscord | <haxscramper> To perform actual copy of the sequence you probably need to assign between dereferenced versions: `s2[] = s1[]`, which would use value semantics |
11:44:57 | FromDiscord | <Unaimend> Thx again, Is there also some kind move, like in c++, in nim? |
11:45:22 | FromDiscord | <Unaimend> Not that I need it at the moment, reference are perfect for my use case |
11:47:00 | FromDiscord | <Unaimend> Reading through all of those documents [1] at the moment, I hope that after that I dont have to ask that much basic questions as before 🙂↵[1] https://nim-lang.github.io/Nim/ |
11:47:49 | * | Tlanger quit (Remote host closed the connection) |
11:48:03 | FromDiscord | <haxscramper> https://nim-lang.github.io/Nim/destructors.html#lifetimeminustracking-hooks-eqsink-hook |
11:51:03 | FromDiscord | <haxscramper> In reply to @Unaimend "Reading through all of": Actually it is really weird that netiher destructors [1], nor experimental features [2] are not linked from the documentation overview page↵[1] https://nim-lang.github.io/Nim/destructors.html↵[2] https://nim-lang.github.io/Nim/manual_experimental.html |
11:52:46 | FromDiscord | <Unaimend> Yes, I think it would make sense to add those links there |
12:06:45 | FromDiscord | <Yardanico> @Unaimend there is one |
12:07:39 | FromDiscord | <Unaimend> https://nim-lang.github.io/Nim/ on this page? |
12:07:44 | FromDiscord | <Unaimend> Am I blind? |
12:08:05 | FromDiscord | <Yardanico> https://github.com/KeepCoolWithCoolidge/asciigraph a direct port |
12:08:15 | FromDiscord | <Yardanico> Oh sorry it was @PizzaFox |
12:09:07 | FromDiscord | <Unaimend> No problem 😂 |
12:10:00 | FromDiscord | <PizzaFox> In reply to @Yardanico "https://github.com/KeepCoolWithCoolidge/asciigraph ": hm |
12:32:49 | FromDiscord | <PizzaFox> sent a code paste, see https://play.nim-lang.org/#ix=2Rbw |
12:34:48 | FromDiscord | <Yardanico> $maximum |
12:35:16 | FromDiscord | <PizzaFox> tell that to the asciigraph author |
12:35:48 | FromDiscord | <Yardanico> you can easily change that yourself |
12:35:55 | FromDiscord | <Yardanico> Last commit in that repo was in 2019 |
12:36:03 | FromDiscord | <Yardanico> and it's under 50 lines of code |
12:36:11 | FromDiscord | <Yardanico> So you can just copy the entire package in your project and fix it |
12:36:20 | FromDiscord | <PizzaFox> 122 sloc but ok |
12:39:19 | FromDiscord | <PizzaFox> awesome nice good https://zws.im/ |
12:39:44 | FromDiscord | <PizzaFox> btw the lines that weren't compiling? they were just random lines formatting strings without assigning to a variable or anything |
12:39:51 | FromDiscord | <PizzaFox> good library imo |
12:41:48 | FromDiscord | <Yardanico> Honestly not sure why you are complaining :) |
12:42:01 | FromDiscord | <PizzaFox> i expect people to write me high quality libraries! |
12:42:02 | FromDiscord | <PizzaFox> for free! |
12:42:05 | FromDiscord | <Yardanico> It's not a lot of code anyway, easy to fix manually |
12:53:55 | * | xet7 quit (Quit: Leaving) |
13:26:12 | FromDiscord | <Yardanico> @PizzaFox they are not random lines by the way |
13:26:33 | FromDiscord | <Yardanico> they were using this proc from strformat (0.19.0) https://media.discordapp.net/attachments/371759389889003532/815575664693608498/unknown.png |
13:26:43 | FromDiscord | <Yardanico> right now it's https://nim-lang.org/docs/strformat.html#formatValue%2Cstring%2CSomeFloat%2Cstring and the order of args changed a bit |
13:27:18 | ForumUpdaterBot | New thread by HJarausch: Nim can be so difficult to understand, see https://forum.nim-lang.org/t/7566 |
13:28:26 | FromDiscord | <Yardanico> fixed these quite easily - https://gist.github.com/Yardanico/0888bf78c87d4c9cab2dab3f96be077b |
13:28:41 | ForumUpdaterBot | New post on r/nim by Karyo_Ten: Multithreading flavors: Choosing the right scheduler for the right job, see https://reddit.com/r/nim/comments/lug1jk/multithreading_flavors_choosing_the_right/ |
13:28:42 | FromDiscord | <Yardanico> needed to change 3 lines |
13:43:25 | * | ^Q-Master^ quit (Ping timeout: 276 seconds) |
13:47:26 | * | Gustavo6046 joined #nim |
14:00:07 | FromDiscord | <Yardanico> i guess I should take over asciigraph (first I'll check if the author will accept a PR though) |
14:01:04 | * | PMunch joined #nim |
14:05:26 | FromDiscord | <Yardanico> I'll be streaming some random Nim again in Music voice channel (on discord) |
14:06:14 | * | Q-Master joined #nim |
14:09:03 | PMunch | Why do we have a Nim music channel? |
14:09:24 | FromDiscord | <mratsim> we do? |
14:09:35 | PMunch | Apparently *shrug* |
14:10:06 | FromDiscord | <Yardanico> I self-host some music bot which allows to play music in discord vc :P |
14:10:18 | FromDiscord | <Yardanico> it's just a voice channel at the bottom of the server list |
14:10:25 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/815586708577714206/unknown.png |
14:16:23 | FromDiscord | <mratsim> Pulseaudio evolved! |
14:16:51 | FromDiscord | <Yardanico> @PizzaFox https://github.com/Yardanico/asciigraph |
14:18:28 | FromDiscord | <Yardanico> https://github.com/KeepCoolWithCoolidge/asciigraph/pull/3 |
14:19:33 | * | rokups joined #nim |
14:28:56 | FromDiscord | <Yardanico> how come I didn't know about https://nim-lang.org/docs/system.html#newSeq%2Cseq%5BT%5D%2CNatural |
14:29:19 | FromDiscord | <Yardanico> newSeq(var seq[T], len: Natural) so that you can do "result.newSeq(size)" in procs instead of "result = newSeq[type](size)" |
14:33:39 | FromDiscord | <Unaimend> is there no reverse function for strings? |
14:34:09 | FromDiscord | <Yardanico> there's a generic one in algorithm |
14:34:18 | FromDiscord | <Yardanico> but it will only work correctly if your string is ascii |
14:34:35 | FromDiscord | <Yardanico> https://nim-lang.org/docs/algorithm.html#reverse%2CopenArray%5BT%5D |
14:34:41 | FromDiscord | <Yardanico> for unicode use https://nim-lang.org/docs/unicode.html#reversed%2Cstring |
14:34:50 | FromDiscord | <Unaimend> In reply to @Yardanico "but it will only": ascii strings best strings |
14:35:02 | FromDiscord | <Unaimend> utf is heresy |
14:35:13 | FromDiscord | <Unaimend> (edit) "utf" => "unicode" |
14:35:18 | FromDiscord | <Yardanico> non-native english speakers don't agree with you :P |
14:35:29 | FromDiscord | <Unaimend> I am german 🙂 |
14:35:38 | FromDiscord | <Yardanico> your alphabet is at least mostly latin |
14:35:44 | FromDiscord | <Unaimend> true |
14:35:46 | FromDiscord | <Yardanico> i am russian, situation is worse for us with ascii :) |
14:37:10 | FromDiscord | <Unaimend> Yeah, I am so glad that I never had to put up with non-ascii stufff |
14:38:09 | FromDiscord | <Unaimend> In german i just ignore Ä,Ö,Ü |
14:39:01 | FromDiscord | <Unaimend> We can just write ae, oe or ue instead of ä,ö,ü , respectively |
14:43:45 | FromDiscord | <Roundlay> Anyone seen any FizzBuzz one liners in Nim? |
14:44:22 | FromDiscord | <Yardanico> yes |
14:44:30 | FromDiscord | <Yardanico> i submitted one to code.golf |
14:44:36 | FromDiscord | <Yardanico> you can probably make it even shorter though |
14:44:49 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2Rc3 |
14:45:17 | FromDiscord | <Yardanico> https://code.golf/scores/fizz-buzz/nim/bytes |
14:45:41 | FromDiscord | <Roundlay> Woah, thank you! |
14:45:54 | FromDiscord | <Yardanico> the record here is 64 chars but idk how they managed to do it |
14:55:09 | FromDiscord | <mratsim> I have one using neural networks as well: https://github.com/mratsim/Arraymancer/blob/master/examples/ex04_fizzbuzz_interview_cheatsheet.nim 😄 |
15:06:18 | FromDiscord | <Yardanico> honestly sometimes I think that people on codegolf who have #1 for nim entries cheated in some way :P |
15:06:47 | FromDiscord | <Yardanico> like 42chars for "Write a program to print all the leap years from the year 1800 up to and including 2400." |
15:11:52 | FromDiscord | <mratsim> either you use while or countup but yeah 42 is short |
15:12:34 | FromDiscord | <Yardanico> mine is 57 but its cheaty |
15:12:36 | FromDiscord | <Yardanico> `import times;for x in 1801..2400:(if x.isleapyear:echo x)` :P |
15:12:51 | FromDiscord | <zetashift> In reply to @Yardanico "```nim for n in": my eyes are hurting, so it must be a great codegolf |
15:13:05 | FromDiscord | <Yardanico> I just took mratsim's solution from the forum and improved it a bit :D |
15:13:29 | FromDiscord | <Yardanico> or for example quine |
15:13:34 | FromDiscord | <Yardanico> the #1 quine for nim is 55 chars |
15:13:36 | FromDiscord | <Yardanico> HOW?!?! |
15:29:54 | FromDiscord | <mratsim> Ugh, writing RFCs/specs is so complex. |
15:44:19 | * | superbia joined #nim |
15:48:02 | saem | Morning |
15:50:06 | FromDiscord | <DARTHVADER NAXXX> Morning |
15:54:43 | * | Q-Master quit (Ping timeout: 276 seconds) |
15:55:41 | * | abm joined #nim |
15:55:42 | superbia | morning |
15:58:00 | FromDiscord | <Yardanico> evening |
16:00:40 | * | Vladar joined #nim |
16:09:36 | FromDiscord | <Yardanico> will be doing some random stuff at twitch.tv/yardanico (it'll probably be boring, be advised) |
16:10:12 | saem | Less boring than what I do. :D |
16:29:17 | * | Q-Master joined #nim |
16:31:19 | FromDiscord | <Yardanico> built docs in pdf with ./koch pdf (seems to work contrary to https://github.com/nim-lang/Nim/issues/12266 ) |
16:31:28 | FromDiscord | <Yardanico> for today's devel |
16:31:31 | FromDiscord | <Yardanico> https://files.catbox.moe/0u7i5x.pdf manual |
16:31:34 | FromDiscord | <Yardanico> https://files.catbox.moe/litwy9.pdf lib |
16:31:37 | FromDiscord | <Yardanico> https://files.catbox.moe/dmnf7k.pdf tut1 |
16:31:39 | FromDiscord | <Yardanico> https://files.catbox.moe/08pbhw.pdf tut2 |
16:31:42 | FromDiscord | <Yardanico> https://files.catbox.moe/8is2er.pdf tut3 |
16:31:45 | FromDiscord | <Yardanico> https://files.catbox.moe/0v9web.pdf nimc |
16:31:48 | FromDiscord | <Yardanico> https://files.catbox.moe/9fr1k6.pdf niminst |
16:31:50 | FromDiscord | <Yardanico> https://files.catbox.moe/z34328.pdf gc |
16:32:14 | FromDiscord | <Yardanico> manual is 108 pages long |
16:34:09 | * | Q-Master quit (Ping timeout: 264 seconds) |
16:35:26 | saem | Is that everything or just the language and the single HTML page most people know? |
16:37:52 | FromDiscord | <Yardanico> its the html |
16:37:57 | FromDiscord | <Yardanico> i mean it's pdf |
16:38:02 | FromDiscord | <Yardanico> but its the same as going to manual in the docs |
16:38:55 | saem | ah, really does make sense to generate a single page as now and also a multi-page variety. |
16:40:52 | saem | text search over that is already troublesome. |
16:42:17 | saem | mratsim which rfc are you writing? |
17:15:35 | * | teasea quit (Quit: teasea) |
17:18:26 | * | teasea joined #nim |
17:19:49 | FromDiscord | <mratsim> @saem a RFC on threadpool on channels API |
17:20:40 | * | audiofile joined #nim |
17:20:57 | FromDiscord | <mratsim> also defining common vocabulary to talk about multithreading libraries, as in defined but left unspecified like: executors, schedulers, tasks, closures, continuations |
17:21:21 | FromDiscord | <mratsim> threadpools AND channels |
17:21:32 | saem | Yeah, there is a lot to build up that doesn't otherwise exist. |
17:24:09 | FromDiscord | <mratsim> actually executors, schedulers, tasks and closures already exist. But they are not defined. |
17:24:28 | FromDiscord | <mratsim> And they exist for both async/await and within threadpools or Weave |
17:25:22 | audiofile | can someone explain what `roll` should be like in this definition? http://vpaste.net/J3z9K?bg=dark&nu |
17:25:56 | audiofile | I thought the first param to array type was length but here it's a range? |
17:26:17 | FromDiscord | <mratsim> The idea is just to build a common understanding of what they are. So that in the future it's easier to define either how they are implemented (if it's a type that we want inteperable) or what API they should provide (if it's an opaque type/API that is just manipulated as a blockbox). |
17:26:26 | FromDiscord | <mratsim> interoperable |
17:27:25 | audiofile | test |
17:28:23 | * | waleee-cl joined #nim |
17:31:53 | FromDiscord | <InventorMatt> audiofile: nim converts the integer for the first value of the array implicitly into a range of 0..N so in this example they are just explicitly creating the range |
17:41:30 | FromDiscord | <Unaimend> In reply to @mratsim "The idea is just": Sounds like a ton work |
17:42:54 | FromDiscord | <Unaimend> (edit) "In reply to @mratsim "The idea is just": Sounds like a ton ... work" added "of" |
17:43:57 | FromDiscord | <mratsim> sent a long message, see http://ix.io/2Rde |
17:44:34 | FromDiscord | <mratsim> So there is no more research to do, it's putting thoughts together in unambiguous way. |
17:44:55 | FromDiscord | <Unaimend> Which is still pretty hard I would say |
17:45:20 | * | Q-Master joined #nim |
17:46:07 | FromDiscord | <qb> How could I convert a type to a string? Should `fmt` even fail there? https://play.nim-lang.org/#ix=2Rdf |
17:46:13 | FromDiscord | <mratsim> The main issue is that you have things like concurrency vs parallelism, what is a closure, what's a task, what's a job, what's a dispatcher, what's a scheduler, what's a thread, a fiber, an executor that you need to clear up. |
17:46:26 | * | vicfred joined #nim |
17:46:41 | FromDiscord | <Unaimend> yeah good definitions a hard to come by |
17:47:18 | FromDiscord | <mratsim> A thread for example is pretty hard to define. |
17:48:29 | FromDiscord | <Unaimend> In reply to @qb "How could I convert": sent a long message, see http://ix.io/2Rdi |
17:49:05 | FromDiscord | <Unaimend> In reply to @qb "How could I convert": https://play.nim-lang.org/#ix=2Rdj |
17:49:17 | FromDiscord | <qb> thanks |
17:49:38 | FromDiscord | <Unaimend> 🙂 no problem |
17:49:39 | federico3 | @mratsim add the upcoming vectorial cpu instructions to that |
17:50:31 | FromDiscord | <mratsim> vector CPU instructions to do what? |
17:50:47 | FromDiscord | <mratsim> hard to define you mean? |
17:51:22 | FromDiscord | <Unaimend> so how do your guys implement tests for your packages, just with `isMainModule` in the specific source file?? |
17:51:46 | FromDiscord | <mratsim> like this: https://github.com/mratsim/constantine/tree/master/tests |
17:52:10 | FromDiscord | <Unaimend> and then use testament? |
17:52:13 | FromDiscord | <mratsim> isMainModule only for internal sanity checks on private implementations. |
17:52:15 | FromDiscord | <mratsim> No |
17:52:52 | FromDiscord | <mratsim> Either I assemble everything in an overarching all_tests.nim if the tests dont take too much time |
17:53:42 | FromDiscord | <mratsim> or I collect them in a "to_exec.txt" file https://github.com/mratsim/constantine/blob/master/constantine.nimble#L222 |
17:53:53 | federico3 | @mratsim vector instructions that encourage CPUs to move closer to GPUs - adding complexity to the conversation |
17:54:00 | FromDiscord | <mratsim> and then call GNU parallel (or any other parallel stuff on it). |
17:54:10 | FromDiscord | <mratsim> @federico3, that seems unrelated. |
17:54:13 | FromDiscord | <Unaimend> so why does the nim doc advise to not use unittest.nim? |
17:56:05 | FromDiscord | <mratsim> sent a long message, see http://ix.io/2Rdm |
17:57:48 | audiofile | thanks InventorMatt, makes sense |
17:58:13 | FromDiscord | <Unaimend> sent a code paste, see https://play.nim-lang.org/#ix=2Rdn |
17:58:39 | * | JustASlacker joined #nim |
17:58:47 | FromDiscord | <mratsim> yes, with proper indentation 😉 |
17:58:55 | FromDiscord | <Unaimend> kk, thx |
18:24:56 | FromDiscord | <hamidb80> hey everyone |
18:25:46 | FromDiscord | <hamidb80> i reinstalled my `minwg` and missing header files problem solved |
18:25:49 | FromDiscord | <hamidb80> but .. |
18:25:51 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/815650993122705488/unknown.png |
18:26:19 | FromDiscord | <hamidb80> any idea? |
18:28:08 | FromDiscord | <hamidb80> https://media.discordapp.net/attachments/371759389889003532/815651565264044032/unknown.png |
18:29:03 | FromDiscord | <haxscramper> In reply to @Unaimend "so why does the": sent a code paste, see https://play.nim-lang.org/#ix=2Rdx |
18:29:51 | FromDiscord | <mratsim> that rules with a `t` is meh |
18:30:18 | FromDiscord | <mratsim> it's okay for it to be a convention, but there shouldn't be a special rule to look for it, it's like magic. |
18:30:28 | FromDiscord | <haxscramper> Yeah, but it does the job for simple cases, so I guess it is fine probably |
18:30:28 | FromDiscord | <mratsim> just have people create a test task. |
18:31:09 | FromDiscord | <mratsim> juste have a "nimble init" task that does the test task skeleton as well. |
18:31:15 | FromDiscord | <mratsim> (edit) "task" => "command" |
18:31:28 | * | audiophile joined #nim |
18:31:32 | FromDiscord | <mratsim> you need a single file only for very very simple libraries. |
18:31:56 | FromDiscord | <mratsim> People start testing when they graduate from Hello World and AOC types of programs. |
18:31:57 | FromDiscord | <Unaimend> Anybody else had the problem that the nvim syntax highligting died for one buffer even after nvim restart? https://media.discordapp.net/attachments/371759389889003532/815652524248924160/2021-02-28-193052_1919x1022_scrot.png |
18:32:52 | audiophile | what's the recommended way of handling configuration (like an api key by enduser) in nim? |
18:33:03 | audiophile | don't need anything too complex |
18:33:10 | audiophile | is good old .ini okay? |
18:34:55 | * | audiofile quit (Ping timeout: 240 seconds) |
18:34:57 | FromDiscord | <Yardanico> we have `parsecfg` for ini |
18:34:58 | * | audiophile is now known as audiofile |
18:35:04 | FromDiscord | <Yardanico> I personally prefer TOML :) |
18:36:18 | FromDiscord | <hamidb80> is there any example using redis[or any other message broker] with jester? |
18:36:25 | FromDiscord | <hamidb80> (edit) "broker]" => "brokers]" |
18:37:22 | FromDiscord | <hamidb80> i'm confused, how can I use more than one async thing? 😕 |
18:38:05 | FromDiscord | <バロザード> https://gitlab.com/lbartoletti/fpn |
18:38:11 | FromDiscord | <バロザード> does anyone know who made thsi library |
18:38:26 | FromDiscord | <Yardanico> yes |
18:38:30 | FromDiscord | <Yardanico> lbartoletti :P |
18:38:33 | FromDiscord | <Yardanico> I |
18:38:38 | FromDiscord | <Yardanico> 've seen him around in here |
18:38:42 | FromDiscord | <Yardanico> https://github.com/lbartoletti |
18:38:59 | FromDiscord | <バロザード> aigh i need to talk to him about his library |
18:39:05 | FromDiscord | <バロザード> id like to use it lol\ |
18:39:30 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/815654424596840458/unknown.png |
18:39:37 | FromDiscord | <hamidb80> In reply to @hamidb80 "i'm confused, how can": ? |
18:39:41 | FromDiscord | <Yardanico> I guess you can try DMing him on twitter |
18:39:41 | FromDiscord | <Yardanico> https://twitter.com/lo_bartoletti |
18:40:10 | FromDiscord | <Yardanico> @hamidb80 what do you exactly mean? |
18:40:46 | FromDiscord | <バロザード> his twitter doesnt have dms |
18:41:04 | FromDiscord | <Yardanico> he does |
18:41:17 | FromDiscord | <バロザード> he seems to exist in the irc place tho |
18:41:23 | FromDiscord | <バロザード> so i guess i just wait |
18:41:42 | FromDiscord | <Yardanico> he should always be around in freebsd irc chans |
18:41:48 | FromDiscord | <バロザード> ah k |
18:41:55 | FromDiscord | <バロザード> god i hate irc but its for science |
18:42:07 | FromDiscord | <Yardanico> its quite easy |
18:42:11 | FromDiscord | <Yardanico> lemme check if he's on freenode chans |
18:42:20 | FromDiscord | <Yardanico> yeah he is |
18:42:27 | FromDiscord | <Yardanico> he's in here too |
18:42:36 | Yardanico | lbart the guy above wants to talk with you :) |
18:42:49 | Yardanico | abot your fpn lib |
18:42:54 | Yardanico | about* |
18:44:01 | FromDiscord | <hamidb80> In reply to @Yardanico "<@!745944009918251010> what do you": sent a long message, see http://ix.io/2RdB |
18:44:14 | FromDiscord | <hamidb80> (edit) "http://ix.io/2RdB" => "http://ix.io/2RdC" |
18:45:11 | FromDiscord | <Yardanico> I don't really get what do you mean by "async loop". you can run as many async procs as you want if you use asyncCheck which starts the future in the background and continues |
18:45:19 | FromDiscord | <Yardanico> I'd be more comfortable with a concrete code example :) |
18:46:39 | FromDiscord | <mratsim> In reply to @hamidb80 "imagine we have 2": https://tenor.com/view/dbz-dragonball-fusion-gif-4929472 |
18:46:46 | FromDiscord | <mratsim> sorry, couldn't help it. |
18:49:43 | audiofile | http://vpaste.net/frmka?bg=dark&nu here, are the typedefs independent or does userid and language come under the SomeClass ? |
18:50:08 | audiofile | I assume if they were independent, then the class object would also be on a new line right |
18:50:28 | FromDiscord | <Yardanico> they both come under SomeClass |
18:50:33 | audiofile | thanks |
18:50:43 | FromDiscord | <Yardanico> it's based on the indentation levels - fields are indented inside of SomeClass so they are inside |
18:50:51 | audiofile | type |
18:50:51 | audiofile | SomeClass* = object |
18:50:51 | audiofile | userid: string |
18:50:51 | audiofile | language: string |
18:51:00 | Yardanico | this won't compile |
18:51:18 | Yardanico | because you can't declare types with ":" |
18:51:46 | audiofile | ah right mb |
18:52:22 | audiofile | so this is valid and it works http://vpaste.net/GFaKv?bg=dark&nu |
18:52:24 | audiofile | hmm interesting |
18:52:34 | FromDiscord | <Yardanico> yes because you can declare types like that |
18:52:43 | audiofile | got it, ty for clarifying |
18:52:45 | FromDiscord | <Yardanico> it's pretty logical I think, nim is an indentation-sensitive language |
18:53:06 | FromDiscord | <Yardanico> and you can alias types like that easily |
18:53:12 | audiofile | yes, it is, it's just that I'm not so familiar with nim :) |
18:53:35 | audiofile | type\nMyInt = int like that? |
18:53:54 | Yardanico | yes |
18:54:07 | Yardanico | in this case MyInt is just an alternative naming for int |
18:54:21 | Yardanico | you can also create distinct types https://nim-lang.org/docs/manual.html#types-distinct-type |
18:55:06 | FromDiscord | <dom96> huh, didn't even notice Nim on the HN front page 4 days ago |
18:56:40 | audiofile | wow, that's cool! so that's a new level of type safety |
18:56:42 | nisstyre | Hello, when I try compiling this example from the asynchttpserver docs, I get a compiler error https://play.nim-lang.org/#ix=2RdK |
18:56:44 | nisstyre | what's going on? |
18:56:52 | nisstyre | the type of acceptRequest is wrong I guess |
18:57:02 | audiofile | dom96 nim has generally favourable reception on hn so that's good anyway |
18:57:17 | FromDiscord | <hamidb80> hn? |
18:57:18 | nisstyre | this is with nim 1.4.2 |
18:57:42 | FromDiscord | <hamidb80> what is HN? |
18:57:58 | FromDiscord | <Yardanico> hackernews |
18:58:06 | FromDiscord | <Yardanico> https://news.ycombinator.com/ |
18:58:16 | FromDiscord | <Yardanico> @nisstyre the devel has a fixed example https://nim-lang.github.io/Nim/asynchttpserver.html |
18:58:23 | FromDiscord | <Yardanico> althoug if defined(nimAsyncHttpServerEnableTest): should be removed IMO |
18:58:32 | nisstyre | Yardanico: thanks |
18:58:45 | FromDiscord | <Yardanico> it's really confusing for people who will read the example |
19:03:53 | krux02 | My PRs on github are marked as stale by the stale bot https://github.com/nim-lang/Nim/pull/13277 |
19:04:02 | krux02 | and I can't do anything about it, as I've been blocked |
19:04:05 | krux02 | wohoo |
19:09:00 | FromDiscord | <mratsim> In reply to @dom96 "huh, didn't even notice": what article? Nim 1.4.4? |
19:10:39 | audiofile | why is tables not part of standard library or like a type imported by default? |
19:10:59 | audiofile | genuinely curious |
19:11:03 | FromDiscord | <Yardanico> it's a part of the standard library |
19:11:16 | audiofile | i mean like not imported by default if that makes sense |
19:11:21 | audiofile | i have to `import tables` to use it |
19:11:24 | FromDiscord | <Yardanico> yes |
19:11:28 | FromDiscord | <Solitude> why should anything be import by default? |
19:11:30 | FromDiscord | <Solitude> just import it |
19:11:31 | audiofile | yes but why |
19:11:48 | audiofile | hm ok |
19:12:28 | * | valorzard joined #nim |
19:12:44 | valorzard | hello |
19:12:49 | FromDiscord | <dom96> In reply to @mratsim "what article? Nim 1.4.4?": yep |
19:12:50 | FromDiscord | <バロザード> oh cool |
19:12:57 | FromDiscord | <バロザード> i can exist in both worlds |
19:12:59 | FromDiscord | <バロザード> thats freaky |
19:13:15 | valorzard | im the japanese letters guy |
19:13:50 | FromDiscord | <バロザード> seeing myself getting repeated is kinda freaky |
19:14:01 | valorzard | it feels like im talking to myself |
19:14:40 | liblq-dev | almost as if you had schizophrenia, or something. |
19:14:57 | valorzard | looool |
19:14:59 | liblq-dev | welcome to IRC land, friend. quite comfy here, isn't it? |
19:15:09 | valorzard | no, i perfer discord. This is still pretty cool tho |
19:15:21 | valorzard | im mostly here to chase after a certain someone |
19:15:32 | audiofile | is there any way to create hashmap from string to any type? |
19:15:32 | liblq-dev | good luck in finding them |
19:15:36 | FromDiscord | <mratsim> There are converters in `fusion` :/ https://github.com/nim-lang/fusion/blob/master/src/fusion/smartptrs.nim#L100-L103 |
19:16:19 | liblq-dev | audiofile: there is, but trying to do that is usually a bad idea. what are you trying to do? |
19:16:25 | FromDiscord | <mratsim> In reply to @audiofile "is there any way": you need your "any" type to be type erased. Either via inheritance or via object variant. |
19:17:49 | audiofile | ok that sounds complicated, nothing that can't be stored in a string liblq-dev |
19:18:08 | audiofile | so hashmaps in nim are like c and not like python |
19:18:14 | liblq-dev | in c++, rather |
19:18:21 | audiofile | ah yes |
19:18:23 | liblq-dev | because C doesn't have generics |
19:18:38 | audiofile | is this for better hashmap performance? |
19:18:38 | liblq-dev | what are you trying to do, though? |
19:18:58 | audiofile | just store commandline flags in a hashmap and some of them are numbers so I wanted to mix numbers and strings |
19:18:59 | liblq-dev | no, it's a type system thing. |
19:19:04 | liblq-dev | ah. |
19:19:14 | liblq-dev | well you can parseInt wherever necessary |
19:19:16 | audiofile | i can always use string and typecast |
19:19:20 | audiofile | yeah that |
19:19:23 | audiofile | ty |
19:19:27 | liblq-dev | or, you can create an object variant. give me a second |
19:21:46 | liblq-dev | audiofile: https://play.nim-lang.org/#ix=2RdT |
19:26:54 | audiofile | hmm I dont quite grok that example so I'll take your word for it |
19:27:13 | FromDiscord | <Unaimend> so if if compare to refs of seq[seq[int], will nim compare the addresses or the values? |
19:27:45 | FromDiscord | <mratsim> code? |
19:27:52 | FromDiscord | <mratsim> ref seq have ref semantics so yes |
19:28:03 | FromDiscord | <mratsim> seq[seq[T]] have value semantics so no |
19:28:42 | FromDiscord | <Unaimend> In reply to @mratsim "code?": `type Matrix = ref seq[seq[int]] ` so this is my type |
19:29:08 | FromDiscord | <mratsim> address will be compared |
19:29:50 | FromDiscord | <Unaimend> but i should be able to just use the dereference operator to compare the values, shouldnt I? |
19:30:36 | FromDiscord | <Yardanico> yes |
19:31:04 | FromDiscord | <Unaimend> In reply to @mratsim "address will be compared": I always forget that you have to use [] |
19:31:16 | FromDiscord | <Unaimend> because in c++ you just have to deref pointers |
19:31:33 | FromDiscord | <mratsim> a ref is a pointer |
19:31:51 | FromDiscord | <Unaimend> yeah under the hood |
19:32:28 | FromDiscord | <Unaimend> but int test(int ptr) is not the same as int test(int& ref), i.e. it will behave differently |
19:35:23 | superbia | would I gain any performance if I transfer my python OpenCV code to nim ? |
19:36:31 | FromDiscord | <InventorMatt> if you use a lot of foor loops then yes |
19:36:33 | FromDiscord | <Yardanico> it depends on how much of your processing is done in python |
19:37:00 | FromDiscord | <Yardanico> if you just do opencv calls most of the time without any algorithms in python - I doubt that you'll get much performance gain |
19:37:07 | superbia | yup, that is the case |
19:38:23 | FromDiscord | <バロザード> well since searching for my mystery man isnt working |
19:38:37 | FromDiscord | <バロザード> does anyone know how i could go around setting thsi library up? |
19:38:53 | * | rokups quit (Quit: Connection closed for inactivity) |
19:39:34 | FromDiscord | <バロザード> https://gitlab.com/lbartoletti/fpn |
19:40:26 | FromDiscord | <InventorMatt> is there an error when nimble installing it? |
19:40:31 | FromDiscord | <mratsim> `nimble install fpn` ? |
19:40:35 | FromDiscord | <バロザード> ah k |
19:40:37 | audiofile | i cannot initialize properties in an object right? I want to do something like this http://vpaste.net/rCgDl?bg=dark&nu |
19:40:54 | FromDiscord | <バロザード> tho, i wonder how i could make my own fixed point type |
19:41:12 | FromDiscord | <mratsim> no, it's being discussed |
19:41:20 | FromDiscord | <mratsim> @audiofile ^ |
19:41:42 | audiofile | ohhh ok, any workaround for that until that is resolved? :) |
19:42:02 | FromDiscord | <mratsim> In reply to @バロザード "tho, i wonder how": you use uint as a base and arbitrary choose a bit position to be your decimal point. |
19:42:25 | FromDiscord | <mratsim> In reply to @audiofile "ohhh ok, any workaround": use an init/nea function with efault value |
19:42:32 | FromDiscord | <mratsim> init/new |
19:42:49 | audiofile | um like a constructor? |
19:43:03 | FromDiscord | <mratsim> yes |
19:46:30 | FromDiscord | <バロザード> im looking at thsi code and im not seeing where the actual types get made |
19:46:48 | FromDiscord | <バロザード> the main thing im seeing is a function called fracbits, which seems to split a number into high and low |
19:46:57 | FromDiscord | <バロザード> but that method isnt actually defiend anywhere |
19:47:10 | FromDiscord | <Yardanico> https://media.discordapp.net/attachments/371759389889003532/815671449363677184/unknown.png |
19:47:19 | FromDiscord | <Yardanico> `type FixedPoint = fixedPoint8 | fixedPoint16 | fixedPoint32 | fixedPoint64;` |
19:47:58 | FromDiscord | <バロザード> yeah nothats whats im talking about |
19:48:03 | FromDiscord | <バロザード> what does fracBits do? |
19:48:04 | FromDiscord | <バロザード> it doesnt say |
19:48:23 | FromDiscord | <Yardanico> wdym "what does fracBits do"? |
19:48:28 | FromDiscord | <Yardanico> it's a static parameter of the type |
19:48:33 | FromDiscord | <Yardanico> amount of bits for the fraction part I guess |
19:48:48 | FromDiscord | <バロザード> ohhh |
19:48:51 | FromDiscord | <mratsim> This explains how to implement fixed points: https://homepage.divms.uiowa.edu/~jones/bcd/divide.html#fixed |
19:49:59 | FromDiscord | <バロザード> hmmmmm i still dont really get it tho, where is fracBits set? when genQType is called, it takes the name and the already used types |
19:50:11 | FromDiscord | <バロザード> but when thats called, it doesnt take fracbits |
19:50:23 | FromDiscord | <Yardanico> when the type is instantiated |
19:50:33 | FromDiscord | <バロザード> oh wait i think i understand |
19:51:02 | FromDiscord | <バロザード> the floats are hardcoded to be split in half to be converted to fixed point i think |
19:51:36 | audiofile | im still unable to find out how to create constructor with new/init. any links? |
19:51:51 | FromDiscord | <Yardanico> there's no such thing as "constructor" in Nim |
19:52:01 | FromDiscord | <Yardanico> you can just make a proc on your own that'll be named like `newFoo` or `initFoo` |
19:52:02 | FromDiscord | <Yardanico> that' |
19:52:09 | FromDiscord | <Yardanico> s kind of the convention |
19:52:21 | audiofile | oh and how does it get called - automatically when an object is created? |
19:52:23 | FromDiscord | <Yardanico> newFoo for reference types (ref object), initFoo for value types (object) |
19:52:25 | FromDiscord | <Yardanico> no |
19:52:27 | FromDiscord | <Yardanico> you call it manually |
19:52:39 | FromDiscord | <Yardanico> as I said it's just a convention, nim doesn't call constructors for you automatically |
19:53:01 | FromDiscord | <Yardanico> that said, nim initializes all fields to zero by default and you can use object construction syntax |
19:53:18 | audiofile | oh, so what's the recommended way to call it? like where do I call it? I don't want the user to have to call something like obj.initObj |
19:54:03 | JustASlacker | var myObj = initMyObj(foo, bar) |
19:54:27 | audiofile | so initMyObj wraps around the type MyObj? |
19:54:42 | JustASlacker | it returns an instance of that object |
19:54:46 | FromDiscord | <Yardanico> wdym "wraps around"? it returns an object of the type MyObj |
19:54:50 | JustASlacker | like factory pattern |
19:55:20 | FromDiscord | <Yardanico> it's just a convention, you can have a proc `initFoo` that returns an object of type `Bar` :P |
19:58:21 | JustASlacker | just made my first .nimble file |
19:58:23 | JustASlacker | fun |
19:58:41 | audiofile | here is my confusion: https://play.nim-lang.org/#ix=2Re6 like how do I bind 'opt' to the SomeClass object |
19:58:57 | audiofile | I hope I'm doing the init thing right |
20:00:15 | audiofile | L#3 is what I want to do but cannot do now |
20:00:45 | audiofile | it's like class member variables being initialized (from python) |
20:02:31 | FromDiscord | <Yardanico> you can't just "bind" it |
20:02:39 | FromDiscord | <Yardanico> you have to declare a field `opt` in your `SomeClass` |
20:02:42 | FromDiscord | <Yardanico> nim is a static language |
20:03:23 | FromDiscord | <バロザード> sent a code paste, see https://play.nim-lang.org/#ix=2Rec |
20:03:33 | FromDiscord | <Yardanico> what type is a.data? |
20:03:55 | FromDiscord | <Yardanico> ah I see |
20:04:07 | FromDiscord | <バロザード> its a bunch of different ints |
20:04:23 | FromDiscord | <バロザード> ill also have to replace all of the unit tests to test some stuff out, which will also be annoying |
20:04:26 | FromDiscord | <Yardanico> high(typeof(a.data)) |
20:04:30 | FromDiscord | <バロザード> ooo ok |
20:04:39 | FromDiscord | <Unaimend> In reply to @audiofile "I hope I'm doing": https://play.nim-lang.org/#ix=2Re6 |
20:04:43 | FromDiscord | <Yardanico> also this code can be shortened if you want |
20:04:54 | FromDiscord | <Yardanico> result.data = if isSafeAbs(a): abs(a.data) else: high(typeof(a.data)) |
20:05:19 | audiofile | Unaimend, it's the same paste? |
20:05:45 | FromDiscord | <Unaimend> In reply to @audiofile "<@287576619718279178>, it's the same": upsi, waita sec |
20:06:36 | FromDiscord | <Unaimend> In reply to @audiofile "<@287576619718279178>, it's the same": https://play.nim-lang.org/#ix=2Ref |
20:06:51 | FromDiscord | <Yardanico> @Unaimend this can be shortened, you don't need to make a copy here :) |
20:06:53 | audiofile | url still looks the same |
20:07:00 | audiofile | oh nvm |
20:07:34 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2Reg |
20:07:37 | FromDiscord | <Unaimend> In reply to @Yardanico "<@!287576619718279178> this can be": True |
20:07:52 | FromDiscord | <Unaimend> Thats even nicer |
20:14:48 | audiofile | thanks Unaimend, that makese sense now |
20:14:56 | FromDiscord | <バロザード> ugh i tried to fix the deprecated stuff, but it led to a bunch of weird bugs so ill revert for now |
20:16:12 | * | kenran joined #nim |
20:17:30 | audiofile | is there any shorthand notation for assigning values to member variables like the 'sc.<var> = something' |
20:17:45 | audiofile | assuming my initSomeClass(**kwargs) |
20:18:06 | * | xet7 joined #nim |
20:25:36 | * | JustASlacker quit (Ping timeout: 240 seconds) |
20:31:21 | * | kenran quit (Remote host closed the connection) |
20:31:38 | * | kenran joined #nim |
20:36:37 | FromDiscord | <Unaimend> In reply to @audiofile "is there any shorthand": not exactly sure what you mean, could you give an example |
20:37:07 | FromDiscord | <ElegantBeef> I believe they're after `std/with` |
20:37:16 | FromDiscord | <Kiloneie> Should i put my last video into the , this month with/in nim ? |
20:38:46 | FromDiscord | <ElegantBeef> Like i said just go ahead, if anyone dislikes the inclusion it can be removed |
20:39:08 | FromDiscord | <Kiloneie> Okay, so i open up a new issue ? i can't think straight today... |
20:39:14 | FromDiscord | <ElegantBeef> Yep |
20:39:57 | audiofile | Unaimend, something like this https://play.nim-lang.org/#ix=2Rek |
20:40:27 | FromDiscord | <ElegantBeef> How about this audiofile? https://github.com/beef331/constructor |
20:42:06 | FromDiscord | <Unaimend> In reply to @audiofile "<@287576619718279178>, something like this": Maybe one could come up with template/macro sulotion, but I did not work with those at all |
20:44:37 | FromDiscord | <Unaimend> In reply to @audiofile "assuming my initSomeClass(**kwargs)": so you basically would like to unpack a table/dictionary in to your object? |
20:45:00 | audiofile | yes |
20:45:27 | audiofile | ElegantBeef, that is interesting but I was hoping for a smaller solution without a library because this is just a one-time thing |
20:45:29 | audiofile | thanks tho |
20:49:06 | FromDiscord | <Unaimend> In reply to @audiofile "yes": Sry, dont know any way atm |
20:49:14 | FromDiscord | <Unaimend> (edit) "way" => "solution" |
20:53:14 | audiofile | okay nw |
20:53:29 | audiofile | I guess that's the reason for the library ha |
21:08:46 | audiofile | http://vpaste.net/O8XUd?bg=dark&nu can someone tell me why this is wrong? |
21:08:57 | audiofile | I'm trying to assign n only if it's greater than 100 |
21:09:08 | FromDiscord | <Yardanico> then you should have if outside |
21:09:19 | FromDiscord | <Yardanico> if n > 100: obj.opt["n"] = n |
21:11:02 | audiofile | I'm guessing it's not possible to make it a one-liner? |
21:11:10 | audiofile | because I tried that first and still got an error |
21:11:36 | audiofile | oh nvm my bad have to typecast |
21:13:04 | * | valorzard quit (Quit: Connection closed) |
21:15:02 | * | haxscramper quit (Remote host closed the connection) |
21:16:03 | FromDiscord | <hamidb80> uh |
21:16:58 | FromDiscord | <hamidb80> In reply to @audiofile "I'm trying to assign": it's not ruby |
21:17:20 | audiofile | idk ruby so what you say is lost on me |
21:19:53 | FromGitter | <ynfle> @audiofile, you have to put and `else` branch if you are going to assign a value. Like ⏎ ⏎ ```thisVar = if n > 100: n else: 100``` [https://gitter.im/nim-lang/Nim?at=603c08f8e5f1d949d46e3749] |
21:20:23 | audiofile | oh if it's on a single line I can't omit the else branch? |
21:20:30 | FromDiscord | <hamidb80> In reply to @audiofile "oh if it's on": https://play.nim-lang.org/#ix=2Reu |
21:21:19 | FromDiscord | <hamidb80> is that what you want? |
21:21:35 | audiofile | without the else is it possible? |
21:21:45 | FromDiscord | <hamidb80> In reply to @audiofile "without the else is": i dont think so |
21:21:50 | audiofile | hmm ok thanks! |
21:22:08 | audiofile | is there no thing like some noop? like just to fill in the else-branch then |
21:22:29 | FromGitter | <ynfle> @audiofile, what would the value be if the condition isn't true? |
21:22:37 | audiofile | not assigned |
21:23:06 | FromGitter | <ynfle> What use would that be? You'd be reading from nil? |
21:23:48 | FromDiscord | <Yardanico> @audiofile that's the thing |
21:23:52 | FromDiscord | <Yardanico> nim is fully statically typed |
21:23:59 | FromDiscord | <Yardanico> so if you're assigning you have to ALWAYS know the value |
21:24:25 | FromDiscord | <Yardanico> that's why `a.b = if n > 100: n` is not possible but `if n > 100: a.b = n` is |
21:24:40 | FromDiscord | <Solitude> In reply to @audiofile "is there no thing": it wouldnt be an expression then |
21:25:07 | FromDiscord | <Rika> yall ive a question; are there any plans to allow for operators to be async? |
21:25:22 | FromDiscord | <Rika> kinda strange question i know |
21:25:26 | FromDiscord | <Yardanico> uhh |
21:25:30 | FromDiscord | <Yardanico> what does that mean |
21:25:41 | FromDiscord | <Rika> you can do `await a[i] = x` or so |
21:25:41 | FromDiscord | <hamidb80> a +await= a |
21:25:44 | FromDiscord | <Rika> very strange i know |
21:25:53 | audiofile | Yardanico I tried `if n > 100: a.b=n` but get `complex statement requires indentation` |
21:26:02 | FromDiscord | <Yardanico> you need newline or parenthesis |
21:26:26 | FromDiscord | <Rika> not the same. |
21:26:27 | FromDiscord | <hamidb80> In reply to @Rika "you can do `await": sent a code paste, see https://play.nim-lang.org/#ix=2Rew |
21:26:29 | FromDiscord | <hamidb80> In reply to @hamidb80 "```nim a[i] =await ": ?! |
21:26:39 | FromDiscord | <Rika> i want `[]=` to be awaited, not `x` |
21:27:13 | FromDiscord | <Rika> though that does beg the question how would `await a[x]` work huh |
21:28:06 | FromDiscord | <hamidb80> In reply to @Rika "though that does beg": right |
21:29:11 | FromDiscord | <Rika> actually no that would work |
21:29:29 | FromDiscord | <Rika> as long as a doesnt contain a Future as well, then that would need the funkiest shit `await await a[x]` |
21:32:05 | FromDiscord | <Rika> let me actually test if what i said doesnt work, i only recall it not working |
21:34:34 | FromDiscord | <Rika> yup doesnt work for setting |
21:46:45 | FromDiscord | <dom96> pretty sure we wouldn't want that to work actually lol |
22:00:20 | FromDiscord | <Rika> why so? |
22:05:12 | * | kenran quit (Quit: leaving) |
22:09:49 | * | eternaldelta quit (Quit: WeeChat 2.8) |
22:12:44 | * | lritter joined #nim |
22:13:45 | * | PMunch quit (Quit: leaving) |
22:20:33 | * | vicfred quit (Quit: Leaving) |
22:26:38 | * | asdflkj joined #nim |
22:26:41 | FromDiscord | <mratsim> @saem, here you go, only task parallelism/threadpools specified for now and @Unaimend and also all interested in revamping Nim threadpool: https://github.com/mratsim/weave/blob/master/rfcs/multithreading_apis.md↵↵Have to specify channels now and then do some relecture and edits |
22:27:12 | saem | Oh damn |
22:27:45 | saem | Is this the spiritual successor of CPS? |
22:28:18 | saem | Or rather, requires it/it's hiding in there? |
22:29:11 | FromDiscord | <mratsim> No it's different |
22:29:20 | saem | yup, skimmed it and got to non-goals |
22:30:04 | FromDiscord | <mratsim> CPS is a low-level construct that would allow to create scheduler/executor agnostic tasks (among other things). |
22:30:12 | FromDiscord | <mratsim> This is a user-facing API. |
22:30:38 | FromDiscord | <mratsim> CPS would help async/iterators/task/multithreading library authors |
22:31:17 | FromDiscord | <mratsim> while this would help parallel library authors and users, in particular it should guide the rewrite of Nim threadpool. |
22:31:32 | saem | Yeah, I'm more interested in CPS and my interesting in the APIs are as long as they don't have some silly expectations that tie one's hands when implementing the lower level fundamental bits like CPS. |
22:31:50 | saem | s/interesting/interest |
22:32:31 | FromDiscord | <mratsim> I need to reboot the CPS implementation |
22:32:55 | FromDiscord | <mratsim> My current thinking for CPS APi is this: https://github.com/weavers-guild/weave-io/blob/master/design/design_2_continuations.md |
22:33:01 | saem | But I know you're very sounds fundamentals/algebra driven so that's already reassuring |
22:33:39 | FromDiscord | <mratsim> but I need to implement some "user" programs using it to make sure it's usable and there is no hidden gotcha. |
22:34:08 | saem | Of course, it can be as beautiful as it wants, but needs to solve a "real thing" |
22:34:23 | FromDiscord | <Unaimend> In reply to @mratsim "but I need to": Astute readers will think, what’s the difference with a closure? Should this be `Astute readers will think, what’s the difference to a closure?` in the blogpost |
22:38:26 | FromDiscord | <mratsim> sent a long message, see http://ix.io/2ReX |
22:39:27 | FromDiscord | <mratsim> Names subject to bikeshedding, but those are mostly for library authors so it's fine having them somewhat long. |
22:39:48 | FromDiscord | <mratsim> going to sleep now. |
22:40:02 | * | tane quit (Quit: Leaving) |
22:42:06 | saem | nite |
22:44:08 | audiofile | what's wrong with this format specifier? https://play.nim-lang.org/#ix=2ReZ |
22:44:28 | * | gpanders quit (Ping timeout: 268 seconds) |
22:45:04 | FromDiscord | <Yardanico> it's wrong :) |
22:45:09 | FromDiscord | <Yardanico> $# if you don't want to specify the number |
22:45:11 | FromDiscord | <Yardanico> its in the docs |
22:45:13 | * | gpanders joined #nim |
22:45:29 | FromDiscord | <Yardanico> "The notation $# can be used to refer to the next substitution variable" |
22:45:48 | FromDiscord | <Yardanico> https://nim-lang.org/docs/strutils.html#%25%2Cstring%2CopenArray%5Bstring%5D. You should also look at strformat module https://nim-lang.org/docs/strformat.html |
22:46:02 | audiofile | ooof good catch |
22:52:56 | * | superbia quit (Quit: WeeChat 3.0) |
23:08:52 | audiofile | thanks, strformat looks more like what I'm used to |
23:09:00 | audiofile | http://vpaste.net/eakLx?bg=dark&nu is this a valid way of sending a file over a socket |
23:12:44 | * | oprypin quit (Quit: Bye) |
23:12:52 | * | oprypin joined #nim |
23:14:16 | FromDiscord | <Yardanico> not at all |
23:14:23 | FromDiscord | <Yardanico> socket.send(fp.readAll()) is more like it |
23:14:38 | FromDiscord | <Yardanico> or you can also to read and send in chunks so you don't have to hold the whole file content in memory |
23:16:57 | audiofile | ohh ok! |
23:16:59 | audiofile | thanks |
23:18:27 | audiofile | in https://play.nim-lang.org/#ix=2Rf7, the $ for converting to string gets evaluated last, right? |
23:18:35 | FromGitter | <ynfle> Or just use `readFile`, no opening and closing files |
23:18:53 | audiofile | oh lemme look that up >_> |
23:19:29 | FromGitter | <ynfle> @audiofile, Ya. but you can use brackets for precedence |
23:19:55 | FromGitter | <ynfle> https://play.nim-lang.org/#ix=2Rfa |
23:20:05 | FromGitter | <ynfle> @audiofile ☝️ |
23:20:07 | audiofile | convert($abc, destEncoding="UTF-8")? |
23:20:18 | audiofile | ooooh |
23:20:22 | FromGitter | <ynfle> Or that |
23:20:23 | FromDiscord | <Yardanico> $ binds stronger than parenthesis |
23:20:25 | FromDiscord | <Yardanico> or dot access |
23:20:36 | audiofile | highest precedence? |
23:20:43 | FromDiscord | <Yardanico> no I'm wrong |
23:20:48 | FromGitter | <ynfle> I'd recomment putting the `echo` in the front so it's obvious what you're trying to do |
23:20:54 | audiofile | not doubting you, just curious :/ |
23:20:57 | FromDiscord | <Yardanico> but "Unary operators always bind stronger than any binary operator: $a + b is ($a) + b and not $(a + b)." |
23:21:01 | FromDiscord | <Yardanico> I wasn't sarcastic |
23:21:06 | FromDiscord | <Yardanico> I actually said "I'm wrong" :P |
23:21:17 | audiofile | ohhh lmao mb |
23:21:37 | audiofile | yes ynfle but ever since I discovered nim can do that it's easy to write as I think |
23:21:37 | FromGitter | <ynfle> @Yardanico https://play.nim-lang.org/#ix=2Rfb |
23:21:45 | FromGitter | <ynfle> Ok |
23:21:46 | audiofile | like chaining together methods |
23:22:02 | FromGitter | <ynfle> But if you put it in front, it's obvious what you are doing |
23:22:05 | FromGitter | <ynfle> Trying to print |
23:22:08 | audiofile | indeed |
23:22:14 | FromGitter | <ynfle> As apposed to trying to process something |
23:25:47 | * | vicfred joined #nim |
23:27:02 | audiofile | for encodings.convert, the default value for desEncoding is "UTF-8", right? |
23:27:11 | audiofile | the docs have that as a value |
23:27:22 | audiofile | not sure if that function signature is an example or default value |
23:29:10 | FromDiscord | <Yardanico> it's not |
23:29:15 | FromDiscord | <Yardanico> it's the actual default value |
23:29:25 | audiofile | ok nice |
23:29:31 | FromDiscord | <Yardanico> nim doc generator works on actual nim code so it's all from actual signatures |
23:40:18 | audiofile | wow |
23:40:22 | audiofile | that's so meta |
23:40:41 | audiofile | if your docs dont compile that means your code is wrong? O_o |
23:43:54 | FromDiscord | <Rika> Pretty much |
23:44:18 | FromDiscord | <Rika> You can also have tests that are run on docs creation and shown in the docs |
23:49:03 | FromGitter | <ynfle> https://nim-lang.org/docs/system.html#runnableExamples%2Cstring%2Cuntyped |
23:51:55 | * | Prestige quit (Quit: Prestige) |
23:54:09 | * | Prestige joined #nim |
23:54:09 | FromDiscord | <brainproxy> is there an annotation I can use to overcome the compiler failing with `Error: closure in spawn environment is not allowed`.↵↵The thing that's in closure is known by me to always have been allocated on the shared heap, and on the other side of the spawn I know to deallocate just once. |