00:05:41 | * | ghost64 joined #nim |
00:12:03 | * | ghost64 quit (Quit: See you!) |
00:12:37 | * | ghost64 joined #nim |
00:25:20 | * | PrimHelios_ joined #nim |
00:31:53 | * | ghost64 quit (Quit: See you!) |
00:32:37 | * | ghost64 joined #nim |
00:41:59 | * | darithorn_ quit () |
00:43:41 | * | PrimHelios_ quit (Quit: Leaving) |
00:43:52 | * | PrimHelios_ joined #nim |
00:43:53 | * | PrimHelios_ quit (Client Quit) |
00:44:15 | * | PrimHelios_ joined #nim |
00:46:56 | * | zachk quit (Quit: Leaving) |
00:54:51 | * | PrimHelios_ quit (Quit: Leaving) |
01:16:52 | * | a_b_m joined #nim |
01:18:47 | * | abm quit (Ping timeout: 240 seconds) |
01:37:27 | * | a_b_m quit (Ping timeout: 240 seconds) |
02:05:02 | * | banc quit (Quit: ZNC - http://znc.in) |
02:22:00 | * | banc joined #nim |
02:55:47 | FromDiscord | <treeform> dom96, system's reopen works great Demos figured it out. |
03:04:23 | * | darithorn joined #nim |
03:14:13 | * | darithorn quit () |
03:29:15 | * | chemist69 quit (Ping timeout: 252 seconds) |
03:31:19 | * | chemist69 joined #nim |
03:42:32 | * | ftsf joined #nim |
04:12:08 | * | Vladar joined #nim |
04:14:56 | * | darithorn joined #nim |
04:18:26 | * | stefanos82 joined #nim |
04:50:40 | * | endragor joined #nim |
05:11:12 | * | nsf joined #nim |
05:18:12 | * | ftsf_ joined #nim |
05:21:03 | * | ftsf quit (Ping timeout: 264 seconds) |
05:22:54 | * | narimiran joined #nim |
05:29:23 | * | darithorn quit () |
05:31:29 | * | smt` quit (Read error: Connection reset by peer) |
06:06:39 | * | leorize quit (Quit: WeeChat 2.2) |
06:13:30 | * | narimiran quit (Ping timeout: 252 seconds) |
06:16:47 | * | Vladar quit (Ping timeout: 240 seconds) |
06:19:11 | * | krux02 joined #nim |
06:27:29 | krux02 | good moring (or what is suitable for your time zone) |
06:28:37 | * | Pisuke joined #nim |
06:29:10 | * | MyMind quit (Ping timeout: 246 seconds) |
06:30:14 | FromGitter | <timotheecour> good evening :) @krux02 what do you think of https://github.com/nim-lang/Nim/pull/8166 : is 3d param a good idea? |
06:30:55 | * | Vladar joined #nim |
06:34:11 | krux02 | 3d param? |
06:34:23 | krux02 | I did a review already and I don't like it at all |
06:34:30 | krux02 | it is way too low level |
06:35:41 | FromGitter | <timotheecour> well I read all ur comments and I agree; but besides of implementation (which I agree needs to improve), there’s a question regarding API: shd we allow a 3 param variant as he does |
06:36:44 | FromGitter | <timotheecour> the PR itself is desirable (we need `relativePath`) even if currently problematic. |
06:39:44 | * | couven92 quit (Read error: Connection reset by peer) |
06:40:09 | krux02 | well Araq has a new path management module with distinct strings for relative and absolute paths |
06:40:10 | * | couven92 joined #nim |
06:40:50 | krux02 | this module is much more type safe and it has a better implementation than that PR |
06:43:14 | krux02 | I mentioned it, I like your PR about toSeq |
06:43:38 | * | Vladar quit (Ping timeout: 272 seconds) |
06:43:45 | krux02 | I was disappointed it toSeq several times so that I barely used it, you hacked it to just work more often |
06:44:12 | FromGitter | <narimiran> +1 on making toSeq more usable |
06:44:24 | krux02 | I don't like the fact that it feels very much like a hack, I would prfer if it could work somehow with overload resolution |
06:45:22 | krux02 | narimiran: https://github.com/nim-lang/Nim/pull/8711 https://github.com/nim-lang/Nim/pull/8711 |
06:45:59 | FromGitter | <timotheecour> well i do it via overload resolution (3 cases: iterator; not iterator; untyped) |
06:47:21 | FromGitter | <timotheecour> but right now it’s blocked by this comment https://github.com/nim-lang/Nim/pull/8711#issuecomment-432802139 which I don’t fully understand (if you have any tips on how to address it I’m all ears) |
06:50:54 | * | Vladar joined #nim |
06:56:44 | * | Araq_ is now known as Araq |
07:00:35 | * | mech422_ joined #nim |
07:03:48 | * | mech422__ quit (Ping timeout: 245 seconds) |
07:06:07 | * | Vladar quit (Ping timeout: 240 seconds) |
07:13:21 | * | Vladar joined #nim |
07:13:48 | * | Vladar quit (Remote host closed the connection) |
07:14:04 | * | rokups joined #nim |
07:14:07 | * | sagax_ joined #nim |
07:22:14 | * | Vladar joined #nim |
07:24:44 | * | jjido joined #nim |
07:31:07 | * | jjido quit (Ping timeout: 240 seconds) |
07:49:03 | * | jjido joined #nim |
07:57:07 | * | PMunch joined #nim |
08:01:26 | FromGitter | <alehander42> @dom96 , Araq @mratsim I think you misunderstand copygirl, iirc her goal was to have such an Either[T1, T2..] type that e.g. Either[T1, T2] is equivalent to Either[T2, T1] etc |
08:02:24 | * | jjido quit (Ping timeout: 252 seconds) |
08:02:25 | FromGitter | <alehander42> it's not so obvious how to do it just with variants as you need some kind of type ordering (and jsonNodes are very dynamic) |
08:02:38 | FromGitter | <alehander42> at least that's what i recall, maybe her requirements changed |
08:04:31 | FromGitter | <alehander42> on the other hand autogenerating variant fields based on the typename might also work |
08:04:50 | FromGitter | <alehander42> (also the converters idea that somebody (leorize ? ) had) |
08:05:34 | FromGitter | <alehander42> (i was also confused in the beginning) |
08:08:33 | * | floppydh joined #nim |
08:15:57 | * | jjido joined #nim |
08:17:04 | * | a_b_m joined #nim |
08:34:15 | copygirl | o.o? |
08:34:34 | copygirl | I have a macro that takes a `static[int]` but it appears the value is always 0. |
08:46:27 | PMunch | That's strange, code snippet? |
08:47:09 | krux02 | copygirl, static[int] in a macro is a compile time constant that is just an int value in macro context |
08:49:08 | copygirl | Interesting.. |
08:49:40 | PMunch | You can convert it to a static Nim node with newLit |
08:50:11 | copygirl | That's what I'm doing. |
08:50:27 | PMunch | Code snippet? |
08:50:30 | copygirl | For some reason in my macro, the value is 0. In another test macro it isn't. |
08:51:34 | copygirl | https://gist.github.com/copygirl/c1d5b87c88ce76baddc9ad8f148612c5 |
08:51:45 | copygirl | This prints out 1; 2; 0 when compiling. |
08:52:45 | krux02 | copygirl, I can follow you up until 2, then I don't know what you are doing |
08:53:43 | copygirl | At the bottom of the file I call makeEitherType(2) and the echo $size will print "0" for some reason. |
08:54:05 | krux02 | don't use "parseStmt", use result = quote do: |
08:54:15 | krux02 | and then the code you want to generate without the quotes |
08:54:26 | copygirl | quote does things I don't want. |
08:55:40 | copygirl | I tried it. It creates symbols and renames the parameters in ways that even break things. For example renaming "want" to "want758321", but not renaming it as the return type. |
08:56:13 | PMunch | I just get an error when I try to run that.. |
08:56:20 | copygirl | So I have a proc like `proc foo*(want756321: typedesc): want =` |
08:56:36 | krux02 | instead of $node.indent use node.strVal |
08:56:37 | copygirl | I get an error too but also prints out something before that. |
08:56:38 | * | Vladar quit (Ping timeout: 272 seconds) |
08:56:59 | PMunch | Ah right |
08:57:17 | * | hwallann quit (Remote host closed the connection) |
08:57:47 | copygirl | You can comment out the echo result.repr and treeRepr to only get the 1; 2; 0 lines as output. |
08:57:59 | krux02 | this seems weird |
08:58:57 | krux02 | if you can isolate the the cause that triggers the echo $i to print the wrong value, please create an issue for it. This looks like a bug |
08:59:10 | * | copygirl nods. |
09:00:26 | PMunch | Yeah this looks super strange |
09:01:49 | copygirl | I guess it's from the use of size in the inner proc. |
09:02:55 | PMunch | Hmm, I tried to add let size = inSize and renamed the parameter to inSize |
09:02:59 | PMunch | That made it work |
09:03:28 | PMunch | So somehow the code after the echo changes the value of size :S |
09:03:39 | copygirl | https://gist.github.com/copygirl/24e560f007410ed6fef585666da570ea |
09:04:13 | FromGitter | <mratsim> the joy of working with types within macros |
09:05:07 | copygirl | Should I report it to the issue tracker? |
09:05:31 | PMunch | Yes |
09:05:36 | PMunch | That is definitely a bug :P |
09:08:14 | * | Vladar joined #nim |
09:10:44 | * | platoff joined #nim |
09:11:02 | krux02 | yes |
09:11:10 | krux02 | with that code example |
09:11:12 | krux02 | that is good |
09:11:14 | krux02 | I like it |
09:11:34 | copygirl | https://github.com/nim-lang/Nim/issues/9509 Is this a good issue? |
09:11:39 | * | dom96_w joined #nim |
09:11:45 | * | enthus1ast joined #nim |
09:12:39 | krux02 | here is a workaround: http://ix.io/1pYV |
09:12:58 | copygirl | (You can do that??) |
09:13:02 | krux02 | yes |
09:13:11 | copygirl | How!? Why?! |
09:13:27 | krux02 | it just shadows the parameter |
09:13:58 | krux02 | the i on the right doesn't see it's onwn declaration yet, and the parameters are not the same scope |
09:20:06 | * | Arrrr joined #nim |
09:27:17 | * | enthus1ast_ joined #nim |
09:29:36 | Araq | http://cppconf.ru/talks/day-1/track-a/5.pdf |
09:29:51 | * | enthus1ast quit (Ping timeout: 260 seconds) |
09:30:51 | * | enthus1ast__ joined #nim |
09:33:21 | * | enthus1ast_ quit (Ping timeout: 252 seconds) |
09:34:22 | * | enthus1ast_ joined #nim |
09:36:47 | * | enthus1ast__ quit (Ping timeout: 250 seconds) |
09:37:30 | FromGitter | <narimiran> how to re-run CI tests? close PR and open it again later? |
09:37:37 | Araq | yup |
09:37:47 | Araq | you can reopen it immediately though |
09:43:40 | FromGitter | <mratsim> there is a button now to “rebuild” directly on Travis |
09:45:26 | FromGitter | <mratsim> that certainly looks like a fun talk @Araq |
09:45:55 | krux02 | Araq: the thing about string_view is pretty much summarized at the end, it is a borrow type, no ownership, short lived, can do without assignment op, only in function parameter lists, cannot be stored in data structures |
09:46:50 | krux02 | this tells me that there is a change to implicitly work with string views in arguments |
09:47:25 | krux02 | there is a function with argument string |
09:47:57 | krux02 | looks like a value argument, but internally it is a string view |
09:49:00 | krux02 | but yea it breaks at the ``dst : var string`` argument pattern |
09:49:39 | FromGitter | <mratsim> it’s like an openarray |
09:50:22 | krux02 | yes |
09:50:26 | FromGitter | <mratsim> now to end the talk on a high note, let’s talk about utf8_string_view :P |
09:50:48 | krux02 | nope |
09:51:08 | krux02 | string is utf8 |
09:51:22 | krux02 | everything is utf8 |
09:51:43 | krux02 | and whoever disagrees is wrong or has a bug |
10:01:45 | * | jjido quit (Ping timeout: 252 seconds) |
10:25:06 | * | Stiggis joined #nim |
10:27:48 | * | crem quit (Ping timeout: 252 seconds) |
10:29:39 | * | crem joined #nim |
10:31:15 | * | vlad1777d_ joined #nim |
10:35:47 | FromGitter | <timotheecour> @araq where is `llStreamClose` called for this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd19c83069fca52a58fde8a] |
10:37:17 | Araq | in getIndentWidth, closeLexer |
10:38:26 | FromGitter | <timotheecour> Gotcha, indeed, thx; in the (near?) future, will that be replaceable by RAII? |
10:38:35 | * | enthus1ast_ left #nim (#nim) |
10:38:42 | FromGitter | <timotheecour> (less error prone etc) |
10:38:52 | * | enthus1ast joined #nim |
10:39:16 | Araq | yeah, getIndentWidth's inputStream becomes a 'sink' parameter |
10:39:31 | Araq | to signal ownership transfer |
10:39:53 | Araq | and llStream's close is a destructor, so everything works out |
10:40:32 | FromGitter | <timotheecour> cool.. |
10:47:24 | * | enthus1ast_ joined #nim |
10:50:09 | * | enthus1ast quit (Ping timeout: 252 seconds) |
10:50:21 | * | crem quit (Ping timeout: 252 seconds) |
10:52:18 | * | crem joined #nim |
10:52:30 | * | platoff quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
10:53:04 | * | enthus1ast_ quit (Remote host closed the connection) |
10:55:49 | * | enthus1ast joined #nim |
10:57:15 | * | kapil____ joined #nim |
10:57:49 | * | Arrrr quit (Quit: Arrrr) |
10:59:30 | FromGitter | <timotheecour> why `strip` in `if strip(readFile(expected)) != strip(readFile(produced)):` in nimpretty tester? isnt’ that loose ? |
11:00:22 | * | platoff joined #nim |
11:01:04 | enthus1ast | lol just got banned from ##apple because i asked if there is a (official) way to run macos in virtualbox, to test code on it |
11:02:05 | enthus1ast | is the bsd kernel still close enough to macos to test network code? |
11:02:52 | * | dom96_w quit (Changing host) |
11:02:52 | * | dom96_w joined #nim |
11:03:03 | dom96_w | yep |
11:03:21 | enthus1ast | any recommendations? freebsdß |
11:03:22 | enthus1ast | ? |
11:05:29 | Araq | PS4 runs on FreeBSD |
11:05:32 | Araq | so yeah |
11:06:34 | enthus1ast | ok thank you i'll try freebsd then |
11:15:37 | krux02 | enthus1ast, I got banned from #archlinux, because I asked a question but my distro is manjaro |
11:17:17 | enthus1ast | i must say, when the community is that hostile, and access to an os is not granted to developers, then it seems not worth to support it |
11:17:59 | enthus1ast | hell i get even free windows vms :) |
11:18:32 | PMunch | How did you get banned for that krux02, I've done exactly that multiple times .P |
11:22:55 | krux02 | I don't know |
11:24:45 | krux02 | enthus1ast, well consoles usually require you to get a development kit |
11:25:13 | krux02 | you are not allowed to run your own executable on your own console |
11:25:54 | krux02 | so even if you have the hardware, that is not enough to develop for it |
11:27:44 | enthus1ast | its not about gaming consoles, i want to port my multicast lib to macos, by the way would this not be a good fit for net.nim? |
11:28:05 | * | Calinou_ is now known as Calinou |
11:34:13 | FromGitter | <arnetheduck> @Araq ping on https://github.com/nim-lang/Nim/pull/9029 |
11:37:27 | Araq | ok, resolve the conflict please and I prefer 'proc {.noSideEffect.}' over 'func' because all the existing code uses that, but it's a minor style thing and you can also keep the 'func' |
11:40:07 | livcd | enthus1ast: there are some osx cloud providers. You can use those |
11:44:07 | * | Snircle joined #nim |
11:46:05 | FromGitter | <Quelklef> Is there a way to force the type system to accept certain conditions? |
11:46:09 | FromGitter | <Quelklef> Like a cast, but more general |
11:46:25 | FromGitter | <Quelklef> I want to be able to assert that certain calls are `{.noSideEffect.}` even though they're not |
11:46:29 | FromGitter | <Quelklef> Like `debugEcho` |
11:58:25 | FromGitter | <timotheecour> @kaushalmodi I don’t understand your comment in https://github.com/nim-lang/Nim/pull/9510#discussion_r228139225 |
11:58:33 | FromGitter | <timotheecour> where is it already defined? |
11:59:51 | FromGitter | <narimiran> @kaushalmodi thanks for pinging me on that macro issue |
12:00:51 | * | elrood joined #nim |
12:18:31 | FromGitter | <narimiran> can i somehow declare one field of my object to be `foo: array[<something_here>, float]`, and the length of it will be determined later (but still at compile time)? |
12:18:57 | * | smt joined #nim |
12:19:04 | Araq | Quelklef: cast the proc types, it's wordy but it works |
12:19:23 | Araq | cast[proc (paramsHerre) {.nimcall, noSideEffect.}](f)() |
12:19:30 | FromGitter | <Quelklef> Ah, duh. Thanks |
12:19:49 | FromGitter | <Quelklef> Yeah, I'd hope doing something this shady would be wordy and annoying lol |
12:41:17 | FromGitter | <narimiran> is there a way to specify (in nim.cft) in which directory i would like to have my binaries? |
12:41:24 | FromGitter | <narimiran> *nim.cft |
12:41:31 | FromGitter | <narimiran> god dammit, .cfg |
12:43:37 | FromGitter | <narimiran> i've tried with "o:../bin/<something>" (where <something> was $1, *, etc.), but it was always taken literally. it is output *file*, i want to define output *directory* |
12:44:23 | FromGitter | <timotheecour> @narimiran no but I’ve thought about something along what u described; and it’d be useful in combination with https://forum.nim-lang.org/t/4330 |
12:45:52 | FromGitter | <narimiran> so i would need to create a separate "myfile.nim.cfg" for each file where i should specify where bin should go? :( |
12:46:33 | FromGitter | <narimiran> i've never used nims, can maybe that be more helpful? (i've seen on the forum that might be preferred over .cfg) |
12:47:36 | FromGitter | <timotheecour> well nims is more flexible, allowing executing scripts (instead of just declarative stuff like flags) |
12:49:01 | FromGitter | <timotheecour> in nims (or nimble files, which use also use nimscritp), u can call `exec` for eg which can in turn do stuff like: `exec “nim c -r -o:bin/baz test.nim"` |
12:49:48 | FromGitter | <timotheecour> not sure if `-o:foo` in cfg is considered good practice (never saw it before); but with nims u can do as i suggested |
12:50:25 | dom96_w | You can use Nimble's `binDir` directive and compile using `nimble build` |
12:50:27 | Araq | I don't like either but I'm making nims robust for v1 |
12:50:52 | Araq | since as usual my own "much better stuff" is just stuff with unknown problems :P |
12:51:08 | FromGitter | <narimiran> what i like to have is `nim c -o:../bin/$1 $1.nim" so it works for any `.nim` file |
12:51:55 | FromGitter | <narimiran> @dom96_w i might try that |
12:51:58 | Araq | in theory -o:../bin/$projectName works |
12:52:08 | Araq | in practice it doesn't because of phase ordering problems |
12:56:14 | FromGitter | <timotheecour> how about: ⏎ `nim c —outputdir:bin bar.nim` => outputs to bin/bar ; 0 ambiguity, and really would help because now we can add `—outputdir` in nim.cfg (or `switch(“outputdir”, “bin”)` in top-level project config.nims , and then boom, it makes it really easy to conform to a build dir (see https://forum.nim-lang.org/t/4330 ) |
12:57:43 | FromGitter | <timotheecour> avoids need to gitignore specific files, and allows putting generated files all in 1 place without custom complex setup in each nimble project |
12:58:23 | FromGitter | <timotheecour> FWIW in D they have introduced this flag `-od` with roughly same meaning. |
13:00:15 | Araq | yeah, let's have --outputdir |
13:01:19 | FromGitter | <narimiran> i've just tried nimble's `binDir` + `nimble build`, and: please, let's have `--outputdir`;) |
13:02:14 | FromGitter | <kaushalmodi> +1 for --outputdir! |
13:06:01 | FromGitter | <timotheecour> you can add your +1 here: https://github.com/nim-lang/Nim/issues/9513 |
13:06:55 | Araq | implement it already |
13:07:19 | Araq | it's part of our "Nim tooling" week where we improve Nim's tooling. |
13:07:31 | * | Vladar quit (Remote host closed the connection) |
13:07:32 | Araq | (nah, I just invented that...) |
13:09:29 | FromGitter | <narimiran> +1 on Nim tooling week :) |
13:09:54 | FromGitter | <timotheecour> @araq how should this behave: ⏎ `—outputdir:build -o:bar main.nim ` ? my vote is for bar ⏎ `-o:bar —outputdir:build main.nim ` ? my vote is for build/main ⏎ ie, latest option overrides previous [https://gitter.im/nim-lang/Nim?at=5bd1c0a1600c5f6423068be4] |
13:10:45 | Araq | dunno, keep in mind that --outputdir will end up in configs and -o not necessarily |
13:10:50 | * | xace quit (Ping timeout: 246 seconds) |
13:11:12 | FromGitter | <narimiran> @timotheecour why the result of both of those isn't `build/bar`? |
13:12:56 | * | xace joined #nim |
13:13:53 | FromGitter | <timotheecour> build/bar doesn’t make much sense; `-o:bar` always meant to write to bar; but the most flexible approach would be to allow: `-o:$outputdir/bar` (and of course, quote it in the shell) |
13:14:57 | FromGitter | <timotheecour> therefore user can choose whether to override (`-o:foo/bar`) or take advantage of (`-o:$outputdir/foo/bar`) |
13:15:42 | FromGitter | <kaushalmodi> @timotheecour having them order dependent is too confusing |
13:16:07 | FromGitter | <kaushalmodi> Let both orders do the same thing, and have it documented |
13:16:47 | FromGitter | <kaushalmodi> It's better to simply prefix outputdir to whatever output is |
13:16:47 | FromGitter | <narimiran> well, it is not that somebody has been using `outputdir` from before (because it didn't exist), so from now on, when you use both of them you should know what each of them does, so you don't define `-o:path/to/bar` together with `--outputdir:path/to` |
13:17:18 | * | kapil____ quit (Quit: Connection closed for inactivity) |
13:17:52 | FromGitter | <Vindaar> @narimiran (reg. your array question above) unless I misunderstand, you can use `static` like so ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd1c280435c2a518e024845] |
13:18:22 | FromGitter | <kaushalmodi> How about, if someone does --outputdir foo --output bar/zoo, we get foo/bar/zoo |
13:18:37 | FromGitter | <kaushalmodi> In essence --outputdir defaults to pwd |
13:19:08 | FromGitter | <narimiran> @Vindaar thanks! i knew it had to do something with `static` but i didn't know exactly how to do it :) but i think `seq` will do it :D KISS |
13:19:20 | FromGitter | <kaushalmodi> If --output is an absolute path (begins with /), ignore --outputdir |
13:19:29 | FromGitter | <narimiran> @kaushalmodi +1 |
13:19:31 | * | chemist69 quit (Ping timeout: 250 seconds) |
13:19:32 | FromGitter | <kaushalmodi> @timotheecour ^^ |
13:20:32 | * | chemist69 joined #nim |
13:20:37 | FromGitter | <timotheecour> i’d be ok with that |
13:21:27 | FromGitter | <narimiran> but why, oh why, would somebody define path two times? either you want your (one) file to be somewhere (use `o` when compiling that file), or you want the whole project to have some "bin directory" (use `--outputdir` in nim.cfg) |
13:22:49 | FromGitter | <timotheecour> why o why because configs are nested :) |
13:23:18 | FromGitter | <narimiran> ah, true :D |
13:23:46 | FromGitter | <timotheecour> so you may have a config in ~/.config/nim/config.nims that gets overridden by a myproj/config.nims that itself is overridden by myproj/subproj/config.nims |
13:24:27 | FromGitter | <kaushalmodi> This needs an RFC that has a table of all possible scenarios of these 2 switches |
13:25:04 | FromGitter | <kaushalmodi> And having them order independent is very important |
13:25:05 | FromGitter | <timotheecour> well the RFC is here: https://github.com/nim-lang/Nim/issues/9513 |
13:25:17 | FromGitter | <narimiran> that means we can end up with `path/to/something/../../i/changed/my/mind` (where `path/to/something` is `--outputdir` defined somewhere, and then the rest is `-o` |
13:25:37 | FromGitter | <kaushalmodi> +1 |
13:25:42 | FromGitter | <timotheecour> feel free to comment there ; I’ll keep updating top-level msgs until we all agree |
13:25:52 | FromGitter | <kaushalmodi> Heh, you already incorporated |
13:26:02 | FromGitter | <kaushalmodi> my suggestion :) |
13:26:08 | FromGitter | <timotheecour> haha ya |
13:26:13 | Araq | ok, I take it back, RFC for this is appropriate |
13:26:34 | Araq | nothing is ever trivial... |
13:26:49 | FromGitter | <kaushalmodi> @timotheecour also add absolute path cases for --outputdir |
13:27:22 | FromGitter | <narimiran> can we have some example what the other languages do? (no, not just D, @timotheecour :D) |
13:27:30 | FromGitter | <kaushalmodi> For relative path cases that you have right now, make it evident that those are relative to PWD |
13:27:45 | Araq | also keep in mind that --nimcache is unrelated and should stay unrelated |
13:28:47 | * | rockcavera quit (Ping timeout: 240 seconds) |
13:29:15 | Araq | so ... is nimpretty useful now? |
13:30:39 | FromGitter | <kaushalmodi> Araq: I haven't tried, not at pc. Does nimpretty have check-only mode, that returns error code if code is not already pretty? |
13:30:51 | FromGitter | <kaushalmodi> That will be very useful on Travis |
13:31:48 | FromGitter | <kaushalmodi> E.g. PR will fail if code is not "Nim pretty" |
13:32:01 | FromGitter | <kaushalmodi> Like what gofmt does |
13:34:18 | FromGitter | <narimiran> Araq: i started using it couple of days ago, but my code is already pretty so it didn't have much to do :D joking aside, beside some extra newlines added (i think that is now fixed), i find it quite good and useful. will test it some more |
13:34:53 | FromGitter | <timotheecour> @narimiran and @kaushalmodi I added algorithm section; lemme know whether u agree or if needs more description |
13:35:17 | FromGitter | <skellock> @kaushalmodi re: newt fork -- i was just messing around with it. No intention to wrap it. I did see someone did a long time ago in nim already, but I didn't try it. (sorry for the 2 week delay in replying -- i'm on "vacation".) |
13:36:29 | Araq | kaushalmodi: nah, you can run "nim pretty" and see if "git diff" is empty :P |
13:37:42 | FromGitter | <timotheecour> @araq well every time you fix a bug I retry on a bunch of files ; keeps getting better but still some blocks for widespread adoption |
13:38:13 | FromGitter | <timotheecour> it’s almost there though; haven’t seen any other bug than ones currently opened |
13:39:26 | FromGitter | <narimiran> Araq: now i found something that it might also fix: `0 .. <5` to change to `0 ..< 5`, this is not only style but "< is deprecated" |
13:39:47 | Araq | the good news is that I now understand nimpretty :P |
13:40:11 | FromGitter | <timotheecour> @araq can nimpretty be a building block for nimfix2 ? |
13:40:49 | FromGitter | <timotheecour> (for nimfix2 i want to be able to allow a user to write custom transforms, eg switch 2 args) |
13:41:27 | FromGitter | <alehander42> is nimfix2 an automated refactoring tool? |
13:41:45 | Araq | seems too low level, if you want nimpretty to produce a seq/list of tokens with line information |
13:41:49 | FromGitter | <timotheecour> that’d be the idea, allowing advanced refactoring based on arbitrary user defined macros |
13:42:35 | Araq | the old "nimfix" seems better for that, only touch what you must |
13:42:52 | FromGitter | <alehander42> @timotheecour I remember there was an ast-based search/replace tool for JS I really digged http://www.graspjs.com/ I was planning to port it to ruby ages ago |
13:43:00 | FromGitter | <timotheecour> the hope would be to have minimal impact on source code except for changes specified in user defined macro; so i was hoping nimpretty could help there (modulo maybe adaptation) |
13:43:35 | FromGitter | <alehander42> sounds very similar to this idea |
13:43:41 | FromGitter | <timotheecour> Oh, so the flow would be: code=>nimfix2=>nimpretty |
13:43:58 | Araq | or just "nimfix2" |
13:44:00 | krux02 | Araq: what is the module/fieled that is used ot generate global variables into |
13:44:03 | Araq | or just "nimpretty" |
13:44:19 | Araq | krux02, sfGlobal in sym.flags |
13:45:00 | krux02 | that I know, but that is just how I detect a global var |
13:45:09 | krux02 | I would like to know where it is generated into |
13:45:19 | krux02 | the localtion of the string/rope |
13:45:32 | krux02 | in BProc |
13:45:39 | FromGitter | <timotheecour> @alehander42 ya there are similar tools based on libclang that are somewhat hard to use but powerful ; oh and google used a bunch of these for massive scale code refactorings |
13:45:42 | Araq | add(p.module.s[cfsVars], decl) |
13:45:50 | FromGitter | <timotheecour> (beyond just renaming) |
13:45:52 | FromGitter | <alehander42> @timotheecour the benefit of a grasp-like tool is that it also lets you search in codebases way more powerfully based on ast wildcards |
13:45:57 | FromGitter | <alehander42> compared to regex |
13:46:35 | FromGitter | <alehander42> probably, yeah, I think I also watched a fb talk on fosdem for one similar tool |
13:46:38 | FromGitter | <alehander42> maybe infer |
13:46:49 | FromGitter | <timotheecour> yes no doubt AST is more powerful than regex for that task, never doubted that :) |
13:47:22 | Araq | for large scale refactorings you need large code bases |
13:48:15 | FromGitter | <timotheecour> large scale for us would be: “go fix all nimble packages to upgrade to new breaking change in compiler and automatically send PRs" |
13:48:16 | FromGitter | <alehander42> infer is different, maybe i don't remember correctly |
13:49:10 | Araq | I prefer to minimize the "breaking changes" though |
13:49:27 | Araq | otherwise you have even more reasons to keep the current style of development |
13:49:37 | Araq | which is terrible. |
13:50:15 | Araq | "hey, you are not big yet and I'm new so everything that came before me is kinda irrelevant, so let's just use markdown everywhere" |
13:50:38 | Araq | no offense implied. |
13:52:23 | FromGitter | <timotheecour> no offense taken. markdown is a different topic (which originated here https://forum.nim-lang.org/t/4280#26755 ; i didnt’ start it but embraced it) |
13:52:48 | Araq | it was only an example, it applies to everything |
13:52:59 | Araq | "so make Nim case sensitive" |
13:53:05 | Araq | "so make Nim use braces" |
13:53:07 | FromGitter | <alehander42> well, that's not very objective: some things just can be done in a better way |
13:54:11 | FromGitter | <timotheecour> in a closed ecosystem (eg tech company with monorepo) breaking changes happen all the time and are “easy-ish" to handle via automation; in a open eco-system with standardized package manager (nimble), this could be possible too via such nimfix based tooling |
13:54:12 | FromGitter | <kaushalmodi> Braces or not is very subjective, and your preference is respected there. But Markdown wins over RST hands down in the tech field |
13:54:50 | FromGitter | <kaushalmodi> I think the Markdown argument is not in the same category |
13:55:02 | FromGitter | <alehander42> that's not even the problem |
13:55:08 | FromGitter | <alehander42> the problem is that this is not even pure rst |
13:55:16 | FromGitter | <alehander42> it's rst + some other features |
13:55:24 | FromGitter | <alehander42> but this isn't too important, I agree |
13:55:32 | FromGitter | <kaushalmodi> That too, and pure rst is very limiting |
13:55:42 | Araq | I would just add the 3 features from markdown that you miss and call it a day |
13:55:57 | Araq | currently it's an RST dialect |
13:56:08 | Araq | and every markdown impl we choose would be a dialect |
13:56:21 | Araq | so you might as well take the easy route and patch the existing dialect |
13:56:52 | FromGitter | <alehander42> well, as long you don't have ambiguity , this might work as well |
13:56:56 | Araq | and Nim's variant of RST is documented fwiw |
13:57:11 | Araq | maybe incompletely, but that's really easy to improve |
13:57:38 | * | PMunch quit (Quit: Leaving) |
13:57:50 | * | dddddd joined #nim |
13:58:20 | FromGitter | <alehander42> well, fossil is also well documented |
13:58:24 | FromGitter | <timotheecour> Again, automation can help here; see automatically converted RST => markdown docs: https://github.com/timotheecour/Nim/blob/pr_rst_to_markdown_contributing2_output2/doc/contributing.md |
13:58:37 | FromGitter | <alehander42> but if a project comes tomorrow with fossil, people would still be like "wait, i have to learn a different vcs" |
13:58:45 | * | vlad1777d_ quit (Ping timeout: 244 seconds) |
13:58:51 | Araq | again, automation doesn't help much |
13:59:07 | Araq | for a start I need to adapt to markdown syntax. |
13:59:22 | Araq | and so would every other Nim user who happens to like RST |
14:00:38 | Araq | secondly, "stay tuned, we created PRs for all Nimble packages out there" is a questionable idea. the PRs may not be applied |
14:01:02 | Araq | for all sort of reasons |
14:01:06 | Araq | lack of time to review it |
14:01:26 | Araq | abandoned packages (aha! so I fork these -- yeah ok...) |
14:01:42 | Araq | lack of consensus (I liked the old style better, thanks) |
14:02:43 | Araq | you're trying to fix social problems with technology, I don't believe in that. |
14:07:03 | FromGitter | <timotheecour> nim-lang can host a mirror of a whitelist of nimble packages and push commits there; the PR’s would still need to be accepted by upstream obviously, but it’d at least allow to apply a change on a nimble-packages scale automatically. I think that’s worth exploring down the line to improve apis (again, in closed ecosystem, ability to automate changes on large scale really improves codebases) |
14:11:07 | FromGitter | <kaushalmodi> I think that PR-botting is going overboard :) |
14:11:35 | FromGitter | <timotheecour> anyway that’s not for anytime soon. |
14:11:55 | FromGitter | <kaushalmodi> Yeah, this was going into yak shaving |
14:12:08 | FromGitter | <kaushalmodi> Let's focus on objective merits of Markdown |
14:18:15 | dom96_w | One of the most important reasons against switching from rST to Markdown is: we need 1.0!!!! |
14:19:19 | Araq | dom96_w, +1000 |
14:19:20 | dom96_w | There are far more important things that we should consider changing, things that are actually a detriment to adoption |
14:19:32 | dom96_w | Although even those are debatable |
14:19:53 | dom96_w | I haven't heard anyone complain about Nim's use of rST |
14:20:02 | dom96_w | Not a single person |
14:20:25 | dom96_w | Until recently at least :P |
14:20:35 | FromGitter | <kaushalmodi> People who actually work on documentation know the documentation warts |
14:20:35 | FromGitter | <alehander42> which takes us to .. where is the nim survey blog :D |
14:20:46 | FromGitter | <kaushalmodi> i.e. issues with rST |
14:20:59 | dom96_w | alehander42: 90% finished |
14:21:28 | FromGitter | <kaushalmodi> dom96_w: I made my first doc PR and I ended up with this rST limitation: https://github.com/nim-lang/Nim/issues/9070 |
14:21:43 | FromGitter | <kaushalmodi> so unless people actually document, they won't know the issues with rST |
14:21:52 | FromGitter | <alehander42> *blows the dust from the needed-libraries issue generator* |
14:21:54 | * | ftsf_ quit (Ping timeout: 252 seconds) |
14:22:00 | dom96_w | Is this an rST limitation or a limitation with our parser? |
14:22:01 | FromGitter | <timotheecour> well almost everyone who posted in https://forum.nim-lang.org/t/4280#26755 seemed to agree markdown is a better choice; are there more important issues than RST/md? sure, no doubt. |
14:22:12 | FromGitter | <kaushalmodi> that's a limitation in rST spec |
14:22:48 | FromGitter | <kaushalmodi> so I at least don't agree that "people not complaining about rST" *like rST over Markdown* |
14:22:53 | FromGitter | <alehander42> what are to most important issues? the 1.0 milestone list? |
14:24:14 | * | endragor quit (Remote host closed the connection) |
14:24:18 | dom96_w | lol, I love how this has been a todo for rST since 2001 http://docutils.sourceforge.net/docs/dev/rst/alternatives.html#nested-inline-markup |
14:25:06 | FromGitter | <kaushalmodi> dom96_w: Your comment about 1.0 release can be easily flipped around |
14:25:17 | FromGitter | <kaushalmodi> Nim 1.0 supporting Markdown docs can boost its adoption |
14:25:50 | dom96_w | I think it has a strong chance doing the exact opposite |
14:25:54 | FromGitter | <kaushalmodi> every Tom, Dick & Harry commenting on Reddit, GitHub, Gitlab, Stackoverflow, etc. would know how to write Nim docs |
14:25:55 | * | narimiran joined #nim |
14:25:58 | dom96_w | People have a limit of how many breaking changes they can take |
14:26:01 | * | endragor joined #nim |
14:26:10 | dom96_w | And honestly, rST isn't that hard |
14:26:29 | dom96_w | we can fix those parser limitations |
14:26:34 | FromGitter | <kaushalmodi> rST is more like trying to do things that you think are obvious, but don't work |
14:26:48 | FromGitter | <kaushalmodi> I faced another rST spec/parser limitation while linking something on Nim forum |
14:26:53 | FromGitter | <kaushalmodi> it's just broken |
14:27:44 | FromGitter | <alehander42> however, is this about nimdoc ? |
14:28:04 | FromGitter | <alehander42> ah, the inline docs |
14:28:31 | FromGitter | <kaushalmodi> @alehander42 yeah, the Nim doc strings and docs in .nim files in general |
14:28:39 | FromGitter | <alehander42> well honestly another idea is that |
14:29:02 | FromGitter | <alehander42> people who like markdown can write their inline docs in markdown and maintain their own markdoc |
14:29:19 | FromGitter | <alehander42> and offload all this to a 3rd party lib competition |
14:29:25 | FromGitter | <alehander42> the capitalist way |
14:29:46 | FromGitter | <alehander42> i really have to wrtie this "the language is a central goverment" essay |
14:30:11 | FromGitter | <timotheecour> > and docs in .nim files in general ⏎ ⏎ and all the ones in doc/*.rst (for which I have a WIP PR for automated conversion) |
14:30:21 | * | endragor quit (Ping timeout: 252 seconds) |
14:32:46 | * | Stiggis quit (Quit: Leaving) |
14:33:17 | dom96_w | Funnily enough I think the verbose "code-block" syntax that rST uses has a strong chance of pushing people towards using `runnableExamples`, sounds like a win to me :P |
14:34:36 | FromGitter | <kaushalmodi> I agree that `runnableExamples` is an awesome feature |
14:34:49 | FromGitter | <timotheecour> Oh ya, regarding that: saw some cases (ok my bad, some are from my PRs) where the code isn’t even shown at all because of missing newlines before/after teh code-block in rst |
14:34:55 | FromGitter | <kaushalmodi> It needs to be discussed that's the alternative to that in the Markdown world |
14:35:48 | FromGitter | <kaushalmodi> would be good to concentrate these points in that markdown RFC |
14:47:18 | * | rockcavera joined #nim |
14:47:49 | FromGitter | <arnetheduck> the whole point with moving from nim-rst is to avoid all the downstream work that people have to do to get a minimally acceptable experience with the docs - so they can spend time on working on nim instead of yet another shit format for text that nobody else is interested in.. |
14:50:28 | FromGitter | <arnetheduck> the technical reasons are completely uninteresting - the fact that rst has some more features doesn't matter the least - it's a dead format because it's too strict and complicated for what is essentially meant to be unstructured - if structure is needed, you might as well write code, not prose |
14:52:12 | FromGitter | <arnetheduck> editors, site generators, jupyter notebooks, everything needs to support the weird and quirky nim-rst, that's an incredible amount of work compared to what porting the (barely) existing docs found in current nim source code |
14:53:52 | FromGitter | <kaushalmodi> As an aside, `dumpLisp` gives a non-lispy output; it has commas in there |
14:54:27 | FromGitter | <kaushalmodi> Araq: If you are fine, I can work on making that output more lisp like. |
14:54:55 | * | sagax_ quit (Quit: Konversation terminated!) |
15:01:12 | FromGitter | <kaushalmodi> Araq: Here is the current output of an example `dumpLisp`: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd1dab882893a2f3b3abbef] |
15:02:00 | FromGitter | <alehander42> wait until somebody defines scheme macros for all of those and runs nim code on scheme |
15:02:41 | noonien | hello folks! |
15:02:55 | noonien | how do i create a nim library that compiles to an .so? |
15:03:10 | noonien | i've called `nimble init` and initialized the packages a a lib |
15:03:17 | noonien | but don't really know where to go from here |
15:03:23 | noonien | nibmle build says i need to specify a bin |
15:03:47 | enthus1ast | noonien, nim c --app:lib code.nim |
15:03:57 | FromGitter | <kaushalmodi> noonien: you cannot "build" a lib |
15:04:20 | noonien | i see, so i only use nimble for package management? |
15:04:45 | enthus1ast | nimble is also a task runner |
15:05:00 | noonien | oh, right, i remember |
15:05:18 | noonien | forgot about that, i've tried using nimble a few times now over the years |
15:07:22 | noonien | thanks! |
15:07:33 | * | narimiran quit (Ping timeout: 252 seconds) |
15:07:55 | * | narimiran joined #nim |
15:14:24 | * | krux02 quit (Remote host closed the connection) |
15:15:20 | FromGitter | <mratsim> can’t use use a nimble build task that does nim c —app:libfoo my lib.nim? |
15:15:26 | FromGitter | <mratsim> can’t you use* |
15:16:30 | FromGitter | <mratsim> ah, it should be part of nimble install, I wonder if we can deploy shared lib with nimble install |
15:28:06 | * | darithorn joined #nim |
15:33:10 | * | rokups quit (Quit: Connection closed for inactivity) |
15:40:49 | FromGitter | <kaushalmodi> @mratsim It was you who let me know about the existence of `dumpLisp` |
15:41:04 | FromGitter | <kaushalmodi> I used it today, and didn't find the output too lisp, so here's a PR https://github.com/nim-lang/Nim/pull/9515 |
15:46:38 | FromGitter | <mratsim> I don’t speak Lisp so i can’t review :P |
15:53:18 | * | hagna joined #nim |
15:57:38 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
16:02:10 | * | dom96_w joined #nim |
16:06:22 | * | dom96_w quit (Client Quit) |
16:08:46 | * | floppydh quit (Quit: WeeChat 2.2) |
16:09:45 | * | kapil____ joined #nim |
16:10:40 | * | dom96_w joined #nim |
16:11:46 | * | Trustable joined #nim |
16:19:47 | * | UNIcodeX joined #nim |
16:27:16 | * | jjido joined #nim |
16:37:03 | * | jacereda joined #nim |
16:38:14 | jacereda | hi... silly question, what would be the idiomatic way to translate a python dictionary comprehension? |
16:39:27 | narimiran | jacereda: nice one! i haven't tried it, but i would try to do it with `map` |
16:39:56 | jacereda | narimiran, keep in mind a dict comprehension can include a filter operation... |
16:40:26 | narimiran | jacereda: i'll try to make an example, and if i succeed i'll get back to you |
16:40:40 | jacereda | narimiran, ok, thanks |
16:42:19 | * | enthus1ast quit (Ping timeout: 250 seconds) |
16:43:20 | narimiran | but in the mean time, for-loop and `if` are probably your best bet. not even nearly as elegant, but it is at least simple |
16:44:14 | jacereda | narimiran, I was looking for some inliner that could be sold as 'look, not that bad' |
16:44:19 | jacereda | s/inliner/oneliner |
16:44:50 | FromGitter | <kaushalmodi> jacereda: Do you have a small python example of what you want to do? |
16:44:54 | narimiran | jacereda: well, even list comprehensions are ugly (IMO) in nim |
16:45:23 | narimiran | @kaushalmodi `{k: k**2 for k in range(5)}` |
16:45:52 | FromGitter | <kaushalmodi> isn't that `mapIt`? |
16:46:15 | FromGitter | <alehander42> notice `k: v` |
16:46:24 | FromGitter | <alehander42> it creates a dict |
16:46:37 | FromGitter | <alehander42> with the new forloop macros we can do something like |
16:46:40 | FromGitter | <alehander42> `let c = (for t in comp(b): (if true: {v: y}))` |
16:46:53 | FromGitter | <alehander42> but it's a little bit weird, because we need the `()` around `if` |
16:46:59 | FromGitter | <kaushalmodi> ok, I will just observe this discussion silently (new thing to learn) |
16:47:07 | jacereda | Something like the example in py2nim: {k + 2: v - 2 for k, v in a.items()} |
16:47:31 | jacereda | sorry, |
16:47:33 | jacereda | {k + 2: v - 2 for k, v in a.items() if k == 0} |
16:48:12 | narimiran | @kaushalmodi: btw, python has also set comprehension, which i also miss in nim :'( |
16:48:14 | FromGitter | <alehander42> wait for a minute |
16:50:25 | narimiran | (everybody is waiting) |
16:50:52 | FromGitter | <kaushalmodi> @alehander42 no pressure |
16:59:47 | * | jjido quit (Ping timeout: 240 seconds) |
17:01:31 | * | dom96_w quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
17:02:00 | planetis[m] | list comprehesions are weird, especially in python. i could never understand their meaning |
17:02:57 | jacereda | planetis[m]: I could agree, but I'm thinking about transpiling a large project with lots of those |
17:03:55 | planetis[m] | from python? |
17:05:13 | jacereda | yes |
17:06:22 | planetis[m] | nice, does python-nim work or will you do it manually with some regex? |
17:07:33 | jacereda | I didn't know about python-nim, I'm looking at py2nim |
17:07:50 | jacereda | url? |
17:08:13 | planetis[m] | yes that one |
17:08:16 | planetis[m] | sry |
17:08:37 | narimiran | planetis[m]: it's not that weird. you start with the 'body', and after that everything is like it would be in multiple lines |
17:09:10 | planetis[m] | exactly my point :) |
17:10:07 | narimiran | well, the most important part/information is in front, i think that's a good idea |
17:10:54 | planetis[m] | so is this new list comprehensions that look like linq? |
17:11:01 | planetis[m] | actually I like them |
17:11:13 | planetis[m] | its python that i can stand |
17:11:25 | planetis[m] | *can't |
17:11:52 | narimiran | lol, ok |
17:12:22 | * | dorelix joined #nim |
17:13:09 | jacereda | the fact is this is my first day with nim and I was quite happy to find py2nim... after some problems I finally managed to fix the build, but I'm having problems with the dict comprehension |
17:13:55 | jacereda | IMHO having py2nim in good shape would be a good thing for the language |
17:15:36 | narimiran | jacereda: i wouldn't rely solely on py2nim no matter how good it was. it can help you by speeding up some translations, but i would still change some things manually |
17:15:37 | FromGitter | <kaushalmodi> jacereda: In case you haven't, it would help to open an issue on py2nim repo and explaining your dict comprehension use case; with an example of python snippet |
17:15:46 | planetis[m] | its a good thought, but there seems there is no interest in it. last commit was from january |
17:16:11 | FromGitter | <kaushalmodi> nevertheless, it doesn't hurt |
17:16:27 | FromGitter | <kaushalmodi> may be someone in the same situation as yours comes by that issue, and has something to share |
17:16:49 | narimiran | jacereda: i've started with nim by manually translating my python code. and sometimes nim was just 2x faster. until i've learned to do things more idiomatically, and boom: 30x speedup! |
17:17:56 | FromGitter | <kaushalmodi> ah! @alehander42 is the dev of that project :) |
17:18:20 | jacereda | I'll send a PR to the repo, but I wanted to fix the dict comprehension first |
17:19:06 | * | dorelix quit (Quit: Leaving) |
17:19:13 | narimiran | as i said some half an hour ago: manually looping might be your safest bet :) |
17:20:13 | planetis[m] | so the ForLoopStmt will allow to rewrite the code to: ``let t = (var temp: seq[int]; for i in 0 .. 2: temp.add i; temp)`` is that correct? |
17:21:16 | planetis[m] | if so it looks like there is a copy |
17:22:23 | planetis[m] | ofc with destructors that wouldn't be an issue |
17:22:48 | jacereda | Is ForLoopStmt some node in the AST or something? |
17:23:08 | planetis[m] | no actually |
17:23:15 | planetis[m] | i think its magic |
17:23:41 | * | dorelix joined #nim |
17:23:56 | jacereda | ok, I'll try to go that route |
17:24:00 | jacereda | thanks |
17:26:07 | planetis[m] | jacereda: you will write a lc macro yourself, even though you just started with nim? |
17:27:32 | FromGitter | <kaushalmodi> jacereda: In case you go down the `lc` route, I have some notes on that: https://scripter.co/notes/nim/#list-comprehension |
17:29:16 | jacereda | planetis[m]: I won't if anyone else does it for me ;) Is it that hard? I just need something like filterTable() and mapTable() |
17:30:26 | FromGitter | <Vindaar> you could base your custom `lc` on this: https://github.com/nim-lang/Nim/blob/devel/tests/macros/tcollect.nim |
17:30:51 | planetis[m] | it is yes; personally i write only procedural code but there is the `sequtils` module which have functional style procs |
17:31:38 | FromGitter | <mratsim> Nim has For Expression now which the list comprehensions should use soon (but it’s a hidden feature once again :P) |
17:32:16 | planetis[m] | weird the example Vindaar posted doesn't use `ForLoopStmt` i am confused |
17:33:17 | FromGitter | <mratsim> ah @alehander42, regarding the “leaf expressions” I talked yesterday, I wonder what this new `nnkStmtListExpr` NimNode is ;) |
17:36:34 | planetis[m] | they're both ForStmt, what is the hidden feature? |
17:37:18 | FromGitter | <mratsim> for expressions return a container |
17:37:38 | FromGitter | <mratsim> for statements return nothing |
17:39:17 | jacereda | so, would it be better to modify https://github.com/metacraft-labs/py2nim/blob/b627eda8bcb57ded3aaacb673fc975a2f008f268/compiler.nim#L1212 to emit a for loop instead of trying to implement macros for mapTable()/filterTable()? |
17:39:58 | jacereda | s/for loop/for expression |
17:40:21 | FromGitter | <mratsim> Or you can use either zero-functional (https://github.com/zero-functional/zero-functional) or loop-fusion (https://github.com/numforge/loop-fusion) |
17:41:03 | FromGitter | <mratsim> note that if you manage to generate {0: “foo”, 1: “bar”} with macro you can then use totable on it to construct your table. |
17:41:40 | FromGitter | <mratsim> disclaimer @alehander42 the author of Py2Nim is also the author of zero-functional, and I’m the author of loop-fusion. |
17:41:56 | planetis[m] | mratsim: thx i will try to understand it with examples |
17:42:14 | FromGitter | <mratsim> And py2nim was used to kickstart production code: https://github.com/status-im/nimbus from https://github.com/ethereum/py-evm |
17:43:01 | FromGitter | <mratsim> @planetis to be honest, I didn’t try for expressions yet so I understand the theory but I didn’t try using them yet. |
17:43:20 | Araq | jacereda, py2nim suffers from a lack of resources, but not from a lack of interest :-) |
17:43:37 | planetis[m] | once i tried py2nim, and it wouldn't generate code for functions that are not called |
17:43:48 | FromGitter | <mratsim> dead call elimination :P |
17:44:09 | Araq | and since it uses the compiler API to render the Nim code, at least that part gets better as a side effect of us improving Nim's compiler... |
17:45:51 | planetis[m] | so is it easier to change py2nim or make a maptable macro, (i wasn't the one asking just curious :p) |
17:47:01 | Araq | I wish I could py2nim a try but I should work on Nim :-) |
17:47:30 | Araq | the concept it uses is pretty cool |
17:47:35 | FromGitter | <alehander42> ok @jacereda @kaushalmodi I made a small lib for ForLoop macro-based comprehensions |
17:47:52 | FromGitter | <alehander42> stuff like `let f = (for k, v in comp(a): (if k == v: {k: v}))` or `let e = (for k, v in comp(a): (if k == v: {k}))` works now |
17:48:10 | narimiran | what is `comp`? |
17:48:35 | FromGitter | <alehander42> a comprehension macro (it seems one needs this to have a ForLoop macro) |
17:48:53 | FromGitter | <alehander42> the only problem is the initTable/initSet stuff uses an anon proc right now because I am not sure how else to load their types |
17:49:17 | FromGitter | <alehander42> I think I had an approach which should be DCE-d on runtime, but for some reason it's not |
17:50:11 | FromGitter | <alehander42> (I generate ⏎ ⏎ ```# def of `e` ⏎ var unused = `e`() ⏎ var `compResult` = initSet[unused.type]()``` ⏎ ⏎ and `e` is not used anywhere else, but it's not eliminated: Araq, is something like that possible? [https://gitter.im/nim-lang/Nim?at=5bd2025364cfc273f92479e2] |
17:52:39 | Araq | what's wrong with type(e())[0] ? |
17:53:17 | Araq | I added a typeof extension for this to work, but my testing only covered tcollect.nim |
17:53:53 | FromGitter | <alehander42> ahh I have to try that |
17:54:14 | FromGitter | <alehander42> I guess `type(e)[0]` ? |
17:54:54 | Araq | depends on what 'e' is |
17:55:29 | jacereda | alehander42, where's that lib? |
17:56:03 | FromGitter | <alehander42> `e` is a proc |
17:56:04 | FromGitter | <mratsim> in his head :P |
17:56:37 | FromGitter | <alehander42> @jacereda I just wrote it, fixing something and I'll publish it |
17:56:58 | jacereda | ok, thanks |
18:00:09 | planetis[m] | so the lib alehander wrote uses ForLoopStmt whereas tcollect.nim uses for expressions. that was confusing me |
18:01:34 | planetis[m] | it would be nicer if this special purpose macros not needed. |
18:01:50 | planetis[m] | *weren't |
18:03:07 | FromGitter | <alehander42> Araq everything I try with `type(stuff)[0]` fails with `identifier expect` |
18:03:10 | FromGitter | <alehander42> ed |
18:04:19 | Araq | give me a gist please |
18:10:37 | FromGitter | <alehander42> https://gist.github.com/alehander42/90df2c4d8afd2f93c35ee211e91975bc |
18:11:12 | FromGitter | <alehander42> but anyway, I actually saw what you do in tcollect, I didn't have any idea `call to type with a node` works |
18:11:46 | FromGitter | <alehander42> maybe it's because I used quote, manually creating it with bindSym as in your code works |
18:15:56 | Araq | well 'e' is a proc type and [0] is not defined for typeDesc |
18:16:19 | * | zachk joined #nim |
18:18:33 | Araq | ok, what do you wanna read: An article about why exceptions are misunderstood or an article about Nim with memory regions? |
18:19:16 | * | zachk quit (Changing host) |
18:19:16 | * | zachk joined #nim |
18:22:43 | planetis[m] | my vote is exceptions |
18:25:29 | * | mosORadi joined #nim |
18:25:55 | dom96 | Araq: You want me to deploy that blog article too? |
18:28:01 | Araq | sure |
18:28:07 | Araq | dom96, your vote? |
18:29:41 | FromDiscord | <treeform> can i haz blog? |
18:30:23 | Araq | slightly offtopic, any experiences with speech-to-text software? |
18:31:54 | dom96 | Vote for what |
18:31:58 | dom96 | link me to the irc logs if necessary |
18:32:05 | dom96 | Got people over today so don't have much time |
18:32:39 | Araq | what do you wanna read: An article about why exceptions are misunderstood or an article about Nim with memory regions? |
18:34:41 | dom96 | Can you elaborate on the first? |
18:34:53 | dom96 | Are you going to be a proponent of exceptions or not? |
18:38:16 | Araq | lol, yes I will |
18:42:40 | UNIcodeX | py2nim failing to build with some warnings. use 'parseopt' instead of parseopt2, use 'sugar' instead of future. |
18:45:28 | dom96 | Araq: You will be a proponent? Your statement feels ambigous |
18:45:33 | dom96 | *ambiguous |
18:45:45 | FromGitter | <alehander42> @jacereda https://github.com/alehander42/comprehension (honestly maybe `comp(for ..)` is better than `for .. in comp(..)`, not sure, i'd wait for people opinions on the api), thanks to Araq for ForLoop macros & tcollect (maybe it's better to just extend tcollect and stdlib it? ) |
18:49:04 | dom96 | well: exceptions |
18:49:05 | FromGitter | <alehander42> about py2nim: it's a cool idea, but it does require some more work indeed: we've been busy I guess and at least I haven't updated it for Nim 0.19 , but if people have some particular libs/examples I can take a look at low hanging fruits |
18:49:09 | dom96 | as long as you're a proponent |
18:49:34 | FromGitter | <alehander42> (zero-functional is maintained by @michael72 these days ) |
18:51:43 | UNIcodeX | I'm new to Nim. What does this mean? tracer.nim(9, 9) Hint: simpleGetOrDefault(typ, "kind") --> 'getOrDefault(typ, "kind")' [Pattern] |
18:53:03 | UNIcodeX | looking at the line mentioned in that file, there is no "simpleGetOrDefault" or "getOrDefault". I only see: if typ{"kind"} == nil |
18:54:29 | jacereda | alehander42: nice... I think I'll just implement filterTable()/mapTable() for the PR because it looks simpler, but I think your library will help with the objections I'll get from the python front |
18:59:47 | shashlick | we can save ~1.5 minutes by caching built csources in nim builds - is it worth it to consider this in appveyor/travis |
19:00:09 | planetis[m] | alehander42: what type does your macro return for the two examples you posted? |
19:00:49 | FromGitter | <alehander42> @jacereda what kind of code do you want to port? |
19:01:32 | FromGitter | <alehander42> @planetis[m] well basically if your body is `{expr: expr}` it builds a table, if it's `{expr}` it builds a set and if it's something else, it builds a seq |
19:02:04 | planetis[m] | thx |
19:03:27 | FromGitter | <alehander42> honestly we can have a better syntax I think |
19:03:28 | FromGitter | <alehander42> e.g. |
19:03:39 | FromGitter | <alehander42> ```let z = comp{for k, v in a: k: u} ⏎ ``` [https://gitter.im/nim-lang/Nim?at=5bd2138b3844923661995b92] |
19:03:54 | FromGitter | <alehander42> for tables or ⏎ ⏎ ```let z = comp{for k, v in a: k}``` [https://gitter.im/nim-lang/Nim?at=5bd2139ac08b8b306770c212] |
19:03:56 | FromGitter | <alehander42> for sets |
19:04:37 | FromGitter | <alehander42> the set one looks very similar to python and most importantly you can still use comprehensions to build a seq of sets this way (because `{k}` is not special) |
19:04:49 | FromGitter | <alehander42> the table one might be confusing tho |
19:04:59 | FromGitter | <kaushalmodi> shashlick: I was thinking of actually caching just the csources built nim binary |
19:05:08 | FromGitter | <kaushalmodi> that should be enough I think |
19:05:29 | jacereda | alehander42: it's a propietary product that is now using an extended python2, but it has reached the limits of what you should do without a decent type system (and current performance sucks TBH) |
19:05:37 | FromGitter | <kaushalmodi> (I do that locally; I don't build csources if nim binary is present) |
19:06:25 | Araq | dom96: I will argue for exceptions, yes |
19:07:52 | shashlick | @kaushalmodi: I agree - and can just do a git pull on the cached code and if that returns any changes found then do the rebuild |
19:08:11 | shashlick | right now the build.sh isn't smart enough to only recompile changed files |
19:08:20 | shashlick | if we moved that into a makefile, it would do it automatically |
19:08:21 | FromGitter | <alehander42> or even use `~` instead of comp and just have ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd214a5ef4afc4f28cf31d1] |
19:08:39 | shashlick | but for the amount of time savings, it isn't worth it |
19:08:52 | FromGitter | <alehander42> but i guess people would hate another `~` |
19:17:35 | FromGitter | <kaushalmodi> @alehander42 I like the descriptive `comp` |
19:18:23 | planetis[m] | jacareda: take a look at this: https://gist.github.com/b3liever/15968fb7e5ae0b414857360ac930c4e8 |
19:19:08 | planetis[m] | jacereda: ^ |
19:21:09 | FromGitter | <rayman22201> @Araq can Haz both articles? Lol |
19:22:39 | FromGitter | <alehander42> Araq I like the memory region blog idea, much more exotic :D |
19:23:57 | FromGitter | <alehander42> @jacereda I see, it's a good time to change indeed, Python2 is close to end of life afaik |
19:25:00 | FromGitter | <alehander42> @kaushalmodi do you have pref between `comp(for ..)` and `(for .. in comp() )` |
19:40:58 | Araq | comp(for ...) is better |
19:42:36 | FromGitter | <kaushalmodi> @alehander42 I don't have a preference, but `comp(for ..)` is shorter |
19:44:36 | narimiran | one more vote for comp(for ...) |
19:47:18 | FromGitter | <alehander42> @planetis[m] lcSet is pretty good too |
19:47:52 | FromGitter | <alehander42> I think your code is better than mine, but we still need a `k: v` special treament for tables (and generalization for comp) |
19:48:40 | * | xet7 quit (Remote host closed the connection) |
19:48:45 | FromGitter | <timotheecour> @araq not sure how feasible is your comment: https://github.com/nim-lang/Nim/pull/9510#issuecomment-433031254 the only “global” access in nimpretty.nim is via ``ConfigRef`` ; and that is defined in options.nim anyways, so I don’t see how else to do what you suggest |
19:50:16 | planetis[m] | The code comes from tcollect, it just edited to do initSet |
19:51:03 | * | stefanos82 quit (Quit: Quitting for now...) |
19:51:30 | FromGitter | <alehander42> that's a good idea indeed, do you want to generalize it further? |
19:52:51 | FromGitter | <alehander42> otherwise `comp(for ..)` remains, but then does anybody prefer ⏎ `comp{for .. expr}` vs `comp(for .. {expr})` and ⏎ `comp{for .. expr: expr}` vs `comp(for .. {expr: expr})` |
19:53:07 | planetis[m] | I could, don't you want to do it? :D You have already written a similar macro, if you have no time I will do it |
19:53:29 | FromGitter | <alehander42> the first style seems a bit more flexible, as we can later add `comp[..]` for e.g. arrays |
19:53:30 | planetis[m] | eventually |
19:53:33 | * | xet7 joined #nim |
19:54:04 | planetis[m] | but do these special syntaxes valid |
19:54:19 | FromGitter | <alehander42> @planetis[m] I can do it too, just if you're interested you can also do it |
19:54:21 | planetis[m] | sorry, are these valid? |
19:54:37 | FromGitter | <alehander42> I think so, I know that one can override `{}` |
19:55:41 | planetis[m] | no not really, i am very tired |
19:55:49 | narimiran | `comp( {for ... expr} )` for set comprehension, `comp ( [for ... expr] )` for list/seq/array comprehension |
19:56:34 | narimiran | hmmm, maybe we can lose parantheses and just have whitespace? `comp {for ... expr}` and `comp [for ... expr]` |
19:56:58 | FromGitter | <alehander42> yes space works |
19:57:15 | FromGitter | <alehander42> but I am afaid people will easily make a mistake and miss it |
19:57:32 | * | jacereda quit (Ping timeout: 246 seconds) |
19:58:06 | UNIcodeX | I have cloned Nim, built it using the instructions on github, cloned py2nim, followed its instructions to build, and I get errors. Even after making changes to the imports that it suggests. I do not know what to do with the hint about simpleGetOrDefault(typ, "kind") --> 'getOrDefault(typ, "kind")' [Pattern]. Will someone PLEASE help? |
19:58:36 | narimiran | if both space and parentheses work (like they do for a single parameter procs) then i don't see a (big) problem |
19:58:46 | FromGitter | <alehander42> @planetis[m] @narimiran yeah the `comp{..}` works with overriding `{}` |
19:59:03 | FromGitter | <alehander42> the problem is .. it's hard to make it work with the normal macro (space) |
19:59:17 | FromGitter | <alehander42> because I need to have both `comp` macro and `comp` global var |
19:59:20 | FromGitter | <alehander42> which seem to clash :D |
19:59:29 | narimiran | if it was easy, i would do it ;) |
19:59:59 | FromGitter | <alehander42> @UNIcodeX ignore this hint, it's about an autogenerated code, it doesn't really matter |
20:00:03 | FromGitter | <alehander42> for your usage |
20:00:39 | planetis[m] | what is it for, the `comp` global var |
20:01:16 | FromGitter | <alehander42> because I need to be able to override `{}` |
20:01:18 | UNIcodeX | @alehander42, OK. thanks. I guess the real error is "cannot open file: compiler/ast" |
20:01:19 | FromGitter | <alehander42> I think |
20:01:30 | * | xet7 quit (Remote host closed the connection) |
20:01:34 | FromGitter | <alehander42> @UNIcodeX py2nim isn't up to date for Nim 0.19 sadly |
20:01:42 | FromGitter | <alehander42> I can try to take a look at it tomorrow |
20:02:51 | UNIcodeX | I have a web scraper that uses selenium. It runs in parallel using Python's multiprocessing.Pool. Currently the scraper runs at a rate of 1.75 seconds per page. I may not be able to make it go any faster, but I'm trying to see about learning Nim by porting it over. I thought py2Nim would be a good starting place. |
20:03:00 | UNIcodeX | @alehander42^ |
20:03:35 | UNIcodeX | @alehander42 https://hastebin.com/oqahilunox.py |
20:03:44 | FromGitter | <mratsim> selenium is basically launching long-lived chrome instances |
20:03:50 | FromGitter | <mratsim> your bottleneck is Chrome not Python |
20:03:59 | FromGitter | <mratsim> and maybe the captchas |
20:04:59 | UNIcodeX | @mratsim And I figure as much, but would still like to port either it or something to learn Nim. Another reason is distribution of an executable. Nuitka is failing to build with some error about a filename being to long.... :scratches head: |
20:05:24 | FromGitter | <alehander42> @mratsim is right, but if you want to try Nim, that's great |
20:05:44 | FromGitter | <alehander42> well, py2nim needs to be updated, so you might want to directly start with Nim for now, I am sorry |
20:05:52 | UNIcodeX | I'm also having trouble building Aporia on my work machine. Sadly it's Winders |
20:05:59 | UNIcodeX | It built perfectly on my Arch install. |
20:06:04 | UNIcodeX | at home |
20:06:07 | FromGitter | <mratsim> ah Python distribution, always lovely: https://xkcd.com/1987/ |
20:06:31 | FromGitter | <mratsim> Use Vscode, I’m not even sure dom96 is updating it |
20:06:49 | FromGitter | <alehander42> yes, nim has ok plugins for most common editors |
20:06:57 | FromGitter | <alehander42> people also use sublime, vim |
20:07:02 | narimiran | UNIcodeX: AFAIK aporia is not maintained anymore, most of us use VSCode |
20:07:05 | FromGitter | <alehander42> emacs |
20:08:41 | UNIcodeX | I'll check out VSCode. I'm more used to vi for general text editing. and PyCharm for Python, which has really spoiled me on IDEs |
20:09:34 | FromGitter | <mratsim> lots of dev are using vi, check maybe zah’s plugin |
20:09:48 | FromGitter | <mratsim> it works with nimsuggest AFAIK |
20:10:08 | FromGitter | <alehander42> well, I hope one day we get a jetbrains ide too |
20:10:30 | FromGitter | <mratsim> I hope we can replace java :P |
20:10:40 | UNIcodeX | their IDEs are top notch for sure. |
20:10:43 | FromGitter | <alehander42> I wonder what name would they decide on |
20:10:55 | FromGitter | <mratsim> Sunrise? |
20:11:33 | * | nsf quit (Quit: WeeChat 2.2) |
20:11:39 | UNIcodeX | If memory serves, Armin Ronacher, who created the werkzeug and Flask web application libraries for Python, works for JetBrains |
20:11:58 | UNIcodeX | maybe he could be made interested in Nim |
20:13:20 | FromGitter | <alehander42> @mratsim I expect something like a SpaceNimBear |
20:13:39 | FromGitter | <alehander42> yeah, he seems like a cool guy |
20:14:05 | FromGitter | <kaushalmodi> Anyone knows how to write Nim equivalents of these JS snippets |
20:14:17 | FromGitter | <kaushalmodi> https://functions-playground.netlify.com/ |
20:14:51 | FromGitter | <kaushalmodi> plan is to then have Nim -> JS -> Netlify Lambda functions |
20:14:53 | * | xet7 joined #nim |
20:15:11 | * | Trustable quit (Remote host closed the connection) |
20:15:21 | UNIcodeX | VSCode looks neat. |
20:15:49 | UNIcodeX | plugin management within app. 30k plus installs of Nim plugin. |
20:16:24 | FromGitter | <alehander42> @kaushalmodi you can do them kinda easily, in my code I have macros for export, but one could go on without them too |
20:17:56 | FromGitter | <alehander42> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd224f4271506518d6d4352] |
20:18:04 | FromGitter | <alehander42> not tested |
20:18:05 | * | vlad1777d_ joined #nim |
20:18:20 | FromGitter | <kaushalmodi> @alehander42 let me try that out; thanks! |
20:19:05 | FromGitter | <alehander42> the querystring thing I am not sure about: is it coming from their lib? |
20:19:24 | FromGitter | <kaushalmodi> I honestly have no idea |
20:19:33 | FromGitter | <kaushalmodi> I know just Nim and nothing about JS |
20:19:34 | FromGitter | <alehander42> also, not entirely sure if anon async procs work (normal async procs work), but it should be possible eventually |
20:19:39 | FromGitter | <alehander42> ah ok :D |
20:20:19 | FromGitter | <kaushalmodi> that's why, if someone has an a to b association table between Nim and those JS snippets, I think I can start using Netlify functions |
20:20:20 | FromGitter | <kaushalmodi> :) |
20:22:54 | FromGitter | <kaushalmodi> @alehander42 that snippet doesn't work: ⏎ ⏎ > Error: ':' or '=' expected, but got 'exports' |
20:23:45 | * | narimiran quit (Quit: Konversation terminated!) |
20:25:42 | FromGitter | <rayman22201> long shot, but try `var exports : js {.importc.}` |
20:26:37 | FromGitter | <rayman22201> I have JS experience, and Nim experience, but I've never heard of netlify :/ |
20:26:59 | FromGitter | <kaushalmodi> Netlify is a service for deploying static sites |
20:27:07 | FromGitter | <kaushalmodi> I deploy my Hugo site using them (free) |
20:27:20 | FromGitter | <rayman22201> ah. ok |
20:27:21 | FromGitter | <kaushalmodi> btw adding that `: js` type also didn't work |
20:27:30 | FromGitter | <kaushalmodi> *never seen that type* |
20:28:18 | FromGitter | <rayman22201> it's part of the js ffi: https://nim-lang.org/docs/lib.html#pure-libraries-modules-for-js-backend |
20:28:41 | FromGitter | <rayman22201> specifically this type: https://nim-lang.org/docs/jsffi.html#JsObject |
20:29:03 | FromGitter | <rayman22201> importing the jsffi module might help also |
20:33:41 | UNIcodeX | any idea why VSCode wouldn't be able to find nim on the path, when I've verified that it's the first entry in the path and that I can run it without the full path in powershell and cmd? |
20:34:25 | FromGitter | <kaushalmodi> @rayman22201 Adding `import jsffi` worked; it compiled, but the code is https://ptpb.pw/eHda/js |
20:34:50 | * | mosORadi quit (Quit: Connection closed for inactivity) |
20:34:54 | FromGitter | <kaushalmodi> it doesn't have the `exports.handler` that I have in the expected code: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd228ee64cfc273f9257fff] |
20:35:14 | FromGitter | <rayman22201> it's getting name mangled. |
20:35:31 | FromGitter | <kaushalmodi> yeah.. I get `exports_319014[0].handler` |
20:35:44 | FromGitter | <kaushalmodi> so that might not work.. or would it? |
20:35:57 | FromGitter | <rayman22201> would not work. something is amis |
20:36:29 | FromGitter | <rayman22201> It's missing something... hrmmm.... |
20:36:35 | FromGitter | <kaushalmodi> here is the nim code that generated that: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd22952435c2a518e0511aa] |
20:37:19 | FromGitter | <rayman22201> oh, you need the '{.importc.}` part still |
20:37:33 | FromGitter | <rayman22201> `var exports: js {.importc.}` |
20:38:15 | FromGitter | <kaushalmodi> but then I get: ⏎ ⏎ > hello.nim(3, 17) Error: invalid indentation |
20:39:10 | FromGitter | <kaushalmodi> That *(3, 17)* is pointing at the `.` before `importc` in `var exports: js {.importc.}` |
20:40:08 | FromGitter | <kaushalmodi> this worked! |
20:40:13 | FromGitter | <kaushalmodi> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd22a2c1e23486b9319a0df] |
20:40:30 | FromGitter | <kaushalmodi> needed to have that pragma between var and type |
20:40:56 | FromGitter | <rayman22201> ah. ok. I don't use pragmas on vars like that often. good catch. |
20:41:06 | FromGitter | <kaushalmodi> and here's the generated JS:https://ptpb.pw/Pr84/js |
20:41:07 | FromGitter | <rayman22201> That should probably be in the manual... or noted somewhere lol |
20:41:10 | FromGitter | <kaushalmodi> now trying it out |
20:42:30 | FromGitter | <rayman22201> If you want to use the async stuff, remember to use https://nim-lang.org/docs/asyncjs.html to get the js version of the async macro. |
20:44:55 | FromGitter | <kaushalmodi> cool! still working on getting a toy repo out with just that hello.js |
20:46:33 | UNIcodeX | I _REALLY_ am liking the code introspection in VSCode! |
20:46:44 | UNIcodeX | The documentation in the .nim files is excellent! |
20:46:56 | FromGitter | <rayman22201> @kaushalmodi :fingers crossed: should work like a charm :-P |
20:48:02 | FromGitter | <alehander42> @UNIcodeX yeah that feature is cool indeed! |
20:48:17 | FromGitter | <alehander42> @kaushalmodi yeah, sorry about that it seems ok now |
20:48:20 | FromGitter | <rayman22201> @UNIcodeX using VSCode plugin powered by nimsuggest? That's great to hear. |
20:48:45 | FromGitter | <alehander42> for interpolation you can have cstring(&"..{name}") |
20:48:54 | FromGitter | <alehander42> i use `j` instead of cstring in my code |
20:48:59 | FromGitter | <alehander42> but its not in the stdlib |
20:49:12 | FromGitter | <alehander42> (but its useful as you can have a lot of j"..." in such an app) |
20:49:53 | UNIcodeX | @alehander42, @rayman22201, indeed! :) |
21:18:09 | FromGitter | <kaushalmodi> @rayman22201 @alehander42 thanks guys! it works! |
21:18:11 | FromGitter | <kaushalmodi> https://unruffled-heisenberg-ebee10.netlify.com/ |
21:18:23 | * | vlad1777d_ quit (Ping timeout: 246 seconds) |
21:18:25 | FromGitter | <kaushalmodi> Click on *Say hello* |
21:21:53 | * | jacereda joined #nim |
21:23:21 | FromGitter | <kaushalmodi> here's a bare bones repo: https://github.com/kaushalmodi/nim-netlify-functions -> https://nim-lambda-functions.netlify.com/ |
21:29:41 | jacereda | is `k:v` some magic to create a `KeyValuePair`? If so, why isn't `KeyValuePair` public? |
21:32:35 | * | druonysus joined #nim |
21:32:36 | * | druonysus quit (Changing host) |
21:32:36 | * | druonysus joined #nim |
21:46:13 | FromGitter | <alehander42> @jacereda I think it's an implementation detail, it doesn't have builtin meaning outside of table literals |
21:48:14 | * | ghost64 quit (Quit: See you!) |
21:48:36 | * | ghost64 joined #nim |
21:50:06 | FromGitter | <kaushalmodi> Any idea how to convert this from JS to Nim? `const name = event.queryStringParameters.name || "World";` |
21:50:17 | FromGitter | <kaushalmodi> The `|| "World"` is understood |
21:50:33 | FromGitter | <kayabaNerve> That's the part I was going to offer help with D: |
21:50:34 | FromGitter | <kaushalmodi> but the challenge is converting `event.queryStringParameters.name` to string |
21:50:36 | jacereda | so, what would I use to give a type to `mapTable` in something like `tab.mapTable(k + 2: v - 2)`? |
21:50:59 | FromGitter | <kayabaNerve> I thought I could help but nope. Sorry @kaushalmodi :P |
21:51:08 | FromGitter | <kaushalmodi> the type of that `event. ..` is `JsObject` |
21:51:13 | FromGitter | <kaushalmodi> @kayabaNerve no worries :) |
21:51:27 | FromGitter | <kayabaNerve> I'm pretty sure it's via `["` `"]` |
21:52:36 | FromGitter | <kayabaNerve> And then you'd do `.to(cstring)` or `.to(string)` on the final JSObject as `[]` returns another JSObject |
21:52:53 | FromGitter | <kayabaNerve> That's what the `jsffi` docs say 0_o |
21:53:10 | FromGitter | <kayabaNerve> ... there's also the emit pragma /s |
21:53:15 | jacereda | or should I just use `tab.mapTable((k+2,v-2))` instead? |
21:53:15 | FromGitter | <rayman22201> I think you are spot on @kayabaNerve |
21:53:26 | FromGitter | <kayabaNerve> Validation :D |
21:53:51 | * | xet7 quit (Quit: Leaving) |
21:53:55 | FromGitter | <kayabaNerve> I haven't used the JS backend but I've used the JSON lib and grabbed `.to` from the `jsffi` docs. |
21:55:08 | FromGitter | <kaushalmodi> thanks @kayabaNerve, I at least got it compiling |
21:55:25 | FromGitter | <kaushalmodi> converted https://ptpb.pw/Ingo/js to https://ptpb.pw/t9JY/nim |
21:55:51 | FromGitter | <kayabaNerve> Nice |
21:56:13 | FromGitter | <kayabaNerve> Who wants to try getting my code up on the JS backend? :P |
21:56:18 | FromGitter | <rayman22201> I believe jsffi has an experimental `.` macro to let you access js objects like you would regular objects. idk how well it works though |
21:56:26 | FromGitter | <kayabaNerve> I only use multiple C and one C++ library :P |
21:57:44 | * | flaviu quit (Read error: Connection reset by peer) |
21:57:54 | FromGitter | <kaushalmodi> lol, not surprised that that code didn't work right away.. seemed too good to be true |
21:58:02 | FromGitter | <kaushalmodi> https://nim-lambda-functions.netlify.com/ see the 3rd code snippet |
21:58:42 | FromGitter | <kaushalmodi> I get: ⏎ ⏎ > {"errorMessage":"URI malformed","errorType":"URIError","stackTrace":["decodeURIComponent (<anonymous>)","toJSStr (/var/task/hello_name.js:169:31)","inner_463114 (/var/task/hello_name.js:251:21)","HEX3Aanonymous_463055 (/var/task/hello_name.js:275:19)"]} |
21:59:48 | FromGitter | <rayman22201> seems like a netlify error more than a nim js error |
22:01:28 | FromGitter | <kaushalmodi> hmm, oh well. Though, I am excited to see hello.nim and hello_async.nim work |
22:01:57 | FromGitter | <kaushalmodi> *first time seeing JS code indirectly created by me work* |
22:02:36 | FromGitter | <rayman22201> lol. awesome! |
22:02:44 | FromGitter | <rayman22201> when name = "" it works |
22:02:49 | FromGitter | <rayman22201> which is interesting |
22:03:50 | FromGitter | <rayman22201> `https://nim-lambda-functions.netlify.com/.netlify/functions/hello_name?name=` works |
22:04:10 | FromGitter | <kaushalmodi> oh nice! |
22:04:13 | FromGitter | <kaushalmodi> :P |
22:04:43 | FromGitter | <rayman22201> and `decodeURIComponent` is a js built in function, so I'm curious what that function is getting as input |
22:04:47 | FromGitter | <kaushalmodi> so somehow `event.queryStringParameters.name` part is not working |
22:05:10 | FromGitter | <kaushalmodi> this is the nim generated JS: https://nim-lambda-functions.netlify.com/lambda/nimcache/hello_name.js |
22:05:38 | FromGitter | <kaushalmodi> I see `var name_463107 = (event_463057.queryStringParameters.name);` |
22:05:59 | FromGitter | <kaushalmodi> does that look right? |
22:11:06 | FromGitter | <rayman22201> yes. Looking through the generated code... always ugly lol |
22:11:53 | FromGitter | <kaushalmodi> I got it to work! |
22:12:13 | FromGitter | <rayman22201> oh cool. What is the secrect? |
22:12:13 | FromGitter | <kaushalmodi> seems like I cannot ever let become "Nim strings" |
22:12:15 | FromGitter | <kaushalmodi> https://github.com/kaushalmodi/nim-netlify-functions/commit/7c6f7cab4c45d621d148a8fa33ec6e84a4ddb738 |
22:12:21 | FromGitter | <kaushalmodi> can someone explain that commit |
22:12:23 | FromGitter | <kaushalmodi> :P |
22:12:41 | FromGitter | <kaushalmodi> I just compared the hello_name.nim generated code with hello.nim generated one |
22:12:57 | FromGitter | <rayman22201> oh, I see |
22:13:07 | FromGitter | <kaushalmodi> and I saw that earlier I had a lot of Nim generated code for string -> cstring translation |
22:13:21 | FromGitter | <rayman22201> Yeah. You can let it become a Nim string, you just have to convert back again at the right places :-P |
22:13:25 | FromGitter | <kaushalmodi> in that commit, I force type to be cstring to begin with, but the Nim code is ugly |
22:13:38 | FromGitter | <kaushalmodi> .. but I was converting.. |
22:13:57 | FromGitter | <rayman22201> No, if you look at the generated code, it was not |
22:14:02 | FromGitter | <kaushalmodi> I was doing `cstring("Hello, " & name & "! From Nim.")` |
22:14:17 | FromGitter | <kaushalmodi> apparently that's not enough |
22:14:27 | FromGitter | <rayman22201> Yeah, that was not converting `name` to a cstring first. |
22:14:52 | FromGitter | <rayman22201> which may be a code gen bug, maybe.... I'm not sure. |
22:14:59 | FromGitter | <kaushalmodi> if you see https://github.com/kaushalmodi/nim-netlify-functions/commit/7c6f7cab4c45d621d148a8fa33ec6e84a4ddb738#diff-29874c3599f864f516343384b07c48a3L15 |
22:15:01 | FromGitter | <alehander42> this should work for sure |
22:15:06 | FromGitter | <kaushalmodi> I was letting name to be string |
22:15:07 | FromGitter | <alehander42> cstring(&"Hello {name}") too |
22:15:11 | FromGitter | <kaushalmodi> then concat everything to string |
22:15:20 | FromGitter | <kaushalmodi> and then do `cstring(..)` on that whole bunch |
22:15:25 | FromGitter | <kaushalmodi> but that didn't work |
22:16:01 | FromGitter | <kaushalmodi> @alehander42 that `&` is from strformat, right? |
22:16:07 | FromGitter | <alehander42> yes, for example |
22:16:32 | FromGitter | <kaushalmodi> @alehander42 does the above linked diff give any hint on what's wrong? |
22:16:44 | FromGitter | <rayman22201> Yeah, I would expect it to work, but looking at the generated code, you can see, just the first part gets converted and then it is incorrectly concat'ed: https://github.com/kaushalmodi/nim-netlify-functions/commit/7c6f7cab4c45d621d148a8fa33ec6e84a4ddb738#diff-71dcf605e39becd2c05534689bbe3961L251 |
22:16:45 | FromGitter | <alehander42> I am not sure what's the problem |
22:16:50 | FromGitter | <alehander42> I mean what do you expect |
22:16:52 | FromGitter | <alehander42> to happen? |
22:17:34 | FromGitter | <alehander42> ah what is `to(string)` |
22:19:19 | FromGitter | <kaushalmodi> @alehander42 https://nim-lang.org/docs/jsffi.html#to%2CJsObject%2Ctypedesc |
22:19:58 | FromGitter | <kaushalmodi> @alehander42 this works: https://nim-lambda-functions.netlify.com/.netlify/functions/hello_name?name=foo |
22:20:05 | FromGitter | <alehander42> well `toJSStr((makeNimstrLit("Hello, ")).concat(name_463107,makeNimstrLit("! From Nim.")));` seems correct to me too |
22:20:07 | FromGitter | <kaushalmodi> this doesn't: https://nim-lambda-functions.netlify.com/.netlify/functions/hello_name_bad?name=foo |
22:20:08 | FromGitter | <rayman22201> interesting, it looks like to(string) isn't actually doing anything in the generated code. It's still treated as a js string: https://github.com/kaushalmodi/nim-netlify-functions/commit/7c6f7cab4c45d621d148a8fa33ec6e84a4ddb738#diff-71dcf605e39becd2c05534689bbe3961L268 |
22:20:18 | * | druonysus quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
22:20:27 | FromGitter | <alehander42> yeah not sure how well `to` works there |
22:20:32 | * | druonysus joined #nim |
22:20:32 | FromGitter | <alehander42> I usually just cast it |
22:20:32 | * | druonysus quit (Changing host) |
22:20:32 | * | druonysus joined #nim |
22:20:37 | FromGitter | <kaushalmodi> good code: https://nim-lambda-functions.netlify.com/lambda/nimcache/hello_name.js, bad code: https://nim-lambda-functions.netlify.com/lambda/nimcache/hello_name_bad.js |
22:20:43 | FromGitter | <alehander42> or use the js json |
22:22:39 | FromGitter | <kaushalmodi> btw @alehander42 @rayman22201 if you like, you can just follow the commits in https://github.com/kaushalmodi/nim-netlify-functions/tree/master/src/lambda |
22:23:02 | FromGitter | <kaushalmodi> @alehander42 how would you refactor the hello_name.nim in that dir (linked above) to use js json? |
22:23:15 | FromGitter | <rayman22201> The actual problem @kaushalmodi may be that queryStringParamter.name was not actually converted to a Nim string. |
22:23:36 | FromGitter | <kaushalmodi> hmmm |
22:24:13 | FromGitter | <alehander42> but you need to convert it to cstring |
22:24:19 | FromGitter | <alehander42> maybe |
22:25:01 | FromGitter | <rayman22201> you need to convert it to a cstring at the end. But the `to(string)` did nothing in the generated code, but the rest of the code expected it to be a Nim string. |
22:25:09 | FromGitter | <alehander42> so what is `name` ? I mean |
22:25:18 | FromGitter | <alehander42> to is not needed |
22:25:29 | * | xet7 joined #nim |
22:25:31 | FromGitter | <alehander42> because the only way it can work is on JsonNode which is created by the nim json lib |
22:25:36 | FromGitter | <rayman22201> name is a cstring (js string), but I think @kaushalmodi wanted to convert it to a Nim string |
22:25:54 | FromGitter | <alehander42> for this, you need `$event.query...name` |
22:26:29 | FromGitter | <rayman22201> `to` takes a `jsObject` not a `jsonNode` |
22:26:31 | FromGitter | <rayman22201> https://nim-lang.org/docs/jsffi.html#to%2CJsObject%2Ctypedesc |
22:26:46 | FromGitter | <rayman22201> though the json lib may have a similar method |
22:26:47 | FromGitter | <alehander42> ah, I didn't know jsffi has one too |
22:26:54 | FromGitter | <alehander42> but for sure `$` is the right thing to do |
22:26:58 | FromGitter | <alehander42> for cstring -> string |
22:27:08 | FromGitter | <rayman22201> I think you are right @alehander42. that makes sense |
22:27:22 | FromGitter | <kaushalmodi> @alehander42 that doesn't work |
22:27:24 | FromGitter | <kaushalmodi> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5bd2434c271506518d6e07e9] |
22:27:28 | FromGitter | <alehander42> ahhh yeah `to` is a cast |
22:27:37 | FromGitter | <kaushalmodi> there isn't a `$` defined for `JsObject` |
22:27:37 | FromGitter | <alehander42> look at the source it just casts it |
22:27:50 | FromGitter | <alehander42> ah yeah because you have to tell nim its cstring |
22:28:03 | FromGitter | <rayman22201> you have to cast to a cstring, and then use `$` |
22:28:03 | FromGitter | <alehander42> so it should be `$....name.to(cstring)` |
22:28:05 | FromGitter | <alehander42> in this case |
22:28:07 | FromGitter | <alehander42> yep |
22:28:20 | FromGitter | <alehander42> or `$(..to(cstring))` |
22:28:25 | FromGitter | <rayman22201> because doing ffi is always a PITA! |
22:28:26 | FromGitter | <kaushalmodi> so JsObject -> cstring -> string? |
22:28:30 | FromGitter | <rayman22201> yup |
22:28:31 | FromGitter | <alehander42> yes |
22:28:32 | FromGitter | <dom96> https://nim-lang.org/blog/2018/10/25/hired-krux02.html |
22:28:33 | FromGitter | <kaushalmodi> huh |
22:28:40 | FromGitter | <alehander42> well, I have my own jsobject macro |
22:28:48 | FromGitter | <alehander42> which helps with this stuff, but its not in stdlib |
22:29:00 | FromGitter | <rayman22201> Awesome news! contrats @krux02 ! good choice |
22:30:25 | FromGitter | <kaushalmodi> @alehander42 That worked! Thanks! https://nim-lambda-functions.netlify.com/.netlify/functions/hello_name_2?name=foo |
22:30:41 | FromGitter | <kaushalmodi> Congrats @krux02 ! |
22:30:50 | FromGitter | <kayabaNerve> Congrats krux02! |
22:31:24 | FromGitter | <alehander42> well done @krux02 good luck! |
22:31:28 | FromGitter | <alehander42> these demos are weeeird |
22:31:41 | FromGitter | <kaushalmodi> which demos? |
22:32:01 | FromGitter | <alehander42> from the article |
22:32:29 | FromGitter | <rayman22201> I call that the LSD shader :-P |
22:33:19 | FromGitter | <kayabaNerve> If you're on LSD, does it cancel out? |
22:33:54 | * | druonysus quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.) |
22:34:54 | FromGitter | <rayman22201> lol. You could find out 0.o |
22:38:05 | * | jacereda` joined #nim |
22:38:51 | * | kapil____ quit (Quit: Connection closed for inactivity) |
22:41:07 | * | jacereda quit (Ping timeout: 240 seconds) |
22:42:33 | * | jacereda` quit (Ping timeout: 245 seconds) |
22:55:36 | FromGitter | <timotheecour> @krux02 congrats! very glad to see the Nim team is growing |
23:00:44 | FromGitter | <kaushalmodi> Late realization, one of Nim devs is now an Emacs user. Woo! 🎉 |
23:03:59 | * | xace quit (Ping timeout: 268 seconds) |
23:05:31 | * | xace joined #nim |
23:06:11 | * | so quit (Ping timeout: 246 seconds) |
23:10:51 | * | so joined #nim |
23:12:43 | shashlick | Brilliant |
23:13:30 | FromGitter | <kayabaNerve> Nano/Atom ftw. |
23:17:07 | * | druonysus joined #nim |
23:17:07 | * | druonysus quit (Changing host) |
23:17:07 | * | druonysus joined #nim |
23:19:01 | * | elrood quit (Quit: Leaving) |
23:25:35 | * | endragor joined #nim |
23:29:54 | * | endragor quit (Ping timeout: 252 seconds) |
23:32:36 | FromGitter | <zacharycarter> congrats @krux02 |
23:57:48 | * | darithorn quit () |