<< 14-11-2018 >>

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:05FromGitter<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:05FromGitter<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:51FromGitter<DanielSokil> What is an `OG interface`?
00:38:51FromGitter<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:24FromGitter<zacharycarter> by OG I just meant original
00:58:41FromGitter<zacharycarter> there is sensibility in keeping the library API the same
00:59:08FromGitter<zacharycarter> if you're porting it - I don't see any reason not to stick to idiomatic Nim / style and naming conventions
00:59:57FromGitter<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:53FromGitter<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:18FromGitter<zacharycarter> so consumers of the library don't have to rely on passing cints, cstrings, etc... to your procedures
01:02:46FromGitter<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:04FromGitter<DanielSokil> I'm not porting any library, I'm using this module https://nim-lang.org/docs/db_sqlite.html
01:37:25FromGitter<zacharycarter> @DanielSokil - my message about the library stuff wasn't related to your question
01:37:35FromGitter<zacharycarter> it was a response to a topic above where you posted your question
01:37:41FromGitter<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:58FromGitter<zacharycarter> use cstring @ratiotile
01:38:20FromGitter<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:20FromGitter<ratiotile> I do, it results in non-const char*
01:38:24FromGitter<zacharycarter> oh const sorry
01:39:09FromGitter<zacharycarter> hrm - I don't understand your question, do you mean pass a string to C?
01:39:19FromGitter<ratiotile> no, I am passing from C to Nim
01:39:22FromGitter<zacharycarter> okay
01:39:39FromGitter<ratiotile> C++ to be precise
01:40:04FromGitter<zacharycarter> 1) you can use c2nim with the `cpp` flag to generate glue code - there's also nimgen
01:40:33FromGitter<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:53FromGitter<zacharycarter> I think you need a mutable pointer to a immutable string
01:42:40FromGitter<zacharycarter> nim has `ptr` which is an unsafe pointer
01:43:14FromGitter<ratiotile> cstring is already a pointer though
01:43:17FromGitter<zacharycarter> https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers
01:43:41FromGitter<zacharycarter> right and what you're looking for - I believe - is a mutable pointer to an immutable string
01:43:51FromGitter<zacharycarter> that's what `const char*` is in C++ right?
01:44:09FromGitter<ratiotile> and I don't know how to do that, since Nim's proc parameters are immutable by default
01:44:16FromGitter<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:48FromGitter<zacharycarter> `var str*: cstring = "This is GeeksForGeeks" ⏎ `
01:44:51FromGitter<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:51FromGitter<zacharycarter> from
01:44:58FromGitter<zacharycarter> `const char* str = "This is GeeksForGeeks";`
01:45:41FromGitter<zacharycarter> yeah - you need to use `var` I think @ratiotile
01:45:53FromGitter<ratiotile> doesn't var make it non-const?
01:45:59FromGitter<ratiotile> I will try it
01:46:39FromGitter<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:37FromGitter<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:54FromGitter<ratiotile> so without var the error is: cannot convert from NCSTRING to const char*.
01:48:02FromGitter<zacharycarter> there might be some idiosyncrasies in the usage of that library
01:48:07FromGitter<ratiotile> with var: cannot convert from NCSTRING& to char*
01:48:13FromGitter<ratiotile> i mean const char *
01:48:14FromGitter<zacharycarter> heh
01:48:22FromGitter<ratiotile> NCSTRING = char*
01:50:48FromGitter<zacharycarter> @ratiotile - I don't really have any other suggestions to throw at you - sorry
01:50:52FromGitter<zacharycarter> I looked at - https://github.com/acmeism/RosettaCodeData/tree/master/Task/Call-a-function-in-a-shared-library/Nim
01:51:07FromGitter<zacharycarter> I see
01:51:39FromGitter<zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5beb7fabbb06d73a996e11b6]
01:51:42FromGitter<zacharycarter> and then
01:52:02FromGitter<zacharycarter> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5beb7fc162866f7473958ee1]
01:52:19FromGitter<zacharycarter> so I'm not sure why that's not working for you
01:53:02*benjikun quit (Quit: Lost terminal)
01:53:34FromGitter<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:14FromGitter<zacharycarter> ah I see
01:54:15FromGitter<rayman22201> @zacharycarter He wants to go the other way. Call a Nim function from C++, correct?
01:54:27FromGitter<ratiotile> yes
01:54:27FromGitter<zacharycarter> okay sorry - I'm definitely out of my wheel house then
01:54:49FromGitter<rayman22201> This is a less common usecase
01:55:10FromGitter<zacharycarter> interesting nonetheless
01:55:17FromGitter<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:00FromGitter<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:38FromGitter<rayman22201> I think you have to define your own string type that is "const char*"
01:57:49FromGitter<rayman22201> possibly with with an emit pragma
01:57:54*dddddd quit (Remote host closed the connection)
01:57:57FromGitter<ratiotile> I see, that might work
01:59:32FromGitter<ratiotile> does the emit pragma work with types?
02:00:00FromGitter<rayman22201> Yes. See the second example here: https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma
02:04:23FromGitter<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:51FromGitter<ratiotile> @rayman22201 Thanks, it worked! ⏎ What I did was `typedef const char* ConstCStr;` and then importcpp it as an object.
02:17:11FromGitter<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:02FromGitter<zacharycarter> @DanielSokil - interesting, haven't used that lib before
02:19:19FromGitter<zacharycarter> good to know though - may want to post an issue and let the author know to include that in the docs
02:19:33FromGitter<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:48FromGitter<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:09FromGitter<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:04FromGitter<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:45sagaxhi all!
03:54:59sagaxwhat web framework we have?
03:55:13sagaxcan't found this in this place https://nimble.directory/
03:59:44FromGitter<zacharycarter> karax
03:59:46FromGitter<zacharycarter> night all
04:00:08Tangersagax: https://github.com/VPashkov/awesome-nim#web
04:03:45*Aareon_ joined #nim
04:04:35FromGitter<gogolxdong> addr array[] == cstring == char[], cstring works too for sending.
04:08:21*kapil____ joined #nim
04:22:55FromGitter<gogolxdong> @PMunch http://ix.io/1rQ9
04:24:40FromGitter<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:06FromDiscord_<2vg> wow, techempower 🔥
05:01:06FromDiscord_<2vg> https://imgur.com/a/qFtIyhq
05:18:37*vlad1777d quit (Ping timeout: 252 seconds)
05:23:48FromGitter<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:44leorizeAchalaSB: Install a version of LLVM that has wasm target enabled
06:03:47*smt` quit (Read error: Connection reset by peer)
06:07:06FromGitter<gogolxdong> How to convert array[n,byte] to string?
06:10:57leorizewrite a proc?
06:11:33FromGitter<gogolxdong> \x00 in received buffer will be taken as the terminate character of a cstring .
06:18:47leorize``proc `$`(a: openArray[byte]): string = (result = newString(len a); for i in a: (result.add char i))``
06:18:53leorize^ shouldn't that work?
06:19:08leorizenim string doesn't care about `\x00`
06:19:51leorizeoh, 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:51FromGitter<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:00FromGitter<gogolxdong> cannot construct string bypass a cstring because of there is \x00.
07:02:51*mech422__ quit (Ping timeout: 252 seconds)
07:05:33FromGitter<gogolxdong> your proc refresh buffer quickly, have no idea.
07:05:52FromGitter<gogolxdong> even not referenced.
07:06:12leorizegogolxdong: https://ptpb.pw/hQ-B
07:06:57*narimiran quit (Ping timeout: 268 seconds)
07:07:05leorizefor some reason array's `$` always gain precedence over a custom defined `$` so I've to name it `toStr`
07:07:42FromGitter<gogolxdong> Sure, it's straightforward but cause recv not blocking and refresh recv loop rapidly.
07:08:27leorizeyou should fetch the entire thing first before trying to convert it to string
07:08:28FromGitter<gogolxdong> not blocking any more once has such a proc .
07:10:11FromGitter<gogolxdong> even not referenced to the proc.
07:10:57*Aareon_ quit (Ping timeout: 250 seconds)
07:14:22FromGitter<gogolxdong> in the same file, moved it to another file, works.
07:16:47FromGitter<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:40FromGitter<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:37FromGitter<gogolxdong> http://ix.io/1rQv FYI
07:29:01FromGitter<gogolxdong> from the view of seq[byte] it's the same with original .
07:32:11FromGitter<gogolxdong> as shown in `echo castseq[byte (packet)` which packet is the converted string from array buffer.
07:35:37krux02https://github.com/nim-lang/Nim/issues/2286
07:44:55FromGitter<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:48FromGitter<narimiran> krux02 i've tried to run that, uncommenting the line that is supposed to crash the program, and it works fine!?
07:47:51krux02well it doesn't crash
07:47:58krux02but does it do the right thing
07:48:08krux02and another question, is the test actually testing for the right thing
07:48:35FromGitter<narimiran> what is "the right thing"? am i missing something?
08:03:29krux02nirimiran: 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:48FromGitter<gogolxdong> filed a minimal issue reproducable snippet.
08:09:19krux02narimiran[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:24FromDiscord_<lastpass> Hello everyone!
08:27:50Araqhi
08:28:53PMunchHi
08:32:12*floppydh joined #nim
08:33:16FromGitter<gogolxdong> @PMunch, help wanted.
08:36:36PMunchHi gogolxdong, what can I help you with?
08:38:19FromGitter<gogolxdong> http://ix.io/1rQK
08:38:40FromGitter<gogolxdong> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bebdf103102f145219c1de6]
08:40:52FromGitter<gogolxdong> From the view of seq[byte] cast from string , it's the same with original .But got the bottom error.
08:40:54PMunchYeah, that makes sense
08:41:07PMunchOkay, so headerType reads one byte
08:41:26PMunchThen version reads 4 bytes (the four first zeros)
08:42:05PMunchThen dcil and scil reads 4 bits each (17 = 0b00010001) making dcil = 1 and scil = 1
08:42:26PMunchThen dcid tries to read dcil+3 bytes, aka 4 bytes
08:42:44PMunchThis reads the two 15's and the two last zeros
08:43:14PMunchThen scid wants to read 4 bytes (scil+3), but there is no more data
08:47:32PMunchDid that make sense?
08:47:39FromGitter<gogolxdong> dcil and scil is 4-18 bytes, I don't think the syntax is right.
08:48:10FromGitter<gogolxdong> dicd and scid ,sorry ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bebe14ad001b917205a3d46]
08:48:52FromGitter<gogolxdong> should be u16-u144, but cannot define u144
08:49:23PMunchu16? That's only 2 bytes
08:49:25FromGitter<gogolxdong> u32-u144
08:49:28PMunchAh
08:49:51PMunchYeah, what you are doing there is right
08:49:59PMunchIt's reading 4-18 bytes
08:50:11PMunchOr rather 0|4-18
08:50:44PMunchdcil's max value is 0b1111 which is 15 plus 4 which is 18. So 18 bytes (since dcid is u8)
08:51:10PMunchThe problem is that your data stream doesn't actually have enough data
08:51:28FromGitter<gogolxdong> outData.dcid = @[1u8,2,3,4] ⏎ ⏎ ```outData.scid = @[5u8,6,7,8]``` [https://gitter.im/nim-lang/Nim?at=5bebe20f6b9822140d29e19c]
08:51:37PMunchboth dcil and scil are set to 1, which means they'll try to read 4 bytes
08:52:29FromGitter<gogolxdong> I changed to this, and enlarge the read buffer, but only read 1,2 ,0,0,...
08:52:55PMunchHold on, I'm testing it
08:55:34PMunchSeems to work fine for me: http://ix.io/1rQL/
08:58:16FromGitter<gogolxdong> yes, it's out of supportedVersion
08:58:24PMunchHmm, seems like the supportedVersion doesn't work
08:58:29FromGitter<gogolxdong> it's 1|more
08:58:48PMunchLooking at the generated writer it doesn't appear to actual create any code to write that field..
08:59:39PMunchYou can also use -d:binaryparseLog to make it echo out what it's reading
09:00:26PMunchDoesn't do anything for writing atm though
09:00:50FromGitter<gogolxdong> I noticed that, but it's problem of supportedVersion .
09:01:49FromGitter<gogolxdong> it's 1|more, have no idea how to map this to your binary pattern.
09:02:01PMunchYeah, it doesn't have any code to write that field. I'm looking into it right now
09:02:29PMunchIs it dependent on some other value how many fields it is?
09:02:48PMunchOr is it just the rest of the message?
09:03:56FromGitter<gogolxdong> http://ix.io/1rQP
09:04:24PMunchYeah but what is N?
09:05:15PMunchIs 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:09FromGitter<gogolxdong> to the end
09:07:06PMunchOkay, then I'd just have it the way you do now
09:07:15PMunchBut I have to fix binaryparse for it to work
09:08:40FromGitter<gogolxdong> need an additional feature ?
09:09:01PMunchWell, it's more fixing a bug than adding a feature
09:09:06PMunchWhat you have should work
09:09:41PMunchI 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:14FromGitter<gogolxdong> ok, does u32: supportedVersion[] mean it's 1+ field?
09:13:27PMunchNo, it means 0+ fields
09:13:41PMunchSo you need to implement the len != 0 check yourself
09:13:51PMunchOr use a custom reader/writer
09:14:08PMunchhttp://ix.io/1rQT/Nim
09:14:20FromGitter<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:22PMunchThat will work with the current version of binaryparse until I can patch it
09:14:52PMunchThere you can also see how to write a custom reader/writer, and it should be obvious where a length check would go :)
09:16:49PMunchOh wait, writing the sequence like that doesn't work
09:17:26PMunchIt should be like this: http://ix.io/1rQU/Ni
09:17:28PMunchIt should be like this: http://ix.io/1rQU/Nim
09:22:22FromGitter<gogolxdong> It works for writing, not for parsing this time.
09:23:37FromGitter<gogolxdong> http://ix.io/1rQW
09:24:31*alehander42 joined #nim
09:26:11PMunchCode?
09:26:25PMunchThat is an error from the streams module..
09:26:46FromGitter<gogolxdong> http://ix.io/1rQX
09:29:26PMunchHmm yeah
09:29:32PMunchIt seems to be off by 2 bytes
09:29:40PMunchHow do you generate that?
09:32:17PMunchhttp://ix.io/1rQZ/
09:32:26PMunchAs you can see this reads and writes correctly
09:32:50PMunch(Had to make a minor change to the reader I sent you, it was reading little endian and not big endian)
09:35:49FromGitter<gogolxdong> http://ix.io/1rR1
09:37:47FromGitter<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:04PMunchYeah, 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:52PMunchSo 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:09FromGitter<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:52PMunchYay :)
09:44:25PMunchOr where you expecting there to be some data in those fields?
09:45:51FromGitter<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:47FromGitter<gogolxdong> oh, it's dynamic.
09:47:52PMunchYeah..
09:47:58PMunchSo it doesn't really have a size
09:48:18PMunchBut you can do versionNegoPacket.put(ss); ss.getPosition()
09:48:25PMunchThat will tell you the amount of data written
09:48:55PMunchPut of course with another parameter there
09:49:05FromGitter<gogolxdong> good trip
09:49:39FromGitter<gogolxdong> How about the incorrect dcid,scid,supportedVersion field?
09:51:41*alehander42 quit (Remote host closed the connection)
09:52:06PMunchTry 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:29FromGitter<gogolxdong> 3 offset seems didn't work, it read only two bytes.
09:54:17*dddddd joined #nim
09:54:32FromGitter<gogolxdong> why did sender send only 8 bytes?
09:55:12PMunchHuh?
09:55:33FromGitter<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:52FromGitter<gogolxdong> comes to supportedVersions
09:58:16FromGitter<gogolxdong> used your tip of sent size.
09:59:36*deathpoison joined #nim
10:00:28PMunchNice, that looks better
10:00:44PMunchWhat's wrong with the supported versions?
10:01:07FromGitter<gogolxdong> supportedVersion: (supportedVersions: @[167772160, 1677721600, 279183360])
10:01:33FromGitter<gogolxdong> compared with (supportedVersions: @[10, 100, 42000])
10:01:39PMunchRight
10:01:48PMunchThat's big-endian vs little-endian for your :)
10:02:25FromGitter<gogolxdong> oh
10:03:46PMunchAre you using the same version I used?
10:04:41FromGitter<gogolxdong> `s.readDataLE(result.supportedVersions[0].addr , 4)`?
10:04:55FromGitter<gogolxdong> for getter?
10:05:15FromGitter<gogolxdong> not sure what BE and LE means
10:06:20FromGitter<gogolxdong> oh, big-endian and litter-endian.
10:06:32FromGitter<gogolxdong> got it, and fully works.
10:07:37FromGitter<gogolxdong> `s.readDataLE(result.supportedVersions[^1].addr , 4)`
10:14:40PMunchPushed a new version of binaryparse now
10:15:39FromGitter<gogolxdong> checking
10:16:05PMunchHmm wait
10:16:12PMunchI seemed to have messed it up
10:17:13PMunchOh no, it's right. I had just forgotten to update it on my machine :P
10:17:42PMunchSo this now works as expected: http://ix.io/1rRa/
10:22:07FromGitter<gogolxdong> perfect.
10:23:22FromGitter<gogolxdong> How do you check whether it's in BE or LE?
10:23:43PMunchWhat do you mean check?
10:24:56FromGitter<gogolxdong> in native byte order or network byte order.
10:25:44FromGitter<cyberlis> i thought that there is no way to detect it? you just have to know your bite order ?
10:26:02FromGitter<cyberlis> byte*
10:26:17PMunchYeah, there is no way to detect it
10:26:31PMunchTake the 16 bit number 10: 00 0A
10:26:46FromGitter<gogolxdong> I didn't need to take care of supportedVersions in native or network byte order, it's just right.
10:26:59PMunchThat's in big-endian, in little-endian it would be: 0A 00
10:27:54PMunch0A 00 is still a valid number, it's just not 10 but 2560 if read as a big-endian number
10:31:04FromGitter<gogolxdong> Data would be sent in network byte order in the wire, right ? And received as little-endian byte order automaically?
10:34:06FromGitter<gogolxdong> since no matter putting locally or onto network, it's consistent as getting.
10:37:12FromGitter<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:47FromGitter<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:59PMunchbinaryparse 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:35FromGitter<gogolxdong> oh, that explains why it doesn't need to reverse as receiving, right?
11:02:46FromGitter<gogolxdong> otherwise it needs reverse, right?
11:04:49FromGitter<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:14FromGitter<yyyc514> proc `value=`*(i: var Input, v: int) =
11:58:36FromGitter<yyyc514> Error: 'i1.value' cannot be assigned to
11:59:38Araqi1 != i
12:00:18FromGitter<yyyc514> i1 is in the test
12:00:29FromGitter<yyyc514> it's a instance of Input
12:01:22FromGitter<yyyc514> trying to do `i1.value = 2`
12:07:30*kapil____ quit (Quit: Connection closed for inactivity)
12:07:57Araqdon't use 'let' but 'var' for it or something
12:08:43FromGitter<narimiran> yeah, `var` was my first guess too
12:08:52FromGitter<yyyc514> the tests use `let`... changing to it refernce seems to work
12:09:10FromGitter<narimiran> @yyyc514 this works: http://ix.io/1rRD/
12:09:12FromGitter<yyyc514> i see the issue with it being let now though :)
12:10:29FromGitter<alehander42> we can add a hint to the error, does it happen for other cases than `let` vs `var` ?
12:10:46FromGitter<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:26Araqwhich Nim symbol is used most often in Nim's compiler source?
12:43:03PMunchAre you asking or are you quizing?
12:43:39FromGitter<cyberlis> `:` ?
12:44:08Araqa) +
12:44:13Araqb) int
12:44:16Araqc) !=
12:44:19Araqd) string
12:44:41Araq(':' is not a symbol, it is only a token)
12:44:47FromGitter<survivorm> i vote for plus (a)
12:44:51AraqPMunch: quizing
12:44:53FromGitter<cyberlis> a)
12:46:47PMunchI think I'll go for b
12:47:04PMunchHmm
12:47:19Araqlol never mind my query is wrong
12:47:21FromGitter<cyberlis> you can write `let a = 10` without int
12:47:31Araqbut out of these 4, it's !=
12:47:39PMunchHuh
12:47:45PMunchWouldn't have guessed that
12:48:08PMunchcyberlis, yeah but I think the compiler most often works with objects with various fields
12:48:22PMunchAraq, do you have them in order?
12:48:23Araqah hmm my query is right
12:48:35Araqso yeah, it's !=
12:48:44Araqbut it's unfair, == is overloaded and != is not :P
12:49:07FromGitter<alehander42> I also thought for a)
12:49:21Araqthe compiler doesn't do many additions
12:49:51AraqPMunch: no and I gotta go, bbs
12:50:05FromGitter<narimiran> wow! i thought it is either A or B
12:50:06FromGitter<alehander42> that's why i'd prefer isNil/isEmpty everywhere :D
12:50:13FromGitter<narimiran> more quizzes like this, please! :)
12:51:09PMunchWonder how Araq made that query.. Would be fun to get other info like that
12:55:24FromGitter<alehander42> btw PMunch, does LSP support refactoring stuff
12:55:32FromGitter<alehander42> e.g. not only finding usages of variables
12:55:35FromGitter<alehander42> but also replacing them
12:56:36PMunchWell it supports getting usages of a symbol
12:56:56PMunchSo 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:31FromGitter<alehander42> hm, true indeed
13:11:58FromGitter<alehander42> this would be especially useful for e.g. replacing/adding args to changed call
13:12:02FromGitter<alehander42> but that's probably harder
13:12:03*rockcavera quit (Remote host closed the connection)
13:13:19PMunchWell I think that nimsuggest supports what would be required for that
13:13:28PMunchmaybe
13:19:38*rockcavera joined #nim
13:23:59FromGitter<yyyc514> hmmmm
13:24:20FromGitter<yyyc514> now how can i purposely call the getter if i'm within my own class... value() doesn't seem to work
13:42:12FromGitter<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:37FromGitter<narimiran> @kungtotte i know the answer :) i was also surprised/shocked when i first tried ** recently :)
14:13:59FromGitter<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:59PMunchHmm, I'm having trouble with getting nimlsp to set up the correct path when I use my ripped version of nimsuggest..
14:32:23PMunchI 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:09FromGitter<zacharycarter> https://github.com/fungos/cr
14:39:54*vegax87 joined #nim
14:40:30*Vladar quit (Remote host closed the connection)
14:48:13FromGitter<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:34FromGitter<tim-st> allowing `and` and `or` at start of next line would be really nice :\
15:33:47FromGitter<mratsim> C doesn’t allow || or && at the geinning of a line though
15:34:43FromGitter<kayabaNerve> And it's just bad from a design standpoint :thinking:
15:34:56FromGitter<kayabaNerve> That only works out of 1/3 platforms :( no idea about Matrix tbh.
15:35:32FromGitter<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:16FromDiscord_<exelotl> I legit find it really hard to get `shl` and `shr` the right way round
15:51:39*Trustable joined #nim
15:52:23FromDiscord_<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:36FromDiscord_<exelotl> But I have no problem with << and >>
15:53:26*platoff_ joined #nim
15:53:54FromDiscord_<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:34FromGitter<cyberlis> exelotl, maybe you can your own template for `<<` and `>>` ?
15:54:43FromGitter<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:01FromGitter<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:56FromDiscord_<exelotl> Oh yeah, making a template for <<, >> is what I ended up doing in the end
16:52:22*nsf joined #nim
16:52:55FromDiscord_<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:27FromGitter<brentp> I am getting unexpected behavrio only for debug builds and only from an iterator: https://gist.github.com/brentp/e45ab693d4c25881172d2066d63b8717
16:55:39FromGitter<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:54junkazolkeri where are youuuuu
17:09:30junkaZOOOOOOOOOOLKEEEEEEERIIIIIIII
17:09:44junkapm me if you see this
17:09:48*junka left #nim ("Farting")
17:14:35FromGitter<brentp> I updated the gist to simplify: https://gist.github.com/brentp/e45ab693d4c25881172d2066d63b8717
17:18:13Araqdon't use .bitsize
17:18:33Araqit's only for C interop
17:20:29FromGitter<brentp> :(
17:20:54FromGitter<brentp> so I'll have to do my own bitshifting to save memory?
17:21:24Araqno, you can use set[MyEnum]
17:24:26Araqand 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:20FromGitter<brentp> looking at sets now. but in my real use-case, I'm splitting 32 bytes as 1,1,24,6
17:27:41FromGitter<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:18FromGitter<Varriount> @brentp Wouldn't it be better to use bit masks, and operate on the 32-bit integer as a whole?
17:51:34FromDiscord_<lastpass> Idea: rewrite most cryptographic libraries with Nim.
17:52:53FromDiscord_<lastpass> Example: https://github.com/libtom/libtomcrypt
17:52:59FromDiscord_<lastpass> Has a good collection
17:53:15FromGitter<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:30shashlickAraq: had some questions on https://github.com/nim-lang/Nim/issues/8327 - do you have some time to chat?
18:29:55Araqshashlick, I read your comment
18:30:17shashlicki am playing with tree-sitter and was wondering on next steps
18:30:48shashlickmy goal is to simply offer a cimport "cfile.h" type functionality for starters
18:30:52shashlicknot full file conversion
18:30:58Araqwell import compiler / [ast, renderer]
18:31:23shashlickso there's 3 options - 1 = same as c2nim - separate binary but no big advantage
18:31:23Araqand transform the tree-sitter AST into Nim's AST
18:31:41shashlickok so do you want to build tree-sitter into the nim compiler
18:31:46shashlickor keep it as a separate module
18:32:07Araqit would be like c2nim but you can staticExec() the tool from within your Nim program
18:32:30shashlickin that case, wouldn't it be better to use macros and inject the AST that way
18:33:00Araqnot IMO.
18:33:24shashlickso then how will I inject the AST into the currently compiling program with staticExec()?
18:33:45Araqmacros are for Nim to Nim translations
18:33:45shashlickkeeping aside where the tree-sitter AST => Nim AST conversion is done
18:33:49Araqbut bbs
18:41:00*smitop_ quit (Quit: Connection closed for inactivity)
18:41:32FromGitter<kdheepak> How to convert a `cstring` to a `string` and a `string` to a `cstring` type in Nim?
18:42:37FromGitter<brentp> using $ to convert cstring to string and "some".cstring to go the other way.
18:49:52FromGitter<kdheepak> Thanks!
18:52:29Araqshashlick, back
18:53:38Araqwell 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:17shashlickso that's still the c2nim model
18:56:04Araqif you say so ... :P
18:56:12Araqwhat's wrong with the c2nim model?
18:56:31shashlickwell, it keeps the compiler and this interop tool separated again
18:56:53shashlickregardless, when you talk of AST, there's no escape i guess
18:57:13*Amun_Ra quit (Quit: brb)
18:57:16shashlickmy thought was that there was no need for an intermediate nim representation of the C code imported
18:58:05shashlickyou 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:27shashlickall existing C lib documentation will also be relevant
18:58:52*Amun_Ra joined #nim
19:00:09shashlickthanks to identifier equality, names won't matter either
19:00:48*NimBot joined #nim
19:03:08shashlickI agree with that although tree-sitter with C and C++ langs is only ~4mb compiled
19:03:33shashlickanyway, it requires C99 so if that's a limitation, I don't know
19:03:46shashlickno elaborate cmake/configure mess either
19:10:11shashlickmeanwhile, 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:31shashlickthis way there is no dependency on compiler
19:16:13*nsf quit (Quit: WeeChat 2.3)
19:37:26shashlickAraq: 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:57FromGitter<arnetheduck> btw, does treesitter really parse c++? ie does it do contextual parsing based on symbol table?
19:47:41shashlickit parses 18 languages
19:47:45shashlickincluding C++
19:48:54shashlicknot sure how to answer your question though
19:55:32*floppydh quit (Quit: WeeChat 2.3)
20:16:01FromGitter<kdheepak> I have a really weird error when building a shared library from Nim code.
20:16:33FromGitter<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:30FromGitter<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:13FromGitter<kdheepak> It's like a heisenbug, the error changes when I try to observe it.
20:19:03FromGitter<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:40PMunchHow do you compile it?
20:19:49FromGitter<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:09FromGitter<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:43FromGitter<kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec839bd001b917205e99f2]
20:21:08PMunchhttps://nim-lang.org/docs/nimc.html#dll-generation
20:21:12PMunchThat might be helpful for you
20:21:26FromGitter<kdheepak> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec83c5e0fd6b4360f32ea7]
20:21:50PMunchOh wait, that shouldn't matter if you don't run it from Nim..
20:22:56FromGitter<kdheepak> This is the weirdest thing I've encountered.
20:23:05PMunchYeah..
20:23:13FromGitter<rayman22201> He still needs to start up the GC
20:23:15PMunchDynlibs in Nim have been proven not to work too great..
20:23:17FromGitter<kdheepak> I've tried stepping through using lldb as well, and I'm not able to make sense.
20:23:23FromGitter<kdheepak> How do I start the gc?
20:23:45FromGitter<rayman22201> I'm trying to remember. stand by lol
20:24:03PMunchsetupForeignThreadGC()=
20:24:06PMunchPossibly
20:24:09PMunchWithout 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:04FromGitter<rayman22201> Have you seen this @kdheepak ? https://github.com/yglukhov/nimpy
20:25:44FromGitter<rayman22201> may be easier
20:26:40FromGitter<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:30FromGitter<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:54FromGitter<rayman22201> ah. Well, if yglukhov can't figure it out, then it's definitely outside of my expertise! lol
20:28:21FromGitter<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:48FromGitter<kdheepak> Perhaps this is a nim issue when it generates libraries.
20:29:06FromGitter<kdheepak> It does seem like it could be a Nim garbage collection issue.
20:30:42FromGitter<rayman22201> That's what it seems like to me as well, but I'm not familiar enough with Nim's GC internals
20:31:30FromGitter<rayman22201> yglukhov is doing some GC magic here: https://github.com/yglukhov/nimpy/blob/master/nimpy.nim#L705
20:32:58FromGitter<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:59PMunchYour issue might be related to this: https://github.com/nim-lang/Nim/issues/6886
20:35:11PMunchAlthough that is Nim <-> Nim loading
20:36:46FromGitter<rayman22201> Maybe try with `-d:useNimRtl` and the nimRTL.dll ?
20:36:55FromGitter<rayman22201> see if that gives different results
20:38:46*Perkol quit (Quit: Leaving)
20:40:35FromGitter<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:09FromGitter<rayman22201> You could also try using a different GC, like boehm or something
20:43:22FromGitter<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:29PMunchI tried every combination trying to debug the issue I linked, but they all had the same result (with different timings however)
20:48:01FromGitter<rayman22201> I think this is one of the motivations for destructors
20:48:24FromDiscord_<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:04PMunchWell
20:49:12PMunchIt depends on what you're actually wondering about
20:49:26FromGitter<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:50PMunchpotatonomicon: https://www.reddit.com/r/nim/comments/7dm3le/tutorial_for_types_having_a_hard_time/
20:50:02PMunchThat should explain at least some of it
20:50:16FromGitter<Varriount> It's deliberately underspecified, so that platform implementations can vary.
20:50:31FromGitter<rayman22201> Also this: https://github.com/nim-lang/Nim/wiki/Nim-for-C-programmers
20:51:19shashlickanyone have experience with docker? trying to install mattermost-docker on ubuntu but it relies on alpine and doesn't install
20:51:23xaceI 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:42FromDiscord_<potatonomicon> ok, so is there a way to enforce passing by value or reference?
20:52:25FromDiscord_<potatonomicon> I imagine it's probably based on type size
20:52:26PMunchpotatonomicon, well if you have a ref object it will be passed by ref
20:54:18FromDiscord_<potatonomicon> ref objects are always heap allocated correct?
20:54:38PMunchYes
20:54:42PMunchAFAIK
20:55:02xacepotatonomicon: 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:17PMunchxace, correct. Kind of
20:56:00PMunchIf you pass a ref object as a var you can't change the reference but you can change the data
20:56:37PMunchAnd if you do an unsafe cast on a let field you are still able to modify it
20:56:49PMunchIf it was passed by reference (of which there is no guarantee)
20:57:27PMunchvar basically ensures that it is passed by reference since you are able to update the value that was passed in
20:57:43PMunchOtherwise it's up to the compiler, and it chooses whichever is faster
20:57:51xaceI see
20:57:56FromDiscord_<potatonomicon> ok, that makes sense
20:58:30PMunchkdheepak, it's so annoying as this works just fine: https://github.com/nim-lang/Nim/tree/devel/tests/dll
20:58:38FromDiscord_<potatonomicon> ref and let aren't keywords that can be used in parameters right
20:59:29xaceref 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:44FromDiscord_<potatonomicon> oh no, there is a ptr keyword too?
21:02:54xacepotatonomicon: Haha yeah, this language scares me tbh. but it's the best i can find that suits my needs
21:03:10xaceI figured I can learn those quirks with time and experience
21:03:40FromDiscord_<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:38FromGitter<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:21FromGitter<kdheepak> @PMunch haha wow how is that working?
21:06:17FromDiscord_<potatonomicon> safty isn't really what interests me about nim :p
21:07:42FromGitter<rayman22201> lol. fair enough
21:08:32FromGitter<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:42PMunchYeah I was wondering the same, but it should sill use the GC though..
21:10:22FromGitter<rayman22201> Yeah, that's my point actually. Nim strings leverage the GC much more heavily than a simple node allocation.
21:11:17PMunchpotatonomicon, 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:52PMunchUse ref if you want ptr semantics, use var where you would use a ** argument in C
21:12:01xaceoh, thats a rule i can remember
21:12:16FromGitter<kdheepak> @rayman22201 @PMunch ⏎ ⏎ I tried the following: ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/nim-lang/Nim?at=5bec8fb0d001b917205eebb4]
21:12:51FromGitter<kdheepak> The full version of the code is here: https://github.com/NREL/glm
21:12:56PMunchYeah, I've tried combinations of that as well
21:13:22FromGitter<kdheepak> So @PMunch is there no resolution that you found?
21:13:38FromGitter<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:15FromGitter<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:25FromGitter<kdheepak> @PMunch do you think there is anything I can do to get my code work in Python?
21:15:47FromGitter<rayman22201> my hunch is that the `$` is causing the GC issuel
21:15:52FromGitter<kdheepak> @rayman22201 there are no stupid questions! I'm wiling to try whatever.
21:16:45FromGitter<kdheepak> Still segfaults with nimpy ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec90bdbb06d73a99750fe2]
21:17:18FromGitter<kdheepak> I think the GC isn't working the way it should when in shared libaries.
21:17:27FromGitter<rayman22201> shoot
21:18:08FromGitter<rayman22201> Yeah. I'm out of ideas
21:18:38PMunchNothing that I've found no
21:18:42FromGitter<rayman22201> @kdheepak How good are you with GDB? lol
21:18:52PMunchI just tried adding some strings to the client/server thing
21:18:55PMunchBut it didn't work
21:18:57*zachk joined #nim
21:19:16FromGitter<kdheepak> I've learnt a lot in the last couple of days and I'm willing to learn more.
21:19:16PMunchI think the problem is with load and unloadLib
21:19:46FromGitter<kdheepak> Everytime I open gdb/lldb, I find that a pointer deferences to nothing.
21:20:06FromGitter<kdheepak> 1) Everytime I open gdb/lldb and try to run this code I find that a pointer deferences to nothing.
21:20:09PMunchIn fact in some of my testing I've seen data in the libnames array be overwritten
21:20:10FromGitter<rayman22201> what's the gdb stack trace from that pointer derefence?
21:20:30PMunchSo it's certainly something memory related..
21:21:14FromGitter<rayman22201> like the root address of the GC is not being set correctly or something... hrmmm...
21:22:46PMunchYeah, it's certainly strange..
21:22:47*zachk quit (Changing host)
21:22:47*zachk joined #nim
21:23:23FromGitter<kdheepak> This is the result from lldb ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bec924bbb06d73a99751caa]
21:24:32PMunchThis is the error I get from the github issue: http://ix.io/1rUl
21:38:52*seni joined #nim
21:40:11FromGitter<rayman22201> @kdheepak can you compile with `nim c --debuginfo --linedir:on` and then run it with lldb?
21:40:32FromGitter<rayman22201> It's crashing in this function: https://github.com/NREL/glm/blob/master/src/parser.nim#L159
21:41:43FromGitter<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:57FromGitter<kdheepak> @rayman22201 if I use `--debuginfo --linedir:on` it doesn't segfault :P
21:45:04PMunchHmm, curious
21:45:09FromGitter<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:15FromGitter<rayman22201> https://i.kym-cdn.com/photos/images/newsfeed/000/173/576/Wat8.jpg?1315930535
21:46:21PMunchOkay, so if I remove the echo "loading ", libnames[index] line from here: https://github.com/nim-lang/Nim/issues/6886
21:46:27PMunchIt works just fine
21:47:28PMunchSo it can have a echo "loading"
21:47:38PMunchBut not echo "loading ", index either
21:47:45FromGitter<rayman22201> interesting. @PMunch what if you move the echo to the end of the function
21:48:19PMunchOooh, the thick plottens
21:48:28FromGitter<rayman22201> that makes sense, a string literal doesn't allocate
21:48:32PMunchPutting the echo at the end works just fine
21:48:49FromGitter<rayman22201> ah-ha! progress
21:49:54FromGitter<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:20PMunchHmm, might be
21:51:15PMunchBut why would that cause it to segfault at that line..
21:51:25PMunchIs it GC'ing an older string?
21:51:59FromGitter<rayman22201> possible.
21:52:04PMunchTried to do the concatenation before, store it in a variable, and write it out after
21:52:08PMunchThat also crashed
21:52:33FromGitter<rayman22201> I don't think you can do any allocation before
21:52:46PMunchYeah it appears like that is the issue
21:52:57FromGitter<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:44FromGitter<rayman22201> hrmm.... interesting
21:55:23PMunchyglukhov, but why does loadLib trigger it?
21:55:39PMunchIt just calls dlopen..
21:56:57FromDiscord_<Epictek> Been trying to figure out how to use Regex with the Javascript backend, anyone have any ideas?
21:57:37FromGitter<rayman22201> @Epictek just use the jsffi to interface with the native js regex engine.
22:00:22FromGitter<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:12PMunchOh yeah, I've gotten that far
22:01:29PMunchBut how is loadLib triggering the change of stackbottom
22:04:36FromGitter<rayman22201> This is a very good question....
22:06:31FromGitter<yglukhov> @PMunch tell me more. I know nothing about loadLib
22:07:21PMunchWell loadLib only calls dlopen from dlfcn.h
22:08:00FromGitter<yglukhov> yeah i mean, how is loadLib related to nimpy bug?
22:08:19PMunchI was talking about this: https://github.com/nim-lang/Nim/issues/6886
22:08:57FromGitter<rayman22201> I think the nimpy bug and #6886 may be related
22:12:19FromGitter<yglukhov> oh ok. from the first glance it might be similar, but that's just a shot in the dark :)
22:14:21FromGitter<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:56FromGitter<gogolxdong> @PMunch How to put parsers in a common file and import it?
22:14:59PMunchnimsuggest somehow does it, not sure how
22:15:07PMunchOh sorry, that was for iffy
22:15:08FromGitter<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:14FromGitter<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:17PMunchgogolxdong, use include instead of import :)
22:16:12PMunchyglukhov, how do you do setStackBottom now?
22:17:07FromGitter<iffy> PMunch: hehe, here's how nimsuggest does it: https://github.com/nim-lang/Nim/blob/27b081d1f77604ee47c886e69dbc52f53ea3741f/nimsuggest/nimsuggest.nim#L606
22:17:15FromGitter<yglukhov> @PMunch https://github.com/yglukhov/nimpy/blob/master/nimpy.nim#L708
22:17:32FromGitter<rayman22201> I have go afk for a bit. good luck guys
22:17:44PMunchiffy, 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:10PMunchMy findExe("nim") for example doesn't have a lib close to it (because of choosenim)
22:18:10FromGitter<iffy> hmm, well let me see how it works for me
22:18:16FromGitter<yglukhov> hey @iffy nice to meet you. thanks, and feel free to contribute ;)
22:18:16FromGitter<iffy> oh
22:18:16FromGitter<gogolxdong> sure, thanks.
22:19:18FromGitter<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:03PMunchAh, that's a new feature yglukhov?
22:20:41FromGitter<yglukhov> @PMunch you could say that. A few months maybe.
22:22:04PMunchHmm
22:22:39PMunchHmm, could not import: nimrtl_setStackBottom..
22:22:41FromGitter<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:13PMunchI think nimrtl doesn't have it..
22:23:18FromGitter<yglukhov> @PMunch are you trying to use it in the loadLib bug? :)
22:23:25PMunchyglukhov, how is Linux treating you?
22:23:26PMunchYeah
22:24:02FromGitter<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:16FromGitter<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:17PMunchYeah I saw that
22:24:26PMunchI have an idea to redo it
22:24:39PMunchBasically some when isMainModule in the actual nimsuggest code
22:24:51FromGitter<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:51FromGitter<timotheecour> redo what?
22:24:55*rockcavera quit (Remote host closed the connection)
22:25:05PMunchThe nimsuggest library, I'm having some strange issues with it
22:25:14FromGitter<timotheecour> Link?
22:25:18FromGitter<timotheecour> (to issue)
22:25:42PMunchI haven't created an actual issue for it
22:26:00PMunchyglukhov, oh cool. I was considering the Matebook X recently
22:26:18PMunchBut I opted for a Thinkpad t480s
22:27:34FromGitter<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:07FromGitter<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:42FromGitter<iffy> (so that myapp can execute a compile step knowing where nimbase.h is)
22:32:28FromGitter<timotheecour> in that case provide a `—nim:binarytonim` arg?
22:33:22FromDiscord_<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:44FromGitter<iffy> @timotheecour yes, I think I'll have it guess somewhere by default, but otherwise require the user to specify it
22:33:56PMunchOnly those that have been declared with ref
22:34:13FromGitter<iffy> (if the guess is no good). Or is `--nim:binarytonim` a `nim` flag I'm not familiar with?
22:35:42FromGitter<yglukhov> PMunch: cool. i bet thinkpad has a much better cooling and doesn't throttle all the time :)
22:35:46FromGitter<timotheecour> Oh no, that was just if you want a custom binary to allow user to specify nim binary
22:36:39PMunchHaha, I hope not. The Matebook is a beautiful machine though
22:36:43FromGitter<timotheecour> nevermind my comment about `—nim` (and as others mentioned, there’s the slightly less flexible option of using `findExe("nim”)`)
22:37:02PMunchI just realized today though that changing it to Dvorak might be a bit tricky
22:38:07FromGitter<yglukhov> you mean swapping the keycaps? it is tricky indeed.
22:42:04PMunchWell its a breeze on most other machines
22:42:21PMunchBut the trackpad-nub-thing means the keys around it are different from the others..
22:56:58FromGitter<kdheepak> @yglukhov just want to say that you are amazing! your fixes worked and I'm able to run in Python again.
22:58:23PMunchCould get it to work for dynlibs...
22:58:29PMunchCouldn't*
23:21:47*platoff_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
23:25:52FromDiscord_<potatonomicon> so I just installed sdl2 via nimble, and attempting to import it results in a undeclared identifier error for CurrentEndThreada
23:29:23FromDiscord_<potatonomicon> Seems there is a typo in sdl2/private/thread.nim
23:29:35FromDiscord_<potatonomicon> It's supposed to be CurrentEndThread not CurrentEndThreada
23:29:47FromGitter<zetashift> might want to PR that
23:39:10*Xe quit (Ping timeout: 252 seconds)
23:39:13FromDiscord_<potatonomicon> Looks like it's already been fixed on github, but nimble still has an outdated version
23:39:20FromDiscord_<potatonomicon> or something
23:39:43*bozaloshtsh quit (Ping timeout: 252 seconds)
23:40:33FromDiscord_<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:57FromGitter<zetashift> `nimble install sd2@#head` might work @potatonomicon
23:48:09FromGitter<zetashift> sdl2@#head* jeez I need sleep
23:49:36FromDiscord_<potatonomicon> I'll give it a try thanks
23:50:09*Aareon_ joined #nim
23:52:35*vlad1777d joined #nim
23:54:02FromDiscord_<potatonomicon> seems to work
23:55:56*cozachk joined #nim
23:58:17*zachk quit (Ping timeout: 268 seconds)