00:15:18 | * | poopBot1 quit (Ping timeout: 268 seconds) |
00:27:24 | * | poopBot joined #nim |
00:57:01 | * | leorize quit (Ping timeout: 256 seconds) |
01:07:39 | * | leorize joined #nim |
01:15:04 | * | rockcavera joined #nim |
01:15:16 | * | xet7 quit (Quit: Leaving) |
01:16:03 | * | clyybber1 quit (Quit: WeeChat 2.4) |
01:59:35 | * | rnrwashere joined #nim |
02:01:37 | * | banc quit (Quit: Bye) |
02:14:11 | * | rnrwashere quit (Remote host closed the connection) |
02:21:30 | * | banc joined #nim |
02:30:29 | * | xace quit (Remote host closed the connection) |
02:51:30 | * | laaron quit (Remote host closed the connection) |
02:52:00 | * | laaron joined #nim |
03:04:50 | * | laaron quit (Remote host closed the connection) |
03:05:11 | * | laaron joined #nim |
03:12:32 | * | rnrwashere joined #nim |
03:12:38 | * | rnrwashere quit (Remote host closed the connection) |
03:12:51 | * | rnrwashere joined #nim |
03:14:26 | * | theelous3 quit (Ping timeout: 252 seconds) |
03:45:57 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
03:49:24 | * | Jesin quit (Quit: Leaving) |
04:03:48 | * | Jesin joined #nim |
04:09:45 | * | dddddd quit (Remote host closed the connection) |
04:23:02 | * | nsf joined #nim |
04:30:42 | * | vlad1777d quit (Ping timeout: 252 seconds) |
04:42:21 | * | kapilp joined #nim |
05:13:02 | * | ShalokShalom joined #nim |
05:18:20 | * | leorize quit (Quit: WeeChat 2.3) |
05:18:55 | * | narimiran joined #nim |
05:28:42 | * | odc quit (Read error: Connection reset by peer) |
05:30:06 | * | MD87 quit (Ping timeout: 252 seconds) |
05:31:15 | * | hoijui joined #nim |
05:33:39 | * | MD87 joined #nim |
05:33:56 | * | smitop quit (Quit: Connection closed for inactivity) |
05:34:32 | * | odc joined #nim |
05:57:27 | * | leorize joined #nim |
06:19:23 | * | PMunch joined #nim |
06:38:45 | * | solitudesf joined #nim |
06:49:05 | * | kapilp quit (Quit: Connection closed for inactivity) |
07:00:00 | * | gmpreussner quit (Quit: kthxbye) |
07:00:37 | * | krux02 joined #nim |
07:04:19 | * | gmpreussner joined #nim |
07:07:22 | * | solitudesf quit (Ping timeout: 244 seconds) |
07:13:01 | * | rnrwashere quit (Remote host closed the connection) |
07:13:38 | * | rnrwashere joined #nim |
07:17:33 | * | Vladar joined #nim |
07:17:54 | * | rnrwashere quit (Ping timeout: 252 seconds) |
07:21:59 | PMunch | I'm trying to wrap a C library in Nim, I've got c2nim to transform the header file for me, but I'm missing some types from sys/socket.h and netdb.h how do I go about fixing that? Do I need to wrap those headers myself as well? |
07:24:19 | Vladar | well, you can convert just the types required, I guess |
07:26:36 | leorize[m] | PMunch: see if posix module have them |
07:28:28 | PMunch | Hmm, it does have them, but by incompatible names |
07:28:45 | * | laaron quit (Remote host closed the connection) |
07:29:07 | * | laaron joined #nim |
07:32:03 | * | neceve joined #nim |
07:38:07 | PMunch | Okay, fixed those problems and wrote a simple test program |
07:38:31 | PMunch | But the C compiler fails with undefined reference errors |
07:39:35 | PMunch | Oh wait |
07:40:39 | PMunch | I was missing a linkin statement |
07:45:28 | PMunch | Now just to deal with the fact that Nim is a lot stricter about types than C.. |
07:48:49 | * | solitudesf joined #nim |
07:50:01 | * | kapilp joined #nim |
07:52:29 | PMunch | Hey, got it working :) |
07:53:22 | PMunch | Style insensitivity is golden for this kind of stuff, being able to write all my code in the same style even when it converts to a certain style in the C library is really nice |
08:05:01 | FromGitter | <kayabaNerve> PMunch: How is Nim stricter? |
08:05:24 | narimiran | while 1, from top of my head :D |
08:05:28 | PMunch | About types? |
08:05:34 | FromGitter | <kayabaNerve> Yeah |
08:05:42 | PMunch | Enums for example |
08:05:47 | FromGitter | <kayabaNerve> Ah |
08:05:58 | * | floppydh joined #nim |
08:06:05 | FromGitter | <kayabaNerve> So Nim creates distinct types for what C would consider the same? |
08:06:10 | PMunch | This library has defined a bunch of enums with names for different things, but the procedures that takes these variables are defined as taking ints |
08:06:30 | PMunch | Well Nim creates an enum, which isn't directly compatible with an int |
08:06:47 | PMunch | It's nothing worse than throwing on a couple cint conversions here and there though |
08:08:04 | FromGitter | <kayabaNerve> If you can cast it, it sounds like it is directly compatible |
08:08:47 | FromGitter | <kayabaNerve> :P |
08:17:01 | * | stefanos82 joined #nim |
08:21:00 | PMunch | Well, it is compatible, but Nim doesn't treat them like the same thing like C does |
08:23:36 | * | PMunch_ joined #nim |
08:25:54 | * | PMunch quit (Ping timeout: 244 seconds) |
08:28:38 | * | PMunch__ joined #nim |
08:31:30 | * | PMunch_ quit (Ping timeout: 272 seconds) |
08:32:55 | * | PMunch__ is now known as PMunch |
08:33:12 | PMunch | Hmm, is this a good way of doing MD4? https://rosettacode.org/wiki/MD4#Nim |
08:38:30 | leorize | a terrible way imo :p |
08:38:48 | leorize | use seq[byte] for non-text stuff :P |
08:39:36 | leorize | you can try to implement the algo from scratch :) |
08:41:30 | PMunch | Well I need it like that as a hash string |
08:44:29 | PMunch | Ugh, fun stuff porting crypto code from PHP, without really knowing PHP.. |
08:44:35 | PMunch | This is bound to fail :P |
08:45:59 | leorize | maybe reading the RFC will get you further :p |
08:51:26 | FromGitter | <ChristianWitts> Hmmm ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5ce50d8d9d64e537bceef495] |
08:54:06 | * | neceve quit (Remote host closed the connection) |
08:58:05 | narimiran | that's now the third time i hear about choosenim problems in last couple of days :/ |
08:58:51 | FromGitter | <ChristianWitts> It’s only the `self` update portion that’s having issues. `update stable` works |
08:59:50 | * | sz0 quit () |
09:00:49 | * | sz0 joined #nim |
09:07:40 | PMunch | leorize, hmm that was in fact helpful |
09:27:00 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
09:27:18 | * | laaron joined #nim |
09:35:32 | * | seni quit (Quit: Leaving) |
09:36:07 | poopBot | so about http://niv.github.io/websocket.nim/docs/0.3.0/websocket/server.html websocket server i want to share 1 class across all connections do i just dump 1 var up form server and will that work across all connections, duno if each connection is separete thread or what |
09:41:21 | * | neceve joined #nim |
09:43:05 | * | arecaceae quit (Remote host closed the connection) |
09:43:24 | * | arecaceae joined #nim |
09:48:35 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
09:48:45 | * | laaron- joined #nim |
09:55:08 | federico3 | how to read keypresses? |
09:56:47 | livcd | perverse question |
09:57:02 | livcd | anyone having a Nim program talking to a soap service? |
09:59:30 | * | ng0 joined #nim |
10:02:21 | federico3 | shashlick: https://github.com/genotrance/snip/blob/master/src/snip/key.nim#L16 do we still need all of this to handle keyboard input? |
10:07:07 | leorize | federico3: there's getch in the terminal module |
10:07:20 | federico3 | thanks |
10:07:56 | leorize | it can't do arrows though |
10:08:22 | federico3 | urgh |
10:08:30 | federico3 | nor function keys it seems |
10:08:40 | leorize | arrows on linux terminals are 3 bytes sent in one go |
10:08:42 | * | jjido joined #nim |
10:09:10 | federico3 | we need a better built-it |
10:09:42 | leorize | a getch_nonblocking is a start |
10:10:23 | leorize | with smt like that we can retrieve 2 bytes when the escape byte is detected |
10:10:38 | leorize | if can't find anything it probably just someone pressing esc |
10:20:22 | * | xace joined #nim |
10:20:29 | * | leorize quit (Quit: WeeChat 2.3) |
10:21:04 | FromGitter | <kaushalmodi> PMunch: About your comment "I'm trying to wrap a C library in Nim |
10:21:21 | FromGitter | <kaushalmodi> .. have you tried nimterop? |
10:27:51 | federico3 | PMunch: do you strictly need md4? |
10:36:20 | * | dddddd joined #nim |
10:42:19 | FromGitter | <kayabaNerve> MD4? |
10:42:25 | FromGitter | <kayabaNerve> Why would someone use MD4? |
10:42:32 | FromGitter | <kayabaNerve> Even MD5 isn't treated as secure anymore |
10:43:05 | leorize[m] | for interfacing with legacy protocols I think |
10:48:03 | PMunch | kaushalmodi, haven't tried it no. But I was looking at it if that helps :P |
10:48:22 | PMunch | federico3, I need to use MD4, this is for MSCHAPv1 |
10:48:53 | PMunch | kayabaNerve, ask Microsoft, I wouldn't use it if I was designing the protocol myself.. |
10:49:58 | * | lritter joined #nim |
10:50:50 | FromGitter | <kayabaNerve> PMunch: Fight the machine |
10:57:32 | WilhelmVonWeiner | if the .this. pragma is deprecated |
10:57:53 | WilhelmVonWeiner | was it replaced with a more nim-like way to do it |
10:58:28 | FromGitter | <jrfondren> not AFAIK. |
10:58:55 | narimiran | well, "a more nim-like way" is to have full qualification, without shortcuts ;) |
10:59:30 | WilhelmVonWeiner | lame, cheers |
10:59:38 | narimiran | cheers, lame |
11:09:35 | leorize[m] | WilhelmVonWeiner: see github.com/zevv/with |
11:16:46 | Zevv | https://utcc.utoronto.ca/~cks/space/blog/programming/GoIsGooglesLanguage One more reason I Nim |
11:16:56 | federico3 | we all Nim |
11:17:56 | Zevv | yes, but *why* |
11:19:21 | * | abm joined #nim |
11:20:32 | PMunch | WilhelmVonWeiner, there is also the cascade module |
11:21:11 | PMunch | I also miss the this pragma, for gamedev and other heavily object oriented tasks |
11:26:21 | PMunch | Zevv, in the same vein you can say that Nim is Araqs language |
11:26:39 | PMunch | Although it might be harder to picture him as an 800-pound gorilla :P |
11:27:09 | Zevv | In my time here I have seen a few examples of araq not agreeing, but stuff still happening |
11:27:25 | Zevv | probably not about the decisions he *really* cares about, but still |
11:32:03 | FromGitter | <Vindaar> small teaser about what I started working on: |
11:32:09 | FromGitter | <Vindaar> (https://files.gitter.im/nim-lang/Nim/cEIf/ggplotnim_preview.png) |
11:37:55 | FromDiscord_ | <nothing to no one> When should I use object vs ref object? |
11:38:04 | FromDiscord_ | <nothing to no one> When should I use object vs ref object when defining a new data type? |
11:38:38 | Araq | in doubt, use 'object', if you come from Python and don't understand value semantics, use ref |
11:42:47 | FromDiscord_ | <nothing to no one> Value semantics? |
11:43:33 | Araq | stuff is copied around |
11:44:57 | FromDiscord_ | <nothing to no one> I've written a decent amount of C, so I'm probably good there lol. Thanks though, I'll keep that "if in doubt" part in mind |
11:50:58 | xace | Vindaar: that looks nice, I look forward to trying it out :) |
11:55:49 | Zevv | but what a sucky name, ggpplotnim |
11:58:47 | shashlick | federico3 there might be a nimble lib that makes it easier now but that's what I had to do to get raw keys |
11:59:18 | shashlick | Was painful since I had to make kb maps and what not |
11:59:33 | Araq | shashlick, is the Nimble bug fixes that andreaferretti reported? |
12:01:12 | shashlick | The old one yes, is there a new one? |
12:04:04 | FromGitter | <Vindaar> @xace: thanks! I only just started working on the ggplot like interface, so it'll take a while until it even remotely covers ggplot's features. The backend (similar to R's Grid package) has most features I need now though. ⏎ @Zevv: :P |
12:04:32 | federico3 | shashlick: unfortunately your code is non-blocking |
12:05:20 | narimiran | @Vindar how about `nnplot`? :) |
12:05:31 | Zevv | I cant't even properly name my variables, let alone my projects |
12:07:38 | narimiran | or maybe XXplot since this is probably the 20th plotting attempt in nim? :D :D |
12:08:00 | PMunch | nothing to no one: https://peterme.net/nim-types-originally-a-reddit-reply.html |
12:08:38 | federico3 | shashlick: and the reader thread is using a busy loop :-o |
12:09:13 | FromGitter | <Vindaar> @narimiran haha xxplot. `nnplot` is actually kinda nice, although not sure if I want to drop the reference to "grammar of graphics" . But naming the package has time :D |
12:10:22 | narimiran | grogplot :) |
12:10:47 | narimiran | gra2plot :P |
12:13:00 | * | Kaivo joined #nim |
12:13:45 | FromDiscord_ | <nothing to no one> I want to convert a json config into a nim object. the config uses nested lists, are sequences the best thing to use for that? https://hastebin.com/afapewiyog.pl |
12:16:39 | * | hoijui quit (Ping timeout: 250 seconds) |
12:16:42 | Araq | shashlick, he replied on it about something not working |
12:16:53 | shashlick | @federico3 using all cpu? I can fix that |
12:18:55 | shashlick | Araq: do you mean this? https://github.com/nim-lang/nimble/pull/635#issuecomment-488645566 |
12:19:57 | shashlick | I fixed that in this https://github.com/nim-lang/nimble/pull/645 |
12:20:57 | Araq | ok nice |
12:21:03 | Araq | can you tag the Nimble version then? |
12:21:11 | Araq | 0.20 should come with the new Nimble |
12:28:20 | leorize[m] | Araq: is 0.20 coming anytime soon? |
12:28:40 | federico3 | shashlick: thehre's no sleep :) |
12:28:52 | narimiran | leorize[m]: yep |
12:29:22 | leorize[m] | gotta run some checks on Haiku then :) |
12:41:47 | shashlick | @federico3 I figured a nice way to be responsive without blocking in feud |
12:41:52 | shashlick | Will use that |
12:42:18 | shashlick | Araq will do, need to check if I can tag |
12:42:36 | shashlick | @dom96 nimble 0.10.0? |
12:48:12 | PMunch | Hmm, fun PHPs MD4 algorithm, and the one I imported from OpenSSL gives different results.. |
12:49:22 | PMunch | Oh no, wait.. |
12:49:41 | PMunch | The str2unicode function it passes it through converts to UTF16.. |
12:50:46 | federico3 | https://rosettacode.org/wiki/MD4#Nim ? |
12:50:56 | PMunch | Yeah |
12:51:57 | federico3 | a52bcfc6a0d0d300cdc5ddbfbefe478b nim is correct |
12:54:41 | * | Snircle joined #nim |
12:54:45 | shashlick | @federico3 - which OS you testing snip? |
12:55:03 | federico3 | Linux |
12:55:54 | * | hoijui joined #nim |
12:57:07 | * | hoijui quit (Remote host closed the connection) |
12:58:36 | * | theelous3 joined #nim |
13:00:00 | FromDiscord_ | <nothing to no one> Is there a way to map over json's JArray? |
13:00:47 | narimiran | nothing to no one: sequtils.map? |
13:02:48 | FromDiscord_ | <nothing to no one> It gives a type mismatch error |
13:03:37 | FromDiscord_ | <nothing to no one> looks like map wants an openArray, and I'm giving it `seq[JsonNode]` |
13:05:07 | FromDiscord_ | <nothing to no one> ohhhh my issue was in the proc I was passing to map, it has to have a var param |
13:05:23 | leorize[m] | openArray can match both array & seq |
13:07:21 | FromDiscord_ | <nothing to no one> hmmm maybe not. full error message https://hastebin.com/ecapapehef.md |
13:07:58 | FromDiscord_ | <nothing to no one> nvm figured it out, type mismatch on the function i was passing to map |
13:08:11 | federico3 | shashlick: how are you converting keys back to letters/numbers? |
13:09:11 | leorize[m] | federico3: here's how I handled arrows key: https://rosettacode.org/wiki/2048#Nim |
13:09:11 | federico3 | code.parseInt().char it seems |
13:09:39 | leorize[m] | good enough for a demo, but it's not the most reliable way |
13:09:58 | federico3 | leorize[m]: I'm getting A B C D from function keys as well |
13:10:18 | Zevv | haha, 2019 and still people are struggling reading keys |
13:10:37 | Zevv | unix tty handling is hell |
13:12:27 | federico3 | Zevv: the problem is in not having that in Nim or in a library |
13:14:19 | * | stefantalpalaru joined #nim |
13:15:37 | stefantalpalaru | Why is newException() not setting the "name" field? |
13:15:47 | stefantalpalaru | https://github.com/nim-lang/Nim/blob/master/lib/system.nim#L2890 |
13:17:23 | leorize[m] | stefantalpalaru: the docs said raises fill it |
13:20:35 | PMunch | Hmm, I have some imported procedures that takes a cstring, but my string starts with "\0" so when it converts it shows me an empty string |
13:21:24 | PMunch | And since it starts with 0 I can't do cast[cstring](regularString[0].addr) since it doesn't like to index to 0.. |
13:24:22 | leorize[m] | PMunch: find functions that take a string + size |
13:27:12 | PMunch | It does take string+size |
13:27:20 | PMunch | Or rather it takes a void pointer and a size |
13:27:31 | shashlick | @federico3: it is elaborate and ugly - https://github.com/genotrance/snip/blob/master/src/snip/keymap.nim |
13:27:39 | FromGitter | <jrfondren> so, it doesn't take a cstring. pass a ptr and size instead |
13:27:49 | shashlick | https://github.com/genotrance/snip/tree/master/src/snip/term |
13:28:02 | FromGitter | <jrfondren> because a string that begins with '\0' and *isn't* an empty string, certainly isn't a C string |
13:28:29 | shashlick | all to avoid ncurses |
13:28:52 | PMunch | Yeah I was confused by some other code, but the problem still remains, how to get a pointer to the buffer of a nim string |
13:29:01 | FromGitter | <jrfondren> addr(str[0]) |
13:29:14 | FromGitter | <jrfondren> maybe unsafeAddr |
13:29:32 | FromGitter | <jrfondren> but you want the zero'th index because strings and seqs have other data in front of that. |
13:29:35 | leorize[m] | <PMunch "Yeah I was confused by some othe"> cstring(string) |
13:29:47 | PMunch | [0] doesn't work since it starts with a 0, Nim complains.. |
13:30:00 | FromGitter | <jrfondren> where does Nim complain? |
13:30:15 | PMunch | Oh wait, it stopped complaining |
13:30:56 | federico3 | shashlick: https://github.com/genotrance/snip/blob/master/src/snip/key.nim#L40 is not correct: you might get 2 keys back-to-back |
13:31:41 | PMunch | I'm certain I tried myStr[0].addr before and it complained.. |
13:31:43 | federico3 | shashlick: https://github.com/genotrance/snip/blob/master/src/snip/key.nim#L42 are you concatenating integers? 12 & 34 collides with 123 & 4 |
13:33:44 | leorize[m] | PMunch: cstring(string) will give you the underlying buffer as well |
13:33:50 | leorize[m] | parts of stdlib uses it |
13:37:25 | shashlick | @federico3 - like i said it's ugly |
13:37:28 | shashlick | it is in raw mode |
13:38:12 | shashlick | i couldn't find any decent docs to map the numbers to keys |
13:38:24 | * | narimiran quit (Remote host closed the connection) |
13:38:30 | shashlick | nothing is cross-platform |
13:38:51 | * | narimiran joined #nim |
13:41:53 | PMunch | !eval echo len(cstring("\0hello world")) |
13:41:55 | NimBot | 12 |
13:42:16 | PMunch | Huh, why I tried to convert my string to a cstring it gave 0 |
13:42:26 | FromGitter | <jrfondren> a cstring is just going to be a pointer to the zero'th element, same as the other thing. |
13:42:40 | FromGitter | <jrfondren> of course a cstring-aware len is going to say zero |
13:43:06 | FromGitter | <jrfondren> what you're doing is forgetting what you're actually dealing with, but you're using tools that know what you're dealing with |
13:43:24 | FromGitter | <jrfondren> a string that begins with \0 is an empty c-string. so it's going to display as nothing. |
13:43:29 | PMunch | Yeah I know |
13:43:47 | PMunch | The problem was that the function I was passing it to also treated it as a 0 string |
13:44:11 | FromGitter | <jrfondren> you're passing a length to that function as well, right? |
13:44:33 | PMunch | Now I am, that's what was causing the issue |
13:44:54 | FromGitter | <jrfondren> either it's poorly coded and doesn't really accept binary data, or you're confused about something. |
13:45:20 | FromGitter | <jrfondren> you weren't passing a length before? |
13:47:01 | shashlick | @federico3 - fixed the busy loop in snip |
13:47:18 | * | salewski joined #nim |
13:47:48 | PMunch | jrfonden, yeah it was my fault, I wasn't passing a length |
13:48:21 | salewski | !eval assert not [2, 3].contains(1) |
13:48:22 | NimBot | Compile failed: in.nim(1, 8) Error: type mismatch: got <proc (cond: bool, msg: string): typed, bool> |
13:48:27 | FromGitter | <jrfondren> that !eval result is maybe a bug with static strings |
13:48:52 | narimiran | salewski: use devel, it works in it ;) |
13:48:56 | PMunch | There was a field in that function I had never used, just always left at -1, which worked fine for string and integers, since it knew how to handle those (I also passed a type identifier), but with the binary data it needed a length :) |
13:49:01 | federico3 | shashlick: you might get 2 consecutive keys sometime |
13:49:19 | PMunch | Now just to figure out how to traverse a C style linked list in Nim.. |
13:49:26 | FromGitter | <jrfondren> ah. I guess it treats the string as a C string if not given an explicit length |
13:49:29 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
13:50:06 | shashlick | @federico3 it should only do that when it gets a control char which expects a follow up char |
13:50:08 | salewski | narimiran, yes I know. Got an issue report that gintro does not compile with such an assert for v0.19.6 |
13:50:11 | shashlick | 0, 27 and 224 |
13:50:18 | salewski | Stange, i never noticed. |
13:50:22 | FromGitter | <jrfondren> @PMunch dereference with [] |
13:50:35 | narimiran | salewski: there is a workaround if you want |
13:50:40 | federico3 | shashlick: https://github.com/genotrance/snip/blob/master/src/snip/key.nim#L42 |
13:50:56 | FromGitter | <jrfondren> if it's a good list with the cdr pointer at zero, the third element of the list would be at head[][][].val |
13:51:08 | federico3 | the while might encounter [79, 81, 27, 79, 81] |
13:51:19 | salewski | Sure, but I hesitate to make a new gintro release just fot this issue... |
13:51:44 | salewski | I think I will wain if more people complain. |
13:51:54 | salewski | Bye. |
13:52:10 | * | salewski quit (Client Quit) |
13:53:00 | FromGitter | <kaushalmodi> shashlick, federico3: I believe I'll need the keymap support soon .. |
13:53:06 | narimiran | salewski: it is as simple as adding parentheses: `assert(not [2, 3].contains(1))` |
13:53:22 | FromGitter | <kaushalmodi> I might need to design a selector from multiple options thingy like the Go peco |
13:53:28 | federico3 | kaushalmodi: uh? |
13:53:37 | shashlick | @federico3 - not much choice since you get a long stream of numbers for some keys |
13:53:39 | shashlick | https://github.com/genotrance/snip/blob/master/src/snip/term/xterm.txt |
13:53:40 | FromGitter | <kaushalmodi> https://github.com/peco/peco |
13:53:52 | * | stefantalpalaru quit (Quit: stefantalpalaru) |
13:54:32 | shashlick | if there's a way to do cross-platform getch with all control keys, i'll throw all this code out right away |
13:54:37 | shashlick | termbox is only posix |
13:54:37 | * | leorize joined #nim |
13:56:49 | PMunch | Ah, it was another bug in c2nim |
13:57:08 | shashlick | what are you wrapping PMunch |
13:57:39 | Zevv | I volunteer to spend some time on proper keyboard input, sync and async, the posix side |
13:57:48 | Zevv | but I need someone else to jump in for the windows part |
13:58:05 | PMunch | "myLinkedList = myLinkedList.next" worked fine, but the "typedef struct mll {} MyLinkedList;" was cimported as "struct MyLinkedList" and not "struct mll" or "MyLinkedList" |
13:58:14 | PMunch | shashlick, radcli |
13:58:21 | PMunch | A library to write Radius clients |
13:59:55 | shashlick | radcli.h? |
14:00:24 | Araq | Zevv, I can run code on windows fwiw |
14:01:17 | shashlick | i can help on windows too |
14:01:21 | Zevv | well, 'run' is only part of it. I could test with wine and stuff, but finding out which API's to use and getting that to work with async does not sound like a fun job with my total lack of win32 api experience |
14:01:41 | * | vivus joined #nim |
14:01:43 | shashlick | see that's the issue - that way you can wrap termbox and call it a day |
14:01:53 | shashlick | there's many posix libs that make it easy |
14:01:58 | shashlick | libtickit or something |
14:02:01 | FromGitter | <kaushalmodi> Zevv: I'll test it on posix :) |
14:02:06 | PMunch | shashlick, yes radcli.h |
14:02:10 | Zevv | yeah of course. But if you want to go portable, the keymap definition is also part of the game |
14:02:16 | shashlick | PMunch - DLL or compiling in? |
14:02:32 | Zevv | on linux these days the default is libxbk, even on non-X systems like wayland and libevent |
14:02:44 | PMunch | shashlick, so far I'm compiling it in |
14:03:14 | Zevv | but making this portable to windows probably requires a complete new keymap definition, which is then a again a huge pain in the behind if you want to mix that with existing event handling api's. |
14:03:41 | shashlick | tell me about it - see my poor man's keymaps in snip |
14:03:55 | shashlick | works cross platform but is just so sad |
14:04:14 | FromGitter | <kaushalmodi> How do Go and other language deal with cross-platform keymaps? Or do they? |
14:04:36 | Zevv | and how deep do you go - expose scan codes? what to do with key repeats and raw up/down events? |
14:04:53 | shashlick | termbox-go works on windows as well |
14:04:59 | Zevv | What about generating the symbols that come out. Hitting three keys on a french keyboard gives ç. Do you want to handle that? |
14:05:06 | * | PMunch quit (Remote host closed the connection) |
14:05:09 | federico3 | getch does not look at scancodes (also you don't want to go that far) |
14:05:17 | shashlick | nodejs also has its own lib |
14:05:51 | shashlick | Zevv: i was making a text editor so needed arrow keys, ctrl/alt, etc. |
14:06:29 | Zevv | getting modifier keys is pretty much impossible on the terminal level |
14:06:41 | Zevv | that's usually exposed through gui libs or libevent |
14:07:52 | * | nsf quit (Quit: WeeChat 2.4) |
14:10:09 | shashlick | i got it to work with raw mode |
14:10:39 | FromGitter | <jrfondren> sure, with terminals you just have to make assumptions about how certain codes were given. that works for what TUIs expect but you get some overlap, e.g. ctrl-[ and ESC map to the same code. |
14:12:09 | Zevv | what's the node-way? |
14:12:20 | leorize | libuv I believe |
14:12:25 | leorize | neovim uses it |
14:16:11 | FromGitter | <jrfondren> Forth just gives you `KEY KEY? EKEY EKEY?`. KEY blocks and returns a byte (or an error). KEY? returns true if there's anything to get. EKEY blocks and returns an int (or an error), including bytes local constants like K-UP K-DOWN after translating multi-byte codes. On posix KEY and EKEY change the terminal mode during their execution; there's no need for it to be raw all the time if you're not going full curses. |
14:16:48 | Zevv | libuv is only event handling, we have the ioselectors for that |
14:16:56 | FromGitter | <jrfondren> that plus some constants that could have windows and other local definitions, plus a way to change the delay on ESC (no delays' fine locally, but people also use terminal programs over ssh) |
14:17:23 | FromGitter | <jrfondren> would be comfortable enough for many tasks. |
14:17:42 | Zevv | that's all pretty much doable without external libs on posix. It's reading terminals and a bit of tcgetattr/tcsetattr |
14:17:50 | FromGitter | <jrfondren> but seriously, for a text editor you should just get curses. efficiently redrawing the screen is a real problem and you get it with a text editor as soon as you want to move the display up by one line. |
14:18:16 | Zevv | yeah but we're talking keyboard input, right - curses is so much more |
14:18:39 | FromGitter | <jrfondren> you'll still want other stuff in your not-curses terminal lib, like the stuff in man console_codes on linux |
14:19:11 | Zevv | yeah, but the linux consule is just another terminal - there's tons more, and they are still not compatible |
14:19:33 | Zevv | try to read ctrl-shift-F1 in xterm, rxvt, gnome terminal, the linux console and a mac terminal - good luch |
14:19:42 | Zevv | luck |
14:19:53 | FromGitter | <jrfondren> yeah, but this has been the case forever, which is why no terminal program wants you to insert ctrl-shift-F1 |
14:20:14 | FromGitter | <jrfondren> what's wanted is fairly portable. |
14:20:34 | shashlick | PMunch - almost done |
14:21:56 | FromGitter | <jrfondren> anyway, my recommendation is to mimic Forth at least as far as doing tcsetattr within the key-getting function. Change the terminal mode every single time a key's wanted, and then set it back. That'll be easier to work with in a lot of ways. |
14:22:46 | shashlick | @jrfondren: I am doing that but at the beginning of the program - https://github.com/genotrance/snip/blob/master/src/snip/getch.c |
14:23:08 | FromGitter | <jrfondren> right. that's the opposite of what I recommend :) |
14:23:26 | Zevv | jrfondern: kind of makes sense. but if you ^C or kill the program, you'd still have to catch the exit and restore the terminal |
14:23:39 | FromGitter | <jrfondren> sure. |
14:23:47 | vivus | How do I save a table to a file, I tried `writeFile("myfile.txt", mytable)` but it gave an error. Do I need to save it line-by-line? |
14:24:30 | FromGitter | <jrfondren> you need to decide on some way to serialize the data, and do that. |
14:24:54 | vivus | serialize the data? |
14:24:59 | FromGitter | <jrfondren> you're working with csv, right? so emitting csv might be fine. |
14:25:49 | vivus | so I need to make each line in the table to output as a string separated by tabs/commas and then use "write" or whichever save-by-line proc exists? |
14:26:13 | FromGitter | <jrfondren> your table is held in memory in a manner that's convenient in a lot of ways but "someone could look at the sequence of raw bytes the table is within and make sense of it" is not one of those ways. Files though are just a sequence of bytes, and usually you want to be able to make sense of it when you look at it. |
14:26:26 | FromGitter | <jrfondren> yeah that'll work. |
14:28:49 | * | kapilp quit (Quit: Connection closed for inactivity) |
14:28:49 | FromGitter | <jrfondren> @vivus, it might be easiest to use the `json` module. |
14:29:10 | FromGitter | <jrfondren> it has `proc `%`T (table: Table[string, T] | OrderedTable[string, T]): JsonNode` f.e. |
14:29:19 | vivus | interesting. That might work too and I could use JSON to render it as a simple webpage too |
14:29:38 | vivus | great suggestion @jrfondren <3 |
14:32:12 | Araq | damn, 6 open bugs left |
14:32:20 | Araq | before we get it down to 1200 ... |
14:33:26 | Zevv | say "issues" not "bugs" |
14:34:25 | FromGitter | <jrfondren> an issue could be anything. issue: "please adopt my anime character as the official representative of Nim" |
14:35:34 | leorize | @jrfondren: that might have happened |
14:36:07 | FromGitter | <jrfondren> sure. it happened to Ruby, before they decided on a picture of a semi-precious gem (???) |
14:37:32 | leorize | https://github.com/nim-lang/RFCs/issues/104 |
14:37:34 | leorize | not anime though |
14:40:51 | * | a_b_m joined #nim |
14:40:58 | Zevv | leorize: watch out commenting on these things, it might hint narimiran about your age |
14:41:24 | * | narimiran quit (Remote host closed the connection) |
14:41:36 | leorize | don't worry, even google got it wrong ;) |
14:41:51 | * | narimiran joined #nim |
14:42:19 | narimiran | Zevv: too late for that. until proven otherwise, i've set leorize's age in my head |
14:42:52 | Zevv | around 42, right |
14:43:04 | narimiran | ...and i'm jealous of him for being such a smart young boy |
14:43:29 | Zevv | jealous because of the smartness of because of the age |
14:43:43 | narimiran | because of smartness AT that age |
14:43:43 | * | abm quit (Ping timeout: 248 seconds) |
14:43:46 | Zevv | :) |
14:44:51 | shashlick | @PMunch - where do i find radlogin.h |
14:44:59 | narimiran | Zevv: my accomplishments at that time? i managed to win Civilization, or something along those lines |
14:45:19 | Zevv | shashlick: it's part of freeradius if i recall correctly |
14:45:35 | Zevv | narimiran: well, look where it got you, you're pretty civilized these days |
14:45:59 | narimiran | :D |
14:46:18 | shashlick | well, I took this as far as I could |
14:46:26 | shashlick | @PMunch - radcli wrapper - http://ix.io/1JJP/Nim |
14:47:33 | shashlick | output looks like this - http://ix.io/1JJR/Nim |
14:47:52 | shashlick | right now, it fails while compiling the c files since it looks for radlogin.h |
14:48:58 | leorize | narimiran: I'm not that young |
14:48:58 | leorize | but I won't say that I'm not old ;) |
14:48:58 | leorize | but I won't say that I'm old ;) |
14:48:58 | leorize | :p |
14:48:58 | * | leorize quit (Remote host closed the connection) |
14:49:51 | narimiran | leorize until proven otherwise, you're born in 200x |
14:50:01 | * | leorize joined #nim |
14:52:12 | Zevv | well he can tell animie, he might as well have been a teen in the 90's |
14:56:25 | * | floppydh quit (Quit: WeeChat 2.4) |
15:01:22 | * | fredrik92 joined #nim |
15:01:29 | federico3 | shashlick: any way to support light background in snip? |
15:02:38 | narimiran | burn the witch!!! |
15:02:49 | federico3 | ? |
15:03:11 | narimiran | light background, a clear sign of a witch |
15:03:31 | federico3 | https://ux.stackexchange.com/questions/53264/dark-or-white-color-theme-is-better-for-the-eyes |
15:04:02 | shashlick | should be doable - is there a way to detect background and adapt colors? |
15:04:09 | shashlick | or we need some config option |
15:04:16 | federico3 | a simple flag would do :) |
15:05:05 | shashlick | okay sounds fair - need to figure out which colors stand out |
15:05:49 | FromGitter | <Vindaar> light background is good when working with a laptop outside (or maybe I become a witch in sunlight?) |
15:05:59 | shashlick | colors are hard-coded in ui.nim right now - will need to make it a config file or something |
15:06:24 | shashlick | so snip is useful for you? i use it quite often when wanting to quickly test code |
15:06:55 | shashlick | should port some of that compile code into feud |
15:09:15 | federico3 | shashlick: not much with the current colors :-/ |
15:13:48 | * | rnrwashere joined #nim |
15:15:41 | * | rnrwashere quit (Remote host closed the connection) |
15:16:17 | * | rnrwashere joined #nim |
15:17:21 | * | rnrwashere quit (Remote host closed the connection) |
15:17:38 | * | rnrwashere joined #nim |
15:20:13 | * | neceve quit (Ping timeout: 246 seconds) |
15:20:33 | shashlick | okay making it configurable |
15:28:56 | * | neceve joined #nim |
15:33:40 | * | rnrwashere quit (Remote host closed the connection) |
15:34:08 | * | rnrwashere joined #nim |
15:34:33 | * | stefantalpalaru joined #nim |
15:37:49 | stefantalpalaru | How can I avoid type conversions in proc parameters? https://gist.github.com/stefantalpalaru/d07d51e2587510946162946352a611eb |
15:48:11 | shashlick | @federico3 - colors are now configurable with a colors.txt |
15:48:13 | shashlick | see ui.nim |
15:48:20 | federico3 | thanks! |
15:48:35 | shashlick | please let me know if you face any other issues |
15:53:20 | FromGitter | <jrfondren> @stefantalpalaru, don't use OO if you don't want it. |
15:54:31 | shashlick | i'll evaluate libuv - seems like a possible alternative for terminal keyboard |
15:55:39 | stefantalpalaru | @jrfondren - there's nothing about OOP that says there should be hidden type conversions in function parameters. |
15:57:05 | FromGitter | <jrfondren> there's inheritance. |
15:59:39 | stefantalpalaru | And it's being ignored by failing to conserve derived types when the parameter is being declared as the base type. |
16:00:42 | FromDiscord_ | <treeform> what happened to queues? https://nim-lang.org/docs/queues.html where they removed in 0.19.6? |
16:02:10 | FromDiscord_ | <treeform> https://github.com/nim-lang/Nim/commit/cceb28b5eb9bae4f0fc364899858018a1bf480ae |
16:02:16 | FromDiscord_ | <treeform> I guess they were. |
16:02:27 | shashlick | nodejs uses blessed |
16:02:50 | narimiran | @treeform use deques https://nim-lang.github.io/Nim/deques.html |
16:04:20 | shashlick | well i've gone down the terminal keyboard rathole before with nothing to show for it |
16:04:29 | shashlick | if anyone has a better idea, please let me know |
16:05:42 | FromGitter | <jrfondren> @stefantalpalaru, you can use `error of Error1`in `t1` to see if it's an Error1 or not. |
16:07:19 | stefantalpalaru | Yes, that works. Now how do I make it have its original type? |
16:08:54 | FromGitter | <jrfondren> one option's to write a function that accepts the original type instead of a parent. Otherwise, I'd have to look it up. |
16:10:08 | stefantalpalaru | As you can guess, the original proc is being used for custom exception types. Making dozens of variants of it is not an option. |
16:10:41 | vivus | @jrfondren I can't find this in the documentation: `%`T (table: Table[string, T] | OrderedTable[string, T]): JsonNode` |
16:11:11 | FromGitter | <jrfondren> @vivus, https://nim-lang.github.io/Nim/json.html#%25 |
16:12:58 | vivus | @jrfondren the syntax is unclear to me. is it: `var js = %T[mytable]` or `var js = %[T](mytable)` ? |
16:13:25 | vivus | ok I tried both and neither work |
16:13:34 | FromGitter | <jrfondren> it's %mytable or %(mytable) |
16:14:02 | vivus | `Error: type mismatch: got <TableRef[system.string, tuple of (string, seq[string])]>` |
16:15:02 | vivus | ok found the error, sorry |
16:15:23 | FromGitter | <jrfondren> what was the error? |
16:17:13 | FromGitter | <jrfondren> @stefantalpalaru, what's the actual problem? if you raise the exception without "restoring its original type" it still gets caught by exception handlers looking for Error1 |
16:17:27 | FromGitter | <jrfondren> https://nim-lang.github.io/Nim/manual.html#exception-handling-except-clauses has an example of casting though |
16:20:17 | stefantalpalaru | That's exactly the problem: it no longer matches the custom exception type in "except" blocks. |
16:22:44 | * | krux02 quit (Remote host closed the connection) |
16:22:48 | stefantalpalaru | Here's with actual types: TransportError inherits from AsyncError which inherits from CatchableError. Once the type has been converted to Exception, by passing it to a "proc foo(error: Exception)", "except CatchableError:" no longer catches it. |
16:23:11 | FromGitter | <jrfondren> https://gist.github.com/jrfondren/de4ab3f935e55a4fd9c44f8fb81a145b <- seems to work here. |
16:24:53 | FromGitter | <jrfondren> that also works after I raise a child of Error1. the child still gets caught by its specific error handler. |
16:25:16 | FromGitter | <jrfondren> ah, but you're not using the specific type. |
16:25:40 | FromGitter | <jrfondren> a child of Error1 still gets caught by an Error1 handler. |
16:29:13 | stefantalpalaru | Yes, I can confirm that. Back to the drawing board. |
16:29:25 | FromGitter | <jrfondren> I'll believe that there's some real problem here. disruptek and a few other people complained about exceptions a while back. Maybe if you approach it as a bug you'll be able to get a good example for an github issue. |
16:30:18 | FromGitter | <jrfondren> or there might already be an issue for it, like this: https://github.com/nim-lang/Nim/issues/11118 |
16:39:09 | * | laaron- quit (Quit: ZNC 1.7.1 - https://znc.in) |
16:39:27 | * | laaron joined #nim |
16:46:00 | vivus | @jrfondren a noob error (forgot to import), but after doing so, I am getting: `template/generic instantiation from here ... Error: undeclared field: 'data'` |
16:46:38 | FromGitter | <jrfondren> sounds like you're accessing an undeclared field? |
16:47:44 | * | nsf joined #nim |
16:48:09 | vivus | @jrfondren yeah in some of the tuples, they are empty. |
16:48:22 | narimiran | vivus: show us your code, please |
16:49:25 | vivus | (this is by design, as some fields won't have a translation) - perhaps I should exclude those, as non-translated fields have no value for me |
16:52:44 | vivus | ill be back later. gotta run now. ty for the help so far |
16:53:45 | * | vivus quit (Remote host closed the connection) |
16:57:09 | * | PrimHelios_ joined #nim |
16:57:35 | * | xet7 joined #nim |
16:57:52 | * | PrimHelios quit (Ping timeout: 246 seconds) |
16:59:17 | * | laaron- joined #nim |
16:59:29 | * | laaron quit (Remote host closed the connection) |
17:00:18 | * | NimBot joined #nim |
17:07:51 | * | jjido_ joined #nim |
17:27:28 | * | laaron- quit (Quit: ZNC 1.7.1 - https://znc.in) |
17:28:02 | * | laaron joined #nim |
17:31:09 | * | Trustable joined #nim |
17:31:56 | * | Jesin quit (Quit: Leaving) |
17:34:21 | * | leorize quit (Ping timeout: 256 seconds) |
17:34:48 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
17:35:09 | * | laaron joined #nim |
17:35:39 | * | Jesin joined #nim |
17:36:29 | * | leorize joined #nim |
17:48:20 | * | gangstacat joined #nim |
17:49:44 | FromGitter | <alehander42> hm |
17:49:49 | FromGitter | <alehander42> does somebody run nimkernel |
17:49:51 | FromGitter | <alehander42> with new nim |
17:49:56 | FromGitter | <alehander42> i get missing appendString |
17:51:28 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
17:51:44 | * | laaron joined #nim |
17:52:58 | FromGitter | <alehander42> https://github.com/nim-lang/Nim/commit/a85d3879282a15e85ce9dd18b9a5bf020096a76c |
17:53:07 | * | gangstacat quit (Client Quit) |
17:53:07 | FromGitter | <alehander42> this fixed a previous bug |
17:53:10 | FromGitter | <alehander42> with that |
17:53:19 | FromGitter | <alehander42> hm how to find |
17:53:23 | FromGitter | <alehander42> what else is invoking |
17:54:39 | * | fredrik92 quit (Ping timeout: 248 seconds) |
18:25:25 | * | ShalokShalom43 joined #nim |
18:31:24 | * | jjido_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
18:33:44 | * | sz0 quit (Quit: Connection closed for inactivity) |
18:36:54 | * | neceve quit (Read error: Connection reset by peer) |
18:44:34 | * | ShalokShalom43 quit (Remote host closed the connection) |
18:44:34 | * | ShalokShalom quit (Remote host closed the connection) |
18:47:12 | * | ShalokShalom joined #nim |
18:55:53 | * | jxy_ quit (Quit: leaving) |
18:56:11 | * | jxy joined #nim |
19:09:19 | poopBot | https://hastebin.com/lihabejosa.cs |
19:10:10 | poopBot | ^^^ need magic input from guild masters |
19:18:40 | * | rnrwashere quit (Remote host closed the connection) |
19:19:38 | poopBot | i tyred addign {.closure, gcsafe.} after async but that didnet wokr |
19:20:08 | rayman22201 | because it's not gc safe lol. |
19:20:25 | rayman22201 | accessing a global like that will never be gc safe |
19:21:33 | poopBot | so what should i do then, annote it unsafe or what |
19:22:14 | poopBot | is there some turtorial about this |
19:23:05 | * | Vladar quit (Remote host closed the connection) |
19:23:32 | rayman22201 | good question. Maybe the Nim book? idk |
19:24:03 | rayman22201 | don't use global variables. They are almost always bad. |
19:24:58 | poopBot | i hate reading books, so how to implement singleton if no globar variable? |
19:25:44 | poopBot | meyeb this will help i go read https://nim-lang.github.io/Nim/manual.html#threads |
19:26:37 | * | cyraxjoe quit (Ping timeout: 246 seconds) |
19:26:59 | * | elrood joined #nim |
19:27:40 | rayman22201 | You won't read books but you will read websites? lol... |
19:28:27 | rayman22201 | singletons are also generally bad desing |
19:28:29 | rayman22201 | design |
19:28:32 | rayman22201 | use a database |
19:28:37 | rayman22201 | that's what they were built for |
19:29:37 | poopBot | so waht if i am making a gameserver like duno cs go i should use a DB for storing positions and aiming ??? |
19:30:10 | * | vivus joined #nim |
19:30:19 | poopBot | did you read book? does it cower my issue? |
19:30:37 | rayman22201 | You can either wrap your singleton with accessor procs that lock (or use lockfree datastructures), or using message passing, i.e. channels. |
19:31:00 | vivus | is this valid syntax: `and y.row[1] not in table2` ? it gives me an error when I try to run it |
19:31:44 | rayman22201 | don't assume because your game is turn base that you will never have race conditions. |
19:32:00 | narimiran | vivus: use `notin`, without space |
19:32:22 | poopBot | accesor procs that lock -- SOUNDS LIKE WHAT I WANT |
19:32:38 | rayman22201 | https://livebook.manning.com/#!/book/nim-in-action/chapter-6/ |
19:33:23 | rayman22201 | specifically chapter 6.5 "Dealing with race conditions" |
19:34:00 | poopBot | ty will read up |
19:35:48 | vivus | narimiran: can you tell me where my logic is flawed: https://dpaste.de/YFn3 ? the `elif` deletes all the keys except 1 |
19:35:56 | * | nsf quit (Quit: WeeChat 2.4) |
19:37:43 | narimiran | vivus: what are mytable and table2? |
19:38:27 | * | elrood quit (Remote host closed the connection) |
19:38:34 | vivus | narimiran: mytable = newTable[string, (string, seq[string])]() ... table2 = newTable[string, string]() |
19:41:22 | narimiran | first off, does line 17 really work when you uncomment that part? |
19:41:42 | vivus | narimiran: yeah, that works as expected |
19:42:15 | narimiran | well, "working as expected" is unexpected for me :D you can delete elements while iterating over it?! |
19:42:36 | rayman22201 | sorry for coming off like an ass @poopBot. Honestly that error message is not as good as it could be, and there really aren't enough tutorials for Nim in general (yet :-P). If you can catch Dom96's attention, he is the ultimate expert on async in Nim. |
19:43:39 | narimiran | vivus: at least on devel, that should give you an AssertionError |
19:44:09 | vivus | narimiran: yeah it does work. it deletes the item |
19:45:04 | FromGitter | <jrfondren> @narimiran, would you want an error if you iterated over an array[10, int] while mutating it? |
19:45:35 | poopBot | rayman22201, np i am thick skined and grown on playing fallout and ganging in hood so cant touch me xD |
19:47:35 | narimiran | vivus: here is the simplest example: http://ix.io/1JLg this raises AssertionError (unless you are in the release mode) |
19:47:52 | vivus | what is the latest stable version? 0.19.4? |
19:48:11 | narimiran | vivus: 0.19.6; but that AssertionError is only in devel |
19:48:31 | narimiran | so even if it works for you now, it won't work the next week ;) |
19:49:16 | vivus | my code is a bit different though. I am checking if the value is empty, not if the key exists |
19:49:21 | FromGitter | <jrfondren> well that's #2 for "break it for no reason" features coming from devel |
19:49:32 | vivus | let me update |
19:49:51 | narimiran | @jrfondren one thing is `a[i] = newValue`, other thing is resizing of seq |
19:51:54 | * | vlad1777d joined #nim |
19:52:04 | narimiran | without that i think i could do funny things with adding stuff to a table while iterating over it |
19:53:10 | FromGitter | <alehander42> Araq, it seems []= |
19:53:16 | FromGitter | <alehander42> somehow triggers appendString |
19:53:20 | FromGitter | <jrfondren> why are you checking the length of the table instead of the length of seq that's backing the table? |
19:53:35 | FromGitter | <jrfondren> you're erroring out on stuff that won't actually break anything. |
19:53:57 | narimiran | jrfondren: it is faster :P |
19:54:18 | FromGitter | <jrfondren> are you sure about that? |
19:54:53 | narimiran | vivus: "I am checking if the value is empty, not if the key exists" still the same (http://ix.io/1JLk), you shouldn't do that |
19:55:02 | narimiran | @jrfondren i am |
19:55:18 | vivus | does it still cause an error/ |
19:55:21 | vivus | *? |
19:55:27 | narimiran | len(table) = table.counter |
19:55:58 | FromGitter | <jrfondren> yes, and seqs also have a length field |
19:56:23 | narimiran | vivus: you shouldn't modify the table you're iterating over, it doesn't matter how you write your condition |
19:56:33 | narimiran | @jrfondren ah, you got me there :) |
19:57:01 | vivus | narimiran: this is why I was trying to get the `elif` correct, so that I could avoid doing this type of checking |
19:57:59 | FromGitter | <jrfondren> well I'll pause my aggravation for now but I promise that one day, maybe not today, maybe not tomorrow, but one day, I'm going to be really annoyed about this restriction. |
19:59:23 | FromGitter | <jrfondren> but I guess a workaround at that time will be -d:release |
19:59:24 | narimiran | @jrfondren: you might be right, checking if the length of the seq underneath has changed might be "more correct", but that could lead to more questions |
19:59:50 | narimiran | "how come i can add a key 3 times, but not the 4th time?" |
20:00:28 | FromGitter | <jrfondren> questions aren't so bad if you have documentation |
20:00:51 | narimiran | but why are you so upset about this? is this something that you regularly (ab)use? |
20:01:07 | FromGitter | <jrfondren> no, I just said that I was pausing my aggravation. |
20:01:14 | vivus | narimiran: how can I make the `elif` work? |
20:02:06 | narimiran | vivus: why do you even need `if y.row[0] in mytable` part? see `del` documentation: "Deletes ``key`` from hash table ``t``. Does nothing if the key does not exist." |
20:02:36 | FromGitter | <Vindaar> @poopBot: something like this might work for your case: http://ix.io/1JLo/nim ⏎ I'm using this sort of approach myself, but I never have to serve several clients at the same time. So not sure if the server will handle those properly right now (didn't test the code). The communication between main thread and callbacks should work though |
20:03:30 | FromGitter | <jrfondren> @narimiran, also a more amusing example is "why, when I add an 'x' key during iteration, does that key not show up, but when I add an 'A' it does show up during the iteration?" |
20:03:54 | vivus | narimiran: I updated the paste to show the first part too: https://dpaste.de/vJ9F |
20:03:57 | dom96_ | poopBot: What are you trying to do with threads? |
20:04:01 | * | dom96_ is now known as dom96 |
20:04:01 | * | dom96 quit (Changing host) |
20:04:01 | * | dom96 joined #nim |
20:05:26 | poopBot | hmm am making poker game for fun, i finished logic part of figuring out best hands and stuff, now i want to use websockets and basicly i just want to make a singleton where pokergame hepends and process inuput form websockets |
20:06:05 | dom96 | you don't need threads for this |
20:07:18 | poopBot | so how then should i acces an global objec from this webscoket thing |
20:07:32 | poopBot | https://hastebin.com/lihabejosa.cs |
20:07:41 | poopBot | here my inital question, |
20:08:35 | poopBot | @Vindaar: ty will check that too |
20:08:43 | narimiran | vivus: this is just moving the code around, but see if this still doesn't work: http://ix.io/1JLr |
20:08:46 | FromGitter | <jrfondren> @poopBot, make it .threadvar. |
20:09:58 | FromGitter | <jrfondren> you don't actually need a program-wide singleton; you just need gcsafe-marked procs all running under the same thread to be able to access shared data |
20:10:06 | dom96 | yeah ^ |
20:11:56 | poopBot | ok i think i got it |
20:15:42 | * | lritter quit (Quit: Leaving) |
20:22:56 | poopBot | https://hastebin.com/evolitoyes.cs |
20:24:03 | poopBot | so its working, just it gives me warning about this process that its not gcsafe (cuz i makred it .gcsafe.) so cuz myani is GC destoryed until i terminate program all this is good right |
20:24:51 | poopBot | am raning 4 cleint instances and my pig just reached 740+ years |
20:25:09 | poopBot | i frogot to add yeast after getage() |
20:26:05 | poopBot | 'incmyani' is not GC-safe as it accesses 'myani' which is a global using GC'ed memory [GcUnsafe2] |
20:29:47 | * | narimiran quit (Remote host closed the connection) |
20:30:58 | poopBot | i need to learn to write, i just read what i typed and its really hard to figure out what i wanted to say :) |
20:32:12 | poopBot | so my question is, so it gives me warnings about each proc that is unsafe, should i ignore that warning or do i need to learn up, am atm reading about sahred memory 6.5 |
20:34:05 | FromGitter | <jrfondren> make it .threadvar. |
20:36:12 | FromGitter | <jrfondren> typos within words are relatively easy to read. what's harder is deliberate slang like 'cuz'. the hardest thing to understand was that you were aging a pig :p |
20:36:39 | poopBot | hmm, sory but you all little confusing me, first person pointed me to shared memory and locks, second person gived me a channel meyeb working thing, thrid person told me to use threadward, 4th person told me to just use gcsafe procs |
20:37:29 | rayman22201 | *facepalm* too many chefs in the kitchen lol |
20:37:39 | FromGitter | <jrfondren> did anyone really tell you to use gcsafe procs? |
20:37:52 | poopBot | i think you need now to death so i can only serve 1 master |
20:38:24 | poopBot | " you just need gcsafe-marked procs all running under the same thread to be able to access shared data" |
20:38:31 | poopBot | or meybe i got it wrong |
20:38:37 | FromGitter | <jrfondren> that wasn't me telling you to use gcsafe procs. that was me telling you to use threadvar |
20:39:06 | poopBot | ok then so will focuse on threadvar |
20:39:31 | FromGitter | <jrfondren> ```var myani {.threadvar.}: Animal ⏎ myani = Animal(name:"Pig", age:1)``` [https://gitter.im/nim-lang/Nim?at=5ce5b383ecdf942b4c2a5b11] |
20:39:48 | FromGitter | <jrfondren> that's enough to resolve the gc safety warnings |
20:40:15 | FromGitter | <jrfondren> I feel like you have an off-by-one error though. Shouldn't your pig start at age 0 ? |
20:44:58 | * | stefantalpalaru quit (Quit: stefantalpalaru) |
20:46:40 | poopBot | ok now i have no errors, https://nim-lang.github.io/Nim/manual.html, so where can i find info about this threadvar would like to know how it works, whats heppending now cuz i duno |
20:48:20 | poopBot | searhhing it in Nim in Action or in manual dident get anything |
20:49:36 | FromGitter | <jrfondren> https://nim-lang.github.io/Nim/manual.html#threads-gc-safety |
20:50:06 | vivus | narimiran[m]: I tried your suggested solution and it does the same thing as my code does |
20:50:45 | * | Trustable quit (Remote host closed the connection) |
20:53:08 | rayman22201 | a threadvar is essentially a global variable for a single thread only. The manual should probably be expanded to talk about how threadvar and gcsafe interact. |
20:53:25 | rayman22201 | I think that is a common issue with new people, especially when they start to do async stuff. |
20:53:52 | * | fredrik92 joined #nim |
20:54:31 | poopBot | ok so from whati undestod, using {.gcsafe.} just alowes me to copile this proc, and that threadvar make this variable local to this thread, tough wierd i thinked just var something = "sdas" is just a local varbiale |
20:54:36 | * | btbytes joined #nim |
20:55:22 | rayman22201 | yeah, gcsafe is basically to tell the compiler, "shut up, I know what I'm doing". |
20:55:22 | FromGitter | <jrfondren> it could be more explicit. it's implied by the 'no heap sharing' restriction. |
20:55:52 | FromGitter | <jrfondren> {.gcsafe.} as a block does that. {.gcsafe.} as a pragma attached to a proc is asking the compiler to check things actually. |
20:57:24 | * | smitop joined #nim |
20:57:57 | rayman22201 | That's not true. "The gcsafe annotation can be used to mark a proc to be gcsafe, otherwise this property is inferred by the compiler." |
20:58:34 | rayman22201 | and compiler technically always checks, but .gcsafe turns gc safe effect errors into a warning instead of an error. |
20:59:18 | FromGitter | <jrfondren> eh, alright |
21:01:16 | FromDiscord_ | <kiwi> @federico3 ... can you change the background colour of the UI & the background colour of the buttons in ui.nim / libui? Like this .... https://i.imgur.com/4DHBmQn.png |
21:02:18 | rayman22201 | @poopBot, to answer your question about var = "sdas". A var at the top of the file like your example that becomes a global variable. If you were to put it inside a proc, then it would be a local variable. |
21:03:48 | * | couven92 quit (Disconnected by services) |
21:03:50 | * | fredrik92 is now known as couven92 |
21:04:13 | * | fredrik92 joined #nim |
21:19:15 | * | rnrwashere joined #nim |
21:22:53 | * | vivus quit (Remote host closed the connection) |
21:23:39 | * | rnrwashere quit (Ping timeout: 248 seconds) |
21:41:10 | * | cyraxjoe joined #nim |
22:00:05 | * | leorize quit (Remote host closed the connection) |
22:00:51 | * | leorize joined #nim |
22:02:15 | * | couven92 quit (Quit: Client Disconnecting) |
22:02:34 | * | xet7 quit (Quit: Leaving) |
22:04:08 | * | laaron quit (Remote host closed the connection) |
22:04:47 | * | laaron joined #nim |
22:11:58 | * | sealmove joined #nim |
22:18:09 | * | clyybber joined #nim |
22:23:51 | * | arecaceae quit (Remote host closed the connection) |
22:24:10 | * | arecaceae joined #nim |
22:33:15 | * | xet7 joined #nim |
22:35:22 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
22:36:06 | * | laaron joined #nim |
22:39:23 | * | Jesin quit (Quit: Leaving) |
22:47:31 | * | Jesin joined #nim |
22:50:12 | sealmove | Araq: can you remind me what's missing from btrees.nim? |
22:51:54 | * | solitudesf quit (Ping timeout: 258 seconds) |
22:55:14 | * | xet7 quit (Quit: Leaving) |
22:57:38 | * | rantfisch is now known as qwertfisch |
23:13:37 | * | stefanos82 quit (Remote host closed the connection) |
23:53:59 | Araq | sealmove: del() |
23:54:16 | sealmove | cool |