00:02:53 | * | Demon_Fox joined #nim |
00:25:47 | * | Matthias247 quit (Read error: Connection reset by peer) |
00:28:51 | * | lompik joined #nim |
00:42:49 | * | NimBot joined #nim |
00:45:51 | ephja | hm, the error message when removing one of the parameters is: "invalid indentation" |
00:48:12 | * | Demon_Fox joined #nim |
01:16:24 | * | mahasamoot quit (Ping timeout: 256 seconds) |
01:17:25 | * | jaco60 quit (Ping timeout: 260 seconds) |
01:25:48 | * | desophos quit (Ping timeout: 272 seconds) |
01:44:10 | * | low-profile quit (Ping timeout: 256 seconds) |
01:47:04 | * | low-profile joined #nim |
01:54:04 | * | jck quit (Ping timeout: 250 seconds) |
02:11:46 | * | Trustable quit (Remote host closed the connection) |
02:27:48 | * | ludocode quit (Ping timeout: 248 seconds) |
02:28:27 | * | jck joined #nim |
02:39:04 | * | ludocode joined #nim |
02:42:32 | * | pregressive joined #nim |
02:46:05 | * | gokr quit (Ping timeout: 260 seconds) |
02:49:58 | * | filwit quit (Quit: Leaving) |
03:01:45 | * | oio joined #nim |
03:02:13 | * | oio quit (Client Quit) |
03:06:16 | * | FreezerburnV quit (Ping timeout: 252 seconds) |
03:13:30 | * | brson quit (Ping timeout: 260 seconds) |
03:26:48 | * | lompik quit (Ping timeout: 252 seconds) |
03:40:55 | * | ephja quit (Ping timeout: 245 seconds) |
03:58:58 | * | mountaingoat quit (Ping timeout: 240 seconds) |
03:59:03 | * | desophos joined #nim |
04:27:22 | * | mountaingoat joined #nim |
04:30:17 | * | pregressive quit (Remote host closed the connection) |
04:32:30 | * | Earthling joined #nim |
04:32:44 | Earthling | hello |
04:33:27 | Earthling | I tried to register on the forum, and it never sent me the e-mail to do the confirmation. Who can I contact to fix this? |
04:38:51 | * | pregressive joined #nim |
04:45:34 | * | vendethiel joined #nim |
04:57:37 | * | brson joined #nim |
04:59:31 | * | pregressive quit (Remote host closed the connection) |
05:05:29 | * | s4 joined #nim |
05:08:26 | * | vendethiel quit (Ping timeout: 240 seconds) |
05:15:24 | * | Earthling quit (Ping timeout: 252 seconds) |
05:21:15 | * | BitPuffin|osx quit (Ping timeout: 240 seconds) |
05:28:50 | * | StarBrilliant quit (Quit: ZNC - http://znc.in) |
05:44:20 | * | endragor joined #nim |
05:46:40 | * | vendethiel joined #nim |
06:03:55 | * | bjz joined #nim |
06:04:58 | * | qazwsx_ joined #nim |
06:07:55 | * | bjz quit (Ping timeout: 240 seconds) |
06:10:22 | * | dashed quit (Quit: Connection closed for inactivity) |
06:28:15 | * | vendethiel quit (Ping timeout: 240 seconds) |
06:42:53 | * | warkid joined #nim |
06:47:42 | * | qazwsx_ quit (Quit: qazwsx_) |
06:52:07 | * | vendethiel joined #nim |
07:29:22 | * | dashed joined #nim |
07:31:45 | * | vendethiel quit (Ping timeout: 245 seconds) |
07:35:28 | * | filcuc joined #nim |
07:44:14 | * | arnetheduck joined #nim |
07:56:46 | * | endragor quit (Ping timeout: 250 seconds) |
07:59:55 | * | gokr joined #nim |
08:01:45 | * | Ven joined #nim |
08:05:14 | * | Demon_Fox quit (Quit: Leaving) |
08:10:01 | * | endragor joined #nim |
08:14:42 | * | Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
08:15:24 | * | darkf joined #nim |
08:18:00 | * | yglukhov joined #nim |
08:37:31 | * | jaco60 joined #nim |
08:41:50 | * | jaco60 quit (Ping timeout: 250 seconds) |
08:42:49 | * | gour joined #nim |
08:46:03 | * | warkid quit (Ping timeout: 252 seconds) |
08:47:08 | * | warkid joined #nim |
08:49:09 | Araq | earthling: dom96 |
08:55:42 | * | vendethiel joined #nim |
08:57:00 | * | brson quit (Ping timeout: 250 seconds) |
08:59:31 | * | Ven joined #nim |
09:03:53 | arnetheduck | Araq, any plans for the standard library with regards to platform specific stuff? ie try to reimplement everything using a standard interface or provide thin wrappers to platform code? |
09:05:48 | arnetheduck | ie java does everything the java way, while for example rust has a libc library wrapper which exposes as much as possible of the native libc as available on each platform |
09:08:42 | Araq | we have posix.nim and iirc linux.nim (as a nimble package?) as well extensive windows api wrappers |
09:09:09 | Araq | but the stdlib is the stdlib, it tries to provide a most convenient Nim interface |
09:16:45 | * | vendethiel quit (Ping timeout: 245 seconds) |
09:20:51 | * | BlaXpirit quit (Quit: Bye) |
09:21:26 | * | BlaXpirit joined #nim |
09:23:16 | arnetheduck | ok.. I see some code in for example posix.nim which does something like if nimscript: const a = 100 else: var a: { importc, header: xxx.h }.. you mentioned in the llvm thread that you'd be open to header deps in the std lib, was it this kind of code you were referering to? |
09:26:43 | arnetheduck | er, ansi_c.nim |
09:32:23 | * | BlaXpirit quit (Quit: Bye) |
09:33:21 | * | BlaXpirit joined #nim |
09:34:56 | * | Skrylar joined #nim |
09:36:27 | * | Giro joined #nim |
09:38:01 | Giro | Join |
09:38:10 | * | Giro quit (Client Quit) |
09:52:41 | * | coffeepot joined #nim |
09:58:09 | * | Trustable joined #nim |
09:58:19 | * | vendethiel joined #nim |
09:59:54 | * | brson joined #nim |
10:00:33 | vegansk | Araq, hi! What do you think about including => and -> macros in system module? Maybe the time has come to treat them as a standard language constructions? :-) |
10:01:03 | Araq | arnetheduck: yeah |
10:01:23 | Araq | vegansk: yes for '->', not sure I like => all that much |
10:03:07 | vegansk | No no! Do not throw `=>` away, it will kill my code :-) |
10:04:16 | vegansk | Araq, what do you prefer instead of `=>` ? |
10:05:55 | * | derka joined #nim |
10:07:20 | Araq | anon procs if I need a proc, otherwise I use oldschool for+if+break |
10:07:35 | * | brson quit (Ping timeout: 245 seconds) |
10:09:01 | Araq | which is just much more ergonomic, 3 concepts rather than 12 ? (filter, map, groupby, flatmap, join, repeat, ... ) |
10:11:21 | Araq | FP is overrated :P just like OO was back in the days. nothing beats imperative code. ymmv |
10:13:56 | vegansk | Such a `holy war` theme :-) |
10:20:58 | * | vendethiel quit (Ping timeout: 272 seconds) |
10:22:21 | vegansk | Araq, but it doesn't mean that it is not allowed to use Nim for functional programming. We already use Nim as a FP language in production, rewriting peaces of c++ code. |
10:22:51 | Araq | of course not, Nim contains much more than just my personal preferences |
10:23:35 | Araq | plus the foundations for '=>' have to be in the language anyway for lots of other reasons |
10:23:44 | vegansk | So, maybe I'll make a PR with both of them? :-) |
10:24:43 | Araq | keep in mind that system.nim shouldn't import macros.nim, so you have to patch the compiler to move -> and => out of the future module |
10:25:48 | vegansk | Ok, I'll try :-) |
10:27:27 | * | desophos quit (Read error: Connection reset by peer) |
10:28:02 | Araq | but since both macros.nim and the compiler essentially use the same API, it shouldn't require too much thinking :-) |
10:32:30 | * | Skrylar quit () |
10:36:32 | * | Ven quit (Ping timeout: 252 seconds) |
10:37:41 | * | vegansk left #nim ("Ухожу я от вас (xchat 2.4.5 или старше)") |
10:41:26 | * | vegansk joined #nim |
11:04:11 | * | Ven joined #nim |
11:13:54 | * | NimBot joined #nim |
11:21:09 | * | warkid quit (Ping timeout: 252 seconds) |
11:24:52 | * | Gonzih joined #nim |
11:25:30 | * | Sornaensis joined #nim |
11:25:33 | * | Roin joined #nim |
11:29:54 | * | brson joined #nim |
11:34:37 | * | derka quit (Quit: derka) |
11:37:37 | * | yglukhov joined #nim |
11:38:45 | * | vendethiel joined #nim |
11:39:02 | * | vegansk quit (Quit: Ухожу я от вас (xchat 2.4.5 или старше)) |
11:39:22 | * | vegansk joined #nim |
11:50:37 | * | derka joined #nim |
11:55:29 | arnetheduck | what would the best way be to express "unless already defined"? ie what I'm after is a fallback - for example on linux, sigusr1 has value 10, so in linux.nim, I'd like to put const SIGUSR1 = 10.. then, in posix,nim, I'd like to say, "if SIGUSR1 is not defined, use var SIGUSR1 value from signal.h".. that way, for implemented platform one avoids a dep on the header file, while maintaining portability in the compile-to-c version (I would need this for |
11:55:29 | arnetheduck | nlvm) |
11:56:07 | arnetheduck | or any better idea? |
11:56:31 | coffeepot | when not defined(SIGUSR) maybe? |
11:56:37 | Araq | when not declared(...) |
11:56:48 | Araq | defined is only for -d:switches |
11:56:56 | coffeepot | i always get those mixed up... XD |
11:57:09 | Araq | they used to be one and the same |
11:57:22 | Araq | but it was too error prone |
11:57:23 | * | Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
11:57:36 | coffeepot | I'm glad they're different tbf |
11:59:22 | arnetheduck | any way to shorten that? say, for 100 such constants? |
11:59:37 | arnetheduck | where each is checked individually... |
12:00:05 | arnetheduck | (to avoid repeating "when not defined") |
12:00:21 | arnetheduck | er, declared |
12:01:45 | Araq | templates ftw |
12:02:05 | * | vendethiel quit (Ping timeout: 276 seconds) |
12:02:05 | ephja | yay |
12:02:41 | arnetheduck | ah, can stick when in a template? cool |
12:08:37 | ephja | is there anything that can't go in a template? |
12:15:11 | * | brson quit (Read error: Connection reset by peer) |
12:15:26 | Araq | no. and unittest.nim nests templates 3 or 4 levels deep ... |
12:15:52 | coffeepot | <3 templates |
12:16:32 | coffeepot | btw is it bad pactice todeclare vars with untyped template params? |
12:16:59 | Araq | template t(a, b) |
12:17:00 | coffeepot | like template a(b: untyped) = var b: int |
12:17:32 | Araq | is short for: |
12:17:40 | Araq | template t(a, b: untyped) |
12:17:55 | Araq | 'untyped' is just fine, templates are sharp tools |
12:17:56 | * | derka quit (Quit: derka) |
12:17:56 | coffeepot | cool :) |
12:18:16 | Araq | but injecting a 'var' however ... :P |
12:19:23 | * | derka joined #nim |
12:26:19 | * | lg_ joined #nim |
12:27:32 | * | BitPuffin joined #nim |
12:29:49 | * | junw joined #nim |
12:34:55 | coffeepot | not just for injecting a var ofc, but things like tables trygetvale[a,b](theValue): bool meaning i dont need the extra line for defining the value |
12:36:31 | coffeepot | also template timeIt(t: expr, action: stmt) = var t = cpuTime() ... |
12:38:02 | * | derka quit (Quit: derka) |
12:44:18 | * | derka joined #nim |
12:50:41 | * | lompik joined #nim |
12:55:18 | * | Ven joined #nim |
12:56:48 | coffeepot | is there a performance guide for nim about? |
12:57:27 | coffeepot | thought i was saving time by using a massive set[uint16] rather than an IntSet or hash table... |
12:58:24 | coffeepot | until I looked at the C code and realised in order to traverse the set it does "if (!(i_113134 <= ((NI) 65535))) goto <after loop>" |
12:58:48 | coffeepot | ofc sets are really quick when they're not uint16 in size |
12:59:22 | coffeepot | but IntSets are much faster way of doing what I wanted |
13:00:55 | coffeepot | didn't expect it iterating all values when the nim code was just "var s: set[uint16] = {1, 2}; for item in s: ..." |
13:01:28 | * | s4 quit (Quit: Konversation terminated!) |
13:03:34 | coffeepot | *iterating all possible numbers I mean |
13:05:29 | * | Jehan_ joined #nim |
13:21:46 | Araq | coffeepot: sparse big sets are better done with an IntSet or a hash table, that's no surprise |
13:21:50 | * | gour quit (Quit: WeeChat 1.3) |
13:22:07 | Araq | dense big sets can still be faster with 'set' |
13:22:15 | Araq | and small sets are always faster with 'set' |
13:23:04 | Araq | it's really not that complicated and since Nim is a systems programming language there is not SmartSet[T] which uses both implementations under the hood |
13:23:23 | Araq | but feel free to create it :-) |
13:25:21 | coffeepot | It's not that complicated... once you know that! I was testing the best impl for quickly adding/removing big sets of data between hashtable, intset and sets and sets are stupidly fast to add/remove from so I thought 'great, lets use these'. It was only when I came to iterate over them that I realised my mistake. |
13:27:27 | coffeepot | I'm all for the right tool for the right job, but sometimes you need to know what's happening behind the scenes to select the right tool. As a systems programming language, it'd be handy to have a guide for selecting the right tool |
13:27:48 | coffeepot | I mean, I could put in things I've found I guess and maybe cobble something together |
13:31:09 | coffeepot | Another thing is knowing when copies are made. Nim seems to be pretty clever about this, but sometimes I'm not always sure how or when, say, seqs are copied. They're reference types but have value semantics, except sometimes AFAICT. I'm not super sure, so I have to dig into the C code sometimes to see. Sometimes I just want to alias a seq for less |
13:31:09 | coffeepot | typing/cleaner code, and definitely do not want to copy. You probably know how to do this, but I'm not sure right now. I feel it would be nice to have an article that explained this kinda thing. |
13:32:55 | Jehan_ | coffeepot: Using `let` generally avoids copying. Also, passing a seq as a procedure argument doesn't copy. |
13:33:35 | coffeepot | ah okay. See, I thought let generally DID copy! Also, using let means you can't change the seq, right? |
13:34:19 | arnetheduck | any convention on files which as meant to be included (as opposed to imported)? |
13:34:23 | ephja | that's correct, but you also have var parameters |
13:34:53 | * | gour joined #nim |
13:35:12 | Jehan_ | coffeepot: Correct, `let` variables are immutable (or, more precisely, immutable views of potentially mutable data). |
13:36:02 | Jehan_ | arnetheduck: include is pretty much a textual include. It's only for when you want to create a variant version of a module or split a module in several parts or some such thing. |
13:37:57 | * | vendethiel joined #nim |
13:39:06 | arnetheduck | Jehan_, yeah, I know.. I'm thinking about how to organize platform specific code - one way would be through textual includes |
13:40:08 | Jehan_ | arnetheduck: That's definitely an option. Just remember that if you include something multiple times (or both include and import it) that the code/data in the module will be replicated for each instance, which can be wasteful. |
13:42:26 | * | Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
13:53:37 | * | filwit joined #nim |
13:55:17 | coffeepot | thanks Jehan_ so what is the best way to alias a mutable? If I do a var on a non-ref I think it's going to copy? |
13:55:50 | Jehan_ | coffeepot: Hmm, what do you need a mutable alias for? |
13:56:58 | Jehan_ | coffeepot: You can use shallowCopy, that's one way (but potentially unsafe). |
13:57:33 | coffeepot | well say if you have a.b.c[i] and you want to update that - in that case just for typing and readability. Or, in terms of performance if you have data that's looked up and you want to update it in a loop whilst saving the lookup cost |
13:58:26 | * | vendethiel quit (Ping timeout: 240 seconds) |
13:58:34 | coffeepot | shallowCopy is one solution, although as you say I'd be concerned about safety there |
13:59:42 | * | derka quit (Ping timeout: 256 seconds) |
14:00:44 | * | yglukhov quit (Ping timeout: 272 seconds) |
14:00:48 | coffeepot | I guess I'd have to retrieve the address if possible or as you say shallowCopy to copy the ref |
14:02:47 | Jehan_ | If it's a side-effect free expression, I'd just use `template`. |
14:03:09 | * | Ven joined #nim |
14:03:15 | Jehan_ | And let the compiler deal with it during its CSE pass. |
14:04:01 | Jehan_ | About shallowCopy and safety: That's really only an issue if the rhs is immutable. |
14:04:26 | Jehan_ | I've been bugging Araq to have a safe version: shallowAssign[T](x, y: var T) or something like that. |
14:05:08 | coffeepot | Jehan_ shallowCopy: as I understand it the GC only collects on new allocations anyway and IIRC only outside of a proc so I guess that's okay for aliasing |
14:06:07 | Jehan_ | coffeepot: No, the problem occurs if the rhs is actually a constant. In that case, the GC code may try to mess with a reference count that is not actually there. |
14:06:21 | Jehan_ | That's unrelated to having a collection going on. |
14:07:11 | coffeepot | yeah it would be really nice to have some kind of 'real' way to demand a simple alias and avoid having to know what's going on behind the scenes. |
14:07:34 | coffeepot | Jehan_ ah ok well that's fair enough on the constant thing. |
14:07:41 | coffeepot | what do you mean by rhs btw? |
14:07:49 | Jehan_ | right-hand side. |
14:07:52 | coffeepot | ah! :D |
14:07:53 | Jehan_ | of the assignment. |
14:09:35 | coffeepot | I'm quite often aliasing in my code and didn't realise it until I got into Nim |
14:11:17 | coffeepot | using a template does save typing but would still take the lookup hit if the expression is complex |
14:11:36 | coffeepot | unless the 'CSE' pass can solve this for me? |
14:11:48 | * | vendethiel joined #nim |
14:13:22 | * | derka joined #nim |
14:14:23 | coffeepot | or the copy hit if you're making a var. I guess at that point though you'd have to think about using a ref for the thing that's accessed, which is not always wanted |
14:15:05 | * | lompik quit (Ping timeout: 245 seconds) |
14:22:22 | Jehan_ | CSE = common subexpression elimination. You can count on modern compilers optimizing that away. |
14:22:36 | Jehan_ | Unless you do weird side-effecty stuff as part of it. |
14:22:44 | * | endragor quit (Remote host closed the connection) |
14:24:18 | coffeepot | well that's nice to know. I guess the main thing is just to profile stuff and sort any hot loops out as they turn up. Trouble is for me, the profiler doesn't go very deep into the stack trace so whilst I can find slow procs, it's not always obvious why they're slow (at least in my toy game project) |
14:26:35 | * | Jehan_ quit (Quit: Leaving) |
14:27:54 | * | yglukhov joined #nim |
14:32:30 | * | vendethiel quit (Ping timeout: 260 seconds) |
14:44:13 | * | vendethiel joined #nim |
14:48:31 | * | irrequietus joined #nim |
14:51:44 | * | Jehan_ joined #nim |
14:57:46 | * | endragor joined #nim |
15:04:31 | * | Ven quit (Disconnected by services) |
15:05:16 | * | Ven_ joined #nim |
15:05:56 | * | vendethiel quit (Ping timeout: 240 seconds) |
15:06:06 | * | gokr quit (Quit: Leaving.) |
15:07:29 | * | endragor quit (Remote host closed the connection) |
15:20:35 | flyx | is there a possibility to peek onto an iterator (inspect the next element without advancing the iterator)? I would guess not, but before I rewrite my API completely, it may be good to ask |
15:26:32 | * | krux02 joined #nim |
15:28:08 | filwit | flyx: just do the reverse and store the previous element, then compare against the current |
15:28:43 | * | vendethiel joined #nim |
15:29:04 | krux02 | in scala a block evaluates to it's last expression. I there is simalar construct in nim, too? |
15:29:41 | coffeepot | krux02: can you use a template? |
15:30:36 | krux02 | I would like to create an object, apply some procs on it and then have that value in a single expression |
15:31:07 | coffeepot | sounds like a template would work for this |
15:31:18 | * | arnetheduck quit (Ping timeout: 272 seconds) |
15:31:22 | krux02 | in javascript that pattern is often done with anonymous functions that are evealuated in place |
15:32:20 | krux02 | ok, but somehow I do not know how |
15:32:39 | coffeepot | a starter: http://nim-lang.org/docs/tut2.html#templates |
15:32:40 | * | arnetheduck joined #nim |
15:32:49 | coffeepot | :) |
15:33:18 | krux02 | in c++ I could use the comma operator (can't be uglier, but it does what I want) |
15:33:36 | coffeepot | more info in the manual ofc here http://nim-lang.org/docs/manual.html#templates |
15:34:44 | krux02 | I know that tutorial, and I basically know how templates work, but still I have no idea how you think the solution looks like |
15:34:56 | krux02 | best i put some example |
15:35:09 | filwit | krux02: yeah that works in Nim: let x = (var y: int; foo(i); i) |
15:35:54 | filwit | which is basically the same as using a template like coffeepot suggested |
15:36:07 | krux02 | filwit: ok, thank you a lot, that looks exactly like what I want to have, even though I think it is as ugly as the c++ comma operator |
15:36:55 | krux02 | coffeepot just suggested templates, you gave an example so it actually helped me |
15:37:29 | filwit | well the ugly syntax is why you use a template.. that expression syntax is very useful for macros though |
15:37:33 | coffeepot | something like this? https://gist.github.com/coffeepots/82255e018d146b061465 |
15:38:28 | filwit | btw, all procedures in nim evaluate to their last expression, not just templates |
15:39:21 | * | Varriount quit (Disconnected by services) |
15:39:21 | * | Varriount_ joined #nim |
15:40:39 | coffeepot | or rather this https://gist.github.com/coffeepots/7ee94e112f7efc9f04a7 |
15:41:03 | coffeepot | the first one had an error :) |
15:41:26 | * | arnetheduck quit (Ping timeout: 240 seconds) |
15:41:29 | * | pregressive joined #nim |
15:42:36 | krux02 | filwit: the problem is that block is not an expression that evaluates to their last expression |
15:43:09 | krux02 | is scala every block, independantly where it is used, is an expression that evaluates to it's last expression |
15:43:51 | * | derka quit (Quit: derka) |
15:44:29 | filwit | I don't understand.. you mean the literal 'block' keyword in Nim? |
15:44:31 | coffeepot | you could probably make a construct using a template that acts like a block and evals to an expr if you pass the stmt type as a parameter to the template |
15:46:05 | coffeepot | not quite sure on the semantics of that tho |
15:46:22 | flyx | filwit: but then the item is not in the iterator anymore. |
15:46:22 | coffeepot | *syntax I mean |
15:47:00 | * | Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
15:47:03 | flyx | filwit: currently, I'm creating a new iterator which first returns the previously returned element and then iterates over the original iterator |
15:48:02 | * | Varriount joined #nim |
15:48:14 | filwit | flyx: i'm not following that exactly.. but I need to focus more on other things now |
15:48:40 | * | nikesprint joined #nim |
15:48:50 | krux02 | # I think this should work, but it doesn't |
15:48:50 | krux02 | let ii = block: |
15:48:50 | krux02 | var i = 0 |
15:48:50 | krux02 | foo(i) |
15:48:50 | krux02 | i |
15:49:05 | flyx | filwit: that's fine, thanks for answerin |
15:49:18 | def- | krux02: no, blocks don't return anything, procs and templates can |
15:49:38 | * | Varriount_ quit (Ping timeout: 256 seconds) |
15:49:55 | * | nikesprint left #nim (#nim) |
15:50:03 | coffeepot | i tried to work out a template that takes a stmt and returns and expr but don't know how that would work :/ |
15:50:26 | * | vendethiel quit (Ping timeout: 250 seconds) |
15:51:09 | krux02 | luckyly I can write a macro that transforms the block thing in the (;;)-representation |
15:51:41 | coffeepot | krux02: cool! :D |
15:51:51 | krux02 | that I like a lot in nim, I can just write a macro that rewrites everything how I want it :D |
15:51:57 | coffeepot | i still think it could be done with templates but don't know enough :/ |
15:52:18 | coffeepot | yeah I must say metaprograming is amazing in nim |
15:53:44 | * | vendethiel joined #nim |
15:54:06 | krux02 | coffeepot: the question would be, could it be done with a single template for all occurances where I want a block to evaluate to it's last element? Because I do not like to introduce a template for each, because I somhow fear name collisions |
15:54:44 | krux02 | the reason I want this construct, is because I do not want to introduce more variables or names or anything in global scope |
15:56:20 | krux02 | so a solution where I introduce a template each time I want to avoid creating a variable is somewhat not what I want. |
15:56:22 | filwit | krux02: templates in Nim are hygienic, meaning they don't inject their variables into their callers scope so you wont get name collisions (unless you use the {.dirty.} pragma on them to prevent that) |
15:56:52 | krux02 | filwit: yes but the template itself still has a name that can collide |
15:57:16 | filwit | oh i see, sorry I'm barely following chat right now.. |
15:59:19 | coffeepot | krux02: I don't see why not. So to summarise, you want a single named template (or similar) that takes a list of statements (like block:), and returns an expression? |
16:00:07 | coffeepot | perhaps it would look like this? var result = exprBlock: ... list of statements ending with an expression, which then gets evaluated and put into result? |
16:00:48 | krux02 | yes |
16:01:32 | krux02 | I would like to have something that looks like `block:`, but returns a StmtListExpr |
16:02:41 | Jehan_ | krux02: Not sure I'm following. For what it's worth, any statement list (in a block or otherwise) evaluates to the result of the last statement in the list. |
16:03:11 | * | dom96_ joined #nim |
16:04:01 | * | dom96 quit (Ping timeout: 240 seconds) |
16:04:01 | * | dom96_ is now known as dom96 |
16:04:03 | flyx | coffeepot: like this? https://gist.github.com/flyx/e5325e40e11eb14eba9f |
16:04:27 | * | Sornaenst joined #nim |
16:04:43 | coffeepot | flyx: that looks like the job! I tried it with generics and broke the compiler :/ |
16:05:13 | flyx | personally, I always found the do notation a bit awkward. |
16:05:36 | coffeepot | i've never used it, what's it ... uh... do? |
16:06:08 | * | vega_nsk joined #nim |
16:06:09 | krux02 | coffeepot: somewhat, just with the difference that the final value of i is returned and can be assigned to a let variable, and no other variable will be introduced |
16:06:16 | flyx | it basically allows you do specify a block as input parameter to a proc/template |
16:07:03 | flyx | I use it sometimes within macros, because it's convenient for generating code without having to build it with the macros API |
16:07:19 | krux02 | but for some reasons, in macros you do not need to write the `do |
16:07:29 | coffeepot | flyx: sounds like exactly what krux02 needs |
16:08:28 | * | filcuc_ joined #nim |
16:08:29 | coffeepot | krux02 I think the problem is how to separate out a stmt into the last expression, but as Jehan_ says, the result is an expr anyway |
16:09:09 | flyx | according to the manual, it is even able to take multiple stmts: http://nim-lang.org/docs/manual.html#procedures-do-notation |
16:09:58 | * | BlaXpirit_ joined #nim |
16:10:56 | coffeepot | huh, well today I learned, cheers flyx. Nim has a lot of interesting things to learn |
16:11:19 | flyx | I also found it more by chance |
16:14:30 | * | vegansk quit (*.net *.split) |
16:14:30 | * | Sornaensis quit (*.net *.split) |
16:14:31 | * | BlaXpirit quit (*.net *.split) |
16:14:31 | * | filcuc quit (*.net *.split) |
16:14:32 | * | dv-_ quit (*.net *.split) |
16:14:41 | * | BlaXpirit_ is now known as BlaXpirit |
16:15:23 | Jehan_ | I'm still not sure why `block:` isn't good enough? If I understand the question correctly? |
16:16:45 | * | vendethiel quit (Ping timeout: 245 seconds) |
16:17:12 | ephja | it can't be used as an expression |
16:17:23 | Jehan_ | ephja: It can. |
16:17:39 | Jehan_ | let a = (block: |
16:17:39 | Jehan_ | var x = 1 |
16:17:39 | Jehan_ | echo x |
16:17:39 | Jehan_ | x) |
16:18:48 | ephja | someone said it couldn't. you don't need the parentheses with 'if' though |
16:21:22 | * | dv- joined #nim |
16:27:33 | ephja | coffeepot: just keep it readable ;) a lot of code contains too much magic and too few module qualifications |
16:27:48 | coffeepot | so, with what Jehan_ said, you could do this maybe? https://gist.github.com/coffeepots/dc9adcb029e8c53a2e4e |
16:28:44 | coffeepot | ephja: yeah more readable is very important! |
16:30:16 | coffeepot | ^^ gist is only if you don't want to have brackets |
16:30:55 | coffeepot | honestly though, not sure if this is an improvement, a bit hard to read the flow imo |
16:31:07 | Jehan_ | For what it's worth, it may be possible to sweet-talk the parser in accepting a block without parentheses. |
16:32:19 | ephja | though in some cases it wouldn't matter, with the presence of semantic analysis |
16:34:27 | * | vendethiel joined #nim |
16:34:38 | flyx | when I define a concept type, can I define pragmas for the procs? |
16:34:52 | flyx | i.e. can I define „there must be a proc with {.raises:[].} |
16:35:45 | ephja | a high quality engine of which takes a ton of man hours to create apparently |
16:37:01 | * | Varriount quit (Ping timeout: 276 seconds) |
16:37:40 | Araq | flyx: nah. |
16:39:41 | ephja | no ever did a "s/\<nimrod\>/nim/g"? ;) |
16:40:27 | Araq | it used to be more complex :P |
16:40:48 | Araq | for example, you cannot rename magics this way or bootstrapping breaks |
16:43:36 | ephja | the methods used seem to have been rather crude in any case, but only a few instances left now :p |
16:43:41 | * | gour quit (Quit: WeeChat 1.3) |
16:45:58 | ephja | compiler/commands.nim: result = unixToNativePath(p % ["nimrod", getPrefixDir(), --- compiler/nimconf.nim: projectConfig = changeFileExt(gProjectFull, "nimrod.cfg") |
16:46:17 | * | vendethiel quit (Read error: Connection reset by peer) |
16:46:27 | * | vendethiel joined #nim |
16:46:33 | * | gour joined #nim |
16:46:37 | ephja | ok so it checks in multiple dirs. nevermind |
16:56:10 | * | vendethiel quit (Ping timeout: 272 seconds) |
16:58:01 | * | filcuc_ quit (Read error: Connection reset by peer) |
16:59:24 | * | gour quit (Quit: WeeChat 1.3) |
17:03:24 | ephja | Araq: what about this one: result = options.completeGeneratedFilePath("nimrod.gid") |
17:03:43 | ephja | and the identifier for code-block |
17:04:30 | Araq | PRs are always welcome |
17:05:44 | ephja | working on it |
17:13:08 | * | coffeepot quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
17:30:52 | * | brson joined #nim |
17:33:26 | Xe | Hmm, is there a simple example on how to embed nimscript into an arbitrary nim program? |
17:34:40 | * | Jehan_ quit (Quit: Leaving) |
17:35:33 | * | nande joined #nim |
17:38:30 | * | vendethiel joined #nim |
17:47:35 | * | yglukhov quit (Ping timeout: 264 seconds) |
18:06:12 | * | nande quit (Remote host closed the connection) |
18:06:43 | * | vendethiel quit (Ping timeout: 276 seconds) |
18:12:24 | * | sheerun joined #nim |
18:23:10 | * | vendethiel joined #nim |
18:23:44 | Araq | Xe: look at how nimble does it |
18:23:49 | Araq | nimble is open source |
18:35:17 | * | yglukhov joined #nim |
18:39:38 | * | yglukhov quit (Ping timeout: 256 seconds) |
18:39:52 | * | Wildefyr quit (Ping timeout: 250 seconds) |
18:44:06 | * | vendethiel quit (Ping timeout: 245 seconds) |
18:53:57 | * | jsudlow quit (Read error: Connection reset by peer) |
18:56:51 | * | jaco60 joined #nim |
19:02:45 | * | lompik joined #nim |
19:28:48 | * | BitPuffin quit (Ping timeout: 272 seconds) |
19:32:56 | * | lompik quit (Ping timeout: 240 seconds) |
19:38:08 | * | gokr joined #nim |
19:39:59 | * | vendethiel joined #nim |
19:43:22 | * | Matthias247 joined #nim |
19:46:25 | * | Matthias247 quit (Read error: Connection reset by peer) |
19:47:48 | * | Matthias247 joined #nim |
19:56:00 | * | yglukhov joined #nim |
20:02:45 | * | vendethiel quit (Ping timeout: 240 seconds) |
20:02:46 | * | gokr quit (Quit: Leaving.) |
20:11:49 | * | nande joined #nim |
20:29:22 | yglukhov | Can nim output docs in rst? |
20:39:39 | Araq | yglukhov: not really |
20:39:58 | yglukhov | ok thanks |
20:45:29 | * | desophos joined #nim |
20:45:43 | * | Varriount joined #nim |
20:51:26 | * | yglukhov quit (Remote host closed the connection) |
20:53:43 | * | gokr joined #nim |
20:55:17 | * | theduke_ quit (Remote host closed the connection) |
20:55:38 | * | Ven joined #nim |
20:57:43 | * | yglukhov joined #nim |
21:02:33 | * | Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
21:03:57 | * | Ven joined #nim |
21:08:20 | * | matkuki joined #nim |
21:09:14 | * | Varriount quit (Remote host closed the connection) |
21:19:14 | yglukhov | oh btw =) |
21:20:59 | yglukhov | i've been thinking about how nim + task + nims works, and i configured my projects to run tests via "nim test myproj.nims" and it seems to work pretty well. Unfortunately cant say the very same about nimble, because it has this not-yet-installed-dependency problem. |
21:21:47 | yglukhov | so now running tasks with nims is a pretty common pattern for me and i guess ill stick to it for the time being. |
21:23:19 | yglukhov | one slight incovenience though is the need to pass nims file name to nim invocation. would be much nicer to "nim tests" instead of "nim tests nimx.nims". what do you say? |
21:24:27 | ldlework | Araq: are methods going away for suresies? |
21:25:22 | * | tinAndi joined #nim |
21:27:09 | Araq | ldlework: no. but at the same time I don't want to spend more time on them |
21:28:11 | Araq | yglukhov: not sure we need yet another feature. use a bash alias perhaps? |
21:28:48 | ldlework | Araq: they've worked okay in the ways I've used them, do they have some bad cases |
21:29:08 | ldlework | if its a long answer just ignore the question |
21:29:10 | Araq | they don't work well with generics |
21:33:41 | * | Guest4360 is now known as zielmicha |
21:34:25 | yglukhov | Araq: bash alias is a bad answer for cross-platform team environment. seeing windows terminal on my collegues pc is a pain =) and thats why we're still using nake =) |
21:35:47 | yglukhov | but ok, not that critical if you dont like the idea |
21:39:36 | * | yglukhov_ joined #nim |
21:39:36 | * | yglukhov quit (Read error: Connection reset by peer) |
21:42:46 | * | desophos quit (Ping timeout: 252 seconds) |
21:43:12 | Araq | on windows I sometimes write batch files to shorten the stuff |
21:43:23 | * | yglukhov_ quit (Read error: Connection reset by peer) |
21:43:40 | * | yglukhov joined #nim |
21:49:27 | * | yglukhov quit (Read error: Connection reset by peer) |
21:49:31 | * | yglukhov_ joined #nim |
21:49:41 | * | Ven quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
21:50:41 | * | mat4 joined #nim |
21:50:44 | mat4 | hello |
21:50:51 | Araq | servus mat4 |
21:51:01 | mat4 | hi Araq |
21:51:17 | ldlework | hi mat4 |
21:51:25 | mat4 | and hello ldlework |
21:53:35 | * | yglukhov_ quit (Read error: Connection reset by peer) |
21:58:20 | mat4 | one question: Does one see the need for namespaces and implicit destructors (I guess though an destructor keyword or pragma) ? |
21:59:41 | * | yglukhov joined #nim |
22:01:22 | * | zaquest quit (Ping timeout: 256 seconds) |
22:03:53 | Araq | we have destructors but they are experimental and nobody pays me to make them work |
22:04:20 | Araq | and we have namespaces, it's just that people don't know what a namespace is |
22:04:27 | * | ldlework coughs. |
22:07:44 | * | junw_ joined #nim |
22:10:13 | * | vendethiel joined #nim |
22:11:18 | * | junw quit (Ping timeout: 250 seconds) |
22:14:31 | * | Demon_Fox joined #nim |
22:17:04 | Araq | 'from foo import nil' is exactly as annoying as you want it to be. |
22:17:26 | Araq | except that it's more consistent than you like to think about it. |
22:17:41 | Araq | that still doesn't mean that Nim lacks namespaces. |
22:21:05 | ephja | is there a 'find' proc that takes a predicate? |
22:24:36 | ldlework | ephja: http://nim-lang.org/docs/sequtils.html |
22:25:05 | ldlework | But maybe you're looking for the index? |
22:29:48 | ephja | ldlework: yep. actually, 'delete' taking a predicate would be more appropriate. I'll consider adding those. it sure would be nice to use 'var' in concepts though, so that a truly generic container interface could be added already |
22:30:16 | mat4 | Araq: That's different from the explicit encapsulation many are familiar with (C#, C++). Personally I never had any problem with name conflicts (side effect of hungarian notation) |
22:30:24 | ephja | please throw some money at zah ;) |
22:30:42 | ldlework | Actually 'import foo' is exactly as annoying as I want it to be. |
22:31:01 | Araq | mat4: no, it's really quite comparable to C# and C++ ... |
22:31:02 | ldlework | assuming it doesn't actually do 'from foo import *' |
22:31:46 | ldlework | but then you can't call functions with magic dot syntax |
22:31:55 | * | Varriount joined #nim |
22:32:24 | Araq | I don't feel like telling you again that Python is not better in any way in this respect and it's frankly much worse due to the dynamic typing. |
22:32:26 | ephja | ldlework: it means that qualifications are optional |
22:33:00 | ephja | (module name preceding symbols) |
22:33:25 | * | vendethiel quit (Ping timeout: 245 seconds) |
22:34:52 | Araq | ephja: 'var' in concepts is allowed |
22:35:10 | mat4 | Araq: I mean the explicit "namespace <name>" syntax ... 'feature' |
22:35:47 | ephja | still buggy I think |
22:36:17 | Araq | ah ok then. well I wanted to do 'submodule foo' but dom96 claimed he would leave Nim then if it gets added |
22:36:28 | * | irrequietus quit (Ping timeout: 250 seconds) |
22:36:30 | ephja | :o |
22:36:37 | Araq | but it means I would need a 'submodule' filter for nimble. |
22:36:56 | ephja | it's possible to work around it by using 'ptr' instead IIRC |
22:37:36 | Araq | so that nimble would not list any nimble package that uses 'submodule' |
22:38:03 | ldlework | dynamic typing has nothing to do with this |
22:38:13 | Araq | because I really loathe System.Text.RegularExpression.Regex more than you can love it :P |
22:39:27 | * | wuehlmaus quit (Quit: Lost terminal) |
22:39:30 | ldlework | I would take 'import foo' creating a name 'foo' and never being able to use first_arg.f(second_arg) |
22:39:36 | ldlework | but that's just me, I'm not complainign at all |
22:40:11 | * | Varriount_ joined #nim |
22:40:28 | * | Varriount quit (Ping timeout: 256 seconds) |
22:40:59 | ldlework | having 'import foo' actually mean 'from foo import *' tends to work out fine, because of function overloading or whatever its called. |
22:41:13 | * | Varriount_ quit (Read error: Connection reset by peer) |
22:41:36 | * | irrequietus joined #nim |
22:41:37 | * | tinAndi quit (Quit: ChatZilla 0.9.92 [Firefox 43.0.4/20160105164030]) |
22:43:19 | * | vendethiel joined #nim |
22:47:24 | * | Varriount joined #nim |
22:47:52 | * | sheerun quit () |
22:48:41 | * | Varriount quit (Client Quit) |
22:49:01 | * | Varriount joined #nim |
22:49:22 | * | Ven joined #nim |
22:52:08 | * | Ven quit (Client Quit) |
22:57:14 | * | matkuki quit (Quit: ChatZilla 0.9.92 [Firefox 44.0/20160123151951]) |
23:01:28 | * | yglukhov_ joined #nim |
23:01:28 | * | yglukhov quit (Read error: Connection reset by peer) |
23:02:53 | * | Ven joined #nim |
23:04:49 | * | Ven quit (Client Quit) |
23:05:58 | * | vendethiel quit (Ping timeout: 256 seconds) |
23:06:56 | * | saml quit (Remote host closed the connection) |
23:17:23 | * | desophos joined #nim |
23:18:52 | * | pregressive quit () |
23:48:39 | * | irrequietus quit () |
23:48:46 | * | mat4 quit (Quit: Verlassend) |
23:57:37 | * | lompik joined #nim |