00:03:23 | * | theelous3_ quit (Ping timeout: 245 seconds) |
00:04:03 | * | platoff_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
00:07:24 | * | martin1__ joined #nim |
00:08:53 | * | martin1__ quit (Client Quit) |
00:32:00 | * | yonson quit (Quit: WeeChat 2.3) |
00:37:05 | FromGitter | <DanielSokil> Any ideas why a `db_sqlite` instance does not get latest data from database? I'm using the same `DbConn` in a 2 procedures. ⏎ 1: updates the DB. 2: returns the data after reading the DB. |
00:38:05 | FromGitter | <zacharycarter> I think if its bindings, stick to the OG interface. If its a port or new lib, use idiomatic Nim. My two cents. |
00:38:51 | FromGitter | <DanielSokil> What is an `OG interface`? |
00:38:51 | FromGitter | <DanielSokil> I have checked the database after adding values, data is there, but is not being read. |
00:47:59 | * | lukd quit (Quit: WeeChat 2.3) |
00:51:41 | * | krux02 quit (Remote host closed the connection) |
00:53:42 | * | lukd joined #nim |
00:58:24 | FromGitter | <zacharycarter> by OG I just meant original |
00:58:41 | FromGitter | <zacharycarter> there is sensibility in keeping the library API the same |
00:59:08 | FromGitter | <zacharycarter> if you're porting it - I don't see any reason not to stick to idiomatic Nim / style and naming conventions |
00:59:57 | FromGitter | <zacharycarter> if you're just binding to it - people are probably expecting to use the library in the same way as the original |
01:00:53 | FromGitter | <zacharycarter> but - it's also a good idea IMO, if you think the bindings will be widely used and you are using c2nim or nimgen, to create a more idiomatic Nim interface on top of the bindings |
01:01:18 | FromGitter | <zacharycarter> so consumers of the library don't have to rely on passing cints, cstrings, etc... to your procedures |
01:02:46 | FromGitter | <zacharycarter> @DanielSokil - are you using `BEGIN` and if so did you issue a `COMMIT` ? |
01:12:44 | * | smt quit (Read error: Connection reset by peer) |
01:12:50 | * | smt` joined #nim |
01:16:37 | * | leorize joined #nim |
01:28:40 | * | sagax joined #nim |
01:37:04 | FromGitter | <DanielSokil> I'm not porting any library, I'm using this module https://nim-lang.org/docs/db_sqlite.html |
01:37:25 | FromGitter | <zacharycarter> @DanielSokil - my message about the library stuff wasn't related to your question |
01:37:35 | FromGitter | <zacharycarter> it was a response to a topic above where you posted your question |
01:37:41 | FromGitter | <ratiotile> A proc with a cstring parameter compiles to `char*` type. How can I make it `const char*` so that I can pass a string into Nim? |
01:37:58 | FromGitter | <zacharycarter> use cstring @ratiotile |
01:38:20 | FromGitter | <zacharycarter> @DanielSokil - refer to the examples in that module's docs then, if the example works then you're not doing something correctly |
01:38:20 | FromGitter | <ratiotile> I do, it results in non-const char* |
01:38:24 | FromGitter | <zacharycarter> oh const sorry |
01:39:09 | FromGitter | <zacharycarter> hrm - I don't understand your question, do you mean pass a string to C? |
01:39:19 | FromGitter | <ratiotile> no, I am passing from C to Nim |
01:39:22 | FromGitter | <zacharycarter> okay |
01:39:39 | FromGitter | <ratiotile> C++ to be precise |
01:40:04 | FromGitter | <zacharycarter> 1) you can use c2nim with the `cpp` flag to generate glue code - there's also nimgen |
01:40:33 | FromGitter | <zacharycarter> 2) you don't need to worry about what the Nim code compiles to - you need to use the `{.importc.}` / `{.importcpp.}` pragmas |
01:41:53 | FromGitter | <zacharycarter> I think you need a mutable pointer to a immutable string |
01:42:40 | FromGitter | <zacharycarter> nim has `ptr` which is an unsafe pointer |
01:43:14 | FromGitter | <ratiotile> cstring is already a pointer though |
01:43:17 | FromGitter | <zacharycarter> https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers |
01:43:41 | FromGitter | <zacharycarter> right and what you're looking for - I believe - is a mutable pointer to an immutable string |
01:43:51 | FromGitter | <zacharycarter> that's what `const char*` is in C++ right? |
01:44:09 | FromGitter | <ratiotile> and I don't know how to do that, since Nim's proc parameters are immutable by default |
01:44:16 | FromGitter | <DanielSokil> @zacharycarter `BEGIN` and `COMMIT` does not solve the issue. ⏎ This is what I'm executing to DB: `db.exec(sql"INSERT INTO images (user_id, image_name) VALUES (?, ?)", userID, hashedFileName)` |
01:44:48 | FromGitter | <zacharycarter> `var str*: cstring = "This is GeeksForGeeks" ⏎ ` |
01:44:51 | FromGitter | <ratiotile> however, that doesn't carry over to the compiler output. if the cstring param is immutable, why does it compile to char*? |
01:44:51 | FromGitter | <zacharycarter> from |
01:44:58 | FromGitter | <zacharycarter> `const char* str = "This is GeeksForGeeks";` |
01:45:41 | FromGitter | <zacharycarter> yeah - you need to use `var` I think @ratiotile |
01:45:53 | FromGitter | <ratiotile> doesn't var make it non-const? |
01:45:59 | FromGitter | <ratiotile> I will try it |
01:46:39 | FromGitter | <zacharycarter> okay - it's difficult to answer without some code in front of me - I'm not a C++ expert in any sense of the word |
01:47:37 | FromGitter | <zacharycarter> @DanielSokil - I don't know - I have never used that module, but there are a lot of examples in the module documentation |
01:47:54 | FromGitter | <ratiotile> so without var the error is: cannot convert from NCSTRING to const char*. |
01:48:02 | FromGitter | <zacharycarter> there might be some idiosyncrasies in the usage of that library |
01:48:07 | FromGitter | <ratiotile> with var: cannot convert from NCSTRING& to char* |
01:48:13 | FromGitter | <ratiotile> i mean const char * |
01:48:14 | FromGitter | <zacharycarter> heh |
01:48:22 | FromGitter | <ratiotile> NCSTRING = char* |
01:50:48 | FromGitter | <zacharycarter> @ratiotile - I don't really have any other suggestions to throw at you - sorry |
01:50:52 | FromGitter | <zacharycarter> I looked at - https://github.com/acmeism/RosettaCodeData/tree/master/Task/Call-a-function-in-a-shared-library/Nim |
01:51:07 | FromGitter | <zacharycarter> I see |
01:51:39 | FromGitter | <zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5beb7fabbb06d73a996e11b6] |
01:51:42 | FromGitter | <zacharycarter> and then |
01:52:02 | FromGitter | <zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5beb7fc162866f7473958ee1] |
01:52:19 | FromGitter | <zacharycarter> so I'm not sure why that's not working for you |
01:53:02 | * | benjikun quit (Quit: Lost terminal) |
01:53:34 | FromGitter | <ratiotile> I have that type of interaction working, but it's not quite the same thing. The example you give is of Nim passing a string to C++. The compiler lets you pass a non-const char* to a function taking const char*. |
01:54:14 | FromGitter | <zacharycarter> ah I see |
01:54:15 | FromGitter | <rayman22201> @zacharycarter He wants to go the other way. Call a Nim function from C++, correct? |
01:54:27 | FromGitter | <ratiotile> yes |
01:54:27 | FromGitter | <zacharycarter> okay sorry - I'm definitely out of my wheel house then |
01:54:49 | FromGitter | <rayman22201> This is a less common usecase |
01:55:10 | FromGitter | <zacharycarter> interesting nonetheless |
01:55:17 | FromGitter | <ratiotile> to elaborate, my situation is this: ⏎ I have in C++ `void setCallback(void(*cb)(const char*));` ⏎ In Nim: `proc setCallback(cb: proc(text: cstring){.cdecl.})` with importcpp, header ⏎ The problem is that the Nim cb proc type is not compatible with the c++ cb type. [https://gitter.im/nim-lang/Nim?at=5beb8084bb06d73a996e1751] |
01:57:00 | FromGitter | <rayman22201> Nim won't assign const as a parameter because it has it's own rules for "constness" that is more clever / automatic than C |
01:57:38 | FromGitter | <rayman22201> I think you have to define your own string type that is "const char*" |
01:57:49 | FromGitter | <rayman22201> possibly with with an emit pragma |
01:57:54 | * | dddddd quit (Remote host closed the connection) |
01:57:57 | FromGitter | <ratiotile> I see, that might work |
01:59:32 | FromGitter | <ratiotile> does the emit pragma work with types? |
02:00:00 | FromGitter | <rayman22201> Yes. See the second example here: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma |
02:04:23 | FromGitter | <DanielSokil> Turns out, when using `https://github.com/andreaferretti/rosencrantz` module. You would have to create an async scope when reading from the database, otherwise it won't even bother. |
02:12:51 | FromGitter | <ratiotile> @rayman22201 Thanks, it worked! ⏎ What I did was `typedef const char* ConstCStr;` and then importcpp it as an object. |
02:17:11 | FromGitter | <ratiotile> As I understand it, Nim cannot directly use a C++ API that requires inheriting from an abstract class, right? ⏎ I am currently working around it by emitting a C++ class that inherits from the interface, and setting callbacks to Nim. |
02:19:02 | FromGitter | <zacharycarter> @DanielSokil - interesting, haven't used that lib before |
02:19:19 | FromGitter | <zacharycarter> good to know though - may want to post an issue and let the author know to include that in the docs |
02:19:33 | FromGitter | <zacharycarter> so folks don't face the same frustration you ran into, in the future |
02:19:46 | * | zachk quit (Quit: Leaving) |
02:20:04 | * | endragor joined #nim |
02:21:48 | FromGitter | <gogolxdong> Anyone helps to check the following UDP communicating in Nim? Is there anything missing ? Received message is irrelevant with the sent one. ⏎ http://ix.io/1rPV |
02:35:14 | * | abm quit (Quit: Leaving) |
03:00:40 | * | theelous3_ joined #nim |
03:04:09 | FromGitter | <rayman22201> @ratiotile good to hear. Glad I could help. Yes, you are correct about the abstract class. |
03:05:31 | * | banc quit (Quit: ZNC - http://znc.in) |
03:20:22 | * | theelous3_ quit (Read error: Connection reset by peer) |
03:22:03 | * | banc joined #nim |
03:43:04 | FromGitter | <gogolxdong> @PMunch array works instead of casting string to seq[byte] like that , as a result for me, send and recv works with array only. I think it's out of the layout of seq[char] and string is different from array which is identical with char[] in C. |
03:53:28 | * | Aareon_ quit (Ping timeout: 264 seconds) |
03:54:45 | sagax | hi all! |
03:54:59 | sagax | what web framework we have? |
03:55:13 | sagax | can't found this in this place https://nimble.directory/ |
03:59:44 | FromGitter | <zacharycarter> karax |
03:59:46 | FromGitter | <zacharycarter> night all |
04:00:08 | Tanger | sagax: https://github.com/VPashkov/awesome-nim#web |
04:03:45 | * | Aareon_ joined #nim |
04:04:35 | FromGitter | <gogolxdong> addr array[] == cstring == char[], cstring works too for sending. |
04:08:21 | * | kapil____ joined #nim |
04:22:55 | FromGitter | <gogolxdong> @PMunch http://ix.io/1rQ9 |
04:24:40 | FromGitter | <gogolxdong> ```code paste, see link``` ⏎ ⏎ readData should be the same with received buff, like (headerType:128,version:0,...) [https://gitter.im/nim-lang/Nim?at=5beba3874e7ca14520a12928] |
04:58:06 | * | nsf joined #nim |
05:01:06 | FromDiscord_ | <2vg> wow, techempower 🔥 |
05:01:06 | FromDiscord_ | <2vg> https://imgur.com/a/qFtIyhq |
05:18:37 | * | vlad1777d quit (Ping timeout: 252 seconds) |
05:23:48 | FromGitter | <AchalaSB> How to fix this issue? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bebb16362866f7473969fa0] |
05:46:31 | * | narimiran joined #nim |
05:48:17 | * | stefanos82 joined #nim |
05:57:44 | leorize | AchalaSB: Install a version of LLVM that has wasm target enabled |
06:03:47 | * | smt` quit (Read error: Connection reset by peer) |
06:07:06 | FromGitter | <gogolxdong> How to convert array[n,byte] to string? |
06:10:57 | leorize | write a proc? |
06:11:33 | FromGitter | <gogolxdong> \x00 in received buffer will be taken as the terminate character of a cstring . |
06:18:47 | leorize | ``proc `$`(a: openArray[byte]): string = (result = newString(len a); for i in a: (result.add char i))`` |
06:18:53 | leorize | ^ shouldn't that work? |
06:19:08 | leorize | nim string doesn't care about `\x00` |
06:19:51 | leorize | oh, that code I wrote is quite broken :P |
06:30:47 | * | craigger_ quit (Ping timeout: 240 seconds) |
06:35:31 | * | craigger joined #nim |
06:36:10 | * | vlad1777d joined #nim |
06:44:51 | FromGitter | <gogolxdong> do you figure it out? |
06:59:24 | * | mech422_ joined #nim |
07:00:39 | * | Aareon_ quit (Ping timeout: 252 seconds) |
07:00:58 | * | Aareon_ joined #nim |
07:01:00 | FromGitter | <gogolxdong> cannot construct string bypass a cstring because of there is \x00. |
07:02:51 | * | mech422__ quit (Ping timeout: 252 seconds) |
07:05:33 | FromGitter | <gogolxdong> your proc refresh buffer quickly, have no idea. |
07:05:52 | FromGitter | <gogolxdong> even not referenced. |
07:06:12 | leorize | gogolxdong: https://ptpb.pw/hQ-B |
07:06:57 | * | narimiran quit (Ping timeout: 268 seconds) |
07:07:05 | leorize | for some reason array's `$` always gain precedence over a custom defined `$` so I've to name it `toStr` |
07:07:42 | FromGitter | <gogolxdong> Sure, it's straightforward but cause recv not blocking and refresh recv loop rapidly. |
07:08:27 | leorize | you should fetch the entire thing first before trying to convert it to string |
07:08:28 | FromGitter | <gogolxdong> not blocking any more once has such a proc . |
07:10:11 | FromGitter | <gogolxdong> even not referenced to the proc. |
07:10:57 | * | Aareon_ quit (Ping timeout: 250 seconds) |
07:14:22 | FromGitter | <gogolxdong> in the same file, moved it to another file, works. |
07:16:47 | FromGitter | <gogolxdong> strange, I cannot put the proc together with while true: recv() loop, or it refresh rapidly and seems not blocking any more. |
07:18:40 | FromGitter | <gogolxdong> @PMunch even after got the same byte sequence sent earlier , still hints ⏎ Unable to read the requested amount of bytes from file |
07:21:40 | * | krux02 joined #nim |
07:21:56 | * | Aareon_ joined #nim |
07:27:37 | FromGitter | <gogolxdong> http://ix.io/1rQv FYI |
07:29:01 | FromGitter | <gogolxdong> from the view of seq[byte] it's the same with original . |
07:32:11 | FromGitter | <gogolxdong> as shown in `echo castseq[byte (packet)` which packet is the converted string from array buffer. |
07:35:37 | krux02 | https://github.com/nim-lang/Nim/issues/2286 |
07:44:55 | FromGitter | <gogolxdong> Don't understand how it related to refresh a non-parallel loop in the same file, or ⏎ `Unable to read the requested amount of bytes from file` |
07:46:48 | FromGitter | <narimiran> krux02 i've tried to run that, uncommenting the line that is supposed to crash the program, and it works fine!? |
07:47:51 | krux02 | well it doesn't crash |
07:47:58 | krux02 | but does it do the right thing |
07:48:08 | krux02 | and another question, is the test actually testing for the right thing |
07:48:35 | FromGitter | <narimiran> what is "the right thing"? am i missing something? |
08:03:29 | krux02 | nirimiran: I think the problem is that the test should fail, because the pattern is not literally in the generated c file. So maybe everything is correct, but the test case is not correct and should fail |
08:03:48 | FromGitter | <gogolxdong> filed a minimal issue reproducable snippet. |
08:09:19 | krux02 | narimiran[m], I just discussed it with Araq. I could fix the ccodeCheck |
08:09:57 | * | FromGitter * narimiran thumbs up |
08:18:36 | * | PMunch joined #nim |
08:19:52 | * | Vladar joined #nim |
08:22:16 | * | exothermic[m] joined #nim |
08:23:24 | FromDiscord_ | <lastpass> Hello everyone! |
08:27:50 | Araq | hi |
08:28:53 | PMunch | Hi |
08:32:12 | * | floppydh joined #nim |
08:33:16 | FromGitter | <gogolxdong> @PMunch, help wanted. |
08:36:36 | PMunch | Hi gogolxdong, what can I help you with? |
08:38:19 | FromGitter | <gogolxdong> http://ix.io/1rQK |
08:38:40 | FromGitter | <gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bebdf103102f145219c1de6] |
08:40:52 | FromGitter | <gogolxdong> From the view of seq[byte] cast from string , it's the same with original .But got the bottom error. |
08:40:54 | PMunch | Yeah, that makes sense |
08:41:07 | PMunch | Okay, so headerType reads one byte |
08:41:26 | PMunch | Then version reads 4 bytes (the four first zeros) |
08:42:05 | PMunch | Then dcil and scil reads 4 bits each (17 = 0b00010001) making dcil = 1 and scil = 1 |
08:42:26 | PMunch | Then dcid tries to read dcil+3 bytes, aka 4 bytes |
08:42:44 | PMunch | This reads the two 15's and the two last zeros |
08:43:14 | PMunch | Then scid wants to read 4 bytes (scil+3), but there is no more data |
08:47:32 | PMunch | Did that make sense? |
08:47:39 | FromGitter | <gogolxdong> dcil and scil is 4-18 bytes, I don't think the syntax is right. |
08:48:10 | FromGitter | <gogolxdong> dicd and scid ,sorry ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bebe14ad001b917205a3d46] |
08:48:52 | FromGitter | <gogolxdong> should be u16-u144, but cannot define u144 |
08:49:23 | PMunch | u16? That's only 2 bytes |
08:49:25 | FromGitter | <gogolxdong> u32-u144 |
08:49:28 | PMunch | Ah |
08:49:51 | PMunch | Yeah, what you are doing there is right |
08:49:59 | PMunch | It's reading 4-18 bytes |
08:50:11 | PMunch | Or rather 0|4-18 |
08:50:44 | PMunch | dcil's max value is 0b1111 which is 15 plus 4 which is 18. So 18 bytes (since dcid is u8) |
08:51:10 | PMunch | The problem is that your data stream doesn't actually have enough data |
08:51:28 | FromGitter | <gogolxdong> outData.dcid = @[1u8,2,3,4] ⏎ ⏎ ```outData.scid = @[5u8,6,7,8]``` [https://gitter.im/nim-lang/Nim?at=5bebe20f6b9822140d29e19c] |
08:51:37 | PMunch | both dcil and scil are set to 1, which means they'll try to read 4 bytes |
08:52:29 | FromGitter | <gogolxdong> I changed to this, and enlarge the read buffer, but only read 1,2 ,0,0,... |
08:52:55 | PMunch | Hold on, I'm testing it |
08:55:34 | PMunch | Seems to work fine for me: http://ix.io/1rQL/ |
08:58:16 | FromGitter | <gogolxdong> yes, it's out of supportedVersion |
08:58:24 | PMunch | Hmm, seems like the supportedVersion doesn't work |
08:58:29 | FromGitter | <gogolxdong> it's 1|more |
08:58:48 | PMunch | Looking at the generated writer it doesn't appear to actual create any code to write that field.. |
08:59:39 | PMunch | You can also use -d:binaryparseLog to make it echo out what it's reading |
09:00:26 | PMunch | Doesn't do anything for writing atm though |
09:00:50 | FromGitter | <gogolxdong> I noticed that, but it's problem of supportedVersion . |
09:01:49 | FromGitter | <gogolxdong> it's 1|more, have no idea how to map this to your binary pattern. |
09:02:01 | PMunch | Yeah, it doesn't have any code to write that field. I'm looking into it right now |
09:02:29 | PMunch | Is it dependent on some other value how many fields it is? |
09:02:48 | PMunch | Or is it just the rest of the message? |
09:03:56 | FromGitter | <gogolxdong> http://ix.io/1rQP |
09:04:24 | PMunch | Yeah but what is N? |
09:05:15 | PMunch | Is it just read 32 bit integers to the end of the message? Or is there a field in the message that gives you N? |
09:06:09 | FromGitter | <gogolxdong> to the end |
09:07:06 | PMunch | Okay, then I'd just have it the way you do now |
09:07:15 | PMunch | But I have to fix binaryparse for it to work |
09:08:40 | FromGitter | <gogolxdong> need an additional feature ? |
09:09:01 | PMunch | Well, it's more fixing a bug than adding a feature |
09:09:06 | PMunch | What you have should work |
09:09:41 | PMunch | I just forgot to add the code to write that kind of array (as the name implies it started out just reading binary data, not writing it) |
09:12:14 | FromGitter | <gogolxdong> ok, does u32: supportedVersion[] mean it's 1+ field? |
09:13:27 | PMunch | No, it means 0+ fields |
09:13:41 | PMunch | So you need to implement the len != 0 check yourself |
09:13:51 | PMunch | Or use a custom reader/writer |
09:14:08 | PMunch | http://ix.io/1rQT/Nim |
09:14:20 | FromGitter | <gogolxdong> Since it's given empty brackets next field needs to be a magic field and the will be read until the magic is found. |
09:14:22 | PMunch | That will work with the current version of binaryparse until I can patch it |
09:14:52 | PMunch | There you can also see how to write a custom reader/writer, and it should be obvious where a length check would go :) |
09:16:49 | PMunch | Oh wait, writing the sequence like that doesn't work |
09:17:26 | PMunch | It should be like this: http://ix.io/1rQU/Ni |
09:17:28 | PMunch | It should be like this: http://ix.io/1rQU/Nim |
09:22:22 | FromGitter | <gogolxdong> It works for writing, not for parsing this time. |
09:23:37 | FromGitter | <gogolxdong> http://ix.io/1rQW |
09:24:31 | * | alehander42 joined #nim |
09:26:11 | PMunch | Code? |
09:26:25 | PMunch | That is an error from the streams module.. |
09:26:46 | FromGitter | <gogolxdong> http://ix.io/1rQX |
09:29:26 | PMunch | Hmm yeah |
09:29:32 | PMunch | It seems to be off by 2 bytes |
09:29:40 | PMunch | How do you generate that? |
09:32:17 | PMunch | http://ix.io/1rQZ/ |
09:32:26 | PMunch | As you can see this reads and writes correctly |
09:32:50 | PMunch | (Had to make a minor change to the reader I sent you, it was reading little endian and not big endian) |
09:35:49 | FromGitter | <gogolxdong> http://ix.io/1rR1 |
09:37:47 | FromGitter | <gogolxdong> [128, 0, 0, 0, 0, 17, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ⏎ @[128, 0, 0, 0, 0, 17, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ⏎ server.nim(46) server ⏎ binaryparse.nim(254) :tmp ⏎ binaryparse.nim(127) :anonymous ... [https://gitter.im/nim-lang/Nim?at=5bebeceb6b9822140d2a26d8] |
09:39:04 | PMunch | Yeah, you can see after the 17 (dcil + scil) you have four bytes for dcid, four bytes for scid, and then 6 remaining bytes |
09:39:52 | PMunch | So the reader reads the first four and generates a uint32, then it tries to read the last two, which fails because you can't make a 4 byte uint32 out of 2 bytes |
09:43:09 | FromGitter | <gogolxdong> [128, 0, 0, 0, 0, 17, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ⏎ @[128, 0, 0, 0, 0, 17, 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] ⏎ (headerType: 128, version: 0, dcil: 1, scil: 1, dcid: @[1, 2, 0, 0], scid: @[0, 0, 0, 0], supportedVersion: (supportedVersions: @[0, 0])) |
09:43:52 | PMunch | Yay :) |
09:44:25 | PMunch | Or where you expecting there to be some data in those fields? |
09:45:51 | FromGitter | <gogolxdong> dcid and scid and following is not right. the size of received buffer also relate to the size of parse, is there a sizeof parser? |
09:47:47 | FromGitter | <gogolxdong> oh, it's dynamic. |
09:47:52 | PMunch | Yeah.. |
09:47:58 | PMunch | So it doesn't really have a size |
09:48:18 | PMunch | But you can do versionNegoPacket.put(ss); ss.getPosition() |
09:48:25 | PMunch | That will tell you the amount of data written |
09:48:55 | PMunch | Put of course with another parameter there |
09:49:05 | FromGitter | <gogolxdong> good trip |
09:49:39 | FromGitter | <gogolxdong> How about the incorrect dcid,scid,supportedVersion field? |
09:51:41 | * | alehander42 quit (Remote host closed the connection) |
09:52:06 | PMunch | Try to echo it out on the generating side, make sure it actually puts all the data into the stream. Then make sure your sender and receiver are sending and receiving the correct amount of bytes |
09:52:29 | FromGitter | <gogolxdong> 3 offset seems didn't work, it read only two bytes. |
09:54:17 | * | dddddd joined #nim |
09:54:32 | FromGitter | <gogolxdong> why did sender send only 8 bytes? |
09:55:12 | PMunch | Huh? |
09:55:33 | FromGitter | <gogolxdong> (headerType: 128, version: 0, dcil: 1, scil: 1, dcid: @[1, 2, 3, 4], scid: @[5, 6, 7, 8], supportedVersion: (supportedVersions: @[167772160, 1677721600])) |
09:56:52 | FromGitter | <gogolxdong> comes to supportedVersions |
09:58:16 | FromGitter | <gogolxdong> used your tip of sent size. |
09:59:36 | * | deathpoison joined #nim |
10:00:28 | PMunch | Nice, that looks better |
10:00:44 | PMunch | What's wrong with the supported versions? |
10:01:07 | FromGitter | <gogolxdong> supportedVersion: (supportedVersions: @[167772160, 1677721600, 279183360]) |
10:01:33 | FromGitter | <gogolxdong> compared with (supportedVersions: @[10, 100, 42000]) |
10:01:39 | PMunch | Right |
10:01:48 | PMunch | That's big-endian vs little-endian for your :) |
10:02:25 | FromGitter | <gogolxdong> oh |
10:03:46 | PMunch | Are you using the same version I used? |
10:04:41 | FromGitter | <gogolxdong> `s.readDataLE(result.supportedVersions[0].addr , 4)`? |
10:04:55 | FromGitter | <gogolxdong> for getter? |
10:05:15 | FromGitter | <gogolxdong> not sure what BE and LE means |
10:06:20 | FromGitter | <gogolxdong> oh, big-endian and litter-endian. |
10:06:32 | FromGitter | <gogolxdong> got it, and fully works. |
10:07:37 | FromGitter | <gogolxdong> `s.readDataLE(result.supportedVersions[^1].addr , 4)` |
10:14:40 | PMunch | Pushed a new version of binaryparse now |
10:15:39 | FromGitter | <gogolxdong> checking |
10:16:05 | PMunch | Hmm wait |
10:16:12 | PMunch | I seemed to have messed it up |
10:17:13 | PMunch | Oh no, it's right. I had just forgotten to update it on my machine :P |
10:17:42 | PMunch | So this now works as expected: http://ix.io/1rRa/ |
10:22:07 | FromGitter | <gogolxdong> perfect. |
10:23:22 | FromGitter | <gogolxdong> How do you check whether it's in BE or LE? |
10:23:43 | PMunch | What do you mean check? |
10:24:56 | FromGitter | <gogolxdong> in native byte order or network byte order. |
10:25:44 | FromGitter | <cyberlis> i thought that there is no way to detect it? you just have to know your bite order ? |
10:26:02 | FromGitter | <cyberlis> byte* |
10:26:17 | PMunch | Yeah, there is no way to detect it |
10:26:31 | PMunch | Take the 16 bit number 10: 00 0A |
10:26:46 | FromGitter | <gogolxdong> I didn't need to take care of supportedVersions in native or network byte order, it's just right. |
10:26:59 | PMunch | That's in big-endian, in little-endian it would be: 0A 00 |
10:27:54 | PMunch | 0A 00 is still a valid number, it's just not 10 but 2560 if read as a big-endian number |
10:31:04 | FromGitter | <gogolxdong> Data would be sent in network byte order in the wire, right ? And received as little-endian byte order automaically? |
10:34:06 | FromGitter | <gogolxdong> since no matter putting locally or onto network, it's consistent as getting. |
10:37:12 | FromGitter | <gogolxdong> from the commit history cannot see how did you make it. |
10:41:08 | * | couven92 quit (Read error: Connection reset by peer) |
10:42:20 | * | alehander42 joined #nim |
10:44:47 | FromGitter | <gogolxdong> or it stores in LE locally , wire reverses the byte order, therefore it seems that it didn't change ever when we receive data? |
10:45:56 | * | alehander42 quit (Remote host closed the connection) |
10:55:04 | * | couven92 joined #nim |
10:59:59 | PMunch | binaryparse only reads and writes big-endian (or network byte order if you like). But the CPU is free to store it's data however it likes (I think) |
11:01:35 | FromGitter | <gogolxdong> oh, that explains why it doesn't need to reverse as receiving, right? |
11:02:46 | FromGitter | <gogolxdong> otherwise it needs reverse, right? |
11:04:49 | FromGitter | <gogolxdong> x86 uses LE, yes, powerPC uses BE. |
11:33:34 | * | platoff_ joined #nim |
11:54:14 | * | endragor quit (Remote host closed the connection) |
11:58:14 | FromGitter | <yyyc514> proc `value=`*(i: var Input, v: int) = |
11:58:36 | FromGitter | <yyyc514> Error: 'i1.value' cannot be assigned to |
11:59:38 | Araq | i1 != i |
12:00:18 | FromGitter | <yyyc514> i1 is in the test |
12:00:29 | FromGitter | <yyyc514> it's a instance of Input |
12:01:22 | FromGitter | <yyyc514> trying to do `i1.value = 2` |
12:07:30 | * | kapil____ quit (Quit: Connection closed for inactivity) |
12:07:57 | Araq | don't use 'let' but 'var' for it or something |
12:08:43 | FromGitter | <narimiran> yeah, `var` was my first guess too |
12:08:52 | FromGitter | <yyyc514> the tests use `let`... changing to it refernce seems to work |
12:09:10 | FromGitter | <narimiran> @yyyc514 this works: http://ix.io/1rRD/ |
12:09:12 | FromGitter | <yyyc514> i see the issue with it being let now though :) |
12:10:29 | FromGitter | <alehander42> we can add a hint to the error, does it happen for other cases than `let` vs `var` ? |
12:10:46 | FromGitter | <narimiran> @yyyc514 or if you want to use `ref object`, you need to change proc definition too: http://ix.io/1rRE/ |
12:13:21 | * | kapil____ joined #nim |
12:32:46 | * | smt joined #nim |
12:42:26 | Araq | which Nim symbol is used most often in Nim's compiler source? |
12:43:03 | PMunch | Are you asking or are you quizing? |
12:43:39 | FromGitter | <cyberlis> `:` ? |
12:44:08 | Araq | a) + |
12:44:13 | Araq | b) int |
12:44:16 | Araq | c) != |
12:44:19 | Araq | d) string |
12:44:41 | Araq | (':' is not a symbol, it is only a token) |
12:44:47 | FromGitter | <survivorm> i vote for plus (a) |
12:44:51 | Araq | PMunch: quizing |
12:44:53 | FromGitter | <cyberlis> a) |
12:46:47 | PMunch | I think I'll go for b |
12:47:04 | PMunch | Hmm |
12:47:19 | Araq | lol never mind my query is wrong |
12:47:21 | FromGitter | <cyberlis> you can write `let a = 10` without int |
12:47:31 | Araq | but out of these 4, it's != |
12:47:39 | PMunch | Huh |
12:47:45 | PMunch | Wouldn't have guessed that |
12:48:08 | PMunch | cyberlis, yeah but I think the compiler most often works with objects with various fields |
12:48:22 | PMunch | Araq, do you have them in order? |
12:48:23 | Araq | ah hmm my query is right |
12:48:35 | Araq | so yeah, it's != |
12:48:44 | Araq | but it's unfair, == is overloaded and != is not :P |
12:49:07 | FromGitter | <alehander42> I also thought for a) |
12:49:21 | Araq | the compiler doesn't do many additions |
12:49:51 | Araq | PMunch: no and I gotta go, bbs |
12:50:05 | FromGitter | <narimiran> wow! i thought it is either A or B |
12:50:06 | FromGitter | <alehander42> that's why i'd prefer isNil/isEmpty everywhere :D |
12:50:13 | FromGitter | <narimiran> more quizzes like this, please! :) |
12:51:09 | PMunch | Wonder how Araq made that query.. Would be fun to get other info like that |
12:55:24 | FromGitter | <alehander42> btw PMunch, does LSP support refactoring stuff |
12:55:32 | FromGitter | <alehander42> e.g. not only finding usages of variables |
12:55:35 | FromGitter | <alehander42> but also replacing them |
12:56:36 | PMunch | Well it supports getting usages of a symbol |
12:56:56 | PMunch | So your editor should in theory be able to do the replace symbols |
13:06:30 | * | mech422_ quit (Read error: Connection reset by peer) |
13:06:53 | * | mech422_ joined #nim |
13:11:31 | FromGitter | <alehander42> hm, true indeed |
13:11:58 | FromGitter | <alehander42> this would be especially useful for e.g. replacing/adding args to changed call |
13:12:02 | FromGitter | <alehander42> but that's probably harder |
13:12:03 | * | rockcavera quit (Remote host closed the connection) |
13:13:19 | PMunch | Well I think that nimsuggest supports what would be required for that |
13:13:28 | PMunch | maybe |
13:19:38 | * | rockcavera joined #nim |
13:23:59 | FromGitter | <yyyc514> hmmmm |
13:24:20 | FromGitter | <yyyc514> now how can i purposely call the getter if i'm within my own class... value() doesn't seem to work |
13:42:12 | FromGitter | <kungtotte> Fun bit of trivia: if you write the same program in both Nim and Rust, one will produce a 112K binary and the other a 4MB binary with default compilation settings. I'll let you guess which is which. (The 4MB version is dynamically linked against libc, not statically) |
14:07:37 | FromGitter | <narimiran> @kungtotte i know the answer :) i was also surprised/shocked when i first tried ** recently :) |
14:13:59 | FromGitter | <kungtotte> Even after running strip it's at 400+KB |
14:19:31 | * | pigmej quit (Ping timeout: 250 seconds) |
14:20:55 | * | vegax87 quit (Ping timeout: 252 seconds) |
14:21:14 | * | nsf quit (Quit: WeeChat 2.3) |
14:21:42 | * | ftsf quit (Ping timeout: 268 seconds) |
14:25:24 | * | pigmej joined #nim |
14:27:30 | * | kapil____ quit (Quit: Connection closed for inactivity) |
14:31:59 | PMunch | Hmm, I'm having trouble with getting nimlsp to set up the correct path when I use my ripped version of nimsuggest.. |
14:32:23 | PMunch | I keep getting this error "Error: cannot open '/home/peter/div/nimlsp/src/lib/system.nim'" meaning it hasn't properly set up my sources.. |
14:39:09 | FromGitter | <zacharycarter> https://github.com/fungos/cr |
14:39:54 | * | vegax87 joined #nim |
14:40:30 | * | Vladar quit (Remote host closed the connection) |
14:48:13 | FromGitter | <zacharycarter> not sure how well this would work with Nim's default GC |
14:59:14 | * | platoff_ quit (Read error: Connection reset by peer) |
15:21:34 | FromGitter | <tim-st> allowing `and` and `or` at start of next line would be really nice :\ |
15:33:47 | FromGitter | <mratsim> C doesn’t allow || or && at the geinning of a line though |
15:34:43 | FromGitter | <kayabaNerve> And it's just bad from a design standpoint :thinking: |
15:34:56 | FromGitter | <kayabaNerve> That only works out of 1/3 platforms :( no idea about Matrix tbh. |
15:35:32 | FromGitter | <kayabaNerve> Anyways. and at the end of the line says the next statement is part of this. and at the start of the next line says edit the previous complete statement even though we're done with it because we're not. |
15:45:13 | * | vlad1777d quit (Ping timeout: 244 seconds) |
15:51:16 | FromDiscord_ | <exelotl> I legit find it really hard to get `shl` and `shr` the right way round |
15:51:39 | * | Trustable joined #nim |
15:52:23 | FromDiscord_ | <exelotl> I get left/right mixed up all the time, I have done for years and I don't think that's gonna change any time soon |
15:52:36 | FromDiscord_ | <exelotl> But I have no problem with << and >> |
15:53:26 | * | platoff_ joined #nim |
15:53:54 | FromDiscord_ | <exelotl> I was porting some C# code the other day and I ended up defining << and >> because I couldn't be sure my code was correct lol |
15:54:34 | FromGitter | <cyberlis> exelotl, maybe you can your own template for `<<` and `>>` ? |
15:54:43 | FromGitter | <cyberlis> create* |
16:00:38 | * | narimiran joined #nim |
16:21:57 | * | Trustable quit (Remote host closed the connection) |
16:22:03 | * | rockcavera quit (Read error: Connection reset by peer) |
16:22:18 | * | rockcavera joined #nim |
16:22:19 | * | rockcavera quit (Changing host) |
16:22:19 | * | rockcavera joined #nim |
16:31:20 | * | smitop_ joined #nim |
16:50:01 | FromGitter | <cyberlis> what is the best templating engine for Nim (especially for html-templating). I remember there was something like `tmpl` where you wrote you template as commented nim code. Does it still exists and in use ? |
16:50:08 | * | Trustable joined #nim |
16:50:56 | FromDiscord_ | <exelotl> Oh yeah, making a template for <<, >> is what I ended up doing in the end |
16:52:22 | * | nsf joined #nim |
16:52:55 | FromDiscord_ | <exelotl> cyberlis: there is this one that I've seen recommended before. Not sure if there are other good options http://flyx.github.io/emerald/index.html |
16:54:26 | * | narimiran quit (Ping timeout: 276 seconds) |
16:54:27 | FromGitter | <brentp> I am getting unexpected behavrio only for debug builds and only from an iterator: https://gist.github.com/brentp/e45ab693d4c25881172d2066d63b8717 |
16:55:39 | FromGitter | <brentp> that's a minimal self-contained example. am I doing something wrong? the debug build with a nim built from devel ~ 2 days old doesn't get that left_exact is set but only from an iterator where the iterator used a local var. |
17:05:26 | * | junka joined #nim |
17:05:54 | junka | zolkeri where are youuuuu |
17:09:30 | junka | ZOOOOOOOOOOLKEEEEEEERIIIIIIII |
17:09:44 | junka | pm me if you see this |
17:09:48 | * | junka left #nim ("Farting") |
17:14:35 | FromGitter | <brentp> I updated the gist to simplify: https://gist.github.com/brentp/e45ab693d4c25881172d2066d63b8717 |
17:18:13 | Araq | don't use .bitsize |
17:18:33 | Araq | it's only for C interop |
17:20:29 | FromGitter | <brentp> :( |
17:20:54 | FromGitter | <brentp> so I'll have to do my own bitshifting to save memory? |
17:21:24 | Araq | no, you can use set[MyEnum] |
17:24:26 | Araq | and due to alignment, in your case left_exact, right_exact: bool use the same memory but produces smaller code as the CPU can address bytes, not bits |
17:27:20 | FromGitter | <brentp> looking at sets now. but in my real use-case, I'm splitting 32 bytes as 1,1,24,6 |
17:27:41 | FromGitter | <brentp> bits rather |
17:29:15 | * | platoff_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
17:34:09 | * | PMunch quit (Quit: Leaving) |
17:36:08 | * | kapil____ joined #nim |
17:47:56 | * | deathpoison quit (Quit: Leaving.) |
17:49:18 | FromGitter | <Varriount> @brentp Wouldn't it be better to use bit masks, and operate on the 32-bit integer as a whole? |
17:51:34 | FromDiscord_ | <lastpass> Idea: rewrite most cryptographic libraries with Nim. |
17:52:53 | FromDiscord_ | <lastpass> Example: https://github.com/libtom/libtomcrypt |
17:52:59 | FromDiscord_ | <lastpass> Has a good collection |
17:53:15 | FromGitter | <brentp> @Varriount I was hoping ot have the compiler do that for me by using {.bitsize.} |
17:53:37 | * | smt quit (Read error: Connection reset by peer) |
17:53:50 | * | smt joined #nim |
18:17:30 | shashlick | Araq: had some questions on https://github.com/nim-lang/Nim/issues/8327 - do you have some time to chat? |
18:29:55 | Araq | shashlick, I read your comment |
18:30:17 | shashlick | i am playing with tree-sitter and was wondering on next steps |
18:30:48 | shashlick | my goal is to simply offer a cimport "cfile.h" type functionality for starters |
18:30:52 | shashlick | not full file conversion |
18:30:58 | Araq | well import compiler / [ast, renderer] |
18:31:23 | shashlick | so there's 3 options - 1 = same as c2nim - separate binary but no big advantage |
18:31:23 | Araq | and transform the tree-sitter AST into Nim's AST |
18:31:41 | shashlick | ok so do you want to build tree-sitter into the nim compiler |
18:31:46 | shashlick | or keep it as a separate module |
18:32:07 | Araq | it would be like c2nim but you can staticExec() the tool from within your Nim program |
18:32:30 | shashlick | in that case, wouldn't it be better to use macros and inject the AST that way |
18:33:00 | Araq | not IMO. |
18:33:24 | shashlick | so then how will I inject the AST into the currently compiling program with staticExec()? |
18:33:45 | Araq | macros are for Nim to Nim translations |
18:33:45 | shashlick | keeping aside where the tree-sitter AST => Nim AST conversion is done |
18:33:49 | Araq | but bbs |
18:41:00 | * | smitop_ quit (Quit: Connection closed for inactivity) |
18:41:32 | FromGitter | <kdheepak> How to convert a `cstring` to a `string` and a `string` to a `cstring` type in Nim? |
18:42:37 | FromGitter | <brentp> using $ to convert cstring to string and "some".cstring to go the other way. |
18:49:52 | FromGitter | <kdheepak> Thanks! |
18:52:29 | Araq | shashlick, back |
18:53:38 | Araq | well instead of import cfile you write cimport "cfile" and cimport is template/macro that checks if cfile.nim exists and if not, runs staticExec("helpertool cfile.h") |
18:55:17 | shashlick | so that's still the c2nim model |
18:56:04 | Araq | if you say so ... :P |
18:56:12 | Araq | what's wrong with the c2nim model? |
18:56:31 | shashlick | well, it keeps the compiler and this interop tool separated again |
18:56:53 | shashlick | regardless, when you talk of AST, there's no escape i guess |
18:57:13 | * | Amun_Ra quit (Quit: brb) |
18:57:16 | shashlick | my thought was that there was no need for an intermediate nim representation of the C code imported |
18:58:05 | shashlick | you could convert and import the AST directly - end user would still refer to the .h file for definitions |
18:58:12 | * | PMunch joined #nim |
18:58:27 | shashlick | all existing C lib documentation will also be relevant |
18:58:52 | * | Amun_Ra joined #nim |
19:00:09 | shashlick | thanks to identifier equality, names won't matter either |
19:00:48 | * | NimBot joined #nim |
19:03:08 | shashlick | I agree with that although tree-sitter with C and C++ langs is only ~4mb compiled |
19:03:33 | shashlick | anyway, it requires C99 so if that's a limitation, I don't know |
19:03:46 | shashlick | no elaborate cmake/configure mess either |
19:10:11 | shashlick | meanwhile, i feel the best of both worlds is to have tree-sitter simply parse the C/C++ code and spit out text AST - can use staticExec() + macros to translate to Nim AST and inject but i am not sure if this can be accomplished with macros+VM or not |
19:10:31 | shashlick | this way there is no dependency on compiler |
19:16:13 | * | nsf quit (Quit: WeeChat 2.3) |
19:37:26 | shashlick | Araq: so safe to say we won't add this to compiler - but do you think macros method is viable? I prefer to c2nim style of depending on compiler+render |
19:41:25 | * | narimiran joined #nim |
19:46:57 | FromGitter | <arnetheduck> btw, does treesitter really parse c++? ie does it do contextual parsing based on symbol table? |
19:47:41 | shashlick | it parses 18 languages |
19:47:45 | shashlick | including C++ |
19:48:54 | shashlick | not sure how to answer your question though |
19:55:32 | * | floppydh quit (Quit: WeeChat 2.3) |
20:16:01 | FromGitter | <kdheepak> I have a really weird error when building a shared library from Nim code. |
20:16:33 | FromGitter | <kdheepak> I get segfaults when loading the shared library into Python, but when running the Nim code from the command line everything works fine. |
20:17:30 | FromGitter | <kdheepak> When I don't build the shared library with `-d:release`, I get a stacktrace. When I try to echo values near where the error occurred, I error changes to a different location. |
20:18:13 | FromGitter | <kdheepak> It's like a heisenbug, the error changes when I try to observe it. |
20:19:03 | FromGitter | <kdheepak> Normally, this sort of stuff would happen in a C compiler when running unsafe code that the compiler optimizes away when it is not being printed to the screen etc. But here with Nim, I should not see this, right? |
20:19:40 | PMunch | How do you compile it? |
20:19:49 | FromGitter | <kdheepak> It's especially troubling since this only happens when I load the shared library into Python. If I run the same function through Nim and run it through the command line everything works fine. |
20:20:09 | FromGitter | <kdheepak> This is what I'm doing. ⏎ ⏎ ```nim c --app:lib src/glm.nim; python t.py ``` [https://gitter.im/nim-lang/Nim?at=5bec837847217e07ff2148dd] |
20:20:42 | * | Perkol joined #nim |
20:20:43 | FromGitter | <kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec839bd001b917205e99f2] |
20:21:08 | PMunch | https://nim-lang.org/docs/nimc.html#dll-generation |
20:21:12 | PMunch | That might be helpful for you |
20:21:26 | FromGitter | <kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec83c5e0fd6b4360f32ea7] |
20:21:50 | PMunch | Oh wait, that shouldn't matter if you don't run it from Nim.. |
20:22:56 | FromGitter | <kdheepak> This is the weirdest thing I've encountered. |
20:23:05 | PMunch | Yeah.. |
20:23:13 | FromGitter | <rayman22201> He still needs to start up the GC |
20:23:15 | PMunch | Dynlibs in Nim have been proven not to work too great.. |
20:23:17 | FromGitter | <kdheepak> I've tried stepping through using lldb as well, and I'm not able to make sense. |
20:23:23 | FromGitter | <kdheepak> How do I start the gc? |
20:23:45 | FromGitter | <rayman22201> I'm trying to remember. stand by lol |
20:24:03 | PMunch | setupForeignThreadGC()= |
20:24:06 | PMunch | Possibly |
20:24:09 | PMunch | Without the = |
20:24:17 | * | rockcavera quit (Read error: Connection reset by peer) |
20:24:32 | * | rockcavera joined #nim |
20:24:33 | * | rockcavera quit (Changing host) |
20:24:33 | * | rockcavera joined #nim |
20:25:04 | FromGitter | <rayman22201> Have you seen this @kdheepak ? https://github.com/yglukhov/nimpy |
20:25:44 | FromGitter | <rayman22201> may be easier |
20:26:40 | FromGitter | <kdheepak> @rayman22201 thanks for sharing the link, that's an amazing package. I have. I'm having a long discussion with yglukhov in a private message thread as well. I first discovered that I was having this heisenbug when I tried to make a PR to that repo, https://github.com/yglukhov/nimpy/pull/65 |
20:27:30 | FromGitter | <kdheepak> However, my PR resulted in a segfault in my own package. So it's been a slow descent into simplifying as much as possible to try to figure out what the problem was. |
20:27:54 | FromGitter | <rayman22201> ah. Well, if yglukhov can't figure it out, then it's definitely outside of my expertise! lol |
20:28:21 | FromGitter | <kdheepak> At first I thought it was a nimpy issue, but now I've tested the same function and get segfaults outside of nimpy too. |
20:28:48 | FromGitter | <kdheepak> Perhaps this is a nim issue when it generates libraries. |
20:29:06 | FromGitter | <kdheepak> It does seem like it could be a Nim garbage collection issue. |
20:30:42 | FromGitter | <rayman22201> That's what it seems like to me as well, but I'm not familiar enough with Nim's GC internals |
20:31:30 | FromGitter | <rayman22201> yglukhov is doing some GC magic here: https://github.com/yglukhov/nimpy/blob/master/nimpy.nim#L705 |
20:32:58 | FromGitter | <kdheepak> Okay, I think it's definitely a GC thing. I tried loading the Nim shared library into a simple C example, and I still get a segfault. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec867947217e07ff215f40] |
20:33:15 | * | nsf joined #nim |
20:34:01 | * | Trustable quit (Remote host closed the connection) |
20:34:41 | * | kapil____ quit (Quit: Connection closed for inactivity) |
20:34:59 | PMunch | Your issue might be related to this: https://github.com/nim-lang/Nim/issues/6886 |
20:35:11 | PMunch | Although that is Nim <-> Nim loading |
20:36:46 | FromGitter | <rayman22201> Maybe try with `-d:useNimRtl` and the nimRTL.dll ? |
20:36:55 | FromGitter | <rayman22201> see if that gives different results |
20:38:46 | * | Perkol quit (Quit: Leaving) |
20:40:35 | FromGitter | <rayman22201> I think the function I was thinking of is called `initGC()` https://github.com/nim-lang/Nim/blob/10f5f6776799af43ae34501e7aa47fb7fe52dd20/lib/system/mmdisp.nim#L151 |
20:41:09 | FromGitter | <rayman22201> You could also try using a different GC, like boehm or something |
20:43:22 | FromGitter | <kdheepak> It's possible any shared library that was created in Nim being loaded elsewhere is going to have this issue (?). I find it hard to believe that that is the case, since I see a lot of Nim code being used using cdecl, exportc, dynlib. |
20:43:29 | PMunch | I tried every combination trying to debug the issue I linked, but they all had the same result (with different timings however) |
20:48:01 | FromGitter | <rayman22201> I think this is one of the motivations for destructors |
20:48:24 | FromDiscord_ | <potatonomicon> so, is there a page somewhere that describes how nim passes objects to procedures? or maybe something like 'nim for c programmers' |
20:49:04 | PMunch | Well |
20:49:12 | PMunch | It depends on what you're actually wondering about |
20:49:26 | FromGitter | <rayman22201> Quote from Araq: as a general rule, "Nim always passes by reference unless it is cheaper to copy the param by value" |
20:49:50 | PMunch | potatonomicon: https://www.reddit.com/r/nim/comments/7dm3le/tutorial_for_types_having_a_hard_time/ |
20:50:02 | PMunch | That should explain at least some of it |
20:50:16 | FromGitter | <Varriount> It's deliberately underspecified, so that platform implementations can vary. |
20:50:31 | FromGitter | <rayman22201> Also this: https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers |
20:51:19 | shashlick | anyone have experience with docker? trying to install mattermost-docker on ubuntu but it relies on alpine and doesn't install |
20:51:23 | xace | I want to setup a site with jester or karax. and afaik httpbeast doesnt support https. Does someone know of a lightweight minimal https proxy? nginx wouldnt run on the server I have in mind, I only have 128mb ram to spare. I found stunnel but it seems to have a history of vulnerabilities |
20:51:42 | FromDiscord_ | <potatonomicon> ok, so is there a way to enforce passing by value or reference? |
20:52:25 | FromDiscord_ | <potatonomicon> I imagine it's probably based on type size |
20:52:26 | PMunch | potatonomicon, well if you have a ref object it will be passed by ref |
20:54:18 | FromDiscord_ | <potatonomicon> ref objects are always heap allocated correct? |
20:54:38 | PMunch | Yes |
20:54:42 | PMunch | AFAIK |
20:55:02 | xace | potatonomicon: from what I have understood, if you do not specify 'var' as the proc parameter it will be read only, so you can't really asign to it (please correct me if I'm wrong) |
20:55:17 | PMunch | xace, correct. Kind of |
20:56:00 | PMunch | If you pass a ref object as a var you can't change the reference but you can change the data |
20:56:37 | PMunch | And if you do an unsafe cast on a let field you are still able to modify it |
20:56:49 | PMunch | If it was passed by reference (of which there is no guarantee) |
20:57:27 | PMunch | var basically ensures that it is passed by reference since you are able to update the value that was passed in |
20:57:43 | PMunch | Otherwise it's up to the compiler, and it chooses whichever is faster |
20:57:51 | xace | I see |
20:57:56 | FromDiscord_ | <potatonomicon> ok, that makes sense |
20:58:30 | PMunch | kdheepak, it's so annoying as this works just fine: https://github.com/nim-lang/Nim/tree/devel/tests/dll |
20:58:38 | FromDiscord_ | <potatonomicon> ref and let aren't keywords that can be used in parameters right |
20:59:29 | xace | ref can, let cannot. but there was this thing rule for when to use ref/ptr instead of var. |
21:01:01 | * | nsf quit (Quit: WeeChat 2.3) |
21:01:44 | FromDiscord_ | <potatonomicon> oh no, there is a ptr keyword too? |
21:02:54 | xace | potatonomicon: Haha yeah, this language scares me tbh. but it's the best i can find that suits my needs |
21:03:10 | xace | I figured I can learn those quirks with time and experience |
21:03:40 | FromDiscord_ | <potatonomicon> yeah, I'm a little burnt out on C++ and I like that nim has a pretty strong focus on things like macros |
21:04:38 | FromGitter | <rayman22201> Nim is still a million times safer than C++ (imo) but you still have escape hatches that let you poke the memory in the unsafe ways. |
21:05:21 | FromGitter | <kdheepak> @PMunch haha wow how is that working? |
21:06:17 | FromDiscord_ | <potatonomicon> safty isn't really what interests me about nim :p |
21:07:42 | FromGitter | <rayman22201> lol. fair enough |
21:08:32 | FromGitter | <rayman22201> @PMunch, @kdheepak that test doesn't really generate any strings, where-as the @kdheepak example allocates a string. I wonder if that's the difference? |
21:09:42 | PMunch | Yeah I was wondering the same, but it should sill use the GC though.. |
21:10:22 | FromGitter | <rayman22201> Yeah, that's my point actually. Nim strings leverage the GC much more heavily than a simple node allocation. |
21:11:17 | PMunch | potatonomicon, xace, basically never use ptr unless you are doing threads. It is an unchecked reference so you have to make sure yourself that the GC doesn't grab the data. ref on the other hand is checked by the GC. |
21:11:52 | PMunch | Use ref if you want ptr semantics, use var where you would use a ** argument in C |
21:12:01 | xace | oh, thats a rule i can remember |
21:12:16 | FromGitter | <kdheepak> @rayman22201 @PMunch ⏎ ⏎ I tried the following: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/nim-lang/Nim?at=5bec8fb0d001b917205eebb4] |
21:12:51 | FromGitter | <kdheepak> The full version of the code is here: https://github.com/NREL/glm |
21:12:56 | PMunch | Yeah, I've tried combinations of that as well |
21:13:22 | FromGitter | <kdheepak> So @PMunch is there no resolution that you found? |
21:13:38 | FromGitter | <rayman22201> potatonomicon, xace: you might need ptr if you are interfacing with low level C as well. But yeah, generally don't use it. |
21:15:15 | FromGitter | <rayman22201> @kdheepak, this may be a stupid request, but what happens if you return dummy data here? https://github.com/NREL/glm/blob/master/src/glm.nim#L14 |
21:15:25 | FromGitter | <kdheepak> @PMunch do you think there is anything I can do to get my code work in Python? |
21:15:47 | FromGitter | <rayman22201> my hunch is that the `$` is causing the GC issuel |
21:15:52 | FromGitter | <kdheepak> @rayman22201 there are no stupid questions! I'm wiling to try whatever. |
21:16:45 | FromGitter | <kdheepak> Still segfaults with nimpy ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec90bdbb06d73a99750fe2] |
21:17:18 | FromGitter | <kdheepak> I think the GC isn't working the way it should when in shared libaries. |
21:17:27 | FromGitter | <rayman22201> shoot |
21:18:08 | FromGitter | <rayman22201> Yeah. I'm out of ideas |
21:18:38 | PMunch | Nothing that I've found no |
21:18:42 | FromGitter | <rayman22201> @kdheepak How good are you with GDB? lol |
21:18:52 | PMunch | I just tried adding some strings to the client/server thing |
21:18:55 | PMunch | But it didn't work |
21:18:57 | * | zachk joined #nim |
21:19:16 | FromGitter | <kdheepak> I've learnt a lot in the last couple of days and I'm willing to learn more. |
21:19:16 | PMunch | I think the problem is with load and unloadLib |
21:19:46 | FromGitter | <kdheepak> Everytime I open gdb/lldb, I find that a pointer deferences to nothing. |
21:20:06 | FromGitter | <kdheepak> 1) Everytime I open gdb/lldb and try to run this code I find that a pointer deferences to nothing. |
21:20:09 | PMunch | In fact in some of my testing I've seen data in the libnames array be overwritten |
21:20:10 | FromGitter | <rayman22201> what's the gdb stack trace from that pointer derefence? |
21:20:30 | PMunch | So it's certainly something memory related.. |
21:21:14 | FromGitter | <rayman22201> like the root address of the GC is not being set correctly or something... hrmmm... |
21:22:46 | PMunch | Yeah, it's certainly strange.. |
21:22:47 | * | zachk quit (Changing host) |
21:22:47 | * | zachk joined #nim |
21:23:23 | FromGitter | <kdheepak> This is the result from lldb ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec924bbb06d73a99751caa] |
21:24:32 | PMunch | This is the error I get from the github issue: http://ix.io/1rUl |
21:38:52 | * | seni joined #nim |
21:40:11 | FromGitter | <rayman22201> @kdheepak can you compile with `nim c --debuginfo --linedir:on` and then run it with lldb? |
21:40:32 | FromGitter | <rayman22201> It's crashing in this function: https://github.com/NREL/glm/blob/master/src/parser.nim#L159 |
21:41:43 | FromGitter | <rayman22201> but still probably a GC issue, as tokens->data[11] should be a valid memory location |
21:41:49 | * | stefanos82 quit (Quit: Quitting for now...) |
21:42:16 | * | narimiran quit (Ping timeout: 260 seconds) |
21:42:45 | * | platoff_ joined #nim |
21:43:08 | * | druonysus quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
21:44:57 | FromGitter | <kdheepak> @rayman22201 if I use `--debuginfo --linedir:on` it doesn't segfault :P |
21:45:04 | PMunch | Hmm, curious |
21:45:09 | FromGitter | <kdheepak> I told you, heisenbug. |
21:45:55 | * | druonysus joined #nim |
21:45:55 | * | druonysus quit (Changing host) |
21:45:55 | * | druonysus joined #nim |
21:46:15 | FromGitter | <rayman22201> https://i.kym-cdn.com/photos/images/newsfeed/000/173/576/Wat8.jpg?1315930535 |
21:46:21 | PMunch | Okay, so if I remove the echo "loading ", libnames[index] line from here: https://github.com/nim-lang/Nim/issues/6886 |
21:46:27 | PMunch | It works just fine |
21:47:28 | PMunch | So it can have a echo "loading" |
21:47:38 | PMunch | But not echo "loading ", index either |
21:47:45 | FromGitter | <rayman22201> interesting. @PMunch what if you move the echo to the end of the function |
21:48:19 | PMunch | Oooh, the thick plottens |
21:48:28 | FromGitter | <rayman22201> that makes sense, a string literal doesn't allocate |
21:48:32 | PMunch | Putting the echo at the end works just fine |
21:48:49 | FromGitter | <rayman22201> ah-ha! progress |
21:49:54 | FromGitter | <rayman22201> I bet you, the `loadlib()` function changes the GC base address (it has to in order to accommodate the newly loaded code), and the allocated string from before that point is now garbage. |
21:50:20 | PMunch | Hmm, might be |
21:51:15 | PMunch | But why would that cause it to segfault at that line.. |
21:51:25 | PMunch | Is it GC'ing an older string? |
21:51:59 | FromGitter | <rayman22201> possible. |
21:52:04 | PMunch | Tried to do the concatenation before, store it in a variable, and write it out after |
21:52:08 | PMunch | That also crashed |
21:52:33 | FromGitter | <rayman22201> I don't think you can do any allocation before |
21:52:46 | PMunch | Yeah it appears like that is the issue |
21:52:57 | FromGitter | <yglukhov> @kdheepak @rayman22201 @PMunch. The issue is in nimpy stackbottom, it is off by 1 pointer. Problem is I don't know how to fix it ( |
21:53:44 | FromGitter | <rayman22201> hrmm.... interesting |
21:55:23 | PMunch | yglukhov, but why does loadLib trigger it? |
21:55:39 | PMunch | It just calls dlopen.. |
21:56:57 | FromDiscord_ | <Epictek> Been trying to figure out how to use Regex with the Javascript backend, anyone have any ideas? |
21:57:37 | FromGitter | <rayman22201> @Epictek just use the jsffi to interface with the native js regex engine. |
22:00:22 | FromGitter | <yglukhov> @PMunch, the main reason is that a bunch of alive objects are getting deallocated (because the gc missed one pointer on the stack), and they get overwritten with random other stuff, that got allocated on top of this memory. |
22:01:12 | PMunch | Oh yeah, I've gotten that far |
22:01:29 | PMunch | But how is loadLib triggering the change of stackbottom |
22:04:36 | FromGitter | <rayman22201> This is a very good question.... |
22:06:31 | FromGitter | <yglukhov> @PMunch tell me more. I know nothing about loadLib |
22:07:21 | PMunch | Well loadLib only calls dlopen from dlfcn.h |
22:08:00 | FromGitter | <yglukhov> yeah i mean, how is loadLib related to nimpy bug? |
22:08:19 | PMunch | I was talking about this: https://github.com/nim-lang/Nim/issues/6886 |
22:08:57 | FromGitter | <rayman22201> I think the nimpy bug and #6886 may be related |
22:12:19 | FromGitter | <yglukhov> oh ok. from the first glance it might be similar, but that's just a shot in the dark :) |
22:14:21 | FromGitter | <iffy> I think I asked this before, and the answer was "use this hacky method", but is there a nice way to obtain the path to `niminstallation/lib` from within Nim? |
22:14:56 | FromGitter | <gogolxdong> @PMunch How to put parsers in a common file and import it? |
22:14:59 | PMunch | nimsuggest somehow does it, not sure how |
22:15:07 | PMunch | Oh sorry, that was for iffy |
22:15:08 | FromGitter | <yglukhov> but can anyone suggest me how to do setStackBottom more reliably. I could just hardcode some "reasonable" tolerance of say 64 bytes, but would like to know better way... |
22:15:14 | FromGitter | <iffy> Also, hi @yglukhov! this is the first time I've seen you here. I appreciate all the awesome libraries you've made for Nim |
22:15:17 | PMunch | gogolxdong, use include instead of import :) |
22:16:12 | PMunch | yglukhov, how do you do setStackBottom now? |
22:17:07 | FromGitter | <iffy> PMunch: hehe, here's how nimsuggest does it: https://github.com/nim-lang/Nim/blob/27b081d1f77604ee47c886e69dbc52f53ea3741f/nimsuggest/nimsuggest.nim#L606 |
22:17:15 | FromGitter | <yglukhov> @PMunch https://github.com/yglukhov/nimpy/blob/master/nimpy.nim#L708 |
22:17:32 | FromGitter | <rayman22201> I have go afk for a bit. good luck guys |
22:17:44 | PMunch | iffy, well that how it appears to do it. But I've tried echoing out the values around there. Which shows it doesn't actually seem to do it all of the time |
22:18:10 | PMunch | My findExe("nim") for example doesn't have a lib close to it (because of choosenim) |
22:18:10 | FromGitter | <iffy> hmm, well let me see how it works for me |
22:18:16 | FromGitter | <yglukhov> hey @iffy nice to meet you. thanks, and feel free to contribute ;) |
22:18:16 | FromGitter | <iffy> oh |
22:18:16 | FromGitter | <gogolxdong> sure, thanks. |
22:19:18 | FromGitter | <iffy> @yglukhov I've been working on https://github.com/iffy/wiish which I've since learned has a bit more overlap with nimx than I initially thought. I hope to contribute back to nimx some of the stuff that might better fit in there. |
22:20:03 | PMunch | Ah, that's a new feature yglukhov? |
22:20:41 | FromGitter | <yglukhov> @PMunch you could say that. A few months maybe. |
22:22:04 | PMunch | Hmm |
22:22:39 | PMunch | Hmm, could not import: nimrtl_setStackBottom.. |
22:22:41 | FromGitter | <yglukhov> @iffy, awesome, can't wait! It's true i've abandoned ios lately (switched to linux). Though there were times when running "nake ios" would launch the nimx app on the connected iphone flawlessly :) |
22:23:13 | PMunch | I think nimrtl doesn't have it.. |
22:23:18 | FromGitter | <yglukhov> @PMunch are you trying to use it in the loadLib bug? :) |
22:23:25 | PMunch | yglukhov, how is Linux treating you? |
22:23:26 | PMunch | Yeah |
22:24:02 | FromGitter | <timotheecour> hi @pmunch, i know you’ve been massaging nimsuggest as a library lately; I have relevant PR’s where I cc’d you |
22:24:16 | FromGitter | <iffy> PMunch: oh, well I guess it makes sense that the stdlib doesn't include a way to find the nim lib, because the code might be running in a compiled binary on a machine that doesn't even have nim installed. So perhaps I need to rethink my approach |
22:24:17 | PMunch | Yeah I saw that |
22:24:26 | PMunch | I have an idea to redo it |
22:24:39 | PMunch | Basically some when isMainModule in the actual nimsuggest code |
22:24:51 | FromGitter | <yglukhov> I'm quite happy with linux. I've got a Matebook X pro, and with linux it's like a macbook13 on steroids. |
22:24:51 | FromGitter | <timotheecour> redo what? |
22:24:55 | * | rockcavera quit (Remote host closed the connection) |
22:25:05 | PMunch | The nimsuggest library, I'm having some strange issues with it |
22:25:14 | FromGitter | <timotheecour> Link? |
22:25:18 | FromGitter | <timotheecour> (to issue) |
22:25:42 | PMunch | I haven't created an actual issue for it |
22:26:00 | PMunch | yglukhov, oh cool. I was considering the Matebook X recently |
22:26:18 | PMunch | But I opted for a Thinkpad t480s |
22:27:34 | FromGitter | <timotheecour> @PMunch @iffy regarding `oh, well I guess it makes sense that the stdlib doesn't include a way to find the nim lib` does this help? `findNimStdLibCompileTime` which I had added in https://github.com/nim-lang/Nim/pull/9181 |
22:31:07 | FromGitter | <iffy> @timotheecour hmm... I think even knowing the path at compileTime doesn't get me quite to where I want to be. For instance, if myapp was compiled on machine A, then on machine B I run myapp, I'd like for myapp to find the nim library on machine B |
22:31:42 | FromGitter | <iffy> (so that myapp can execute a compile step knowing where nimbase.h is) |
22:32:28 | FromGitter | <timotheecour> in that case provide a `—nim:binarytonim` arg? |
22:33:22 | FromDiscord_ | <potatonomicon> so, if I use ref in a procedures parameters does it only accept objects that have been declaired with ref or will it promote stack allocated objects into reference counted ones and reallocate them on the heap? |
22:33:44 | FromGitter | <iffy> @timotheecour yes, I think I'll have it guess somewhere by default, but otherwise require the user to specify it |
22:33:56 | PMunch | Only those that have been declared with ref |
22:34:13 | FromGitter | <iffy> (if the guess is no good). Or is `--nim:binarytonim` a `nim` flag I'm not familiar with? |
22:35:42 | FromGitter | <yglukhov> PMunch: cool. i bet thinkpad has a much better cooling and doesn't throttle all the time :) |
22:35:46 | FromGitter | <timotheecour> Oh no, that was just if you want a custom binary to allow user to specify nim binary |
22:36:39 | PMunch | Haha, I hope not. The Matebook is a beautiful machine though |
22:36:43 | FromGitter | <timotheecour> nevermind my comment about `—nim` (and as others mentioned, there’s the slightly less flexible option of using `findExe("nim”)`) |
22:37:02 | PMunch | I just realized today though that changing it to Dvorak might be a bit tricky |
22:38:07 | FromGitter | <yglukhov> you mean swapping the keycaps? it is tricky indeed. |
22:42:04 | PMunch | Well its a breeze on most other machines |
22:42:21 | PMunch | But the trackpad-nub-thing means the keys around it are different from the others.. |
22:56:58 | FromGitter | <kdheepak> @yglukhov just want to say that you are amazing! your fixes worked and I'm able to run in Python again. |
22:58:23 | PMunch | Could get it to work for dynlibs... |
22:58:29 | PMunch | Couldn't* |
23:21:47 | * | platoff_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
23:25:52 | FromDiscord_ | <potatonomicon> so I just installed sdl2 via nimble, and attempting to import it results in a undeclared identifier error for CurrentEndThreada |
23:29:23 | FromDiscord_ | <potatonomicon> Seems there is a typo in sdl2/private/thread.nim |
23:29:35 | FromDiscord_ | <potatonomicon> It's supposed to be CurrentEndThread not CurrentEndThreada |
23:29:47 | FromGitter | <zetashift> might want to PR that |
23:39:10 | * | Xe quit (Ping timeout: 252 seconds) |
23:39:13 | FromDiscord_ | <potatonomicon> Looks like it's already been fixed on github, but nimble still has an outdated version |
23:39:20 | FromDiscord_ | <potatonomicon> or something |
23:39:43 | * | bozaloshtsh quit (Ping timeout: 252 seconds) |
23:40:33 | FromDiscord_ | <potatonomicon> can I get nimble to pull from github? |
23:40:45 | * | bozaloshtsh joined #nim |
23:40:45 | * | bozaloshtsh quit (Changing host) |
23:40:45 | * | bozaloshtsh joined #nim |
23:45:29 | * | Xe joined #nim |
23:45:35 | * | Xe quit (Changing host) |
23:45:35 | * | Xe joined #nim |
23:47:34 | * | Aareon_ quit (Ping timeout: 250 seconds) |
23:47:57 | FromGitter | <zetashift> `nimble install sd2@#head` might work @potatonomicon |
23:48:09 | FromGitter | <zetashift> sdl2@#head* jeez I need sleep |
23:49:36 | FromDiscord_ | <potatonomicon> I'll give it a try thanks |
23:50:09 | * | Aareon_ joined #nim |
23:52:35 | * | vlad1777d joined #nim |
23:54:02 | FromDiscord_ | <potatonomicon> seems to work |
23:55:56 | * | cozachk joined #nim |
23:58:17 | * | zachk quit (Ping timeout: 268 seconds) |