00:27:21 | * | xet7 quit (Remote host closed the connection) |
00:43:56 | * | rnrwashere joined #nim |
00:46:28 | * | rnrwashere quit (Remote host closed the connection) |
00:50:53 | * | rnrwashere joined #nim |
00:50:59 | * | abm quit (Read error: Connection reset by peer) |
00:57:20 | * | rnrwashere quit (Remote host closed the connection) |
01:06:29 | * | ricardo_ is now known as ricardo |
01:08:41 | * | ricardo quit (Quit: ricardo) |
01:24:46 | FromGitter | <Varriount> פ ח ו ף: How does one type your nickname? |
01:28:12 | * | Tyresc quit (Quit: WeeChat 2.5-dev) |
01:30:02 | FromGitter | <kayabaNerve> פ ח ו ף <- Like that |
01:37:14 | * | Hexeratops joined #nim |
01:45:45 | FromGitter | <kayabaNerve> What's the fastest way to turn a string of size X into an array[X, uint8]? Just a copyMem? |
01:48:20 | leorize | unless you study their internals and play with cast |
01:48:49 | leorize | but usually that wouldn't work so, yea, copyMem |
01:49:38 | FromGitter | <kayabaNerve> I don't think that helps unless I move from a raw array to a ptr |
02:00:16 | * | banc quit (Quit: Bye) |
02:13:06 | * | rnrwashere joined #nim |
02:17:44 | * | rnrwashere quit (Remote host closed the connection) |
02:19:23 | * | rnrwashere joined #nim |
02:20:11 | FromGitter | <jrfondren> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cce485bb4700e023d233ee7] |
02:23:15 | * | banc joined #nim |
02:25:58 | * | rnrwashere quit (Remote host closed the connection) |
02:27:48 | FromGitter | <kayabaNerve> So that's moving to a pointer :P |
02:28:56 | FromGitter | <jrfondren> aye. use a pointer and don't copy, or copy and use whatever you like |
02:29:10 | * | deech quit (Ping timeout: 252 seconds) |
02:29:16 | * | rnrwashere joined #nim |
02:31:02 | FromGitter | <kayabaNerve> I ended up using a var and then an in-the-moment `addr`. |
02:31:23 | FromGitter | <kayabaNerve> I was asking because I knew copyMem existed but was curious if there's a faster way that's GC compliant. |
02:38:42 | * | theelous3_ quit (Ping timeout: 252 seconds) |
02:44:12 | * | rnrwashere quit (Remote host closed the connection) |
02:44:28 | * | rnrwashere joined #nim |
02:53:21 | * | [rg] joined #nim |
02:54:33 | * | nsf joined #nim |
03:01:59 | * | rnrwashere quit (Remote host closed the connection) |
03:12:20 | * | rescartes joined #nim |
03:12:25 | rescartes | Hi |
03:24:25 | * | rnrwashere joined #nim |
03:26:56 | cy1 | great, now I have 126 fields on various objects, and I have to write boilerplate accessors for all of them. Is that really how you have to do it? |
03:27:36 | cy1 | I could probably write a macro that just created accessors for every field in an object. |
03:28:55 | leorize | cy1: you want read-only accessors? |
03:28:59 | rescartes | What fields |
03:29:45 | leorize | if r/w then just add a bunch of `*` to the fields :p |
03:30:03 | leorize | if r/o then... well macros is the way to go |
03:30:09 | cy1 | I did that, and it still said it was looking for a username= function... |
03:30:20 | cy1 | that * thing I mean |
03:30:23 | * | rnrwashere quit (Remote host closed the connection) |
03:30:47 | leorize | can you make a sample? |
03:31:03 | * | rnrwashere joined #nim |
03:31:07 | leorize | also, have you exported the type itself? |
03:40:00 | * | Hexeratops quit (Remote host closed the connection) |
03:42:12 | * | rescartes quit (Remote host closed the connection) |
04:08:04 | * | rnrwashere quit (Remote host closed the connection) |
04:08:55 | * | rnrwashere joined #nim |
04:33:02 | cy1 | leorize: no, I'm doing something wrong, I'm sure of it. My sample worked perfectly with no errors. |
04:35:31 | * | [rg] quit (Quit: Konversation terminated!) |
04:38:15 | * | rnrwashere quit (Remote host closed the connection) |
04:39:46 | * | dddddd quit (Remote host closed the connection) |
05:02:49 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
05:04:33 | * | rnrwashere joined #nim |
05:34:55 | * | [rg] joined #nim |
06:02:32 | * | solitudesf joined #nim |
06:03:02 | * | traviss joined #nim |
06:10:04 | * | rnrwashere quit (Remote host closed the connection) |
06:19:02 | * | ng0 quit (Quit: Alexa, when is the end of world?) |
06:20:02 | traviss | how can I tell nim to always use make a local nimcache in the directory where its run rather than use ~/nimcache? |
06:20:25 | leorize | --nimcache:/path/to/nimcache |
06:20:27 | * | narimiran joined #nim |
06:20:43 | leorize | in your case it should be --nimcache:nimcache |
06:20:53 | leorize | you can put this in a config file |
06:21:02 | traviss | thank you, sorry i should have said: without specifying every time from command line |
06:21:31 | traviss | yes, do you know where the config file is? |
06:21:45 | leorize | depends on what os and how you install Nim |
06:21:58 | traviss | i built from source on windows |
06:22:43 | leorize | go to the source -> config -> config.nims |
06:22:52 | leorize | then add --nimcache:nimcache there |
06:23:12 | leorize | --nimcache:"nimcache", sorry |
06:23:21 | traviss | ok thanks a bunch. will give it a try :) |
06:23:49 | * | slugm joined #nim |
06:25:42 | traviss | that worked, except i had to omit the quotes. when i tried with quotes i got: cannot create directory: F:\Users\...\"nimcache" |
06:26:58 | leorize | nice, glad it worked |
06:28:26 | traviss | thanks again. i'm a new user. have been exploring lots of languages lately and I really like nim a lot. very powerful and elegant language with lots of support for functional features that I like using |
06:29:49 | traviss | it seems to almost have algebraic data types... i'm planning to explore this further. been watching lots of Araq's vods today. |
06:48:43 | * | slugm_ joined #nim |
06:48:46 | * | slugm quit (Ping timeout: 252 seconds) |
06:52:56 | FromGitter | <mratsim> It has ADT |
06:54:07 | FromGitter | <mratsim> They are called variants |
06:55:12 | traviss | thank you i haven't heard of variants yet. i'll check it out. |
06:56:50 | traviss | nim doesn't have higher kinded types does it? |
07:00:00 | * | gmpreussner quit (Quit: kthxbye) |
07:00:57 | FromGitter | <mratsim> In practice you can do everything you can do with higher kinded types with generics |
07:01:08 | FromGitter | <mratsim> but some times it's a bit annoying |
07:01:36 | FromGitter | <mratsim> you can have proc fooT (a: T, b: T): T for example |
07:01:52 | FromGitter | <mratsim> argh the code was eaten by Gitter |
07:02:27 | FromGitter | <mratsim> `proc fooT (a: T, b: T): T`, and T can also be a generic |
07:02:58 | FromGitter | <mratsim> see this RFC: https://github.com/nim-lang/RFCs/issues/5 |
07:03:38 | traviss | haha, i am already reading it :) |
07:04:37 | traviss | ok, i see you can use concepts |
07:04:45 | * | gmpreussner joined #nim |
07:05:28 | FromGitter | <mratsim> An advanced example of concept use for Monad-like construcs is here: https://github.com/unicredit/emmy |
07:06:22 | FromGitter | <mratsim> for FP data structures I like this one: https://github.com/vegansk/nimfp, and for FP-like composition on Nim sequences: https://github.com/zero-functional/zero-functional |
07:06:58 | traviss | cool! |
07:07:54 | FromGitter | <mratsim> And for Haskell-like type classes: https://github.com/nigredo-tori/classy |
07:10:35 | traviss | thanks a bunch. these are exactly what i was looking for. |
07:11:17 | FromGitter | <mratsim> @narimiran maybe you should write a piece of Nim (ecosystem) for the Haskell dev ;) |
07:11:27 | FromGitter | <mratsim> on* |
07:11:31 | narimiran | :) |
07:11:33 | * | jjido joined #nim |
07:12:01 | narimiran | i've only played with haskell for a bit, until i discovered (and fell in love with) F# |
07:15:17 | traviss | i went from haskell toward ocaml recently. really like that its easier to do mutations and imperative style in ocaml. thats what i like about nim, but the syntax and flexibility with nim is just amazing. |
07:16:23 | traviss | ocaml syntax suffers from lack of function/operator overloading i think. |
07:16:50 | traviss | but its almost the same as F#. |
07:19:46 | FromGitter | <mratsim> Haskell was my first language (not counting bash and Excel) |
07:20:30 | FromGitter | <mratsim> but I was spending a lot of time trying to optimize stuff like prime number generation and fighting the GC. |
07:21:05 | FromGitter | <mratsim> the repl was really nice though |
07:21:29 | traviss | yes same in ocaml. nice repl... does nim have a repl? |
07:21:42 | FromGitter | <mratsim> weeeeeellll |
07:21:54 | FromGitter | <mratsim> you can do "nim secret" :P and you will get a repl |
07:22:23 | FromGitter | <mratsim> you can also try inim: https://github.com/AndreiRegiani/INim |
07:23:27 | FromGitter | <mratsim> and there was a recent merge of Nim hot code reloading branch at the beginning of April but AFAIK no one used it to create a proper REPL yet: https://github.com/nim-lang/Nim/issues/8927 |
07:24:22 | traviss | nim secret looks good... i may have heard about it in a youtube video that described the hot reloading as a bit hacky. |
07:25:02 | * | slugm__ joined #nim |
07:25:11 | traviss | maybe not supporting when you redefine types or function parameters |
07:25:29 | FromGitter | <mratsim> before April, it was possible to do hot code reloading with hacks, but the HCR branch brings hot code reloading at suport at the language level |
07:26:12 | traviss | so no gotchas in the repl then? |
07:26:14 | FromGitter | <mratsim> yes, because Nim is statically typed and you cannot change the size in memory as they those locations are fixed and already loeaded by the OS |
07:27:15 | FromGitter | <mratsim> nim secret doesn't allow any kind of FFI. so you cannot call any C library for example or use the standard lib that uses C libraries (like math for floating point math or regexp) |
07:27:16 | * | slugm_ quit (Ping timeout: 250 seconds) |
07:28:09 | FromGitter | <mratsim> @dom96 I think the redis package suddenly needs some love :P https://forum.nim-lang.org/t/4824 |
07:28:21 | traviss | oh thats fine. thanks. one more question: is there an llvm backend for nim or just the c/cpp/objc/js backends? |
07:32:10 | FromGitter | <mratsim> Not official but it's working: https://github.com/arnetheduck/nlvm |
07:32:44 | traviss | ah yes, i found this project but just wondered if this was being pursued from within nim |
07:32:50 | FromGitter | <mratsim> You can even write your own Nim compiler. You can just do "import compiler" and you have access to Nim internals, nlvm is written using that. |
07:33:37 | FromGitter | <mratsim> @arnetheduck is working with me at Status, we're the biggest backer of Nim development at the moment as we use it for blockchain. |
07:36:38 | FromGitter | <mratsim> @shashlick, how do you deal with projects that uses configure.sh in nimterop/nimgen? staticExec? |
07:37:13 | traviss | yes i'm very curious about the nim compiler. do you know if the current compiler is written in an idiomatic nim style or is it more of a port from delphi and pascal? |
07:38:04 | leorize | a translation from pascal |
07:38:19 | traviss | i heard araq mention that's where nim started out |
07:38:28 | FromGitter | <mratsim> I don't think there is any pascal remaining besides the P and T type prefixes |
07:38:41 | leorize | yea, the current compiler is a translation from pascal :P |
07:38:43 | FromGitter | <mratsim> but it started as such yes, now it's pure Nim |
07:39:01 | leorize | there's a pascal to nim transpiler iirc |
07:39:06 | FromGitter | <mratsim> yeah |
07:39:19 | FromGitter | <mratsim> pas2nim, py2nim, c2nim, and apparently rb2nim :P |
07:39:36 | FromGitter | <mratsim> to translate pascal, python, C/C++ and ruby to Nim :P |
07:40:31 | traviss | wow. yeah i saw that nllvm used c2nim to generate their llvm bindings. |
07:44:31 | FromGitter | <mratsim> for bindings nimgen and nimterop are the new shiny things: https://github.com/nimterop/nimterop |
07:46:08 | * | slugm__ quit (Read error: Connection reset by peer) |
07:47:00 | * | slugm__ joined #nim |
07:50:44 | traviss | any ideas how to move the nimble repo? i want to use a secondary drive.. |
07:54:12 | FromGitter | <mratsim> no idea :/ |
07:54:17 | FromGitter | <mratsim> symlink? |
07:54:52 | traviss | thats a good idea.. will try. was looking for a nimble config file but can't find one. |
07:55:18 | FromGitter | <mratsim> ah yes there is: https://github.com/nim-lang/nimble#configuration |
07:56:14 | traviss | i see there is an option --nimbleDir:dirname but not sure if that saves the config or not |
07:56:21 | traviss | *setting or not |
08:05:59 | FromGitter | <mratsim> just save the nimble.ini as in the link I gave you |
08:07:46 | leorize | note that you'd also need to add --nimbleDir:dirname to the compiler configuration |
08:08:20 | traviss | thanks again. i got it working. yes, i followed the link and saved a nimble.ini with nimbleDir = r"F:\...\.nimble" |
08:09:00 | traviss | i had to create the nimble.ini in C:\Users\<YourUser>\AppData\Roaming\nimble\nimble.ini |
08:10:16 | traviss | oh thanks leorize. will add that too. |
08:16:38 | traviss | when i added --nimbleDir: F:\...\.nimble to config.nims, i got a compiler error: Error: invalid command line option: '--nimbleDir'. i tried enclosing the path with quotes but same error. I don't think the option is supported |
08:25:07 | FromGitter | <dom96> Traviss: put it in Nim's nim.cfg file |
08:25:28 | FromGitter | <dom96> Also it's nimblePath iirc |
08:31:32 | traviss | ok, after adding the line: --nimblePath: "F:\\...\\.nimble\\pkgs" to the end of my nim.cfg, i was able to build and run while importing a package i installed with nimble. |
08:33:34 | * | natrys joined #nim |
08:36:22 | traviss | i took a while as i had to surround path with quotes, escape slashes, and add pkgs to the path before it would work. error messages were pretty helpful except for just guessing i needed to add pkgs to the path. |
08:39:39 | traviss | but overall i think nim is really easy to work with compared to other things i've been using lately. it seems like it just works! |
08:43:02 | * | cyberjpn joined #nim |
08:44:24 | leorize | for nim.cfg there's a simpler syntax :P |
08:44:31 | leorize | nimblepath=r"F:\...\nimble\pkgs" |
08:44:48 | leorize | just like nimble.ini (they use the same parser iirc) |
08:46:01 | narimiran | leorize: is this a placebo or does the `indentexp` branch of nim.nvim work faster/smoother than master? |
08:46:41 | leorize | placebo :p it should be slower, now that I actually (kinda) parse the code for indent |
08:46:54 | leorize | altho I cap it at 3ms timeout |
08:47:43 | leorize | or maybe I did some optimization and forgot about it :p |
08:48:00 | narimiran | eh, i feel like there is a less lag between my typing and showing the change on the screen. |
08:48:11 | traviss | much better. |
08:48:22 | narimiran | maybe an update of some other plugin is responsible :) |
08:51:57 | traviss | any other twitch streamers or youtubers for nim? so far i found araq4k and d0m96. |
08:55:06 | * | Vladar joined #nim |
09:07:56 | * | hzx joined #nim |
09:16:22 | * | stefanos82 joined #nim |
09:33:09 | * | luis__ joined #nim |
09:34:37 | * | cyberjpn quit (Ping timeout: 245 seconds) |
09:45:34 | * | NimBot joined #nim |
09:48:07 | * | deech joined #nim |
09:48:23 | * | nsf quit (Quit: WeeChat 2.4) |
09:52:53 | * | luis__ quit (Remote host closed the connection) |
09:57:38 | * | slugm__ quit (Remote host closed the connection) |
09:58:10 | * | slugm joined #nim |
09:59:24 | * | cyberjpn joined #nim |
10:06:19 | FromGitter | <mratsim> I think it's only them. But they are a couple of youtube videos from conferences |
10:07:44 | * | cyberjpn quit (Quit: WeeChat 2.4) |
10:08:30 | FromGitter | <mratsim> @Araq, if I use Nim compiler as a plugin, does that mean that people will need to compile their own Nim compiler and call it if they want to use that plugin? |
10:09:47 | FromGitter | <mratsim> or can I just register extra passes that I can tag with a pragma for example |
10:10:50 | * | rnrwashere joined #nim |
10:13:04 | * | cyberjpn joined #nim |
10:15:09 | * | rnrwashere quit (Ping timeout: 258 seconds) |
10:16:29 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
10:20:50 | * | jjido joined #nim |
10:22:19 | * | [rg] quit (Quit: Konversation terminated!) |
10:48:22 | * | narimiran quit (Ping timeout: 245 seconds) |
10:49:31 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
10:50:39 | * | xet7 joined #nim |
11:03:14 | * | dddddd joined #nim |
11:09:15 | * | slugm quit (Ping timeout: 248 seconds) |
11:11:24 | * | slugm joined #nim |
11:20:24 | * | slugm quit (Read error: Connection reset by peer) |
11:20:50 | * | slugm joined #nim |
11:29:45 | * | Gertm joined #nim |
11:30:03 | * | Gertm left #nim ("Leaving") |
11:30:49 | * | Snircle joined #nim |
11:32:46 | noonien | is there a better way of doing this? `(getTime() + 10.days).utc().toTime().toUnix().uint32`? |
11:38:42 | noonien | i want the unix timestamp of utc() + 10days |
11:46:32 | * | jjido joined #nim |
11:48:50 | * | slugm_ joined #nim |
11:49:22 | * | slugm quit (Read error: Connection reset by peer) |
11:58:13 | * | cyberjpn quit (Ping timeout: 246 seconds) |
11:59:02 | FromGitter | <GULPF> you don't need the call to `utc()`, just `(getTime() + 10.days).toUnix` should work |
12:00:28 | noonien | i find no indication that getTime() returns a UTC date |
12:00:29 | * | slugm_ quit (Read error: Connection reset by peer) |
12:00:54 | * | slugm joined #nim |
12:00:55 | FromGitter | <GULPF> getTime returns a Time which doesn't have a timezone |
12:01:02 | noonien | well, yes. |
12:01:05 | noonien | it returns local time |
12:01:11 | noonien | i need a utc timestamp |
12:01:20 | FromGitter | <GULPF> no, Time is not local time |
12:01:22 | noonien | not a current system timestamp |
12:02:05 | noonien | getTime() on your system might return a different time than mine. |
12:02:19 | FromGitter | <GULPF> it will not |
12:02:46 | FromGitter | <GULPF> time is implemented as a unix timestamp + nanoseconds |
12:03:12 | * | lritter joined #nim |
12:03:54 | noonien | yes, and the unix timestamp has no timezone associated, it's the current system's time, which is usually in user local time |
12:04:16 | noonien | for example, echo getTime().toUnix on my system, returns `1557057851` |
12:04:50 | noonien | because, where i live, it's 13:04, where you live, it might not be |
12:06:31 | FromGitter | <GULPF> When I'm saying that Time doesn't have a timezone, I'm saying that it represents an unambiguous point in time without any concept of timezones associated with it. I don't mean that it's implicitly in local time |
12:06:57 | FromGitter | <GULPF> The unix timestamp stored in Time is always treated as a unix timestamp starting at 1970-01-01T00:00:00 UTC |
12:07:58 | noonien | hmm, i seemed to have missed this, i was never aware that the unix epoch is in UTC, my bad |
12:09:51 | noonien | thanks for the clarification! |
12:10:46 | FromGitter | <GULPF> No problem, the docs might need improvement. Also, beware that when using `TimeInterval` (for example `10.days` creates a `TimeInterval`) the result can depend on the local timezone. If you want to work in UTC, it's better to use the `Duration` type (e.g `initDuration(days = 10)`). |
12:11:16 | FromGitter | <GULPF> so `(getTime() + initDuration(days = 10)).toUnix` |
12:13:00 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
12:13:45 | noonien | i'm guessing this is functionally equivalent to `(now() + 10.days).utc().toTime().toUnix()` |
12:13:51 | noonien | well, without .utc(), yes |
12:17:26 | FromGitter | <GULPF> Almost. Due to the way that `TimeInterval` works, `now() + 10.days` can give a different result than `now() + initDuration(days = 10)`. There's a good explanation in the devel docs: https://nim-lang.github.io/Nim/times.html#duration-vs-timeinterval |
12:18:43 | leorize | is there any sugar for initDuration? |
12:19:50 | FromGitter | <GULPF> No. `TimeInterval` is older than `Duration` which is why it has the nice sugar |
12:20:44 | FromGitter | <GULPF> I would have preferred if `TimeInterval` didn't exist, but it's been around for to long |
12:25:52 | * | solitudesf quit (Ping timeout: 246 seconds) |
12:26:11 | FromGitter | <mratsim> we can deprecate it and slowly phase it out |
12:26:35 | leorize | well, sugars for the newer interface first :p |
12:33:26 | * | cyberjpn joined #nim |
12:34:30 | * | luis_ joined #nim |
12:38:14 | FromGitter | <liquid600pgm> what does this mean? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5cced93697dcb371d8693639] |
12:38:33 | leorize | it means: you found a nim bug |
12:38:40 | FromGitter | <liquid600pgm> yay |
12:39:16 | FromGitter | <liquid600pgm> all I'm trying to do is to cast a pointer into an UncheckedArray[uint8] |
12:39:38 | * | slugm quit (Remote host closed the connection) |
12:39:42 | leorize | please make a small reproducible sample then open an issue on github :) |
12:40:00 | * | slugm joined #nim |
12:40:19 | FromGitter | <liquid600pgm> that'll be difficult to do since I don't know what's the problem and I have a rather large amount of code |
12:40:52 | leorize | well, if it's just caused by casting a pointer to UA, then try to do that? :p |
12:41:08 | FromGitter | <liquid600pgm> I'm trying to cast a FreeType glyph slot's bitmap into an UncheckedArray[uint8], to be exact |
12:41:13 | FromGitter | <liquid600pgm> I'll try to reproduce this |
12:41:39 | FromGitter | <liquid600pgm> I'm using Nim 0.19.4 for this, btw, so it may have been fixed in devel |
12:41:52 | FromGitter | <liquid600pgm> oh wait, actually not |
12:42:07 | FromGitter | <liquid600pgm> I'm on devel |
12:42:10 | leorize | related: https://github.com/nim-lang/Nim/issues/9403 |
12:42:23 | leorize | also, you'd want to cast to `ptr UA` instead |
12:42:37 | FromGitter | <liquid600pgm> aaaah of course |
12:42:43 | FromGitter | <liquid600pgm> forgot about that |
12:43:10 | FromGitter | <liquid600pgm> yeah, that's the exact issue, thank you |
12:43:25 | leorize | but still, please report the bug :p |
12:53:48 | noonien | is there something akin to printf in nim? |
12:54:13 | FromDiscord_ | <פ ח ו ף> fmt? |
12:54:13 | leorize | you can always import `printf` from C :p |
12:54:23 | leorize | well there's strformat and strutils.format |
12:54:23 | FromDiscord_ | <פ ח ו ף> https://nim-lang.org/docs/strformat.html |
12:55:12 | noonien | awesome, thanks! |
12:57:15 | * | nsf joined #nim |
13:08:58 | * | hzx quit (Quit: Going offline, see ya! (www.adiirc.com)) |
13:23:49 | shashlick | @mratsim: I've hard coded configure results so far instead of running configure |
13:26:16 | shashlick | Some examples |
13:26:20 | shashlick | https://github.com/nimterop/nimterop/blob/master/tests/tsoloud.nim#L24 |
13:26:56 | shashlick | https://github.com/genotrance/nimarchive/blob/master/nimarchive.cfg#L43 |
13:27:07 | shashlick | Is not pretty but portable |
13:27:39 | shashlick | Might be smarter to run configure on posix and hack up windows when msys is available |
13:29:06 | shashlick | Saw your issue as well - am planning on focusing on nimterop for the next few days and round up some features and issues |
13:30:00 | shashlick | Once I finish porting nimarchive to nimterop |
13:32:06 | * | luis_ quit (Ping timeout: 252 seconds) |
13:37:15 | * | theelous3_ joined #nim |
13:42:56 | FromDiscord_ | <פ ח ו ף> can i just import sdl2 and start using it right away? |
13:45:13 | * | luis_ joined #nim |
13:53:34 | Araq | sure |
13:56:12 | FromDiscord_ | <פ ח ו ף> nothing special required to use C libs? |
13:57:03 | Araq | nah |
13:57:09 | FromGitter | <liquid600pgm> I think you just need the DLL, possibly the development headers too |
13:59:50 | * | Trustable joined #nim |
14:07:17 | * | bobito joined #nim |
14:07:29 | bobito | i have something like |
14:07:30 | bobito | type vec2 = object x, y: int |
14:07:40 | bobito | what would the difference be if i made it ref object |
14:07:47 | bobito | one thing i found i can no longer echo it |
14:07:54 | FromGitter | <liquid600pgm> the object would be reference-counted |
14:08:04 | leorize | append `[]` and you can echo again |
14:08:09 | bobito | how is that different to a non reference counted one? |
14:08:14 | leorize | `ref` means that it's allocated on the heap |
14:08:20 | leorize | non-ref means stack |
14:08:53 | FromGitter | <liquid600pgm> `ref` also makes the object nil-able |
14:08:55 | * | narimiran joined #nim |
14:09:00 | bobito | wait why is the object itself the place to choose if its stack or heap instead of like using a static array or vector |
14:09:16 | Araq | it's not "reference counted", it's garbage collected. how the GC works is up to the implementation and we have 4 different GCs available |
14:09:47 | leorize | bobito: well, you can do `ref int` as well |
14:09:57 | leorize | even though it's rather pointless |
14:10:20 | FromGitter | <liquid600pgm> another thing: you should prefer ref objects over regular objects when doing inheritance |
14:10:31 | bobito | so if i have a vec2 thats just a normal object i can go like let v = ref vec2(.....) |
14:10:38 | leorize | nope |
14:10:44 | FromGitter | <liquid600pgm> no, you have to do `new(vec2)` |
14:10:52 | FromGitter | <liquid600pgm> in order to create a `ref vec2` |
14:11:25 | bobito | this model of heap or stack being tied to the object confuses me :/ |
14:11:46 | FromGitter | <liquid600pgm> do you have experience with C? |
14:12:06 | bobito | yeah some |
14:12:21 | bobito | you wouldnt put it in a struct if its stack or heap |
14:12:27 | bobito | you would malloc one of i you need heap |
14:12:49 | leorize | as I said, `ref` can be applied to all types |
14:12:49 | FromGitter | <liquid600pgm> ref acts like a garbage collected malloc |
14:13:08 | bobito | i know that |
14:13:16 | bobito | but why should i make the object ref instead of using new() |
14:13:33 | FromGitter | <liquid600pgm> it depends whether you want to allocate it on the heap or the stack |
14:13:49 | Araq | there is no "instead" here, they go together, 'ref' is a type constructor, new() is a malloc()-like primitive |
14:13:54 | bobito | i know but if the object is ref it will always be on heap no? |
14:14:08 | leorize | yea |
14:14:17 | * | cyberjpn quit (Ping timeout: 258 seconds) |
14:14:30 | bobito | so if there is no instead what if i want the choice for both |
14:14:31 | leorize | it's just boils down to the semantics |
14:14:36 | Araq | yeah, we have many people coming form Python who only understand 'ref object's *semantics* |
14:15:05 | bobito | ive never used python before so maybe its confusing for me |
14:15:12 | leorize | you can have both |
14:15:27 | leorize | new() can be used to create ref anything |
14:15:40 | leorize | the `[]` is Nim's dereference operator |
14:15:48 | bobito | `there is no "instead" here, they go together, 'ref' is a type constructor, new() is a malloc()-like primitive` no? |
14:16:18 | FromGitter | <liquid600pgm> `new(T)`creates a new `ref T` |
14:16:42 | bobito | oh ok |
14:16:55 | bobito | so i should make everything non ref except for inheritance and then use new? |
14:17:17 | leorize | if you found yourself typing new rapidly, go for a ref object |
14:17:30 | leorize | if you want "choice", use this pattern: |
14:17:38 | leorize | type SomethingObj = object |
14:17:45 | leorize | type Something = ref SomethingObj |
14:17:52 | FromGitter | <liquid600pgm> I always use ref objects for large objects or ones that use inheritance, and normal objects for everything else |
14:17:57 | Araq | bobito, it's a very good rule of thumb. |
14:18:56 | bobito | ok |
14:19:20 | Araq | and if you need to mutate the vec2, use 'myparam: var vec2' |
14:19:33 | Araq | do not use 'ref' just to fight the immutability |
14:19:45 | FromGitter | <liquid600pgm> also, remember that `ref object`s are always mutable no matter what |
14:21:52 | leorize | how to crash nimsuggest: `include karax / prelude` :P |
14:22:16 | leorize | ah, it survived |
14:22:22 | leorize | at least until I use buildHtml |
14:22:45 | FromGitter | <liquid600pgm> how to crash nimsuggest: use concepts |
14:24:08 | leorize | Araq: is there anyway to reset a form created by karax? |
14:24:41 | leorize | I want to reset the form after the user click "Submit" (it's a simple login form) |
14:25:04 | Araq | leorize, setInputText("") on the widgets? |
14:26:37 | leorize | I'm doing this from an `onSubmit` handler however :/ |
14:27:24 | leorize | guess I'm just gonna create the input before the handler |
14:28:14 | FromGitter | <mratsim> @lqde, unfinished macro as well, but concepts used to make nimsuggest use GB of memory in the past :p |
14:29:36 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
14:32:54 | * | abm joined #nim |
14:33:19 | * | Vladar quit (Read error: Connection reset by peer) |
14:37:12 | * | jjido joined #nim |
14:41:20 | * | PMunch joined #nim |
14:47:34 | * | marcazar joined #nim |
14:48:27 | * | luis_ quit (Ping timeout: 248 seconds) |
14:48:30 | * | bobito quit (Quit: Page closed) |
14:54:17 | marcazar | hello, I'm trying to create a new distinct type while using {.borrow.} pragma. I followed the manual and tried to compile the code in https://nim-lang.org/docs/manual.html#types-distinct-type . I'm using nim v 0.19.4 and I get an error for the multiplicative template saying: template multiplicative(typ, base: type) \n first type mismatch at position: 2 \n required type: type \n but expression 'int' is of type: type int |
14:54:39 | marcazar | any help with what might that error mean is appreciated :) |
14:56:14 | Araq | marcazar, it's a known regression in the manual, use 'typ, base: typedesc' instead |
14:57:24 | marcazar | aha okay will do, thank you |
15:21:19 | leorize | Araq: looks like you can't redraw a child component in karax :/ |
15:27:39 | * | deech quit (Remote host closed the connection) |
15:29:41 | shashlick | @liquid600pgm - am looking at that nimterop branch again |
15:33:03 | * | PMunch quit (Remote host closed the connection) |
15:48:38 | * | clyybber joined #nim |
15:57:09 | shashlick | I don't know man, a lot of stuff breaks with -d:mingw - DirSep is wrong, creating dirs, files, everything doesn't work |
15:59:35 | FromGitter | <mratsim> +1 on DirSep |
16:04:04 | shashlick | i can work around in nimterop but it still sucks |
16:04:21 | shashlick | stuff you do at compile time using when defined(OS) is all delicate |
16:04:41 | shashlick | you want to target the OS most of the time, but there's also crazy stuff you can do on the buildOS |
16:07:55 | shashlick | getTempDir doesn't work |
16:09:57 | FromGitter | <arnetheduck> the longer term method to remain sane when dealing with paths is to have an internal canonical representation (so algorithms are simple / sane), and serialize/deserialize when interacting with os.. typically, libraries tend to favor `/` for this internal representation |
16:10:42 | shashlick | ya and i've had zero issues with paths in nim |
16:11:02 | shashlick | only now that os = windows when -d:mingw throws off all assumptions |
16:11:24 | shashlick | home dir, temp dir, probably calls to read, write, etc |
16:11:27 | shashlick | everything will break |
16:11:28 | * | rnrwashere joined #nim |
16:11:42 | shashlick | so setting os = windows is wrong |
16:11:57 | shashlick | at least as far as compile time is concerned |
16:12:00 | shashlick | but it is correct for run time |
16:12:07 | * | fredrik92 quit (Read error: Connection reset by peer) |
16:13:07 | shashlick | thing is that so called run time is also evaluated at compile time so you need two different checks |
16:13:22 | shashlick | if readFile is called at compile time, when defined(windows) should check if buildOS = windows |
16:13:39 | shashlick | but if same readFile is called at run time, it should use nim.cfg's os definition |
16:14:12 | shashlick | or we need when nimvm calls everywhere |
16:14:19 | shashlick | cc @Araq for any opinions on this |
16:19:39 | * | rnrwashere quit (Ping timeout: 248 seconds) |
16:20:22 | * | druonysus quit (Ping timeout: 246 seconds) |
16:21:35 | disruptek | wow, that's a mess. |
16:21:57 | FromGitter | <mratsim> @arnetheduck I had this DirSep problem in nim-beacon-chain when debugging the windows build a month ago iirc |
16:28:38 | * | rockcavera joined #nim |
16:31:55 | * | theelous3_ quit (Ping timeout: 248 seconds) |
16:32:25 | * | theelous3 joined #nim |
16:40:08 | * | slugm quit (Remote host closed the connection) |
16:40:29 | * | slugm joined #nim |
16:49:27 | * | cval joined #nim |
16:49:33 | cval | hi |
16:49:52 | FromGitter | <liquid600pgm> hello! |
16:49:52 | cval | im new on nim, come from python |
16:50:06 | cval | just install nim on windows 10 |
16:50:47 | cval | and i installed nimPDF for some practice |
16:51:15 | cval | but when i run nim compile get this error |
16:51:41 | livcd | What kind of error do you see ? |
16:52:04 | cval | error: cannot open file nimPDF |
16:52:21 | FromGitter | <liquid600pgm> are you sure you installed the package using nimble? |
16:52:28 | cval | run nimble path nimPDF |
16:53:23 | cval | and get this: c:\Users\XXX\.nimble\pkgs\nimPDF-0.4.2 |
16:54:05 | cval | check the nim-0.19.4\config\nim.cfg to see the nimblepath and it is |
16:54:17 | cval | nimblepath="$home/.nimble/pkgs/" |
16:54:54 | cval | i have the feeling that is a path configutarion but i don't know how to solve it |
16:55:29 | * | [rg] joined #nim |
16:58:01 | leorize | cval: try passing `--verbosity:3` to the compiler |
16:58:12 | noonien | hmmm, why does `3.uint16 > 0` not work? |
16:58:32 | narimiran | noonien: because 0 != 0.uint16? |
16:58:58 | FromGitter | <liquid600pgm> noonien: protip: you don't have to do 3.uint16 explicitly, you can do 3'u16 |
16:59:10 | leorize | 3u16 also works :) |
16:59:16 | FromDiscord_ | <demotomohiro> !eval echo(3.uint16 > 0) |
16:59:17 | NimBot | Compile failed: in.nim(1, 15) Error: type mismatch: got <int literal(0), uint16> |
16:59:23 | Zevv | import lenienttypes |
16:59:28 | noonien | !eval echo(3.int16 > 0) |
16:59:30 | NimBot | true |
16:59:31 | noonien | this works though |
16:59:53 | Zevv | you can't compare int and unsigned int |
17:00:16 | Zevv | you can't compare int and unsigned int |
17:01:09 | Zevv | no, its lenientops |
17:01:26 | leorize | however, for this trivial sample the compiler should have inferred the types IMO |
17:01:35 | noonien | i see, so, by default, number literals are signed |
17:01:45 | leorize | well, unsigned is never a first class citizen in Nim :p |
17:01:50 | FromGitter | <arnetheduck> no, number literals are *sometimes* inferred |
17:01:58 | * | al_ joined #nim |
17:02:19 | leorize | !eval echo 3u16 > 0u |
17:02:21 | NimBot | true |
17:02:30 | Zevv | but why does lenientops not help? I'd expect it to define `<` for two SomeIntegers |
17:02:46 | leorize | echo uint is SomeInteger |
17:02:52 | leorize | !eval echo uint is SomeInteger |
17:02:54 | NimBot | true |
17:03:08 | FromGitter | <arnetheduck> when they're inferred depend on how and in what order the templates are expanded |
17:03:24 | leorize | !eval import lenientops; echo 3u16 > 0 |
17:03:25 | NimBot | Compile failed: in.nim(1, 30) Error: type mismatch: got <int literal(0), uint16> |
17:03:46 | Zevv | leorize: no, lenientops simply doesnt define for two SomeIntegers, only for int/float combos |
17:04:51 | * | luis__ joined #nim |
17:04:52 | FromGitter | <arnetheduck> for example, `>=` is defined in terms of `<` and thus will not behave the same as `<` on its own.. there's not a lot of consistency or soundness in nim with regards to `uint` |
17:05:14 | * | Lexy joined #nim |
17:06:16 | FromGitter | <arnetheduck> then there's half of the code that uses the operator based approach where integers are integers with no sign implied and the operator determines the sign (`+%` vs `+`) so there are now two incomplete ways of dealing with this issue :) |
17:06:18 | cval | Hint: used config file 'C:\Users\Carlos\Downloads\nim-0.19.4\config\nim.cfg' [Conf] Hint: system [Processing] Hint: test [Processing] test.nim(1, 8) Error: cannot open file: nimPDF C:\Users\Carlos\Documents>nim compile --verbosity:3 test.nim ..\Downloads\nim-0.19.4\config\nim.cfg(47, 3) Hint: added path: 'C:\Users\Carlos\.nimble\pkgs\nimSHA2-0.1.1' [Path] nimblepath="$home/.nimble/pkgs/" ^ ..\Downloads\nim-0.19.4\config\nim.cfg(47 |
17:06:25 | leorize | I guess unsigned should be inferred automatically |
17:06:57 | narimiran | cval: how did you install nimPDF? |
17:06:59 | FromGitter | <arnetheduck> to infer, you need an anchor to infer it to - not always so easy |
17:10:37 | * | cval quit (Ping timeout: 256 seconds) |
17:14:58 | * | cval joined #nim |
17:15:15 | cval | i'm installed nimpdf with nimble |
17:15:20 | cval | nimble install nimPDF |
17:18:18 | * | nsf quit (Quit: WeeChat 2.4) |
17:27:08 | * | rnrwashere joined #nim |
17:28:28 | narimiran | cval: just tried it myself |
17:29:21 | narimiran | `nimble install` reports success, but when i do `impor nimPDF` i get the same error as you (Error: cannot open file: nimPDF), this is on linux and Nim 0.19.9 |
17:29:49 | narimiran | cval: i think you should report it |
17:30:47 | cval | ok, thanks for your fast answer! |
17:32:14 | * | rnrwashere quit (Remote host closed the connection) |
17:38:12 | * | Trustable quit (Remote host closed the connection) |
17:46:14 | * | solitudesf joined #nim |
17:46:25 | * | al_ quit (Quit: al_) |
17:47:24 | * | cval quit (Quit: Page closed) |
17:55:51 | disruptek | !import json; echo %* "foo" |
17:56:29 | narimiran | disruptek: the command is `!eval` and then code |
17:56:38 | disruptek | oh yeah |
17:56:42 | disruptek | !eval import json; echo %* "foo" |
17:56:44 | NimBot | Compile failed: in.nim(1, 19) Error: type mismatch: got <proc (x: varargs[typed]){.gcsafe, locks: 0.}, string> |
17:56:47 | disruptek | !eval import json; echo %*("foo") |
17:56:49 | NimBot | "foo" |
17:56:52 | disruptek | thanks. |
18:04:04 | shashlick | @liquid600pgm - as you can see from my messages, no clean fix right now for mingw |
18:07:40 | shashlick | @mratsim - am looking at your nimterop issue now |
18:08:06 | noonien | given i have the string: "00005678" in a var, and the string "1234", can i copy the second string into the first one, replacing the zeros, without additional allocations? |
18:08:33 | narimiran | first[0..3] = second ? |
18:09:05 | marcazar | #quit |
18:09:10 | * | marcazar quit (Remote host closed the connection) |
18:09:25 | FromGitter | <mratsim> @shashlick, this is the kind of dump I need: https://github.com/mratsim/nim-isl/blob/master/debug_generated_wrapper.log.nim notice that I've anonymized the paths |
18:09:30 | FromGitter | <liquid600pgm> shashlick: which messages? |
18:10:02 | * | Perkol joined #nim |
18:10:06 | shashlick | @liquid600pgm: https://irclogs.nim-lang.org/05-05-2019.html#16:04:04 |
18:10:36 | shashlick | @mratsim: doesn't nim c a.nim > aout.nim work? |
18:10:46 | shashlick | of course you need cDebug() |
18:11:11 | FromGitter | <mratsim> yes that's what I did + search/replace for anonymization |
18:11:16 | shashlick | you already have cDebug |
18:12:00 | FromGitter | <mratsim> one implementation would be for cDebug to accept a file path and dump here is not empty |
18:12:04 | shashlick | ya - @arnetheduck already asked for something similar - https://github.com/nimterop/nimterop/issues/125 |
18:12:29 | FromGitter | <liquid600pgm> shashlick: can't we just check for `defined(mingw)`? I don't think it's set under Windows |
18:12:39 | FromGitter | <liquid600pgm> only when you pass `-d:mingw` |
18:13:11 | shashlick | @liquid600pgm - problem is that -d:mingw changes os = windows which breaks all built-in stuff like readFile, writeFile and so forth |
18:13:21 | FromGitter | <mratsim> also how do you deal with ./configure project in general? staticExec? |
18:13:29 | FromGitter | <liquid600pgm> oh that sucks |
18:14:06 | shashlick | that is - you want different behavior for compile time vs run time but the stdlib procs only know runtime state |
18:14:46 | shashlick | @mratsim - i replied here - https://irclogs.nim-lang.org/05-05-2019.html#13:23:49 |
18:15:06 | FromGitter | <mratsim> ah I see |
18:16:12 | FromGitter | <mratsim> well in my case the "make" command also generates header with types which is quite annoying |
18:16:12 | shashlick | but i'm still not clear what you need from your issue - why is > output.nim not good enough? |
18:16:53 | shashlick | ya i've seen stuff like that - its a pain to make those portable wrappers |
18:17:41 | FromGitter | <mratsim> mostly the absolute paths in the output, and secondly I think it will be better as a debug argument instead of potentially mixing it with other outputs |
18:17:50 | FromGitter | <mratsim> I don't mind if it's low-priority though |
18:17:52 | shashlick | my graphql lib is still delicate that way |
18:17:53 | shashlick | https://github.com/genotrance/nimgraphql/blob/master/nimgraphql.cfg |
18:18:10 | FromGitter | <liquid600pgm> shashlick: how can I compile for Windows, then? |
18:18:18 | FromGitter | <mratsim> I'm mostly experimenting with that library to reimplement part of it in pure Nim |
18:18:41 | shashlick | @mratsim - so > output.nim will only give the nim output and a few comments - all the nim output goes to stderr so won't be in the output |
18:18:46 | shashlick | the file should still compile |
18:19:55 | shashlick | @liquid600pgm - i can hack around nimterop to make it work but problem is that in general, cross compilation will be a mess for people |
18:20:03 | shashlick | so that's a general nim problem |
18:20:18 | shashlick | if you use readFile in a wrapper to edit a file, it might not work |
18:20:33 | FromGitter | <liquid600pgm> I'll figure out a way to do it on my local machine, at least |
18:20:44 | shashlick | i can make you a build on windows if you need |
18:20:51 | shashlick | or you can use travis |
18:21:08 | FromGitter | <liquid600pgm> sounds like an idea, I really need to get into CI at some point |
18:21:21 | FromGitter | <liquid600pgm> I'm still stuck testing manually lmao |
18:21:47 | FromGitter | <mratsim> well, Nim is much better than C/C++ in that regards ... I spent too much of my weekend tinkering other people broken CMake due to LD_LIBRARY_PATH (yeah QT), GCC 8, C++14 or other issues ... |
18:23:10 | shashlick | ok so removing absolute paths is a challenge for multiple reasons |
18:23:28 | shashlick | when recursing header files in gcc -E output, i need exact paths or output gets missed |
18:23:45 | shashlick | second, i don't have typical os procs available at compile time |
18:24:00 | shashlick | so relativePath kind of procs aren't available to fix things |
18:24:34 | shashlick | getting exact path to the wrapper deps (h/c files) has to be based on currentSourcePath which is absolute from the beginning |
18:25:34 | * | rnrwashere joined #nim |
18:26:45 | * | PMunch joined #nim |
18:27:53 | shashlick | @mratsim - so are you good with the > output.nim method? the other absolute path requirement is already in arne's issue |
18:28:48 | shashlick | an option is to remove {.header.} pragmas altogether as arne suggests but not sure if it will work for all cases |
18:29:05 | FromGitter | <mratsim> my relative path requirement is only w.r.t. to debug output when dumped |
18:29:32 | FromGitter | <mratsim> I still think a "outputFile" param for cDebug would be good |
18:30:01 | FromGitter | <mratsim> for now I don't have a pressing need though so it can be low prio to see if others wants it or not |
18:30:36 | shashlick | sounds fair |
18:31:50 | * | vlad1777d_ quit (Ping timeout: 246 seconds) |
18:32:00 | * | JappleAck joined #nim |
18:34:47 | * | Jesin quit (Quit: Leaving) |
18:36:09 | shashlick | @mratsim - any other big concerns with nimterop? i am looking into what i should fix |
18:36:24 | shashlick | feedback from others also appreciated - @liquid600pgm @arnetheduck @leorize |
18:37:14 | FromGitter | <mratsim> No, it's easy enough that I probably won't do things like that anymore: https://github.com/numforge/agent-smith/blob/master/third_party/ale_wrap.nim |
18:37:58 | FromGitter | <mratsim> one thing but more for nimsuggest, I get spammed by *nimterop** files |
18:39:08 | FromGitter | <mratsim> (https://files.gitter.im/nim-lang/Nim/rKcv/DeepinScreenshot_select-area_20190505203847.png) |
18:40:34 | shashlick | so are you saying you won't use nimterop anymore? |
18:40:45 | shashlick | those files should go into temp, why are they in your local dir |
18:41:56 | * | nsf joined #nim |
18:46:24 | leorize | mratsim: something must have gone really wrong with your editor :p |
18:51:15 | * | Hexeratops joined #nim |
18:53:15 | * | luis__ quit (Ping timeout: 248 seconds) |
18:55:11 | * | a_b_m joined #nim |
18:56:26 | * | a__b__m joined #nim |
18:56:30 | dom96 | Good evening everyone |
18:58:23 | * | abm quit (Ping timeout: 245 seconds) |
18:58:24 | PMunch | Evening |
18:59:33 | * | rnrwashere quit (Remote host closed the connection) |
19:00:11 | * | a_b_m quit (Ping timeout: 248 seconds) |
19:01:03 | * | rnrwashere joined #nim |
19:02:37 | shashlick | Hey how's it going |
19:02:41 | * | Jesin joined #nim |
19:02:58 | dom96 | Good good. Happy there is a Bank Holiday tomorrow |
19:04:06 | shashlick | @dom96 did you have an opinion on this - https://irclogs.nim-lang.org/05-05-2019.html#16:04:04 |
19:04:44 | dom96 | Hrm, chance DirSep for when `mingw` is defined? |
19:05:22 | shashlick | well, everything that has a when defined(os) block will do the wrong thing at compile time |
19:06:22 | shashlick | @mratsim @leorize - that's because of nimterop - cCompile has to disambiguate files with same names in diffrent source dirs since they get compiled to the same .o file |
19:06:27 | shashlick | https://github.com/nimterop/nimterop/blob/master/nimterop/cimport.nim#L417 |
19:07:39 | dom96 | `mingw` is effectively an OS |
19:08:10 | dom96 | wait, what even is it? |
19:08:13 | dom96 | Why does DirSep change? |
19:08:16 | shashlick | I agree for runtime, but for compile time you are still sitting in linux |
19:08:26 | shashlick | cause nim.cfg defines os = windows when -d:mingw |
19:08:55 | shashlick | you can use the -d:mingw flag to cross compile to windows |
19:09:28 | * | rnrwashere quit (Remote host closed the connection) |
19:10:31 | FromGitter | <liquid600pgm> shashlick: I really like nimterop, it's the thing I was looking for when getting into Nim FFI. something that's easy to use, has good documentation, and doesn't require a ton of code to use |
19:11:38 | FromGitter | <kayabaNerve> dom96 Does that apply to TDM GCC too? I assume not but have no idea. |
19:12:02 | dom96 | No idea what TDM is |
19:13:18 | shashlick | well, anytime you set --os:xyz in nim, all your when defined(os) statements get affected - which is what should happen at runtime but it shouldn't affect compile time where you are still on the build OS |
19:13:46 | FromGitter | <liquid600pgm> the thing is, `when` *is* a compile-time feature |
19:14:02 | shashlick | agreed so it's not as simple |
19:14:59 | noonien | `var x, y: string; x = "foo"; y = x;` do x and y point to the same string? |
19:15:14 | noonien | i'm guessing not |
19:15:31 | noonien | just wanted to make sure |
19:16:25 | FromGitter | <liquid600pgm> afaik yes, strings are mutable in Nim |
19:16:27 | * | a_b_m joined #nim |
19:16:51 | dom96 | !eval var x = "foo"; var y = x; echo(repr(x));echo(repr(y)) |
19:16:53 | NimBot | 0x7fe9857d4058"foo"↵0x7fe9857d4080"foo" |
19:16:59 | noonien | yes, they are, but i'm unsure of copy conventions |
19:17:11 | dom96 | strings are copied |
19:17:24 | FromGitter | <liquid600pgm> good to know |
19:17:26 | noonien | can i get a "reference"? |
19:17:42 | FromGitter | <liquid600pgm> perhaps `addr` can help? |
19:17:58 | dom96 | noonien, what are you trying to do? |
19:18:34 | clyybber | mratsim: What are your opinions on https://github.com/nim-lang/Nim/issues/11178#issuecomment-489452673 ? |
19:18:35 | noonien | hmm, i guess i just want an alias |
19:18:45 | dom96 | liquid600pgm: that's unsafe. I'd suggest not using it unless you're dealing with FFI |
19:19:12 | dom96 | noonien, template alias: string = otherString |
19:19:44 | dom96 | maybe someone will eventually make an `alias` macro that does this and put it in the stdlib... :) |
19:20:04 | * | a__b__m quit (Ping timeout: 252 seconds) |
19:20:04 | noonien | ah, ok |
19:20:27 | * | Jesin quit (Quit: Leaving) |
19:20:40 | noonien | hopefully accessing the same field multiple times on an object gets optimized |
19:20:45 | narimiran | !eval var x = "foo"; let y = x; echo(repr(x));echo(repr(y)) |
19:20:46 | NimBot | 0x7f5f1349f058"foo"↵0x7f5f1349f080"foo" |
19:21:24 | * | slugm quit (Ping timeout: 250 seconds) |
19:21:40 | * | tefter quit (Remote host closed the connection) |
19:22:10 | clyybber | shashlick: Do you propose differentiating for hostOs and buildOs ? |
19:22:41 | shashlick | they are different already |
19:22:48 | shashlick | buildOs = linux even if -d:mingw |
19:23:07 | shashlick | but getTempFile() checks for when defined(windows) and does something different, compared to posix |
19:23:21 | shashlick | if you call getTempFile() at runtime, it should be windows %TEMP% |
19:23:30 | shashlick | but if in a static block, it should be /tmp |
19:23:43 | clyybber | ah, I see. |
19:23:44 | * | slugm joined #nim |
19:23:52 | * | stefanos82 quit (Remote host closed the connection) |
19:24:34 | dom96 | shashlick, I don't understand the problem. You're cross compiling to Windows, so os == windows sounds right? |
19:25:13 | shashlick | ya but if i do a getTempDir() at compile time to write something there like i have to for nimterop, it runs getEnv("TEMP") which doesn't work |
19:25:22 | shashlick | and that's just one example |
19:25:57 | shashlick | everything in os.nim that has different code by OS that somehow works in the VM will do this |
19:26:53 | clyybber | so we gotta `when nimvm` all of 'em |
19:27:50 | shashlick | but that also isn't clean cause then you still got to run the os specific code there |
19:28:24 | shashlick | so in some sense, all the procs are written correctly but if the code is running in the VM, it should check buildOS for that when condition and not hostOS |
19:28:49 | clyybber | yeah, so we should patch the vm |
19:29:50 | clyybber | the vm caring about the target os doesn't make sense anyways, so it shouldn't cause problems |
19:30:40 | FromGitter | <mratsim> @shashlick, no I will try nimterop first when wrapping that's what I meant |
19:31:28 | FromGitter | <mratsim> well it really depends because for ISL I tried to wrap I think it's better if I only import select proc because it's just oo overwhelming :/ |
19:31:53 | * | rnrwashere joined #nim |
19:32:10 | shashlick | maybe a whitelist would be cool - only import these 5 things |
19:32:42 | shashlick | you could also add a cPlugin to exclude by some pattern |
19:33:03 | FromGitter | <mratsim> @clybber sounds good, except I prefer static let then the assignment statement to the tiny difference between static and static: |
19:33:06 | shashlick | but there's really no harm since it only has to run once, after that the results are cached |
19:38:34 | * | rnrwashere quit (Remote host closed the connection) |
19:41:15 | dom96 | oh, I understand the problem now. |
19:41:26 | * | jjido quit (Quit: Textual IRC Client: www.textualapp.com) |
19:42:25 | * | narimiran quit (Ping timeout: 258 seconds) |
19:42:54 | * | deech joined #nim |
19:43:00 | dom96 | So what was the problem with changing when nimterop generates wrappers? |
19:43:11 | dom96 | Doing it at installation time seems like it's proving to be just a massive pain |
19:43:29 | dom96 | Why not just let people generate their wrappers by running `nimterop` manually before commiting their generated wrappers? |
19:43:39 | shashlick | well, nimterop does various tasks at compile time - pulling code from git, writing/reading files, running commands etc |
19:44:06 | shashlick | even if you do it one off like you say, it breaks down for cross compile scenarios |
19:44:24 | shashlick | basically i'm having to tell @liquid600pgm not to use -d:mingw on linux and use a real windows system |
19:44:46 | * | Lexy quit (Quit: � Www.Kelebek.Org Mutlaka Download Edin! Kelebek Final irc.kelebek.org �y wToprak �) |
19:44:54 | clyybber | Hi deech |
19:44:58 | dom96 | Why does it break down? |
19:45:05 | FromGitter | <liquid600pgm> I don't want to use windows D: |
19:45:19 | dom96 | And it seems that nimterop as it is right now has already broken down for cross-compilation? |
19:45:48 | deech | Hi |
19:45:55 | dom96 | I guess nimterop generates wrappers that are specific to the architecture the installation occurs on? |
19:46:20 | dom96 | Would it be hard to make it generate appropriate `when`s to ensure the wrappers work across all os/archs? |
19:46:31 | shashlick | it isn't specific to nimterop really |
19:46:33 | clyybber | deech: mratsim is supportive of the unification of compiletime and static, so we are 3 ppl now \o/ |
19:46:54 | shashlick | if you want to do anything at compile time and set --os:xyz, all stuff will not work anymore |
19:47:01 | shashlick | simple example = getTempDir |
19:47:11 | deech | clyybber, haha! |
19:47:59 | FromGitter | <liquid600pgm> clyybber: I support your initiative, too |
19:48:06 | shashlick | run static: getTempDir() and it won't work as expected |
19:48:49 | deech | I would be happy to see `{.compileTime.}` go away. :) You can get into confusing situations like, `let (a,b {.compileTime.}, c) = ...`. |
19:51:05 | deech | I'd also love to see variants supported at compile time. Currently they're explicitly disallowed for reasons I don't fully understand. |
20:04:14 | * | [rg] quit (Ping timeout: 246 seconds) |
20:15:23 | * | rnrwashere joined #nim |
20:17:56 | * | Jesin joined #nim |
20:25:23 | * | Sencatsu joined #nim |
20:26:24 | * | [rg] joined #nim |
20:28:22 | * | Senketsu_ quit (Ping timeout: 245 seconds) |
20:30:37 | * | [rg] quit (Ping timeout: 246 seconds) |
20:35:47 | * | jjido joined #nim |
20:40:47 | * | slugm quit (Read error: Connection reset by peer) |
20:41:00 | * | slugm joined #nim |
20:42:43 | * | a_b_m quit (Quit: Leaving) |
20:42:46 | FromGitter | <akavel> Hi! I'm trying to compile a .nim file to get a .c file, but I don't seem to be getting any output; I'm confused why is that so (o_O) |
20:42:52 | FromGitter | <akavel> My command is: `nim c --app:lib -d:noSignalHandler --compileOnly hello.nim` |
20:43:33 | FromGitter | <akavel> but even with a simple `nim c --compileOnly hello.nim`, I don't see any .c file :( |
20:43:43 | clyybber | deech: I agree, I think its because variants are implemented with some pointer stuff, but don't quote me on that |
20:43:46 | FromGitter | <akavel> what am I doing wrong? :/ |
20:43:52 | clyybber | liquid600pgm: Nice \o/ |
20:44:09 | PMunch | akavel, looking in the wrong place |
20:44:45 | FromGitter | <akavel> PMunch: oh, then where are the files put? |
20:44:48 | clyybber | akavel: The c file should be in ~/.cache/nim/a_d |
20:44:50 | PMunch | Try setting --nimcache or looking in the default location for your platform |
20:45:09 | FromGitter | <akavel> Oh, ok, thanks! |
20:45:47 | FromGitter | <akavel> Hm, if I tried to use -o option, would I get the file in the current dir? Or also not? |
20:46:23 | * | vlad1777d_ joined #nim |
20:47:04 | * | nsf quit (Quit: WeeChat 2.4) |
20:47:29 | * | PMunch quit (Remote host closed the connection) |
20:47:34 | FromGitter | <akavel> tried -o, didn't change. Wil read about --nimcache, thanks |
20:48:02 | * | PMunch joined #nim |
20:48:27 | PMunch | akavel, -o is only for the binary IIRC |
20:48:49 | PMunch | --nimcache:. should put it in your current directory I think |
20:50:29 | * | Perkol quit (Quit: Leaving) |
20:52:23 | FromGitter | <akavel> PMunch: yep, tried --nimcache:./cache, just in case it'd clobber it with much stuff, and I did well, as all the .c files for the imported libraries seem to get saved there too. |
20:53:08 | * | lritter quit (Quit: Leaving) |
20:53:19 | FromGitter | <akavel> Do you know how I can instruct nim to use a particular C compiler for the current project? |
20:53:28 | FromGitter | <akavel> and CFLAGS? |
20:53:29 | * | PMunch quit (Remote host closed the connection) |
20:53:48 | FromGitter | <akavel> I should probably read more about nimble, is that correct? |
20:54:06 | * | PMunch joined #nim |
20:54:09 | FromGitter | <akavel> I'm trying to cross-compile for an Android device |
20:54:33 | FromGitter | <akavel> I have Android NDK installed |
20:54:58 | FromGitter | <akavel> I managed to cross-compile a simple hello-world in C, and verify it works OK on the device |
20:55:01 | * | PMunch quit (Remote host closed the connection) |
20:55:21 | FromGitter | <akavel> Now I'm trying to do a similar one from Nim... |
20:56:50 | FromGitter | <akavel> Does nim look in some .cfg files or something? I seem to recall I've seen something like that, but can't remember enough detail to know where to look in the manual/docs/... :/ |
20:59:50 | FromGitter | <akavel> Ok, I think it's https://nim-lang.org/docs/nimc.html, which suggests a `nim.cfg` file is consulted |
21:01:01 | * | slugm quit (Remote host closed the connection) |
21:03:39 | shashlick | Use $CC |
21:04:11 | shashlick | Also check nightlies dx.sh to see how Nim itself gets compiled for Android |
21:04:19 | shashlick | There's android binaries posted |
21:11:56 | FromGitter | <akavel> there's some build.sh mentioned in dx.sh, but I don't seem to see it neither in nightlies/ nor in nim/ ? (there's nim/build_all.sh, but don't see build.sh) |
21:18:58 | * | rnrwashere quit (Remote host closed the connection) |
21:28:00 | FromGitter | <akavel> Ok, managed to get some .so to build, with --hint[CC]:on to see what compiler is called. Thanks guys again! Now "only" to see if it works on the device ;) |
21:35:56 | shashlick | Build.sh comes from csources |
21:36:04 | shashlick | It is packaged as part of the build |
21:36:18 | shashlick | But basically just set CC to your compiler |
21:39:46 | FromGitter | <akavel> I did: `nim c --app:lib --os:android --cpu=arm -d:noSignalHandler --hint[CC]:on hello.nim` |
21:39:58 | FromGitter | <akavel> somehow it auto-detected that clang must be used |
21:40:06 | FromGitter | <akavel> I also added the following in nim.cfg: |
21:40:21 | FromGitter | <akavel> --clang.path:r"c:\android-ndk-r19c\toolchains\llvm\prebuilt\windows-x86_64\bin\" ⏎ --clang.exe:"armv7a-linux-androideabi16-clang.cmd" ⏎ --clang.linkerexe:"armv7a-linux-androideabi16-clang.cmd" |
21:41:12 | FromGitter | <akavel> And the result works, woohoo! :D \^u^/ |
21:41:43 | * | rnrwashere joined #nim |
21:41:47 | FromGitter | <akavel> I expect to do a writeup and post it on the Nim forum |
21:42:04 | clyybber | good night |
21:42:14 | * | clyybber quit (Quit: WeeChat 2.4) |
21:42:14 | FromGitter | <akavel> but probably not today; hopefully before end of the week |
21:42:48 | FromGitter | <akavel> The achievement is building an .apk for Android without Android SDK |
21:43:02 | FromGitter | <akavel> though I still needed Android NDK for now |
21:43:26 | FromGitter | <akavel> But I wrote a (MVP) .dex assembler in Nim, + some helper tools, one in Nim, one in Go |
21:44:47 | FromGitter | <akavel> Thanks again for help, and hope you'll like the writeup. |
21:45:50 | shashlick | Oh you are the one who posted on lobsters |
21:46:33 | shashlick | I was going to try building an so later |
21:50:59 | FromDiscord_ | <פ ח ו ף> should i enable check for release versions |
21:52:01 | FromGitter | <akavel> shashlick: yep. What do you mean by "an so"? |
21:53:30 | xace | akavel: he might be referring to *.so files. Where will you publish your findings? |
21:54:02 | FromGitter | <akavel> xace: Ah, right. Probably on the Nim forum. |
21:54:29 | xace | Alright :) |
21:54:55 | FromGitter | <akavel> Hopefully with a Show Lobste.rs & Show HN linking to the to-be article on the forum. |
21:55:31 | dom96 | akavel: ooh, super excited for the write up! |
21:55:32 | FromGitter | <akavel> Note however that's a very MVP grade stuff, with an emphasis on M ;) |
21:55:56 | FromGitter | <akavel> dom96: happy to hear :D |
21:56:51 | dom96 | I actually have a project that might make use of this. Writing a game that I would like to eventually get running on Android :) |
21:57:44 | FromGitter | <akavel> @dom96: Actually, with games it might be even easier than with "regular" full-blown GUI stuff |
21:58:04 | FromGitter | <akavel> (which is what I'd be interested in) |
21:59:43 | FromGitter | <akavel> OTOH, there may be some divergence between the two use cases. Haven't really explored the game-like one. |
21:59:49 | shashlick | On the move now but happy to help with this |
21:59:59 | shashlick | Are you running in termux? |
22:00:14 | FromGitter | <akavel> @shashlick: help with what in particular? |
22:00:22 | FromGitter | <akavel> @shashlick: no, not in termux |
22:02:07 | xace | he seems to be crosscompiling from windows... Yeah I'm also interested in full-blown GUI for android using nim... atm I know of nimx and wiish, which seems to be viable candidates |
22:02:14 | FromGitter | <akavel> By the way, as a teaser, if you have an ARM-based phone, and are not afraid of installing random APKs from a semi-random guy on the Internet, you can try downloading: https://github.com/akavel/tests/releases/download/foobar/hello-jni.apk |
22:02:55 | xace | akavel im paranoid as f*ck, but what happens when you run that apk? what does it look like? |
22:04:23 | FromGitter | <akavel> just a "boring" (actually, super exciting to me ;P) "Hello from Nim" message in a simplest possible TextView |
22:05:00 | FromGitter | <akavel> And no Java was hurt in making this .apk ;) |
22:05:26 | FromGitter | <akavel> Or, actually, no PC was hurt by Java. |
22:06:30 | xace | actually no cpu was hurt by java |
22:07:01 | FromGitter | <akavel> hm, the phone CPU was kinda involved |
22:07:37 | FromGitter | <akavel> and the .apk verifier there was bashed quite some... |
22:07:37 | xace | well... we do our best trying to nim the world |
22:08:11 | FromGitter | <akavel> In case you are not afraid of seeing some gory details pre-writeup, |
22:08:48 | FromGitter | <akavel> the TextView creation and Nim call via JNI is at: https://github.com/akavel/dali/blob/master/jni_hello.nim#L79-L88 |
22:09:05 | xace | nah i wouldnt mind. infact i'd offer a non-sexual kiss to whoever makes it easy for nim to make proper API usage and UI for OSX and android... |
22:09:50 | * | lritter joined #nim |
22:10:18 | FromGitter | <akavel> whereas the source of the JNI .so in Nim is at: https://github.com/akavel/hellomello/blob/master/hello.nim#L20 |
22:10:46 | FromGitter | <akavel> Now, "easy" is in the eye of the beholder ;) |
22:11:24 | FromGitter | <akavel> I'm definitely not promising "easy" at this point ;) but "not requiring Android Studio" it is. |
22:11:29 | xace | haha dw, this information itself is helpful to get started, might aswell add you to the "nim+android" list im stashing |
22:14:05 | FromGitter | <akavel> yw |
22:19:39 | * | solitudesf quit (Ping timeout: 248 seconds) |
22:20:53 | FromGitter | <akavel> Bye guys, must go to sleep now. |
22:21:42 | * | natrys quit (Ping timeout: 245 seconds) |
22:25:42 | * | mal`` quit (Quit: Leaving) |
22:30:35 | * | mal`` joined #nim |
22:54:34 | * | lritter quit (Quit: Leaving) |
23:01:52 | * | rnrwashere quit (Remote host closed the connection) |
23:06:35 | * | jjido quit (Ping timeout: 248 seconds) |
23:07:39 | * | vlad1777d_ quit (Ping timeout: 248 seconds) |
23:15:23 | * | rnrwashere joined #nim |
23:19:55 | * | rnrwashere quit (Ping timeout: 248 seconds) |
23:46:29 | noonien | given `let foo = Foo()`, why can i `foo.fieldPairs` but not `Foo.fieldPairs`? |
23:46:46 | noonien | hmm, err, `.fields` |
23:50:08 | FromGitter | <jrfondren> what would you want Foo.fields to do? |
23:50:47 | * | [rg] joined #nim |
23:51:40 | noonien | hmm, return an iterator that provides each field name as a string, or as a descriptor which i can extract a string from |
23:58:40 | FromGitter | <JasperJenkins> It expects a object not a typedesc[object]. Just declare a temp of typ Foo and call fieldPairs over that. see: http://ix.io/1I9Q/nim |