00:20:50 | * | krux02 joined #nim |
00:21:07 | krux02 | how do I run just one test? |
00:21:14 | krux02 | there is ./koch tests |
00:21:27 | krux02 | but how do I run just a single test? |
00:22:50 | libman | In koch.nim, it looks at the rest of the command line after "tests" or defaults to "all". |
00:26:33 | libman | That 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:49 | FromGitter | <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:28 | FromGitter | <NevnHiwEjuam_twitter> I tried matching the C implewmentation down to the letter but there's one discrepency that keeps popping up |
03:02:18 | FromGitter | <NevnHiwEjuam_twitter> https://pastebin.com/63yyLBPM |
03:02:19 | * | libman quit (Quit: Connection closed for inactivity) |
03:03:53 | FromGitter | <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:58 | FromGitter | <NevnHiwEjuam_twitter> Something's happening at those particular entries that bricks the remaining entries |
03:07:46 | FromGitter | <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:37 | FromGitter | <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:23 | FromGitter | <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:33 | FromGitter | <ephja> @NevnHiwEjuam_twitter wait. where does it generate values up to 511? |
06:53:33 | FromGitter | <ephja> doesn't that value only appear in the array definition? which determines its length |
06:55:13 | FromGitter | <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:52 | FromGitter | <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:45 | FromGitter | <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:34 | FromGitter | <ephja> but the length of the array is 512, and you're generating values from 0 to 256, right? |
07:06:19 | FromGitter | <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:39 | FromGitter | <NevnHiwEjuam_twitter> It's an array of int16s, and some entries should be 511 (0x1FF) but instead I get 0xFF (256) |
07:07:51 | FromGitter | <NevnHiwEjuam_twitter> erm 255 |
07:09:30 | FromGitter | <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:01 | Arrrr | This '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:23 | Araq | I like package.module.type to be unique, I need to hash this shit to produce consistent names |
10:45:59 | Araq | otherwise it would be relative/path/we/dont/know/howto/make/unique.module.type I need to hash |
10:46:50 | Araq | if you tell me how to create a canonical relative path from an existing relative path I'm all ears |
10:47:31 | Arrrr | Can't you generate the hashes relative to main module and use these hashes when relative path is used? |
10:49:46 | Arrrr | https://pastebin.com/bHfjNSxy |
10:49:55 | Araq | then we end up with ../../../../.nimble/pkgs/foo-1.0/ |
10:50:04 | * | bjz joined #nim |
10:51:20 | Arrrr | Why? and can't you replace the relative-to-module path to relative-to-main path? |
10:52:51 | Araq | the point is to get consistent name mangling. on a CI server the paths are likely different from your local ones |
10:53:37 | Araq | so a relative path like ../../../../.nimble/pkgs/foo-1.0/ is still tied to your local machine |
10:53:46 | Araq | might as well use absolute paths then |
10:55:00 | Araq | alternatively I can come up with a scheme to use $nimble/dir $project/dir $stdlib/dir for the addressing |
10:58:09 | Arrrr | Why does it have to be consistent between two computers? For DLLs gen? |
10:58:46 | Arrrr | Maybe you could simple `copy` the nimble package next to main |
10:59:27 | Arrrr | Or fake the hashes |
10:59:37 | * | Tiberium joined #nim |
10:59:45 | Araq | ideally you want to be able to unmangle the name with an algorithm (like C++ dos it) |
11:00:12 | Arrrr | instead of from "../../", whenever a nimble package is used, gen the hash thinking that it resides inside the main module folder |
11:00:39 | Araq | but this is not correct. |
11:00:59 | Araq | you can use package jester and yet have your own 'jester' dir with the same module names |
11:02:55 | Araq | we're far from having an unmangle algorithm but deterministic code generation is a strength |
11:03:54 | Arrrr | So, you cannot copy or fake the path because there could be two modules/folders named the same then. |
11:03:54 | Araq | and "deterministic on my machine only" is worse than "deterministic and the same on my coworker's computer" |
11:04:50 | Arrrr | You could generate an unique folder-name for nimble packages, as long as you remove this relative-to-computer nimble paths |
11:05:10 | Arrrr | That way you would avoid any possible collision |
11:05:36 | couven92 | can 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:45 | Araq | Arrrr: you just described my idea |
11:07:58 | Araq | "alternatively I can come up with a scheme to use $nimble/dir $project/dir $stdlib/dir for the addressing" |
11:09:25 | Arrrr | Then fantastic. I think is a limitation that is worth removing |
11:11:09 | couven92 | Ah, 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:29 | Araq | couven92: it could work nowadays |
11:11:54 | couven92 | Araq, how? I'd like my magic macro to document the AST it generates :P |
11:13:07 | couven92 | (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:51 | Araq | n.comment = "x" ? or n.strVal = "x", not sure |
11:15:07 | Araq | Arrrr: ok, as a nice bonus it shouldn't require too many changes in the compiler. it just changes its definition of 'package' |
11:24:01 | Arrrr | Ok, i can test it when the time comes. |
11:27:12 | Araq | or you implement it, edit compiler/packagehandling |
11:27:30 | Araq | other changes are not required, I think |
11:28:12 | Arrrr | W-well, i can give it a shoot |
11:28:39 | Arrrr | *shot |
11:29:46 | couven92 | Araq, 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:04 | Araq | couven92: guess it can only be used to read the doc comment then :P |
11:37:17 | couven92 | should be possible though :( |
11:37:37 | * | kunev joined #nim |
11:39:23 | * | krux02 joined #nim |
11:50:33 | Araq | fix it |
11:53:09 | Araq | compiler/vm.nim line 1409 |
11:53:43 | Araq | add an 'elif dest.kind == nkCommentStmt: dest.comment = regs[rb].node.strVal' |
11:55:11 | Araq | then 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:38 | couven92 | Araq, 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:54 | FromGitter | <andreaferretti> @Araq is there a reason why c2nim parser bails on macros such as `__align__(2)`? |
13:34:24 | FromGitter | <andreaferretti> I am trying to ignore these annotations by setting `#def *align*(2)` |
13:34:35 | FromGitter | <andreaferretti> but the parser seems to have problems |
13:35:20 | FromGitter | <andreaferretti> `identifier expected, but found '2'` |
13:36:41 | FromGitter | <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:43 | FromGitter | <Varriount> @andreaferretti `#def *align*(x)` |
13:51:20 | FromGitter | <Varriount> Macro arguments can't be number literals |
13:53:00 | FromGitter | <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:11 | FromGitter | <Varriount> It's ridiculous |
13:53:36 | FromGitter | <Varriount> Or rather, irritating |
13:53:56 | FromGitter | <ephja> who were using that website style first? :p |
13:54:34 | * | libman joined #nim |
13:54:58 | FromGitter | <ephja> or maybe full screen-ish elements are all the rage right now |
13:59:23 | FromGitter | <ephja> @Varriount I'm sure the JVM target has something to do with the popularity |
14:00:12 | FromGitter | <andreaferretti> @Varriount thank you, it was so simple! |
14:00:21 | * | vlad1777d joined #nim |
14:00:57 | libman | Russian Hackers ™ => Hacker News |
14:01:51 | libman | Vast conspiwwwacy, I tells ya! |
14:02:58 | libman | They're out to to sap and impurify all of our precious MIT-licensed codely fluids... |
14:19:30 | FromGitter | <zacharycarter> @Varriount I don't get the kotlin hype |
14:20:25 | FromGitter | <ephja> do any of the other languages that support JVM and/or android appear to be better? |
14:20:34 | FromGitter | <zacharycarter> No |
14:20:58 | FromGitter | <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:14 | euantor | I like Kotlin personally |
14:40:18 | ftsf | hmm kotlin looks interesting, error if you try to use a nullable type without checking if it's null is cute. |
14:40:26 | ftsf | never heard of it before today |
14:40:40 | euantor | I translated our Android app across to it earlier this year, and it was a much nicer experience than writing pure java |
14:41:06 | euantor | There are some nice Kotlin libraries too, and data classes are very useful |
14:41:15 | ftsf | yeah, 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:54 | FromGitter | <Varriount> I was going to say, given a choice between Java and another language... I would almost always pick the alternative |
14:42:03 | ftsf | how about java or php? ;) |
14:42:22 | FromGitter | <Varriount> Ouch. Tough decision |
14:42:39 | FromGitter | <Varriount> That is a case where I would pick java |
14:44:57 | euantor | I 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:53 | FromGitter | <ephja> @andreaferretti great c2nim additions. it has been difficult to deal with convoluted ifdefs |
14:49:07 | FromGitter | <andreaferretti> thank you :-) |
14:49:26 | FromGitter | <andreaferretti> I am planning a few more improvements |
14:49:37 | FromGitter | <andreaferretti> for https://github.com/unicredit/nimcuda |
14:54:02 | FromGitter | <Varriount> @andreaferretti What additions have been made to c2nim? |
14:55:08 | FromGitter | <andreaferretti> I have added two annotation `#skipifdef` and `#skipifndef` |
14:55:54 | FromGitter | <andreaferretti> if you add `#skipifdef SOMENAME`, c2nim will assume that `SOMENAME` is not defined and correspondently skip `#ifdef SOMENAME` blocks |
14:56:04 | FromGitter | <andreaferretti> and similarly for `#skipifndef` |
14:57:22 | FromGitter | <andreaferretti> it also handles more complex conditions such as `#if !defined(__CUDACC_INTEGRATED__) && (!defined(__CUDA_ARCH__) || (__CUDA_ARCH__ >= 350))` |
14:58:15 | FromGitter | <andreaferretti> there are three more things that I would need to parse cuda headers cleanly |
14:58:51 | FromGitter | <andreaferretti> 1) correctly parse large numbers |
14:59:11 | FromGitter | <andreaferretti> 1) not produce empty blocks (need to add a `discard` in postprocessing) |
14:59:44 | FromGitter | <andreaferretti> I forgot the third one |
14:59:46 | FromGitter | <andreaferretti> :-P |
15:00:09 | FromGitter | <andreaferretti> ah ok, |
15:00:51 | FromGitter | <andreaferretti> 1) recognize the guard pattern and omit the corresponding `when not defined(GUARD):` |
15:01:05 | FromGitter | <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:24 | FromGitter | <Varriount> @andreaferretti Sounds like that will help when wrapping windows stuff too |
15:25:45 | FromGitter | <Varriount> especially if `ifdef` stuff |
15:26:10 | FromGitter | <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:30 | FromGitter | <Varriount> @ephja `:=`? |
15:26:36 | FromGitter | <ephja> DSL |
15:27:52 | * | yglukhov quit () |
15:28:24 | * | yglukhov joined #nim |
15:29:23 | FromGitter | <andreaferretti> I have a variant object with three variants |
15:29:37 | FromGitter | <andreaferretti> and a field shared between variant 1 and 2 |
15:29:44 | FromGitter | <andreaferretti> another between variant 1 and 3 |
15:29:51 | FromGitter | <andreaferretti> and finally one between variant 2 and 3 |
15:29:58 | FromGitter | <andreaferretti> how to write it? |
15:30:35 | FromGitter | <andreaferretti> I am trying as follow |
15:30:40 | FromGitter | <andreaferretti> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=591f0fa083cb5db0734a1586] |
15:31:00 | FromGitter | <ephja> I can make it not give me a syntax error if I remove the signature from the proc expression |
15:31:10 | FromGitter | <andreaferretti> but it complains that case labels are repeated |
15:31:28 | FromGitter | <andreaferretti> if instead I give each label its section |
15:31:41 | FromGitter | <andreaferretti> I get an error because field names are duplicated |
15:31:44 | FromGitter | <andreaferretti> any idea? |
15:32:04 | FromGitter | <ephja> @andreaferretti it isn't possible |
15:32:18 | FromGitter | <andreaferretti> that's a little unfortunate |
15:32:29 | FromGitter | <andreaferretti> I will go with different field names then |
15:35:17 | * | LyndsySimon joined #nim |
15:36:22 | LyndsySimon | Greetings! I'm interested in learning Nim, at least on the side. I came from this Reddit thread: https://www.reddit.com/6c1jnv/ |
15:36:54 | FromGitter | <ephja> what about patty? I was going to give you a link but of course it was written by you |
15:37:10 | LyndsySimon | Two 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:37 | FromGitter | <ephja> @andreaferretti btw, did it ever break for you after upgrading nim? |
15:38:52 | FromGitter | <Varriount> Hi LyndsySimon |
15:39:06 | FromGitter | <ephja> "Patty 0.3.0 works for latest Nim (devel)" alright! |
15:40:02 | FromGitter | <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:36 | FromGitter | <andreaferretti> @ephja patty rewrites fields into a variant object at the end of the day |
15:40:45 | FromGitter | <ephja> has anyone made a shell-ish DSL? |
15:40:50 | FromGitter | <andreaferretti> so it cannot overcome this naming limitation |
15:41:12 | FromGitter | <ephja> no but maybe it makes it less annoying |
15:41:22 | FromGitter | <andreaferretti> about breaking: yes, from time to time, but it was always very simple to upgrade it |
15:41:34 | FromGitter | <andreaferretti> usually it is just some new node added in the AST |
15:41:47 | FromGitter | <andreaferretti> so maybe I have to shift an index by one when traversing the AST |
15:41:50 | * | couven92 joined #nim |
15:41:52 | FromGitter | <andreaferretti> stuff like that |
15:41:55 | FromGitter | <andreaferretti> nothing serious |
15:42:17 | FromGitter | <andreaferretti> Latest patty (0.3.1) should work fine on nim 0.17 |
16:01:38 | dyce[m] | LyndsySimon: Nim works great for that in my experience |
16:02:07 | dyce[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:11 | couven92 | okay 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:23 | Trioxin | db_mysql needs some work |
17:06:38 | * | Arrrr joined #nim |
17:20:29 | * | yglukhov joined #nim |
17:22:31 | FromGitter | <mratsim> Wooow nimcuda @andreaferretti wonderful ! |
17:24:43 | FromGitter | <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:05 | Tiberium | how to print nim code (not ast) generated by macro? |
17:45:27 | * | sz0 joined #nim |
17:45:33 | Tiberium | ah, 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:08 | couven92 | argh, 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:22 | couven92 | aha, setting the newExceptionCall to take `type(ValueError)` instead of just `ValueError` did the trick |
18:43:38 | FromGitter | <Varriount> Huh, wonder what the difference is |
18:45:04 | Araq | couven92: that shouldn't be necessary |
18:45:09 | Araq | looking into it |
18:46:12 | couven92 | Araq, ah, sorry that I updated my gist... But luckily Gist keeps Revisions... :P |
18:49:24 | Araq | ok, found it, use raisesValue = newNimNode(nnkBracket).add(ident("ValueError")) |
18:50:02 | Araq | you share the ident node and for reasons that escape me now it means the type computation is "shared" too |
18:50:29 | couven92 | Ah! okay... I cannot reuse nodes... That makes sense |
18:50:43 | Araq | so ValueError is of type ValueError for the "raises" and then stays so. instead of producing typedesc[ValueError] |
18:51:54 | couven92 | yeah, I understand, okay... so I should always create new nodes everywhere in my macro... |
18:52:04 | Araq | no, but in this case |
18:52:07 | Araq | ;-) |
18:52:27 | couven92 | Araq, 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:25 | JHonaker | How can I make a type def that is just a generic array |
19:11:55 | JHonaker | Like type Die[N, T] = array[N, T]? |
19:12:13 | JHonaker | Can I use openarray? |
19:12:33 | Araq | what's wrong with the syntax you used? |
19:12:51 | JHonaker | Well I'm just curious how I'd use that type in a proc |
19:13:00 | FromGitter | <cooldome> you can simple use - array |
19:13:11 | FromGitter | <cooldome> proc xx(a: array) |
19:13:23 | Araq | that's not the same, cooldome |
19:13:25 | JHonaker | Can I say proc roll[N, T](die: Die[N, T]): T? |
19:13:38 | Araq | yeah |
19:13:52 | FromGitter | <cooldome> proc xxN,T (a: array[N, T]) |
19:14:31 | JHonaker | Thanks! |
19:16:44 | LyndsySimon | Does Nim have string templating? I'm looking to simplify this line: `echo("You passed in " & $(paramCount()) & " arguments");` |
19:17:12 | LyndsySimon | Ignore the semicolon, not sure how that got there.... |
19:17:36 | couven92 | LyndsySimon, "You passed in $# arguments" % [$paramCount()] |
19:18:07 | LyndsySimon | couven92: Cool, thanks. :) |
19:18:18 | couven92 | LyndsySimon, and many more, check out: https://nim-lang.org/docs/strutils.html#%,string,openArray[string] |
19:18:42 | couven92 | and you'll need to import the strutils module for that |
19:19:23 | * | Ven_ joined #nim |
19:19:42 | LyndsySimon | Yeah, 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:48 | Araq | what happened to the string interpolation macro? |
19:19:56 | Araq | somebody wanted to submit it to the core |
19:20:03 | Araq | and now 0.17 still is without one :-( |
19:20:06 | Araq | boo!!! |
19:20:26 | * | Ven_ quit (Client Quit) |
19:20:41 | couven92 | Araq, indeed that sounds like fun! Interpolation as in, merging together on string literals? |
19:21:29 | couven92 | to pay the interpolation cost at compiletime rather than at runtime? Or interpolation as in the way C# does it nowadays? |
19:22:10 | Araq | a simple macro that uses parseutils.interpolatedFragments |
19:22:24 | Araq | 3 line implementation, 10 lines of documentation |
19:22:39 | Araq | as it's getting the norm for Nim code :P |
19:22:53 | LyndsySimon | :) |
19:23:16 | LyndsySimon | I'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:57 | LyndsySimon | I'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:20 | Araq | true and the JS target has been a stepchild |
19:24:48 | couven92 | as some stated here some days ago: "JavaScript is a horror show!" :P |
19:25:07 | LyndsySimon | There'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:03 | Araq | but 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:02 | JHonaker | import random |
19:27:02 | JHonaker | |
19:27:02 | JHonaker | type |
19:27:02 | JHonaker | GenericDie[N, T] = array[0..N, T] |
19:27:06 | JHonaker | Die[N] = GenericDie[N, int] |
19:27:09 | JHonaker | |
19:27:12 | JHonaker | proc roll[N, T](die: GenericDie[N, T]): T = |
19:27:15 | JHonaker | random(die) |
19:27:20 | JHonaker | |
19:27:20 | JHonaker | var d20: GenericDie[20, int] = [1..20] |
19:27:25 | JHonaker | echo d20.roll |
19:27:29 | JHonaker | echo d20.roll |
19:27:29 | JHonaker | |
19:27:32 | JHonaker | whoops |
19:27:38 | JHonaker | but can anyone tell me what's wrong with this code? I get a type mismatch on line 4 |
19:28:21 | JHonaker | https://pastebin.com/JqNFFkmW |
19:37:10 | * | Arrrr quit (Read error: Connection reset by peer) |
19:43:36 | FromGitter | <Varriount> JHonaker: Your passing in two generic parameters to `Die`, which only takes one. |
19:43:40 | FromGitter | <Varriount> *You're |
19:44:56 | FromGitter | <Varriount> Oh wait, my bad. |
19:45:15 | JHonaker | It takes two. |
19:46:11 | JHonaker | I think I figured out what my problem was |
19:46:14 | FromGitter | <Varriount> Use `array[N, T]` instead of `array[0..N, T]` |
19:46:32 | JHonaker | Yea, that fixed it, I thought I was still getting an error though |
19:46:54 | JHonaker | but I was calling random([1..20]) and getting {a: 1, b: 20}, not a number like I expected |
19:47:10 | JHonaker | But it was choosing a random slice from the array of one slice |
19:47:26 | JHonaker | Is there an easy way to say array from 1 to 20? |
19:48:18 | FromGitter | <Varriount> You mean, you want the index of the array to start at 1? |
19:48:32 | demi- | 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:09 | JHonaker | Varriount: No, I'd like the type GenericDie to be an array of T's |
19:49:16 | JHonaker | And Die to be an array of ints |
19:49:41 | JHonaker | I'd like it to be able to handle arbitrarily numbered faces, but I think I'm having a misunderstading |
19:50:14 | FromGitter | <Varriount> type GenericDie[N, T] = array[N, T] |
19:50:30 | JHonaker | demi-: of is highlighted for me, I'm using the nim layer on spacemacs though |
19:50:35 | FromGitter | <Varriount> type Die[N] = GenericDie[N, int] |
19:51:30 | JHonaker | Thats what I had, argh! I must have confused myself with the iterator thing. Can I cast 1..20 to [1, 2, ..., 20]? |
19:53:09 | FromGitter | <Varriount> You could write a converter. Those implement implicit conversions. |
19:53:21 | FromGitter | <Varriount> Might be easier for you to just use sequences though. |
19:53:24 | * | sz0 quit (Quit: Connection closed for inactivity) |
19:54:13 | FromGitter | <Varriount> import sequtils; echo toSeq(0..20) |
19:54:44 | JHonaker | Thanks, I just started today, I have no idea what's in the standard library |
19:56:57 | FromGitter | <Varriount> The only benefit in using arrays is that they are fixed length, and located on the stack. |
19:58:50 | JHonaker | Awesome, thanks. Got it to work as expected first time with seqs |
20:00:02 | * | nsf quit (Quit: WeeChat 1.7.1) |
20:00:07 | FromGitter | <zacharycarter> is it possible to FFI with Nim and JS? |
20:00:10 | FromGitter | <zacharycarter> or Node rather |
20:00:20 | FromGitter | <zacharycarter> like could I potentially execute some Nim code from NodeJS code? |
20:00:28 | FromGitter | <zacharycarter> Rust has something like this I think |
20:01:03 | FromGitter | <zacharycarter> https://github.com/neon-bindings/neon |
20:01:29 | demi- | 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:56 | FromGitter | <zacharycarter> hrm but that's essentially just node calling more JS right? |
20:03:16 | * | JHonaker quit (Ping timeout: 246 seconds) |
20:03:23 | FromGitter | <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:01 | demi- | you mean, like having node call into a compiled nim library? |
20:04:05 | FromGitter | <zacharycarter> yes |
20:04:12 | FromGitter | <zacharycarter> I believe this is the concept Neon has for Rust |
20:04:21 | demi- | yeah i believe part of the core of node is to allow that sort of thing? |
20:04:28 | FromGitter | <zacharycarter> I think so |
20:04:38 | FromGitter | <zacharycarter> it might help me gain traction for using Nim at work |
20:04:39 | demi- | so you would have to exportc your code and then make the binding yourself |
20:04:46 | FromGitter | <zacharycarter> hrm okay |
20:05:04 | FromGitter | <zacharycarter> I'll play around w/ the concept this weekend |
20:05:06 | demi- | but i mean, that is the same process if you wanted a C program to interact with nim |
20:05:12 | FromGitter | <zacharycarter> right |
20:05:18 | demi- | just a javascript file instead of a C header |
20:06:02 | demi- | 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:16 | demi- | https://github.com/node-ffi/node-ffi |
20:06:33 | FromGitter | <zacharycarter> oooo this is interesting |
20:07:10 | demi- | the node-ffi thing seems a lot better than swig imo |
20:07:14 | FromGitter | <zacharycarter> yeah |
20:08:07 | * | nmooney joined #nim |
20:08:07 | * | nmooney quit (Client Quit) |
20:08:22 | * | nickmooney joined #nim |
20:08:58 | nickmooney | Hi all! I was just curious if "case" supported pattern-matching-like functionality, i.e. matching over more than one distinct value? |
20:09:15 | nickmooney | It seems like the answer is no, but I wasn't sure. |
20:09:20 | FromGitter | <Varriount> nickmooney: Not in the standard language. |
20:09:27 | nickmooney | gotcha |
20:09:30 | nickmooney | thanks Varriount |
20:09:34 | FromGitter | <Varriount> One moment though, I think I have something for you |
20:09:37 | nickmooney | sure, thanks |
20:09:56 | FromGitter | <Varriount> https://github.com/andreaferretti/patty |
20:10:35 | nickmooney | interesting, I'll check it out |
20:11:27 | FromGitter | <Varriount> nickmooney: Though, that's for data types more than general matching |
20:12:32 | * | Trustable joined #nim |
20:12:47 | nickmooney | gotcha. 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:29 | nickmooney | I've been doing a lot of FP lately so it feels like pattern matching is an elegant way hah |
20:14:10 | nickmooney | right now I just hardcode the four cases but I'm trying to learn idiomatic Nim |
20:14:39 | nickmooney | pattern matching is likely not the idiomatic solution |
20:18:43 | nickmooney | here'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:04 | FromGitter | <Varriount> If you want to be efficient, use one sequence. |
20:30:30 | FromGitter | <Varriount> Sequences are copy-on-assignment, but are still references to heap allocated memory |
20:31:56 | * | Ven_ joined #nim |
20:32:53 | FromGitter | <Varriount> nickmooney: What data type are you storing in the sequence? |
20:33:37 | Araq | or call 'shallow' on the sequence and call it day, it's not *that* bad |
20:33:47 | * | Calinou joined #nim |
20:34:19 | Araq | varriount exaggerates the problem |
20:35:02 | FromGitter | <Varriount> Araq: I just point out unexpected behavior. |
20:36:00 | FromGitter | <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:36 | Araq | in fact, maybe we should change the default and introduce bycopy(str|seq) |
20:37:03 | Araq | and make non-const strings/seqs all shallow() by default |
20:37:41 | FromGitter | <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:11 | Araq | it's mutated? |
20:49:02 | * | nickmooney joined #nim |
20:49:23 | FromGitter | <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:27 | FromGitter | <Varriount> Operations which mutate already existing data will be fine, but operations that act on size will cause nondeterministic divergence. |
20:53:49 | yglukhov | where is nimble/bin on windows? |
20:53:56 | Araq | I know but so what. |
20:55:04 | dom96 | yglukhov: same place they are on unix |
20:55:26 | yglukhov | windows doesn't have ~ |
20:55:27 | yglukhov | =) |
20:55:43 | FromGitter | <ephja> some windowses do |
20:56:06 | yglukhov | ok, how do i refer to nimble/nim in a batch script? |
20:56:27 | yglukhov | * nimble/bin |
20:56:33 | * | JHonaker joined #nim |
20:56:37 | FromGitter | <ephja> well, you can do ls ~ :p |
20:56:50 | JHonaker | Can I not use the length of a seq in a case statement? |
20:57:21 | FromGitter | <ephja> @yglukhov shouldn't they be in your path? |
20:57:31 | yglukhov | ephja: will powershell eat that? |
20:57:43 | JHonaker | case N: .... of 0..rolls.len: ... gives Error cannot evaluate rolls at compile time |
20:57:54 | yglukhov | ephja: yeah, that's what i'm trying to do. add nimble/bin to PATH |
20:58:13 | Araq | JHonaker: if N in 0..<rolls.len |
20:59:18 | yglukhov | so will %HOME%/.nimble/bin work? |
21:02:21 | * | ephja quit (Quit: Leaving) |
21:03:21 | yglukhov | ah, ok, its USERPROFILE |
21:03:24 | JHonaker | Araq: Yea, that worked, but why can't case do it? |
21:03:49 | Araq | because 'case' is about exhaustiveness checking |
21:04:28 | JHonaker | Yea, I had exhaustive cases set up, low(int)..<0, 0..<rolls.len, roll.len..high(int) |
21:04:37 | JHonaker | Does it have to be a static value? |
21:05:09 | Araq | yes. we have no symbolic proof engine |
21:05:20 | Araq | (actually we have, but 'case' doesn't use it) |
21:05:28 | * | rauss quit (Quit: WeeChat 1.8) |
21:06:40 | JHonaker | That's what I figured. It's a little unintuitive though |
21:09:40 | * | Sentreen quit (Ping timeout: 268 seconds) |
21:10:51 | FromGitter | <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:01 | Araq | if x < 0: ... elif x < rolls.len else: ... |
21:11:52 | Araq | yeah and they all have horrible hacks like StringBuilder or "use a list of string and concat them all at the end" |
21:12:34 | Araq | and 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:22 | Araq | Nim 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:04 | FromGitter | <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:13 | FromGitter | <Varriount> Quite frankly, if you want Python-like strings in Nim, all you have to is create string references. |
21:17:19 | FromGitter | <Varriount> Or use shallow |
21:17:44 | FromGitter | <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:37 | FromGitter | <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:00 | FromGitter | <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:44 | yglukhov | where should i put pcre*.dll so that it will be found by any nim program that uses it? |
22:07:32 | FromGitter | <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:00 | FromGitter | <zacharycarter> thank you @stisa |
22:09:41 | FromGitter | <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) |