<< 19-05-2017 >>

00:20:50*krux02 joined #nim
00:21:07krux02how do I run just one test?
00:21:14krux02there is ./koch tests
00:21:27krux02but how do I run just a single test?
00:22:50libmanIn koch.nim, it looks at the rest of the command line after "tests" or defaults to "all".
00:26:33libmanThat gets passed to https://github.com/nim-lang/Nim/blob/devel/tests/testament/tester.nim (I think, I'm a n00b).
00:27:15*ludocode quit (Disconnected by services)
00:27:18*ludocode_ joined #nim
00:34:13*sz0 quit (Quit: Connection closed for inactivity)
00:35:45*dddddd quit (Quit: Hasta otra..)
00:36:21*rupil quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
01:03:45*krux02 quit (Remote host closed the connection)
01:16:23*vlad1777d quit (Remote host closed the connection)
01:34:16*pilne quit (Quit: Quitting!)
01:37:01*ludocode_ quit (Ping timeout: 246 seconds)
01:38:47*ludocode joined #nim
01:50:55*chemist69 quit (Ping timeout: 258 seconds)
01:50:58*rauss joined #nim
02:03:19*chemist69 joined #nim
02:27:58*rauss quit (Quit: WeeChat 1.7.1)
02:28:47*rauss joined #nim
02:31:52*def-pri-pub joined #nim
02:33:12*jackv quit (Quit: WeeChat 1.8)
02:54:29*jackv joined #nim
03:00:49FromGitter<NevnHiwEjuam_twitter> I'm coming across a problem when implementing an RNG that I think Nim's internals may be at fault for
03:01:28FromGitter<NevnHiwEjuam_twitter> I tried matching the C implewmentation down to the letter but there's one discrepency that keeps popping up
03:02:18FromGitter<NevnHiwEjuam_twitter> https://pastebin.com/63yyLBPM
03:02:19*libman quit (Quit: Connection closed for inactivity)
03:03:53FromGitter<NevnHiwEjuam_twitter> initCodec() is supposed to populate a 512-entry array of int16s, and in the C impl. a few of those entries are 511 (1FF), but Nim seems to truncate them to 255 (0FF) and from there the values are all wrong
03:04:58FromGitter<NevnHiwEjuam_twitter> Something's happening at those particular entries that bricks the remaining entries
03:07:46FromGitter<NevnHiwEjuam_twitter> original C code: https://pastebin.com/fx5q48cp It has a bit of extra stuff I cut out because it seemed like bloat but on a hunch I tried putting that bloat in anyway with the same results
03:08:37FromGitter<NevnHiwEjuam_twitter> like the seed validation thing (it's always initialised to 666666 so it's unnecessary)
03:34:48*def-pri-pub quit (Quit: leaving)
03:37:45*jsgrant joined #nim
03:42:36*xet7 joined #nim
05:34:00*gokr joined #nim
05:50:08*gokr quit (Ping timeout: 240 seconds)
05:51:12*ephja joined #nim
06:33:04*Senketsu quit (Quit: Leaving)
06:44:43*nsf joined #nim
06:46:36*rauss quit (Quit: WeeChat 1.7.1)
06:48:23FromGitter<NevnHiwEjuam_twitter> Oh, which reminds me, I was hoping to somehow make all this compile-time so that the lookup table's already generated before runtime. {.compiletime.} and a const don't work for that
06:52:33FromGitter<ephja> @NevnHiwEjuam_twitter wait. where does it generate values up to 511?
06:53:33FromGitter<ephja> doesn't that value only appear in the array definition? which determines its length
06:55:13FromGitter<NevnHiwEjuam_twitter> well what I want to do is have a const or a compile-time deduced variable where RNG (with a set seed) populates it during compile time
06:56:52FromGitter<NevnHiwEjuam_twitter> It seems pointless to populate an array with the same contents every runtime. Sure I could post the table in brackets as a const but maybe one day, I'd want to change the seed or the array size
06:57:45FromGitter<NevnHiwEjuam_twitter> I'd have to make a separate program that generates it, then copy and paste it
07:00:22*noethics joined #nim
07:01:34FromGitter<ephja> but the length of the array is 512, and you're generating values from 0 to 256, right?
07:06:19FromGitter<NevnHiwEjuam_twitter> well no, I'm taking the value 666,666 as a seed, applying it in a math expression that returns an int. If that int is 0 or below, add 2,147,483,647 to it, and set that as the seed's new value. Then, I cast it to float64 and divide it by 2,147,483,647. Finally, I'm taking that value and multiplying it by 256. I do that for the 512 entries in the table
07:07:39FromGitter<NevnHiwEjuam_twitter> It's an array of int16s, and some entries should be 511 (0x1FF) but instead I get 0xFF (256)
07:07:51FromGitter<NevnHiwEjuam_twitter> erm 255
07:09:30FromGitter<NevnHiwEjuam_twitter> I put the procs in order in terms of the RNG process, except initCodec() which calls shortRandom()
07:18:04*gangstacat quit (Ping timeout: 255 seconds)
07:18:11*dexterk__ quit (Remote host closed the connection)
07:18:34*dexterk__ joined #nim
07:19:53*yglukhov joined #nim
07:30:47*Vladar joined #nim
07:37:12*kunev quit (Ping timeout: 260 seconds)
07:38:38*kunev joined #nim
07:42:42*gokr joined #nim
08:25:55*gggs joined #nim
08:25:57*gggs quit (Changing host)
08:25:57*gggs joined #nim
08:26:46*gokr quit (Ping timeout: 246 seconds)
08:31:22*Andris_zbx joined #nim
08:34:53*yglukhov quit (Remote host closed the connection)
08:43:54*gokr joined #nim
08:45:11*yglukhov joined #nim
08:49:22*ephja quit (Ping timeout: 240 seconds)
08:49:28*yglukhov quit (Ping timeout: 240 seconds)
08:53:38*yglukhov joined #nim
08:54:59*yglukhov quit (Remote host closed the connection)
08:56:28*yglukhov joined #nim
09:09:50*Trioxin2 joined #nim
09:12:49*Trioxin quit (Ping timeout: 255 seconds)
09:19:21*Arrrr joined #nim
09:19:21*Arrrr quit (Changing host)
09:19:21*Arrrr joined #nim
09:26:01*bjz joined #nim
10:01:18*BennyElg joined #nim
10:03:36*couven92 joined #nim
10:09:29*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
10:17:25*bjz joined #nim
10:18:05*jsgrant quit (Ping timeout: 240 seconds)
10:40:01ArrrrThis 'Error: module names need to be unique per Nimble package' is quite annoying, i'm not even making a nimble package.
10:43:34*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
10:44:04*gokr quit (Ping timeout: 246 seconds)
10:44:23AraqI like package.module.type to be unique, I need to hash this shit to produce consistent names
10:45:59Araqotherwise it would be relative/path/we/dont/know/howto/make/unique.module.type I need to hash
10:46:50Araqif you tell me how to create a canonical relative path from an existing relative path I'm all ears
10:47:31ArrrrCan't you generate the hashes relative to main module and use these hashes when relative path is used?
10:49:46Arrrrhttps://pastebin.com/bHfjNSxy
10:49:55Araqthen we end up with ../../../../.nimble/pkgs/foo-1.0/
10:50:04*bjz joined #nim
10:51:20ArrrrWhy? and can't you replace the relative-to-module path to relative-to-main path?
10:52:51Araqthe point is to get consistent name mangling. on a CI server the paths are likely different from your local ones
10:53:37Araqso a relative path like ../../../../.nimble/pkgs/foo-1.0/ is still tied to your local machine
10:53:46Araqmight as well use absolute paths then
10:55:00Araqalternatively I can come up with a scheme to use $nimble/dir $project/dir $stdlib/dir for the addressing
10:58:09ArrrrWhy does it have to be consistent between two computers? For DLLs gen?
10:58:46ArrrrMaybe you could simple `copy` the nimble package next to main
10:59:27ArrrrOr fake the hashes
10:59:37*Tiberium joined #nim
10:59:45Araqideally you want to be able to unmangle the name with an algorithm (like C++ dos it)
11:00:12Arrrrinstead of from "../../", whenever a nimble package is used, gen the hash thinking that it resides inside the main module folder
11:00:39Araqbut this is not correct.
11:00:59Araqyou can use package jester and yet have your own 'jester' dir with the same module names
11:02:55Araqwe're far from having an unmangle algorithm but deterministic code generation is a strength
11:03:54ArrrrSo, you cannot copy or fake the path because there could be two modules/folders named the same then.
11:03:54Araqand "deterministic on my machine only" is worse than "deterministic and the same on my coworker's computer"
11:04:50ArrrrYou could generate an unique folder-name for nimble packages, as long as you remove this relative-to-computer nimble paths
11:05:10ArrrrThat way you would avoid any possible collision
11:05:36couven92can I assign a value to an `nnkComment` ast node? I essence, I want to emit a doc comment for a proc I declare in a macro
11:07:45AraqArrrr: you just described my idea
11:07:58Araq"alternatively I can come up with a scheme to use $nimble/dir $project/dir $stdlib/dir for the addressing"
11:09:25ArrrrThen fantastic. I think is a limitation that is worth removing
11:11:09couven92Ah, https://nim-lang.org/docs/macros.html#calls-expressions-documentation-comments says, that there is no way to do that... nnkComment just shows that there is a comment there, not what the comment actually says... Hmm, but how does `nim doc` and `nim doc2` work then if the AST doesn't give you information about doc comments?
11:11:29Araqcouven92: it could work nowadays
11:11:54couven92Araq, how? I'd like my magic macro to document the AST it generates :P
11:13:07couven92(I do, of course, have proper documentation on the macro itself, but people should not need to know which procs have been auto-generated to go look for the documentation)
11:13:51Araqn.comment = "x" ? or n.strVal = "x", not sure
11:15:07AraqArrrr: ok, as a nice bonus it shouldn't require too many changes in the compiler. it just changes its definition of 'package'
11:24:01ArrrrOk, i can test it when the time comes.
11:27:12Araqor you implement it, edit compiler/packagehandling
11:27:30Araqother changes are not required, I think
11:28:12ArrrrW-well, i can give it a shoot
11:28:39Arrrr*shot
11:29:46couven92Araq, strVal does not exist on a comment node, comment does not exits and name does not work either... I'm on 0.17
11:33:30*gangstacat joined #nim
11:33:53*Matthias247 joined #nim
11:35:33*kunev quit (Ping timeout: 268 seconds)
11:36:04Araqcouven92: guess it can only be used to read the doc comment then :P
11:37:17couven92should be possible though :(
11:37:37*kunev joined #nim
11:39:23*krux02 joined #nim
11:50:33Araqfix it
11:53:09Araqcompiler/vm.nim line 1409
11:53:43Araqadd an 'elif dest.kind == nkCommentStmt: dest.comment = regs[rb].node.strVal'
11:55:11Araqthen you can use the x.strVal = "x" to set the comment
12:23:01*elrood joined #nim
12:34:20*noethics quit (Remote host closed the connection)
12:34:39*noethics joined #nim
12:47:53*yglukhov quit (Remote host closed the connection)
12:48:50*yglukhov joined #nim
12:54:07*Arrrr quit (Ping timeout: 240 seconds)
12:54:32*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
12:59:38couven92Araq, thx for the hint, will do and submit PR later today...
13:06:47*krux02 quit (Remote host closed the connection)
13:08:55*krux02 joined #nim
13:22:16*ephja joined #nim
13:24:58*arnetheduck_ joined #nim
13:33:54FromGitter<andreaferretti> @Araq is there a reason why c2nim parser bails on macros such as `__align__(2)`?
13:34:24FromGitter<andreaferretti> I am trying to ignore these annotations by setting `#def *align*(2)`
13:34:35FromGitter<andreaferretti> but the parser seems to have problems
13:35:20FromGitter<andreaferretti> `identifier expected, but found '2'`
13:36:41FromGitter<andreaferretti> (I can try to fix the parsing of such macros, but it would be a different PR then the one about ifdefs and it is not easy to make two independent PRs, because I need both functionalities)
13:50:43FromGitter<Varriount> @andreaferretti `#def *align*(x)`
13:51:20FromGitter<Varriount> Macro arguments can't be number literals
13:53:00FromGitter<Varriount> By the way, anyone seen the number of Kotlin-related posts on Hacker News lately? There's been at least 5 front-page posts in the last 24 hours.
13:53:11FromGitter<Varriount> It's ridiculous
13:53:36FromGitter<Varriount> Or rather, irritating
13:53:56FromGitter<ephja> who were using that website style first? :p
13:54:34*libman joined #nim
13:54:58FromGitter<ephja> or maybe full screen-ish elements are all the rage right now
13:59:23FromGitter<ephja> @Varriount I'm sure the JVM target has something to do with the popularity
14:00:12FromGitter<andreaferretti> @Varriount thank you, it was so simple!
14:00:21*vlad1777d joined #nim
14:00:57libmanRussian Hackers ™ => Hacker News
14:01:51libmanVast conspiwwwacy, I tells ya!
14:02:58libmanThey're out to to sap and impurify all of our precious MIT-licensed codely fluids...
14:19:30FromGitter<zacharycarter> @Varriount I don't get the kotlin hype
14:20:25FromGitter<ephja> do any of the other languages that support JVM and/or android appear to be better?
14:20:34FromGitter<zacharycarter> No
14:20:58FromGitter<zacharycarter> but I think Kotlin Native has everyone excited prematurely
14:22:29*pilne joined #nim
14:24:10*pilne quit (Client Quit)
14:25:32*gokr joined #nim
14:28:01*couven92 quit (Quit: Client disconnecting)
14:33:31*rauss joined #nim
14:40:14euantorI like Kotlin personally
14:40:18ftsfhmm kotlin looks interesting, error if you try to use a nullable type without checking if it's null is cute.
14:40:26ftsfnever heard of it before today
14:40:40euantorI translated our Android app across to it earlier this year, and it was a much nicer experience than writing pure java
14:41:06euantorThere are some nice Kotlin libraries too, and data classes are very useful
14:41:15ftsfyeah, i'll be happy if i never have to touch java again
14:41:18*Snircle quit (Quit: Textual IRC Client: www.textualapp.com)
14:41:54FromGitter<Varriount> I was going to say, given a choice between Java and another language... I would almost always pick the alternative
14:42:03ftsfhow about java or php? ;)
14:42:22FromGitter<Varriount> Ouch. Tough decision
14:42:39FromGitter<Varriount> That is a case where I would pick java
14:44:57euantorI also maintain an iOS version of the same app written in Swift, and the two languages have some similar syntax which makes moving between them much easier
14:47:53FromGitter<ephja> @andreaferretti great c2nim additions. it has been difficult to deal with convoluted ifdefs
14:49:07FromGitter<andreaferretti> thank you :-)
14:49:26FromGitter<andreaferretti> I am planning a few more improvements
14:49:37FromGitter<andreaferretti> for https://github.com/unicredit/nimcuda
14:54:02FromGitter<Varriount> @andreaferretti What additions have been made to c2nim?
14:55:08FromGitter<andreaferretti> I have added two annotation `#skipifdef` and `#skipifndef`
14:55:54FromGitter<andreaferretti> if you add `#skipifdef SOMENAME`, c2nim will assume that `SOMENAME` is not defined and correspondently skip `#ifdef SOMENAME` blocks
14:56:04FromGitter<andreaferretti> and similarly for `#skipifndef`
14:57:22FromGitter<andreaferretti> it also handles more complex conditions such as `#if !defined(__CUDACC_INTEGRATED__) && (!defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350))`
14:58:15FromGitter<andreaferretti> there are three more things that I would need to parse cuda headers cleanly
14:58:51FromGitter<andreaferretti> 1) correctly parse large numbers
14:59:11FromGitter<andreaferretti> 1) not produce empty blocks (need to add a `discard` in postprocessing)
14:59:44FromGitter<andreaferretti> I forgot the third one
14:59:46FromGitter<andreaferretti> :-P
15:00:09FromGitter<andreaferretti> ah ok,
15:00:51FromGitter<andreaferretti> 1) recognize the guard pattern and omit the corresponding `when not defined(GUARD):`
15:01:05FromGitter<andreaferretti> although the latter is mostly cosmetic
15:07:14*Andris_zbx quit (Remote host closed the connection)
15:24:41*JHonaker joined #nim
15:25:24FromGitter<Varriount> @andreaferretti Sounds like that will help when wrapping windows stuff too
15:25:45FromGitter<Varriount> especially if `ifdef` stuff
15:26:10FromGitter<ephja> ```code paste, see link``` ⏎ ⏎ I'm having trouble making this particular instance of the do notation comply with the new rules [https://gitter.im/nim-lang/Nim?at=591f0e929f4f4ab05bde6004]
15:26:30FromGitter<Varriount> @ephja `:=`?
15:26:36FromGitter<ephja> DSL
15:27:52*yglukhov quit ()
15:28:24*yglukhov joined #nim
15:29:23FromGitter<andreaferretti> I have a variant object with three variants
15:29:37FromGitter<andreaferretti> and a field shared between variant 1 and 2
15:29:44FromGitter<andreaferretti> another between variant 1 and 3
15:29:51FromGitter<andreaferretti> and finally one between variant 2 and 3
15:29:58FromGitter<andreaferretti> how to write it?
15:30:35FromGitter<andreaferretti> I am trying as follow
15:30:40FromGitter<andreaferretti> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=591f0fa083cb5db0734a1586]
15:31:00FromGitter<ephja> I can make it not give me a syntax error if I remove the signature from the proc expression
15:31:10FromGitter<andreaferretti> but it complains that case labels are repeated
15:31:28FromGitter<andreaferretti> if instead I give each label its section
15:31:41FromGitter<andreaferretti> I get an error because field names are duplicated
15:31:44FromGitter<andreaferretti> any idea?
15:32:04FromGitter<ephja> @andreaferretti it isn't possible
15:32:18FromGitter<andreaferretti> that's a little unfortunate
15:32:29FromGitter<andreaferretti> I will go with different field names then
15:35:17*LyndsySimon joined #nim
15:36:22LyndsySimonGreetings! I'm interested in learning Nim, at least on the side. I came from this Reddit thread: https://www.reddit.com/6c1jnv/
15:36:54FromGitter<ephja> what about patty? I was going to give you a link but of course it was written by you
15:37:10LyndsySimonTwo use cases I'm interested in at the moment: writing portable binaries for fairly simple shell tasks that I can distribute to coworkers (a replacement for bash scripts, basically), and avoiding ever writing JavaScript again :)
15:38:37FromGitter<ephja> @andreaferretti btw, did it ever break for you after upgrading nim?
15:38:52FromGitter<Varriount> Hi LyndsySimon
15:39:06FromGitter<ephja> "Patty 0.3.0 works for latest Nim (devel)" alright!
15:40:02FromGitter<Varriount> LyndsySimon: If you look at the os and osproc modules, both of those allow calling other programs like you would in a bash script.
15:40:36FromGitter<andreaferretti> @ephja patty rewrites fields into a variant object at the end of the day
15:40:45FromGitter<ephja> has anyone made a shell-ish DSL?
15:40:50FromGitter<andreaferretti> so it cannot overcome this naming limitation
15:41:12FromGitter<ephja> no but maybe it makes it less annoying
15:41:22FromGitter<andreaferretti> about breaking: yes, from time to time, but it was always very simple to upgrade it
15:41:34FromGitter<andreaferretti> usually it is just some new node added in the AST
15:41:47FromGitter<andreaferretti> so maybe I have to shift an index by one when traversing the AST
15:41:50*couven92 joined #nim
15:41:52FromGitter<andreaferretti> stuff like that
15:41:55FromGitter<andreaferretti> nothing serious
15:42:17FromGitter<andreaferretti> Latest patty (0.3.1) should work fine on nim 0.17
16:01:38dyce[m]LyndsySimon: Nim works great for that in my experience
16:02:07dyce[m]the standard library is has everything covered :)
16:12:54*jsgrant joined #nim
16:27:10*jsgrant left #nim (#nim)
16:29:49*jsgrant joined #nim
16:31:41*yglukhov quit (Remote host closed the connection)
16:34:18*yglukhov joined #nim
16:35:48*yglukhov_ joined #nim
16:35:48*yglukhov quit (Read error: Connection reset by peer)
16:40:11*yglukhov_ quit (Ping timeout: 268 seconds)
16:42:21*yglukhov joined #nim
16:43:11couven92okay Araq, fixed documentation comments as requested https://github.com/nim-lang/Nim/pull/5850 :) Thanks for pointing me in the right direction. I also added tests and documentation
16:46:40*yglukhov quit (Ping timeout: 246 seconds)
16:54:48*rauss quit (Ping timeout: 240 seconds)
16:56:04*rauss joined #nim
17:01:00*Trioxin2 is now known as Trioxin
17:01:23Trioxindb_mysql needs some work
17:06:38*Arrrr joined #nim
17:20:29*yglukhov joined #nim
17:22:31FromGitter<mratsim> Wooow nimcuda @andreaferretti wonderful !
17:24:43FromGitter<mratsim> @NevnHiwEjuam_twitter For hashing/PseudoRNG at compile-time you can check this thread: https://forum.nim-lang.org/t/1305
17:24:49*yglukhov quit (Ping timeout: 246 seconds)
17:27:59*yglukhov joined #nim
17:42:05Tiberiumhow to print nim code (not ast) generated by macro?
17:45:27*sz0 joined #nim
17:45:33Tiberiumah, expandMacros
17:55:58*ludocode quit (Read error: Connection reset by peer)
17:56:56*ludocode joined #nim
17:59:34*ludocode quit (Read error: Connection reset by peer)
18:00:29*ludocode joined #nim
18:25:06*dddddd joined #nim
18:28:07*Tiberium quit (Ping timeout: 240 seconds)
18:29:08couven92argh, I am trying to create a macro that auto-implements stringify and parse functions for distinct types... I do not understand why I can't get the raise newException(ValueError) call right... can someone please help me? https://gist.github.com/couven92/ebbc3b6a7aa6cb36cfc7691c39a3b7e6
18:35:22couven92aha, setting the newExceptionCall to take `type(ValueError)` instead of just `ValueError` did the trick
18:43:38FromGitter<Varriount> Huh, wonder what the difference is
18:45:04Araqcouven92: that shouldn't be necessary
18:45:09Araqlooking into it
18:46:12couven92Araq, ah, sorry that I updated my gist... But luckily Gist keeps Revisions... :P
18:49:24Araqok, found it, use raisesValue = newNimNode(nnkBracket).add(ident("ValueError"))
18:50:02Araqyou share the ident node and for reasons that escape me now it means the type computation is "shared" too
18:50:29couven92Ah! okay... I cannot reuse nodes... That makes sense
18:50:43Araqso ValueError is of type ValueError for the "raises" and then stays so. instead of producing typedesc[ValueError]
18:51:54couven92yeah, I understand, okay... so I should always create new nodes everywhere in my macro...
18:52:04Araqno, but in this case
18:52:07Araq;-)
18:52:27couven92Araq, thanks a lot! :)
18:54:27*kunev quit (Ping timeout: 240 seconds)
18:57:18*kunev joined #nim
19:04:08*libman quit (Quit: Connection closed for inactivity)
19:06:52*Ven joined #nim
19:07:16*Ven is now known as Guest63831
19:10:57*Guest63831 quit (Ping timeout: 240 seconds)
19:11:25JHonakerHow can I make a type def that is just a generic array
19:11:55JHonakerLike type Die[N, T] = array[N, T]?
19:12:13JHonakerCan I use openarray?
19:12:33Araqwhat's wrong with the syntax you used?
19:12:51JHonakerWell I'm just curious how I'd use that type in a proc
19:13:00FromGitter<cooldome> you can simple use - array
19:13:11FromGitter<cooldome> proc xx(a: array)
19:13:23Araqthat's not the same, cooldome
19:13:25JHonakerCan I say proc roll[N, T](die: Die[N, T]): T?
19:13:38Araqyeah
19:13:52FromGitter<cooldome> proc xxN,T (a: array[N, T])
19:14:31JHonakerThanks!
19:16:44LyndsySimonDoes Nim have string templating? I'm looking to simplify this line: `echo("You passed in " & $(paramCount()) & " arguments");`
19:17:12LyndsySimonIgnore the semicolon, not sure how that got there....
19:17:36couven92LyndsySimon, "You passed in $# arguments" % [$paramCount()]
19:18:07LyndsySimoncouven92: Cool, thanks. :)
19:18:18couven92LyndsySimon, and many more, check out: https://nim-lang.org/docs/strutils.html#%,string,openArray[string]
19:18:42couven92and you'll need to import the strutils module for that
19:19:23*Ven_ joined #nim
19:19:42LyndsySimonYeah, I have it included. I think I'm struggling at the moment with the fact that I have to convert from an int to a string before I can use it to build a string.
19:19:48Araqwhat happened to the string interpolation macro?
19:19:56Araqsomebody wanted to submit it to the core
19:20:03Araqand now 0.17 still is without one :-(
19:20:06Araqboo!!!
19:20:26*Ven_ quit (Client Quit)
19:20:41couven92Araq, indeed that sounds like fun! Interpolation as in, merging together on string literals?
19:21:29couven92to pay the interpolation cost at compiletime rather than at runtime? Or interpolation as in the way C# does it nowadays?
19:22:10Araqa simple macro that uses parseutils.interpolatedFragments
19:22:24Araq3 line implementation, 10 lines of documentation
19:22:39Araqas it's getting the norm for Nim code :P
19:22:53LyndsySimon:)
19:23:16LyndsySimonI've been playing with Nim for all of an hour so far - and half of that in a meeting when I should have been paying attention - and so far I'm *really* liking it as a language.
19:23:57LyndsySimonI'm very excited about the possibility of using it in place of JavaScript for front-end stuff, but I want to grok it fully before I start dealing with that, since it seems like the ecosystem for it is still very immature.
19:24:20Araqtrue and the JS target has been a stepchild
19:24:48couven92as some stated here some days ago: "JavaScript is a horror show!" :P
19:25:07LyndsySimonThere's a reason compile-to-js languages are in demand.
19:25:09*dexterk__ quit (Read error: Connection reset by peer)
19:25:24*dexterk__ joined #nim
19:26:03Araqbut with 'Karax' and the planned features like asm.js/webassembly code generation we're getting there. also 'nimx' is a big framework that runs on JS
19:27:02JHonakerimport random
19:27:02JHonaker
19:27:02JHonakertype
19:27:02JHonaker GenericDie[N, T] = array[0..N, T]
19:27:06JHonaker Die[N] = GenericDie[N, int]
19:27:09JHonaker
19:27:12JHonakerproc roll[N, T](die: GenericDie[N, T]): T =
19:27:15JHonaker random(die)
19:27:20JHonaker
19:27:20JHonakervar d20: GenericDie[20, int] = [1..20]
19:27:25JHonakerecho d20.roll
19:27:29JHonakerecho d20.roll
19:27:29JHonaker
19:27:32JHonakerwhoops
19:27:38JHonakerbut can anyone tell me what's wrong with this code? I get a type mismatch on line 4
19:28:21JHonakerhttps://pastebin.com/JqNFFkmW
19:37:10*Arrrr quit (Read error: Connection reset by peer)
19:43:36FromGitter<Varriount> JHonaker: Your passing in two generic parameters to `Die`, which only takes one.
19:43:40FromGitter<Varriount> *You're
19:44:56FromGitter<Varriount> Oh wait, my bad.
19:45:15JHonakerIt takes two.
19:46:11JHonakerI think I figured out what my problem was
19:46:14FromGitter<Varriount> Use `array[N, T]` instead of `array[0..N, T]`
19:46:32JHonakerYea, that fixed it, I thought I was still getting an error though
19:46:54JHonakerbut I was calling random([1..20]) and getting {a: 1, b: 20}, not a number like I expected
19:47:10JHonakerBut it was choosing a random slice from the array of one slice
19:47:26JHonakerIs there an easy way to say array from 1 to 20?
19:48:18FromGitter<Varriount> You mean, you want the index of the array to start at 1?
19:48:32demi-hmm i'm trying out nim mode in emacs and it doesn't seem to highlight a bunch of syntax that i would expect it to. for example, it isn't highlighting `of` in `case` statements
19:49:09JHonakerVarriount: No, I'd like the type GenericDie to be an array of T's
19:49:16JHonakerAnd Die to be an array of ints
19:49:41JHonakerI'd like it to be able to handle arbitrarily numbered faces, but I think I'm having a misunderstading
19:50:14FromGitter<Varriount> type GenericDie[N, T] = array[N, T]
19:50:30JHonakerdemi-: of is highlighted for me, I'm using the nim layer on spacemacs though
19:50:35FromGitter<Varriount> type Die[N] = GenericDie[N, int]
19:51:30JHonakerThats what I had, argh! I must have confused myself with the iterator thing. Can I cast 1..20 to [1, 2, ..., 20]?
19:53:09FromGitter<Varriount> You could write a converter. Those implement implicit conversions.
19:53:21FromGitter<Varriount> Might be easier for you to just use sequences though.
19:53:24*sz0 quit (Quit: Connection closed for inactivity)
19:54:13FromGitter<Varriount> import sequtils; echo toSeq(0..20)
19:54:44JHonakerThanks, I just started today, I have no idea what's in the standard library
19:56:57FromGitter<Varriount> The only benefit in using arrays is that they are fixed length, and located on the stack.
19:58:50JHonakerAwesome, thanks. Got it to work as expected first time with seqs
20:00:02*nsf quit (Quit: WeeChat 1.7.1)
20:00:07FromGitter<zacharycarter> is it possible to FFI with Nim and JS?
20:00:10FromGitter<zacharycarter> or Node rather
20:00:20FromGitter<zacharycarter> like could I potentially execute some Nim code from NodeJS code?
20:00:28FromGitter<zacharycarter> Rust has something like this I think
20:01:03FromGitter<zacharycarter> https://github.com/neon-bindings/neon
20:01:29demi-zacharycarter, i believe you can export nim code as JS which is callable by node, and you can wrap JS libraries in nim
20:02:39*libman joined #nim
20:02:56FromGitter<zacharycarter> hrm but that's essentially just node calling more JS right?
20:03:16*JHonaker quit (Ping timeout: 246 seconds)
20:03:23FromGitter<zacharycarter> I'm thinking like, you have some performance intensive operation you need to run - node is the web server and you FFI with Nim for the performant piece
20:04:01demi-you mean, like having node call into a compiled nim library?
20:04:05FromGitter<zacharycarter> yes
20:04:12FromGitter<zacharycarter> I believe this is the concept Neon has for Rust
20:04:21demi-yeah i believe part of the core of node is to allow that sort of thing?
20:04:28FromGitter<zacharycarter> I think so
20:04:38FromGitter<zacharycarter> it might help me gain traction for using Nim at work
20:04:39demi-so you would have to exportc your code and then make the binding yourself
20:04:46FromGitter<zacharycarter> hrm okay
20:05:04FromGitter<zacharycarter> I'll play around w/ the concept this weekend
20:05:06demi-but i mean, that is the same process if you wanted a C program to interact with nim
20:05:12FromGitter<zacharycarter> right
20:05:18demi-just a javascript file instead of a C header
20:06:02demi-oh you might be able to swig it, http://stackoverflow.com/questions/9629677/how-can-i-use-a-c-library-from-node-js#27917698
20:06:16demi-https://github.com/node-ffi/node-ffi
20:06:33FromGitter<zacharycarter> oooo this is interesting
20:07:10demi-the node-ffi thing seems a lot better than swig imo
20:07:14FromGitter<zacharycarter> yeah
20:08:07*nmooney joined #nim
20:08:07*nmooney quit (Client Quit)
20:08:22*nickmooney joined #nim
20:08:58nickmooneyHi all! I was just curious if "case" supported pattern-matching-like functionality, i.e. matching over more than one distinct value?
20:09:15nickmooneyIt seems like the answer is no, but I wasn't sure.
20:09:20FromGitter<Varriount> nickmooney: Not in the standard language.
20:09:27nickmooneygotcha
20:09:30nickmooneythanks Varriount
20:09:34FromGitter<Varriount> One moment though, I think I have something for you
20:09:37nickmooneysure, thanks
20:09:56FromGitter<Varriount> https://github.com/andreaferretti/patty
20:10:35nickmooneyinteresting, I'll check it out
20:11:27FromGitter<Varriount> nickmooney: Though, that's for data types more than general matching
20:12:32*Trustable joined #nim
20:12:47nickmooneygotcha. I'm implementing the Nussinov algorithm for RNA secondary structure prediction, and it needs to allow A/U, C/G pairs but not others
20:13:29nickmooneyI've been doing a lot of FP lately so it feels like pattern matching is an elegant way hah
20:14:10nickmooneyright now I just hardcode the four cases but I'm trying to learn idiomatic Nim
20:14:39nickmooneypattern matching is likely not the idiomatic solution
20:18:43nickmooneyhere's one more question about the correct idioms: given an RNA sequence of length n, I have to create an (n+1) x (n+1) array. I'm using nested seqs right now -- is this the "right way"? in Java I'd use an array of dynamic size. Efficiency is important and I'm not sure what seq overhead looks like
20:19:45*Ven joined #nim
20:20:08*Ven is now known as Guest58788
20:21:29*nickmooney quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client)
20:24:14*yglukhov quit (Remote host closed the connection)
20:25:49*Calinou quit (Remote host closed the connection)
20:29:11*Guest58788 quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:29:44*Vladar quit (Remote host closed the connection)
20:30:04FromGitter<Varriount> If you want to be efficient, use one sequence.
20:30:30FromGitter<Varriount> Sequences are copy-on-assignment, but are still references to heap allocated memory
20:31:56*Ven_ joined #nim
20:32:53FromGitter<Varriount> nickmooney: What data type are you storing in the sequence?
20:33:37Araqor call 'shallow' on the sequence and call it day, it's not *that* bad
20:33:47*Calinou joined #nim
20:34:19Araqvarriount exaggerates the problem
20:35:02FromGitter<Varriount> Araq: I just point out unexpected behavior.
20:36:00FromGitter<Varriount> Besides, the real change that needs to be made is using a single sequence rather than multiple. That way all the columns/rows will be contiguous
20:36:36Araqin fact, maybe we should change the default and introduce bycopy(str|seq)
20:37:03Araqand make non-const strings/seqs all shallow() by default
20:37:41FromGitter<Varriount> Uh.. What happens when mutating then?
20:40:58*yglukhov joined #nim
20:42:12*Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
20:43:48*Ven_ joined #nim
20:46:05*jsgrant quit (Quit: Peace Peeps. o/ If you need me asap, message me at 'msg([at])jsgrant.io' & I'll try to get back to you within 24 hours.)
20:48:11Araqit's mutated?
20:49:02*nickmooney joined #nim
20:49:23FromGitter<Varriount> Araq: But you have the problem that appending may or may not cause the sequence to diverge from other references
20:49:48*couven92 quit (Ping timeout: 240 seconds)
20:50:23*nickmooney quit (Client Quit)
20:50:27FromGitter<Varriount> Operations which mutate already existing data will be fine, but operations that act on size will cause nondeterministic divergence.
20:53:49yglukhovwhere is nimble/bin on windows?
20:53:56AraqI know but so what.
20:55:04dom96yglukhov: same place they are on unix
20:55:26yglukhovwindows doesn't have ~
20:55:27yglukhov=)
20:55:43FromGitter<ephja> some windowses do
20:56:06yglukhovok, how do i refer to nimble/nim in a batch script?
20:56:27yglukhov* nimble/bin
20:56:33*JHonaker joined #nim
20:56:37FromGitter<ephja> well, you can do ls ~ :p
20:56:50JHonakerCan I not use the length of a seq in a case statement?
20:57:21FromGitter<ephja> @yglukhov shouldn't they be in your path?
20:57:31yglukhovephja: will powershell eat that?
20:57:43JHonakercase N: .... of 0..rolls.len: ... gives Error cannot evaluate rolls at compile time
20:57:54yglukhovephja: yeah, that's what i'm trying to do. add nimble/bin to PATH
20:58:13AraqJHonaker: if N in 0..<rolls.len
20:59:18yglukhovso will %HOME%/.nimble/bin work?
21:02:21*ephja quit (Quit: Leaving)
21:03:21yglukhovah, ok, its USERPROFILE
21:03:24JHonakerAraq: Yea, that worked, but why can't case do it?
21:03:49Araqbecause 'case' is about exhaustiveness checking
21:04:28JHonakerYea, I had exhaustive cases set up, low(int)..<0, 0..<rolls.len, roll.len..high(int)
21:04:37JHonakerDoes it have to be a static value?
21:05:09Araqyes. we have no symbolic proof engine
21:05:20Araq(actually we have, but 'case' doesn't use it)
21:05:28*rauss quit (Quit: WeeChat 1.8)
21:06:40JHonakerThat's what I figured. It's a little unintuitive though
21:09:40*Sentreen quit (Ping timeout: 268 seconds)
21:10:51FromGitter<Varriount> Araq: For what it's worth, I'm not trying to make a big deal of strings and sequences copy-on-write. It's just that most new programmers are coming from C#, Java, Python, and Ruby. All those languages treat strings as references, and only Ruby has mutable strings.
21:11:01Araqif x < 0: ... elif x < rolls.len else: ...
21:11:52Araqyeah and they all have horrible hacks like StringBuilder or "use a list of string and concat them all at the end"
21:12:34Araqand for optimizing it you quickly hit a wall whereas in Nim you can optimize it to the optimum
21:13:20*yglukhov quit (Remote host closed the connection)
21:13:22AraqNim doesn't differ from C# just to piss you off, it differs because C#'s solution is inferior.
21:14:25*yglukhov joined #nim
21:15:04FromGitter<Varriount> I'm not saying that though. I'm just informing others about it, rather than leaving them to trip over it and get angry when their code is slower than Python
21:17:13FromGitter<Varriount> Quite frankly, if you want Python-like strings in Nim, all you have to is create string references.
21:17:19FromGitter<Varriount> Or use shallow
21:17:44FromGitter<cooldome> @Araq: I am working on one pull request. Do you expect "type StringArray[N] = array[N, string]; echo StringArray is array" to return true? it is false currently.
21:21:11*yglukhov quit (Remote host closed the connection)
21:22:42*Sentreen joined #nim
21:22:44*JHonaker quit (Ping timeout: 272 seconds)
21:46:05*bjz joined #nim
21:48:11*vlad1777d quit (Remote host closed the connection)
21:48:37FromGitter<zacharycarter> is it possible to bind to a dynamic js object like a hashmap with a variable number of key value pair properties?
21:48:59*nsf joined #nim
21:51:57*couven92 joined #nim
21:54:36*dexterk joined #nim
21:55:00FromGitter<zacharycarter> or map rather
21:55:02*dexterk__ quit (Ping timeout: 272 seconds)
21:55:44*Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:56:58*Ven joined #nim
21:57:21*Ven is now known as Guest72935
21:57:53*pilne joined #nim
22:04:30*peted quit (Quit: WeeChat 1.4)
22:05:19*yglukhov joined #nim
22:06:44yglukhovwhere should i put pcre*.dll so that it will be found by any nim program that uses it?
22:07:32FromGitter<stisa> @zacharycarter you can probably define a type and importcpp the accessors, or use something like https://github.com/nim-lang/Nim/blob/devel/lib/js/jsffi.nim
22:08:00FromGitter<zacharycarter> thank you @stisa
22:09:41FromGitter<stisa> yhlukhov mine are in `Nim/bin`, which is in Path. It's also the default location I think?
22:10:05*Trustable quit (Remote host closed the connection)
22:20:03*tigerfinch joined #nim
22:20:08*tigerfinch left #nim (#nim)
22:20:14*tigerfinch joined #nim
22:20:47*elrood quit (Quit: Leaving)
22:41:50*byte512 joined #nim
22:43:31*Guest72935 quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
22:43:53*Ven joined #nim
22:44:16*Ven is now known as Guest39520
22:48:20*tigerfinch quit (Ping timeout: 268 seconds)
22:56:13*libman quit (Quit: Connection closed for inactivity)
22:59:49*Guest39520 quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
23:05:07*bjz quit (Quit: My MacBook Pro has gone to sleep. ZZZzzz…)
23:06:53*Ven_ joined #nim
23:20:04*Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
23:24:52*Ven_ joined #nim
23:32:48*chemist69 quit (Ping timeout: 240 seconds)
23:33:20*Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
23:40:46*Ven joined #nim
23:40:46*Ven quit (Client Quit)
23:48:45*Matthias247 quit (Read error: Connection reset by peer)