00:16:43 | shashlick | @rayman22201 how will hcr help |
00:17:21 | rayman22201 | instead of dlls, your plugins become HCR modules |
00:18:44 | rayman22201 | but I guess you need some way to detect entirely new modules, not just module changes.... so actually, nvm |
00:19:52 | rayman22201 | actually. as long as the "main" module doesn't change, you can add new imports and do this. |
00:21:51 | rayman22201 | can a macro define an import? |
00:23:02 | rayman22201 | nvm. It would be very hacky |
00:25:27 | shashlick | It's not about the plugins |
00:25:36 | shashlick | That works fine without hcr |
00:25:45 | shashlick | Predates it by a couple months |
00:26:21 | shashlick | In my main module itself, I need to share strings and seqs across threads |
00:28:07 | rayman22201 | oh I see |
00:28:37 | rayman22201 | I thought it was your plugins that caused the problem. I misunderstood. |
00:28:39 | * | abm quit (Quit: Leaving) |
00:29:09 | rayman22201 | then, newruntime is really your best bet |
00:29:30 | shashlick | well problem is that newruntime isn't targeted at 1.0 |
00:29:42 | shashlick | so we need some sharing support until then |
00:30:46 | rayman22201 | maintaining a fork with your own version of seq and string doesn't seem great either. |
00:31:10 | shashlick | not doing that, doesn't seem sensible to mess with compiler when a real solution is in the works |
00:31:23 | shashlick | am thinking of creating a sharedString type |
00:31:41 | rayman22201 | Yeah. making your own userspace datastructure is probably your best bet. |
00:31:52 | rayman22201 | as annoying as that is |
00:32:21 | * | rayman22201 overuses the phrase "best bet" |
00:32:41 | shashlick | i was thinking of wrapping libck |
00:32:46 | shashlick | but that starts at arrays |
00:35:28 | rayman22201 | you are kind of stuck with manual memory management either way. |
00:36:28 | shashlick | yep |
00:36:38 | rayman22201 | :sadpanda" |
00:37:57 | shashlick | how do you override =destroy |
00:38:27 | shashlick | Error: signature for '=destroy' must be proc[T: object](x: var T) |
00:39:20 | rayman22201 | can you share your destroy proc definition? |
00:41:37 | shashlick | proc `=destroy`*(ss: var sharedString) = |
00:42:56 | shashlick | never mind |
00:43:58 | rayman22201 | ok |
00:48:14 | shashlick | how do you say string|cstring and default initialize for a proc param |
00:49:57 | shashlick | never mind, nim implicitly converts anyway |
01:00:56 | shashlick | well its coming along |
01:03:43 | FromGitter | <zetashift> @SychoRyn did you get it to install? You might also be easier off with choosenim: https://github.com/dom96/choosenim |
01:07:49 | FromDiscord_ | <SychoRyn> I'll check out choosenim |
01:08:19 | * | rayman22201 was waiting for the pastebin |
01:08:31 | shashlick | well, actually you can use =destroy only on an object and a sharedString has to be allocShared itself so it has to be a pointer |
01:13:07 | rayman22201 | You can wrap the shared pointer in a type that is regular alloc'ed. Then the type does DIY ref counting in the destructor |
01:14:30 | shashlick | right but then that type is on the threadlocal heap |
01:14:33 | shashlick | and cannot be shared |
01:15:38 | rayman22201 | to "share" it, you copy the type to the new thread, and increase the ref count (which is also shared). |
01:16:31 | shashlick | so the bucket is copied but the contents are shared? |
01:16:35 | rayman22201 | yup |
01:16:57 | rayman22201 | That's one solution I can think of anyway |
01:20:22 | shashlick | well, the contents can change so i want the bucket to be shared too |
01:20:30 | shashlick | i guess i cannot avoid the explicit destroy |
01:21:02 | shashlick | which will be ugly since you use strings often and each one will need to be explicitly destroyed |
01:21:31 | shashlick | unfortunately destroy is restricted to objects |
01:22:38 | rayman22201 | well, that is a type safety thing. dangerous to destroy a pointer that you can't prove size info about. |
01:24:12 | rayman22201 | you can get around the changing buckets limitation by defering deletes, and having your shared pointers be linked lists. |
01:25:13 | rayman22201 | perf is probably going to start to suffer here though. it starts to become a lot of overhead. |
01:26:48 | shashlick | looks like the opposite - the contents can change, but the bucket stays the same so both threads have a pointer to the same bucket |
01:30:37 | * | mal`` quit (Quit: Leaving) |
01:31:52 | rayman22201 | yeah. the only real change you care about is a resize. Instead of keeping a `ref: sharedString`inside each threads bucket, you keep `ref: sharedStringLinkedListNode`. |
01:31:52 | rayman22201 | The linked list node has an "invalid" flag, which tells you to go to the next node. (This is all shared memory, so the nextNode field is available to all threads) |
01:31:52 | rayman22201 | On a resize, you make a new `sharedStringLinkedListNode`, marks the old one as invalid (but doesn't free the memory). |
01:31:52 | rayman22201 | When the local thread goes the read the string, it first checks the ptr to see if it's still valid, if it isn't it updates it's internal pointer to the latest node. |
01:34:45 | rayman22201 | And you can't delete a linked list node until you know that no thread has a reference to it |
01:35:22 | rayman22201 | (so each node has it's own ref count I suppose) |
01:41:09 | * | mal`` joined #nim |
01:44:35 | rayman22201 | Every read, write, and destroy has to wrapped for this to work. Override all the operators lol |
02:05:03 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
02:09:46 | rayman22201 | This would replace the shared bucket. Instead of a shared bucket, each thread gets it's own bucket, that is backed by the shared linked list. The coordination and automatic memory management is then taken care of by overriding the necessary operators (including `destroy`, which allows you to hook into the thread local gc). |
02:09:52 | rayman22201 | it's very C++ like actually |
02:11:25 | rayman22201 | It's complicated as hell to implement and get right, but it will give you automatic memory management. (no explicit destroys). |
02:14:59 | rayman22201 | I also have no idea what the perf cost would be. It is probably going to be slower than the stdlib string, and it's definitely slower than just doing the explicit memory management yourself. IDK how much slower though. It might be ok, depending on your use case. |
02:15:07 | * | rayman22201 is now just rambling |
02:18:45 | rayman22201 | It will be very safe (in the Rust sense of the word). Safer than libck |
02:27:33 | shashlick | Sorry dinner, brb |
02:28:41 | rayman22201 | no worries |
02:33:00 | FromDiscord_ | <SychoRyn> Nim is cool so far |
02:37:14 | rayman22201 | I guess that means you got it to install successfully ๐ |
02:37:27 | rayman22201 | yay |
02:57:42 | * | deech_ joined #nim |
02:58:20 | * | dddddd quit (Remote host closed the connection) |
03:03:27 | shashlick | @rayman22201 - in my case, I just want to sync two threads, so that might be overkill |
03:03:58 | shashlick | i could just use channels and make up some bogus language but that annoys me |
03:04:18 | shashlick | nim already has sharedlist so could leverage that for your idea |
03:06:15 | * | leorize quit (Ping timeout: 256 seconds) |
03:07:43 | * | NimBot joined #nim |
03:11:18 | * | leorize joined #nim |
03:12:10 | * | deech_ quit (Remote host closed the connection) |
03:16:46 | rayman22201 | Pick your poison lol |
03:29:12 | * | theelous3 quit (Ping timeout: 245 seconds) |
03:54:06 | * | fjellfras joined #nim |
04:07:27 | FromDiscord_ | <SychoRyn> guys |
04:07:29 | FromDiscord_ | <SychoRyn> I made a great program |
04:07:57 | FromDiscord_ | <SychoRyn> https://pastebin.com/TyGck40c |
04:29:13 | * | envoyt quit (Ping timeout: 245 seconds) |
04:29:55 | * | envoyt joined #nim |
04:32:08 | * | nsf joined #nim |
04:35:24 | * | arecaceae quit (Remote host closed the connection) |
04:35:43 | * | arecaceae joined #nim |
05:23:34 | * | narimiran joined #nim |
05:27:42 | * | leorize quit (Quit: WeeChat 2.3) |
05:28:42 | * | sentreen quit (Ping timeout: 268 seconds) |
05:31:32 | * | envoyt quit (Ping timeout: 272 seconds) |
05:31:53 | * | envoyt joined #nim |
05:55:00 | * | sentreen joined #nim |
05:57:26 | * | leorize joined #nim |
06:21:40 | * | leorize quit (Quit: WeeChat 2.3) |
06:26:13 | * | rokups joined #nim |
06:29:14 | * | leorize joined #nim |
06:30:16 | rokups | are -d:useMalloc and -d:nogc documented anywhere? i cant find it |
06:30:36 | leorize | nogc is --gc:none |
06:31:03 | leorize | -d:useMalloc is currently undocumented, but when used with --newruntime it'll use the OS's malloc instead of Nim's allocator |
06:31:09 | * | PMunch joined #nim |
06:32:41 | rokups | how is memory freed with --gc:none? |
06:32:55 | leorize | memory is not freed with --gc:none |
06:33:02 | leorize | it's discouraged to use --gc:none |
06:33:11 | leorize | --newruntime is aiming to be a better --gc:none |
06:34:21 | leorize | an another alternative to --gc:none is --gc:regions |
06:34:44 | leorize | memory is allocated within a region and the entire region is freed at one time |
06:34:57 | leorize | unfortunately there aren't any docs for this gc mode |
06:35:21 | rokups | are garbage collectors documented anywhere? i again cant see any descriptions of all these values that can be passed to --gc |
06:36:11 | * | drewr quit (Ping timeout: 248 seconds) |
06:36:12 | rokups | `--gc:refc` sounds very much like objects being refcounted, but i suspect there is a catch |
06:36:49 | leorize | it's slow :p |
06:36:51 | leorize | and it's the default |
06:37:13 | leorize | refc is a deterred refcounting gc iirc |
06:37:53 | leorize | https://nim-lang.org/docs/nimc.html |
06:38:02 | PMunch | leorize, it's not that slow |
06:38:08 | leorize | ^ this should cover some switches |
06:38:29 | leorize | yea, still faster than --newruntime the last time I checked :p |
06:38:38 | rokups | anyway im looking for a combination of flags to use with function hooking. i guess it must be `--gc:none --newruntime` as per message in forum. you said memory is not freed with that gc which cant be right .did you mean memory is meant to be freed manually? |
06:39:04 | leorize | --newruntime implies --gc:destructor |
06:39:13 | leorize | this is a brand new operation mode |
06:39:32 | leorize | but what are you trying to do? |
06:39:36 | rokups | so how is it supposed to be used? |
06:40:14 | leorize | just add --newruntime :p |
06:40:29 | leorize | https://nim-lang.org/araq/ownedrefs.html |
06:40:37 | leorize | ^ that's the original proposal for newruntime |
06:40:58 | * | drewr joined #nim |
06:41:02 | PMunch | rokups, with gc:none you get a warning every time you use a garbage collected structure (like string, or seq). And you can do you own memory management. Mostly useful for things like microcontrollers and super performance critical stuff that will actually get tested for leaks |
06:41:21 | rokups | yeah i misspoke. it was `--newruntime -d:useMalloc` |
06:41:46 | rokups | so using these no manual memory management is needed and objects are destroyed when they go out of scope? |
06:41:55 | rokups | even ref objects? |
06:42:14 | leorize | yea, see that blog I linked above |
06:42:22 | rokups | alright, thanks |
06:42:37 | leorize | it's worth noting that --newruntime is... new |
06:42:57 | leorize | and there are many bugs, like not working well with closures |
06:43:00 | Araq | rokups, try hcr.rst? |
06:43:36 | Araq | I documented how it works, it works with the old runtime (but will also work with the new runtime) |
06:43:36 | rokups | where is that? certainly not in Nim repo |
06:44:12 | Araq | https://raw.githubusercontent.com/nim-lang/Nim/devel/doc/hcr.rst |
06:44:16 | Araq | it's new |
06:44:22 | rokups | leorize: yeah i realize that. just testing waters. in the past Nim was absolutely nogo for this specific usecase im after, now it is becoming viable |
06:44:33 | leorize | https://nim-lang.github.io/Nim/hcr |
06:44:39 | leorize | ^ doc's up |
06:45:03 | PMunch | rokups, what is your specific usecase? |
06:45:25 | rokups | function hooking in foreign processes |
06:47:23 | PMunch | For any specific scenario? And why does that mean you can't use the GC (don't know much about how that works under the hood, sorry if that's a really obvious question) |
06:48:07 | rokups | code implemented in nim would be called by some random thread that GC is not aware of |
06:48:33 | Araq | there is setupForeignThreadGc() or whatever it's called |
06:49:10 | PMunch | nim-lang.org/docs/system.html#setupForeignThreadGc.t |
06:49:21 | rokups | i cant say i trust GC very much to run in such conditions. who knows what could go wrong |
06:49:21 | PMunch | Documentation on that is a bit... sparse |
06:49:34 | Araq | Edit button! |
06:49:43 | * | Vladar joined #nim |
06:49:57 | PMunch | Well I sorta knows what it does, but certainly not enough to write documentation for it.. |
06:50:07 | Araq | fair enough |
06:50:33 | leorize | there's already documentation for it... |
06:50:39 | leorize | just that it's not exposed to nimdoc |
06:51:07 | leorize | a simple change should be enough |
06:52:00 | Araq | hmmm Source links are wrong, probably because 'master' is dead |
06:52:06 | Araq | narimiran, ? |
06:52:07 | PMunch | Ah, it's the classic documentation was created without the required switches issue: https://github.com/nim-lang/Nim/blob/master/lib/system/gc_common.nim#L200-L234 |
06:52:19 | Araq | yup |
06:52:56 | PMunch | Hmm, it would be cool if Nim could create sections for that in the output |
06:54:04 | PMunch | Not entirely sure what the output would be though |
06:54:21 | leorize | for now `or defined(nimdoc)` works well enough :p |
06:54:38 | PMunch | Maybe when branches could get a `docswitch` pragma that takes some explanation |
06:55:51 | PMunch | leorize, oh yeah, for this that works fine. But take eg. some cross platform code that does slightly different things between Windows and Linux. |
06:56:02 | PMunch | So you can't easily just choose one of the branches |
06:56:15 | leorize | a nimdoc branch with detailed doc ftw |
06:57:10 | Araq | just fix the issue, don't introduce more machinery that we can get wrong |
06:57:18 | Araq | 'when defined(nimdoc)' is fine |
06:57:46 | Araq | and doc comments can already outline platform specific behaviour |
06:57:50 | PMunch | Come to think of it you can do most of it with just defined(nimdoc), but maybe Nim should at least throw a warning when you generate documentation that are missing pieces? |
06:58:17 | narimiran | Araq: yeah, source links are wrong, we need to patch docgen.nim:683, but i'm not sure how to make it both simple and effective |
06:58:19 | PMunch | I think a lot of people (myself included) just forget that this will happen |
06:58:21 | leorize | an optional [ExportedButNoDoc] hint? |
06:58:35 | Araq | for the stdlib, yeah, for other projects it can be fine to not have doc comments |
06:58:48 | Araq | ideally everything there is to say is in the proc type declaration already |
06:59:01 | Araq | and no informal description is required :P |
06:59:22 | * | Araq remembers Eclipse writing doc comments for him |
06:59:40 | PMunch | leorize, ExportedButNoDoc would help, but I was more thinking of DocumentedButSwitchedAway |
07:00:00 | * | gmpreussner quit (Quit: kthxbye) |
07:00:01 | * | PMunch shudders at Araqs mention of Eclipse doc comments |
07:00:02 | leorize | looks like when --threads:on, setupForeignThreadGc is a proc instead of a template :p |
07:00:21 | PMunch | Yes, and that might be a bit confusing :P |
07:00:26 | Araq | it's beautiful :P |
07:00:31 | PMunch | I mean it makes perfect sense |
07:00:46 | PMunch | (The template vs. proc, not the doc comments in Eclipse) |
07:02:07 | PMunch | I was talking to someone the other day about doc comments by the way, and one thing Nim doesn't have is a formalized way to outline what a parameter is, and what the return value is. Although with its expressive type system I hardly ever find the need to explain them anyways |
07:02:44 | PMunch | rokups, sorry for derailing the chat :P |
07:03:41 | PMunch | Hmm, are you supposed to have setupForeignThreadGc at the start of a callback and tearDownForeignThreadGc at the end? |
07:03:50 | Araq | no |
07:03:54 | PMunch | Or is tearDownForeignThreadGc used for something else? |
07:03:58 | PMunch | Ah |
07:03:59 | Araq | don't call tearDownForeignThreadGc |
07:04:05 | PMunch | Ever? |
07:04:43 | * | gmpreussner joined #nim |
07:05:24 | FromGitter | <gogolxdong> I've made hcr.rst compile with latest sdl2, does this need a PR? |
07:06:18 | rokups | im not sure its a good idea to have a gc in such situations anyhow. there is no knowing when code will be called again (if ever). and gc touching random memory might become a problem when these hooks must remain as invisible as possible |
07:07:12 | leorize | the docs said "the GC for this thread will only be initialized once per thread, no matter how often it is called." |
07:08:33 | rokups | sounds like gc uses thread-local variables for some state too. another reason to avoid it ^_^ |
07:08:52 | * | krux02 joined #nim |
07:08:59 | leorize | Araq: done https://github.com/nim-lang/Nim/pull/11536 |
07:10:42 | PMunch | rokups, it should work fine. setupForeignThreadGC is literally meant to do exactly what you need. The GC won't touch memory that it isn't in charge of, and if you need to pass memory to or from some other code you can use GC_ref and GC_unref. |
07:11:18 | * | laaron- quit (Remote host closed the connection) |
07:11:33 | rokups | gc would still scan stack when hook is called. or not scan anything and free anything if hook is not called |
07:12:57 | PMunch | Well yes, that is how GCs work. If the hook is called often enough that it actually acrues some amount of memory it will also be freed. But if is called very seldom and it doesn't allocate a lot of memory it will just be left there |
07:12:59 | rokups | further more if one thread calls multiple hooks then gc will start scanning stack that belongs to parent native application too which may or may not be a problem. this is a touchy subject ^_^ |
07:13:17 | PMunch | The same way you don't empty your trash can every day, but only once it gets full |
07:13:31 | leorize | it won't be a problem :p |
07:13:44 | * | laaron joined #nim |
07:14:06 | PMunch | The GC will only scan memory that it has allocated I think |
07:14:21 | PMunch | So it won't go ham and just scan through all you memory willy nilly |
07:14:26 | rokups | GC scans stack for pointer it has allocated |
07:14:39 | rokups | and it scans from the stack top to the current position |
07:14:51 | PMunch | Ah yes, it will scan the stack |
07:15:24 | rokups | call me memory nazi but i prefer to have explicit control in this kind of setting |
07:15:44 | PMunch | Not actually sure how that works with setupForeignThreadGC, will it still scan the entire stack, even from before that call? |
07:16:04 | leorize | the code is really simple, actually |
07:16:10 | PMunch | Well then gc:none and manually managing it is probably your best bet :) |
07:16:18 | leorize | https://github.com/nim-lang/Nim/blob/devel/lib/system/gc_common.nim#L160 |
07:16:34 | PMunch | But I don't think it's necessary |
07:16:51 | leorize | one thing for sure, the GC won't corrupt memory :p |
07:16:53 | rokups | it wont, but if say we are in situation such as: [hook_a call][some parent app code calls[hook_b call] then when hook_b is called gc could scan entire stack from hook_a to hook_b, including stack with data from parent app |
07:17:10 | PMunch | Ah yes, so it will only scan from wherever setupForeignThreadGC was called |
07:17:51 | leorize | aside from possible performance issue, I don't think there's any other problem |
07:19:09 | * | Trustable joined #nim |
07:19:16 | PMunch | Yeah, the GC is meant to scan your entire programs stack anyways, so scanning a frame or two from another program really shouldn't do much |
07:19:46 | leorize | my advice would be: try it first and see if there's any real problem |
07:20:25 | PMunch | Worst case scenario it points to some memory you have allocated, which isn't very likely, and you will have some memory that lingers about for a bit longer that it should |
07:22:30 | PMunch | Hmm, what does "thread local storage emulation" mean? (from `tlsEmulation`) |
07:22:47 | leorize | some OS doesn't have native tls support |
07:23:10 | leorize | so it's emulated with primitives like pthread_setspecific |
07:23:17 | PMunch | Aah |
07:30:13 | * | solitudesf joined #nim |
07:33:01 | * | lf-araujo joined #nim |
07:39:10 | * | leorize quit (Remote host closed the connection) |
07:46:23 | * | leorize joined #nim |
08:01:20 | leorize | looks like travis' OSX homebrew is totally broken |
08:01:32 | * | couven92 joined #nim |
08:02:01 | narimiran | leorize: yep |
08:02:30 | leorize | maybe open an issue at https://github.com/travis-ci/travis-ci/ ? |
08:04:24 | leorize | narimiran: I've spent some time to debug tfloatrange |
08:04:42 | leorize | the result is... idk, it just fails when it feels like it |
08:08:19 | Tanger | Hey folks, I'm trying to define a constructor for an object, but I get an error fro redefining the symbol. Pastebin here: https://pastebin.com/3WTpvNUF |
08:08:46 | leorize | yea, that's not how you define a constructor... |
08:08:58 | Tanger | Sorry, a casting function I guess |
08:09:26 | leorize | use `proc initMQTTByte` or toMqttByte instead |
08:10:07 | leorize | "constructor" in Nim doesn't really exist :p |
08:10:24 | leorize | also the object constructor is only available to object types |
08:10:59 | leorize | btw, with the playground working really well now, you can share code snippet there :) |
08:11:02 | Tanger | How is a Port object in nativesockets able to be cast from an int then leorize? ie 1337.Port. Wouldn't that be something like `proc Port(x:SomeUnsignedInteger)`? |
08:11:12 | Tanger | Oh yeah, I keep forgetting about the playground, thanks |
08:11:31 | leorize | no, it's just a normal conversion :p |
08:11:44 | Tanger | Ah, because it's a distinct uint? |
08:12:09 | leorize | https://nim-lang.org/docs/manual.html#statements-and-expressions-type-conversions |
08:12:37 | leorize | and https://nim-lang.org/docs/manual.html#type-relations-convertible-relation |
08:13:18 | leorize | and thanks to Nim's method call syntax |
08:13:30 | leorize | !eval uint8(8) == 8.uint8 |
08:13:32 | NimBot | Compile failed: /usercode/in.nim(1, 10) Error: expression 'true' is of type 'bool' and has to be discarded |
08:13:40 | leorize | !eval doAssert uint8(8) == 8.uint8 |
08:13:43 | NimBot | <no output> |
08:14:22 | Tanger | Thanks leorize, it's all clicking now |
08:19:35 | FromGitter | <kayabaNerve> leorize: Why echo over doAssert? |
08:19:59 | leorize | ? |
08:23:19 | * | floppydh joined #nim |
08:27:09 | FromGitter | <kayabaNerve> !eval echo uint8(8) == 8.uint8 |
08:27:12 | NimBot | true |
08:27:19 | FromGitter | <kayabaNerve> :thinking: |
08:30:57 | * | leorize quit (Ping timeout: 256 seconds) |
08:33:59 | * | leorize joined #nim |
08:49:46 | * | neceve joined #nim |
08:51:33 | * | dddddd joined #nim |
08:59:00 | * | leorize quit (Remote host closed the connection) |
09:08:05 | * | leorize joined #nim |
09:28:46 | leorize[m] | narimiran: looks like cirrus Windows VMs have at least 4 cores |
09:29:19 | leorize[m] | but they don't have live console, so... we have to wait for a step to finish before it's output can be seen |
09:29:39 | * | leorize_ joined #nim |
09:31:01 | * | leorize quit (Ping timeout: 256 seconds) |
09:35:10 | * | lf-araujo quit (Ping timeout: 252 seconds) |
09:36:53 | * | stefanos82 joined #nim |
09:39:28 | * | Acid147 joined #nim |
10:06:38 | lqdev[m] | seems like Nim playground is dead, the XHR sent to play.nim-lang.org/compile returns a 502 (bad gateway) status code |
10:06:51 | leorize[m] | !eval echo "alive!" |
10:06:53 | NimBot | Compile failed: <no output> |
10:07:05 | leorize[m] | PMunch: ^ |
10:07:06 | lqdev[m] | huh, interesting |
10:09:51 | * | leorize_ quit (Quit: WeeChat 2.3) |
10:15:43 | rokups | is there a way to turn `nnkIdent` into actual type? for example i have `nnkIdent "TableRef"` which and i want to test if it is a ref type |
10:18:04 | FromGitter | <mratsim> getType |
10:18:14 | FromGitter | <mratsim> getType(yourIdent) might work |
10:18:56 | rokups | i tried that already: `Error: node has no type` |
10:18:59 | FromGitter | <mratsim> ah no, getType(int) will create the NimNode representation of the int type |
10:19:25 | FromGitter | <mratsim> but nnkIdents have no types, you need an nnkSym for that so your input must be typed (and not untyped) |
10:20:29 | FromGitter | <mratsim> the easiest would be to quote do your ident and test |
10:21:51 | rokups | yes changing to `typed` looks like should do. it broke my macro but it should be fixable |
10:21:53 | FromGitter | <mratsim> also let myType = bindSym($myIdent) could work |
10:22:04 | FromGitter | <mratsim> but it's a bit convoluted |
10:23:01 | FromGitter | <mratsim> This is how I test if something is a int using bindSym for example: https://github.com/mratsim/Arraymancer/blob/master/src/private/ast_utils.nim#L20-L26 |
10:24:28 | * | fjellfras quit (Quit: Leaving) |
10:29:43 | PMunch | leorize[m], yeah I'm updating the server |
10:32:30 | PMunch | I left for lunch and it had popped up a prompt, but by the time I came back the ssh connection had timed out.. |
10:33:22 | lqdev[m] | seems like I'm not the only one always caught up by the [y/N] prompts when I go afk |
10:35:02 | * | abm joined #nim |
10:38:23 | livcd | !eval echo "alive!" |
10:39:23 | NimBot | Compile failed: <no output> |
10:40:14 | PMunch | Working on it.. |
10:40:22 | PMunch | I think something messed up.. |
10:47:12 | PMunch | Seems to be an issue with docker |
10:56:43 | rokups | any idea how could i create `Sym "_:type"` under `nnkGenericParams`? that thingy is created when i have a first parameter `_: typedesc[Table[A, B]]`. not sure how to synthesize that symbol manually |
10:58:36 | rokups | i ofc tried `genSym(nskType|nskLet, "_"|"_:type")` but at this point i have no idea what im doing |
11:01:32 | PMunch | newIdent("_") should work |
11:02:36 | rokups | that produces `Ident "_"` while i need `Sym "_:type"` |
11:05:49 | PMunch | Are you sure? |
11:06:21 | PMunch | That you need a Sym |
11:06:32 | PMunch | Most of the time an ident works just fine |
11:06:46 | PMunch | Nim will consider it a sym when it needs to |
11:07:49 | rokups | i am not sure of anything heh. i tried and it didnt work though. the way i make macro is i write code that i would like macro to produce, dump it's ast and then massage my macro until it produces same thing |
11:08:18 | rokups | and i have basically same thing except that one sym |
11:08:52 | rokups | `Error: illformed AST: [A; B; _:type300260]` is not very helpful error |
11:09:36 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
11:09:46 | * | laaron- joined #nim |
11:09:58 | PMunch | !eval echo "And we're back! leorize[m] and lqdev[m]" |
11:10:01 | NimBot | And we're back! leorize[m] and lqdev[m] |
11:10:14 | lqdev[m] | yay! |
11:10:48 | PMunch | rokups, have you seen dumpAstGen? |
11:11:01 | PMunch | Not to mention `quote` |
11:11:16 | rokups | dumpAstGen produces code that does not compile :D |
11:11:29 | PMunch | Hmm, yeah it's not perfect.. |
11:13:11 | PMunch | play.nim-lang.org/index.html?ix=1MbM |
11:13:24 | PMunch | Hmm, I need to fix indent in the playground output |
11:14:19 | * | Mister_Magister quit (Quit: bye) |
11:16:27 | * | Mister_Magister joined #nim |
11:20:57 | lqdev[m] | there's a bug with the playground, if you get a compile error, `nim`'s stderr (and only stderr) will be displayed no matter if compilation succeeds or not |
11:21:43 | PMunch | Really? |
11:21:55 | PMunch | Even if you switch from debug output to normal output? |
11:22:02 | lqdev[m] | aah, that's a thing |
11:22:06 | lqdev[m] | I didn't know about that |
11:22:09 | PMunch | Yes :P |
11:22:17 | PMunch | The button beside "Run" |
11:22:32 | lqdev[m] | I see it now |
11:22:46 | PMunch | If there is debug output it auto-switches to that |
11:23:49 | Zevv | PMunch: that bit me as well, could we make that more obvious somehow? |
11:24:13 | PMunch | I'm open to ideas |
11:24:38 | PMunch | Maybe the button could change colour? |
11:24:48 | PMunch | At least a bit easier to notice that it has switched |
11:25:22 | Zevv | something like that. Personally I'd prefer to just have it all in one window, but I guess thats not nice for everyone |
11:26:01 | Zevv | or if the window is large enough, show both windows in panes? |
11:26:03 | PMunch | Well, I wanted to have it separated so new users wouldn't wonder what all that output was |
11:26:18 | lqdev[m] | btw, I discovered that you can just browse the container's filesystem but probably isn't a vuln since the playground's running in a Docker container |
11:26:23 | Zevv | but then again, you dont want to develop a complete IDE there |
11:26:34 | Zevv | lqdev[m]: right |
11:26:56 | PMunch | lqdev[m], yeah you have complete freedom within the container |
11:26:58 | Zevv | I spent some time looking for vulnerabilities, and from my limited perspective it looks pretty solid |
11:27:08 | Zevv | I cant get it to blow up anymore either |
11:27:09 | PMunch | But it's nuked as soon as compilation is done, or time runs out |
11:27:13 | PMunch | :D |
11:28:09 | lqdev[m] | it runs in a container after all, so no vulnerabilities should be present. since everyone gets their very own Linux instance |
11:28:39 | PMunch | Well, short of meltdown/spectre/whatever-the-rest-are-called |
11:28:59 | PMunch | I think there was a new Docker vuln as well that allowed it to gain access to the actual file system |
11:29:17 | lqdev[m] | ah yes, but the easy ones are simply not a thing |
11:30:08 | Zevv | that was fun: inits /proc/self/exe was a physical link to the docker binary |
11:30:15 | Zevv | and would be writable |
11:30:26 | * | AndChat|624225 joined #nim |
11:30:37 | Zevv | I believe the workaround is that they now make a one time copy of that binary |
11:30:47 | Zevv | and dispose of it right after the exec() |
11:31:44 | PMunch | http://ix.io/1MbT |
11:31:54 | PMunch | Hmm, anyone got any ideas why 0.20.0 fails to build? |
11:32:07 | * | envoyt quit (Ping timeout: 245 seconds) |
11:32:53 | Zevv | do you even have a gcc :) |
11:33:23 | PMunch | Yup: http://ix.io/1MbV |
11:33:49 | PMunch | It's a bit old though.. |
11:33:57 | PMunch | But that's Ubuntu for you.. |
11:40:50 | vegai_ | seems to be building fine on my Ubuntu though |
11:41:00 | vegai_ | not complete yet, admittedly |
11:41:50 | * | laaron- quit (Remote host closed the connection) |
11:42:23 | PMunch | Yeah it went for a while before crashing |
11:43:37 | PMunch | Hmm, I cloned the repo and checked out the tag to build it manually. It failed in a different place this time: Error: execution of an external program failed: 'gcc -c -w -O3 -fno-strict-aliasing -I/home/pmunch/Nim/lib -I/home/pmunch/Nim/compiler -o /home/pmunch/Nim/nimcache/r_linux_amd64/stdlib_assertions.nim.c.o /home/pmunch/Nim/nimcache/r_linux_amd64/stdlib_assertions.nim.c' |
11:43:49 | PMunch | Strange thing is, running that command works fine.. |
11:44:54 | * | laaron joined #nim |
11:46:26 | PMunch | Hmm, I wonder if the machine is just running out of memory or something |
11:48:13 | * | lritter joined #nim |
11:48:58 | vegai_ | Hint: operation successful (99192 lines compiled; 25.280 sec total; 139.199MiB peakmem; Release Build) [SuccessX] |
11:49:15 | vegai_ | same version of ubuntu as you have, I believe |
11:49:21 | vegai_ | I have 2GB on this |
11:49:28 | PMunch | This machine has 1GB |
11:49:41 | vegai_ | hmm, well, I guess that could be it |
11:49:58 | PMunch | Shame though if you need more than a Gig of RAM to build Nim.. |
11:56:39 | vegai_ | is that comment about peakmem accurate? |
11:57:08 | vegai_ | I guess it's just about some part of the whole build, since it certainly took longer than 25.280 seconds |
11:57:44 | vegai_ | Hetzner Cloud gives you 2GB virtual machines for 2.49euros though :) |
11:57:53 | vegai_ | dunno if that's more than what you're currently using but I'm guessing not |
11:59:02 | PMunch | I've got no idea |
11:59:14 | PMunch | It's dom96 who's set this up |
11:59:33 | rokups | anyhow im trying to get this work. anyone bored enough to take a look? http://ix.io/1Mc9/nim |
12:02:04 | PMunch | Yeah.. That genSym is definitely wrong |
12:03:21 | rokups | that genSym is me being desperate ^_^ |
12:06:34 | PMunch | What is it that you're actually trying to do? |
12:07:01 | PMunch | I guess adding the _:typedesc[TableRef[A, B]] as the first argument? |
12:07:08 | rokups | trying to make a macro that inserts `_: typedesc[TableRef[A, B]]` as a first parameter yes |
12:13:36 | PMunch | Something like this: https://play.nim-lang.org/index.html?ix=1MbM |
12:14:08 | PMunch | By the way, Nim uses 2 spaces for indentation, not 4 |
12:14:42 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
12:15:16 | * | laaron joined #nim |
12:16:25 | PMunch | rokups ^ |
12:17:01 | rokups | and that is a mistake (2 spaces) :p |
12:17:26 | PMunch | Haha, you get used to it :) |
12:17:42 | narimiran | yep, now 4 spaces feel like way too much waste |
12:17:45 | rokups | thankfully we dont have to :p |
12:17:49 | PMunch | I thought it looked weird at first as well, but now I think Python and C looks so wasteful |
12:18:05 | narimiran | `is_main_module` also now looks quite strange |
12:18:38 | rokups | its funny you guys bring these up, considering that nim tries to enable people using their own style without forcing it on to others ^_^ |
12:18:56 | PMunch | Oh no, by all means, do what you like :) |
12:19:04 | narimiran | we bring it up, after reading "and that is a mistake" ;) |
12:19:22 | rokups | :D |
12:19:34 | rokups | 2 spaces are too much mental strain for me, harder to see indentations |
12:20:00 | PMunch | It's just that a lot of people who haven't used Nim don't realise that Nim uses 2 spaces or that we have style insensitivity so they stick to what they know and end up with some odd looking Nim code |
12:20:51 | PMunch | If you want to use 4 spaces and snake_case then be my guest, I just wanted to let you know it wasn't canonical in case you weren't aware |
12:21:25 | PMunch | I still think Nim should've gone with tabs though.. |
12:21:43 | lqdev[m] | please no |
12:21:49 | PMunch | So much nicer, everyone can choose how big or small they want their tabs to appear |
12:22:05 | lqdev[m] | 80 columns |
12:22:10 | narimiran | ...and on github you have this "nice" 8 space tabs. how about no :P |
12:22:25 | PMunch | What?! Are tabs on GitHub 8 spaces? |
12:22:31 | lqdev[m] | ah yes, it's been like that for a while and they haven't fixed it yet |
12:22:42 | FromGitter | <kaushalmodi> > I still think Nim should've gone with tabs though.. โ โ Please no from me too :) |
12:23:18 | PMunch | Well it's the only way to make the old kind of C code where you use 4 spaces for indentation but combine every two indent level into a single 8 wide tab |
12:23:34 | PMunch | That stuff looks absolutely horrid if you use anything but 8 wide tabs :P |
12:23:56 | PMunch | But apart from GitHub showing tabs as 8 spaces, what else is wrong with them? |
12:24:13 | PMunch | I like the idea that 1 tab = 1 level of indentation |
12:24:17 | rokups | PMunch: go has very strong opinions about code style. that is why i am in nim room and not in go room :D |
12:24:20 | lqdev[m] | it's easy to mix them up with spaces, so forbidding tabs is a good thing |
12:24:25 | rokups | developer freedom is important |
12:24:26 | PMunch | No ambiguity, no way to create weird half-indents |
12:25:19 | rokups | as for tabs vs spaces... spaces are better because you cant configure your editor to show spaces wrong, where with tabs you can |
12:25:30 | rokups | other than that it matters little |
12:25:44 | * | Snircle joined #nim |
12:26:29 | PMunch | "you cant configure your editor to show spaces wrong" well you probably could.. :P |
12:27:07 | rokups | be nice if nimsuggest could infer style used by current file and suggest names in pascalCase, CamelCase or snake_case |
12:27:18 | PMunch | lqdev[m], yes for Python that allows you to use either it's a valid argument, but if only tabs were allowed then it wouldn't really be an issue |
12:27:39 | PMunch | I mean how often do you hit the space key to indent? |
12:27:39 | * | Trustable quit (Remote host closed the connection) |
12:28:03 | rokups | sometimes..? |
12:28:18 | rokups | to fix indentation of single line |
12:29:14 | PMunch | Yes, because using spaces as indentation is inherently flawed.. |
12:29:27 | PMunch | With tabs that wouldn't be an issue |
12:29:36 | lqdev[m] | spaces are more versatile in terms of indentation, you can wrap your proc arguments to line up without any problem |
12:29:40 | PMunch | Because there would be no half-indents |
12:30:10 | PMunch | lqdev[m], that's a fair point |
12:31:41 | rokups | and this is exactly where tabs break when editor is misconfigured |
12:32:23 | rokups | and then we end up with files that contain configuration for tab width for vim for example. a configuration in every file and just for one editor kind. spaces - they work everywhere without any configuration |
12:33:07 | PMunch | But you are stuck with looking at code that might be indented in a way you don't like |
12:33:24 | rokups | indent it in a way you like then |
12:34:00 | PMunch | The thing with tabs is that as long as you don't mix them with spaces for indentation you can configure them any way you like without any actual issues |
12:34:15 | PMunch | But what if you are e.g. browsing GitHub |
12:34:27 | PMunch | Or just a code-paste |
12:34:37 | PMunch | I'm not going to download it just to indent it the way I prefer |
12:35:11 | PMunch | Anyways, did you try the solution I sent? |
12:36:41 | narimiran | ok, if tabs vs spaces is over, our travis now says "Error: Your Homebrew is outdated. Please run `brew update`." :rolleyes: |
12:37:41 | rokups | PMunch: what happens if i write code with editor where tab width is = 4 spaces and you edit my code in editor with tab width = 8 spaces? |
12:37:46 | PMunch | It's not over until the blood of the infidels water our tab-crops! |
12:37:55 | rokups | what happens if you are a weird one and set your tab width to 6 spaces? |
12:38:01 | PMunch | rokups, absolutely nothing |
12:38:09 | PMunch | Well, apart from code being written |
12:38:15 | narimiran | leorize[m]: should we re-introduce a part of this: https://github.com/nim-lang/Nim/commit/6a94599d66484396b4e080e5bb8c1aa8e8f129af#diff-354f30a63fb0907d4ad57269548329e3 ? |
12:38:24 | lqdev[m] | you don't get 80 columns and it pisses me off |
12:38:35 | rokups | oh yeah? what about comments that are aligned to your chosen column limit (like 80)? |
12:38:37 | PMunch | The code will have literal tab characters in it, so whatever you set them to display as it would work the same |
12:38:48 | rokups | there will be many cases where tabs break under different width |
12:38:59 | PMunch | rokups, ah well that's actually a good point |
12:39:13 | narimiran | ...but aside from that? :P :D |
12:39:59 | rokups | when proc parameters go to new line you may choose to align them with ( on previous line. good luck doing that, but if you manage that will also break with different tab width |
12:40:11 | rokups | idk if this is a thing in nim, but it is a thing in c family |
12:40:23 | PMunch | I think it's actually discouraged in NEP-1 |
12:40:33 | PMunch | But I do it anyways (shh, don't tell anyone) |
12:40:35 | * | narimiran People's Front of Judea vs the Judean People's Front |
12:40:41 | PMunch | At least to a certain degree |
12:40:47 | rokups | discouraged or not its not exactly relevant ^_^ |
12:40:56 | PMunch | narimiran, haha :P |
12:41:07 | rokups | people will do it. people are doing it. and spaces dont break in all these situations |
12:41:13 | lqdev[m] | actually it's encouraged not discouraged |
12:41:36 | lqdev[m] | gosh, we're fighting over tabs vs spaces for indentation, are there really no better, less subjective topics to talk about? |
12:41:57 | rokups | but the most important argument for spaces is that everybody else is using them. at this point its just easier to use spaces and not fight against the current. i used to be tab user myself you know |
12:42:13 | narimiran | PMunch: "what advatages do spaces have?", "well, you can wrap better", "ok, but besides wrapping?", "nicer github", "ok, but besides wrapping, github, ....., what did spaces ever bring?" |
12:42:21 | PMunch | lqdev[m], wait is that a new thing? I'm pretty sure it used to say not to do that.. |
12:42:28 | rokups | this is also same reason why i use cmake as my primary build system. its just easier to use the popular tool/configuration |
12:42:59 | PMunch | narimiran, wrapping and 80 char limit are the only good arguments I've heard |
12:43:15 | PMunch | GitHub supports ?ts=4 if you want to have a different tab size |
12:43:23 | lqdev[m] | https://nim-lang.org/docs/nep1.html#introduction-conventions-for-multiminusline-statements-and-expressions |
12:43:37 | lqdev[m] | it's been like that in 0.19.4 |
12:43:44 | PMunch | lqdev[m], yeah I found that |
12:43:58 | PMunch | Aah, yeah so fairly recent |
12:44:00 | lqdev[m] | don't know what it was back in the day since I was not a user of Nim, unfortunately |
12:44:58 | rokups | `?ts=4` is just another hoop to jump over. another reason why tabs suck |
12:46:04 | PMunch | lqdev[m], eh it seems like it was always that way.. |
12:46:59 | PMunch | rokups, no it's why tabs are great. I can decide how I want to see my tabs, and it doesn't affect the code at all |
12:47:55 | rokups | ok you use tabs then :D |
12:49:13 | PMunch | Don't get me wrong, I don't mind using spaces. But if I could change the world with the snap of my fingers I'd make people use tabs |
12:49:44 | PMunch | As in from the beginning |
12:50:43 | rokups | im glad you cant, you would break it :D |
12:51:33 | PMunch | But yeah, back to more useful topics. Did you try the solution? |
12:51:55 | narimiran | no please, talk about tabs/spaces a bit more |
12:52:25 | * | laaron quit (Remote host closed the connection) |
12:52:32 | * | AndChat|624225 quit (Read error: Connection reset by peer) |
12:52:34 | narimiran | it has been only half an hour :P |
12:52:53 | * | envoyt joined #nim |
12:53:44 | rokups | PMunch what solution? that hello-world thingy you posted seems totally unrelated |
12:54:12 | rokups | maybe if it had tabs... :D |
12:55:02 | PMunch | Oh woops, that was the wrong paste: http://ix.io/1Mcp/Nim |
12:56:14 | rokups | ok person who made that paste site deserves a special place in the hell |
12:56:24 | PMunch | What, ix? |
12:56:28 | PMunch | It's amazing |
12:56:35 | narimiran | rokups: you'll get banned for saying that! :P |
12:56:43 | * | deech quit (Ping timeout: 246 seconds) |
12:56:54 | narimiran | hating 2 spaces? ok. but hating ix.io? nope. |
12:57:03 | rokups | PMunch: nothing amazing about gutter being selected when trying to copy code :[ |
12:57:08 | PMunch | rokups, if you want to turn line numbers and highlighting off just remove /Nim from the URL |
12:57:30 | rokups | see this is like tabs vs spaces all over again ;D |
12:57:38 | PMunch | That's the beauty of it you decide how you want to view the code :) |
12:58:00 | rokups | nono, beauty is when thing works without knowing and having to do arcane url modifications |
12:58:00 | PMunch | But yeah, for easy copy just go to http://ix.io/1Mcp |
12:58:06 | PMunch | And you will get the paste in raw form |
12:58:19 | * | laaron joined #nim |
13:00:12 | rokups | PMunch: that solution - about same i had before. but we established we need `typed` to check if type is a ref type and then it all collapsed |
13:02:07 | PMunch | Aaah |
13:06:51 | PMunch | So you want to check if type is a ref in order to verify that the name is init? |
13:06:57 | PMunch | Otherwise it should be new? |
13:08:10 | rokups | i would like to be able to call `Table[int, int].new()` and have it return `TableRef`. so my plan is to check if return type of `new` is ref type and remove that ref in the macro and then add a first parameter to the proc |
13:12:13 | PMunch | Wait, can you give me a usage example? |
13:12:49 | * | laaron quit (Remote host closed the connection) |
13:12:51 | rokups | `Table[int, int].new()` ought to construct a new object of `TableRef[int, int]` type |
13:14:22 | * | laaron joined #nim |
13:14:37 | PMunch | And TableRef[int, int].new()? |
13:15:34 | rokups | that would be a `ref TableRef[int, int]` then. no idea if its a thing |
13:15:43 | PMunch | Ah okay |
13:23:28 | narimiran | "So you want to check if type is a ref in order to verify that the name is init" -- i didn't follow the discussion nor read the code, but: what's wrong with how system.nim does it? `when (t is ref):`? |
13:23:55 | PMunch | Yeah, that wasn't what he wanted |
13:24:01 | rokups | problem is not checking if type is ref |
13:24:10 | rokups | problem is inserting a new argument to a proc in a typed macro |
13:24:18 | narimiran | aha |
13:24:33 | PMunch | How do you check the type by the way? I have a way, but it feels a bit dirty |
13:25:06 | rokups | im not there yet as you can see ^_^ |
13:25:23 | rokups | but i expect to be able to look for nnkRef or something |
13:40:55 | * | brett-soric joined #nim |
13:45:05 | PMunch | Well, it's not pretty: http://ix.io/1McO/nim |
13:45:07 | PMunch | But it works.. |
13:45:31 | PMunch | So new is apparently already defined for Table, which was doing strange things |
13:46:28 | PMunch | well, you can rename it to `new` now, but since your example didn't pass an openarray it appeared to work but never really called the generated procedure |
13:50:44 | PMunch | http://ix.io/1McP/Nim |
13:50:46 | PMunch | Fixed a little bug |
13:50:50 | PMunch | rokups ^ |
13:51:35 | PMunch | One caveat though, since you take in a typed argument you can't have two procs with only the same return type |
13:51:57 | PMunch | Even though the resulting procedure would be valid, the type system will stop you before it gets that far.. |
13:52:29 | PMunch | Although that does seem a bit weird.. |
13:53:16 | rokups | oh wow this is some kung-fu. i didnt realize we can mix typed and untyped that way. thanks! |
13:53:56 | PMunch | Yeah it's a little trick I learned long ago |
13:54:19 | PMunch | Basically just make the typed part do as little as possible, and output something that an untyped macro can read and do the actual work with |
13:54:53 | PMunch | It's a bit annoying though that you have to "detype" the arguments, and the way I'm doing it there isn't very nice.. |
13:55:05 | PMunch | But I don't know of another way of doing it.. |
13:58:12 | * | nsf quit (Quit: WeeChat 2.4) |
14:21:51 | FromGitter | <alehander42> i think araq wanted |
14:21:54 | FromGitter | <alehander42> a semityped stuff |
14:22:03 | FromGitter | <alehander42> but i dont knwo how it works |
14:22:17 | FromGitter | <alehander42> btw do you guys use some tools to visualize data structures |
14:22:27 | FromGitter | <alehander42> e.g. for education or just debugging or anything |
14:24:27 | FromGitter | <alehander42> not really sure if applicable |
14:25:24 | FromGitter | <mratsim> @alehander42 I use pen and paper :p |
14:29:24 | * | laaron quit (Remote host closed the connection) |
14:30:32 | * | brett-soric left #nim (#nim) |
14:31:32 | FromGitter | <alehander42> do you have photos :P |
14:33:30 | * | laaron joined #nim |
14:36:05 | * | laaron quit (Remote host closed the connection) |
14:38:07 | * | laaron joined #nim |
14:47:05 | PMunch | rokups, I did some tinkering and I think maybe ctorAlt is a better approach: http://ix.io/1Mde/Nim |
14:48:05 | PMunch | It means you only specify the return/type declaration once, doesn't rely on "kung-fu" as you put it, and means you can have multiple procedures with the same input types and different return types |
14:48:44 | PMunch | It might not look as cool, but it definitely works better.. |
14:49:04 | rokups | this is interesting. although it puts a return type to not intuitive spot |
14:49:10 | PMunch | Yeah.. |
14:49:16 | PMunch | That's the only minus |
14:49:59 | FromGitter | <alehander42> honestly i wouldn't use `new` for int/floats |
14:50:01 | FromGitter | <alehander42> seems confusing |
14:50:04 | PMunch | You could create a macro though that took a block of procedures and rewrote them, since the problem with ctor is that it creates multiple instances |
14:50:09 | FromGitter | <alehander42> e.g. i thought new(5) |
14:50:13 | PMunch | alehander42, yeah that was just for testing :P |
14:50:14 | FromGitter | <alehander42> creates a string with length |
14:50:18 | PMunch | I needed some types |
14:50:24 | FromGitter | <alehander42> oh yeah, just saying |
14:51:11 | PMunch | But I should be heading home, ttyl |
14:51:12 | * | PMunch quit (Remote host closed the connection) |
14:58:57 | * | narimiran quit (Ping timeout: 258 seconds) |
15:01:18 | rokups | though i wonder whats that 3rd generic argument inserted in ast |
15:11:15 | * | floppydh quit (Quit: WeeChat 2.5) |
15:16:16 | * | envoyt quit (Ping timeout: 248 seconds) |
15:17:32 | * | leorize joined #nim |
15:34:38 | * | dGtlc3 quit (Ping timeout: 245 seconds) |
15:35:31 | * | dGtlc3 joined #nim |
15:44:06 | FromDiscord_ | <CrowbarKZ> hi folks, what is the idiomatic way of removing items from a sequence while iterating it? |
15:44:07 | FromDiscord_ | <CrowbarKZ> e.g. below doesn't work because length of sequence changes during iteration |
15:44:07 | FromDiscord_ | <CrowbarKZ> ``` |
15:44:07 | FromDiscord_ | <CrowbarKZ> for e in entities.items: |
15:44:07 | FromDiscord_ | <CrowbarKZ> if e.energy <= 0: |
15:44:07 | FromDiscord_ | <CrowbarKZ> entities.delete(p.entities.find(e)) |
15:44:08 | FromDiscord_ | <CrowbarKZ> ``` |
15:45:00 | leorize | var i = 0; while i < len(entities): <body> inc i |
15:45:20 | leorize | also, please avoid pasting code on discord, long code block will spam IRC |
15:45:23 | lqdev[m] | is there a `fract` function or do I have to use `x mod 1`? |
15:47:36 | FromDiscord_ | <CrowbarKZ> Thanks leorize! Sorry, didn't know about discord code blocks, noted. |
15:59:58 | FromDiscord_ | <CrowbarKZ> hm having tested the above - it produces incorrect result if you delete already processed index (some index after will be skipped) |
16:01:37 | * | laaron- joined #nim |
16:01:57 | * | laaron quit (Quit: ZNC 1.7.1 - https://znc.in) |
16:07:20 | leorize | yea, that's why the default iterator doesn't support that |
16:07:29 | leorize | so you should add some logic to shift your index around |
16:09:35 | Araq | while i < entities.len: |
16:10:03 | Araq | if entities[i].energy <= 0: entities.del(i) |
16:10:07 | Araq | else: inc(i) |
16:11:24 | disruptek | elide indentation whenever possible; `if entities[i].energy <= 0: entities.del(i); continue` |
16:16:16 | * | envoyt joined #nim |
16:23:00 | FromDiscord_ | <CrowbarKZ> yep i think now it works as expected, thanks for the help guys ๐ |
16:38:24 | * | d10n-work joined #nim |
16:54:38 | * | envoyt quit (Ping timeout: 245 seconds) |
16:54:59 | * | envoyt joined #nim |
17:35:06 | * | elrood joined #nim |
17:35:10 | * | dwdv joined #nim |
17:56:18 | * | neceve quit (Remote host closed the connection) |
18:11:31 | Araq | yay, I found it |
18:11:44 | Araq | new runtime closures are close! |
18:21:54 | * | theelous3 joined #nim |
18:22:47 | * | rayman22201 is very excited about this :-) |
18:26:51 | * | nsf joined #nim |
18:29:27 | shashlick | @rayman22201 - here's what i have so far for shared string - https://pastebin.com/jbT2fw3f |
18:29:55 | shashlick | nothing exotic anymore, but since the bucket is also shared, any shared string will be a pointer within the bucket |
18:30:11 | shashlick | string cannot change, have to point to a new string after freeing the old one |
18:31:23 | shashlick | am going to build a sharedStringSeq using this sharedString as the backing |
18:32:20 | shashlick | access the seq using .split(":") and create a new seq with ":".join(seq) and save as a sharedString |
18:32:34 | shashlick | really poor man's sharing but will work until we have a real solution with newruntime |
18:33:38 | shashlick | actually, the underlying string can change since the pointer to sharedString can be kept the same, only sharedStringObj.sptr will change if anything |
18:33:53 | shashlick | let's see anyway, how it evolves |
18:39:51 | rayman22201 | I would put a lock around your free procedure or you can get race conditions |
18:40:33 | shashlick | well, so i have a lock on the bucket, but your suggestion would make this safer in geenral |
18:41:19 | rayman22201 | Other than, good enough. ๐ |
18:46:09 | * | dwdv quit (Quit: quit) |
18:47:33 | * | nolanv quit (Ping timeout: 245 seconds) |
18:52:03 | shashlick | how come you can overload `&=` for `ptr object` type but not `=` |
18:56:07 | leorize | `=` is a special symbol I believe |
18:56:13 | leorize | it can only be overloaded for objects |
18:56:38 | shashlick | well, i would be diligent when i override, like i am with `&=` |
18:57:53 | * | PMunch joined #nim |
18:59:40 | * | rokups quit (Quit: Connection closed for inactivity) |
19:05:20 | FromGitter | <xmonader> returning TableRef from an object returns mutable version? is there away to return a readonly version of that? or do I need to do .deepCopy on it ? |
19:07:00 | lqdev[m] | I think you can only make it immutable if you return a regular Table |
19:10:33 | FromGitter | <xmonader> @lqdev works thanks! thought i needed to use ref types when i'm using ref objects all the way |
19:22:56 | PMunch | A TableRef is the same as a ref Table. So it's essentially just a pointer to a Table object on the heap. With this pointer you are of course able to go to that memory location and change whatever is there |
19:23:21 | PMunch | That's why it's mutable |
19:28:08 | FromGitter | <xmonader> @pmunch so that's the efficient definition? https://github.com/xmonader/nim-cachedtable/blob/master/src/cachedtable.nim#L10 to use mutable one or the ref one? |
19:28:44 | PMunch | Huh? |
19:28:45 | FromGitter | <xmonader> basically i'm manipulating the table from a higherlevel, but want people to `peek` into that table state without being able to modify it themselves |
19:29:15 | PMunch | The best thing to do then would be to not expose that field in your type and write a "peek" proc |
19:30:01 | FromGitter | <xmonader> yes, i did so, but the return of that function in that specific case should be the immutable version. |
19:32:40 | * | rockcavera quit (Remote host closed the connection) |
19:34:19 | * | Tyresc joined #nim |
19:44:58 | * | rockcavera joined #nim |
19:51:27 | * | narimiran joined #nim |
19:54:42 | * | nsf quit (Quit: WeeChat 2.4) |
19:57:39 | * | vlad1777d_ joined #nim |
19:57:47 | * | Cthalupa quit (Ping timeout: 248 seconds) |
19:59:34 | * | Cthalupa joined #nim |
20:00:53 | * | vlad1777d quit (Ping timeout: 245 seconds) |
20:13:19 | * | nolanv joined #nim |
20:20:18 | * | abm quit (Quit: Leaving) |
20:32:03 | * | solitudesf- joined #nim |
20:35:12 | * | solitudesf quit (Ping timeout: 268 seconds) |
20:42:05 | * | solitudesf- quit (Quit: Leaving) |
20:42:41 | * | solitudesf joined #nim |
20:57:54 | * | Vladar quit (Remote host closed the connection) |
21:09:25 | * | drewr quit (Quit: ERC (IRC client for Emacs 26.2)) |
21:20:01 | * | solitudesf quit (Ping timeout: 244 seconds) |
21:26:35 | * | PMunch quit (Remote host closed the connection) |
21:39:35 | Araq | closures work! --> PR incoming |
21:42:25 | * | narimiran quit (Ping timeout: 268 seconds) |
21:46:49 | * | jfoutaise joined #nim |
22:02:15 | * | dGtlc3 quit (Remote host closed the connection) |
22:02:37 | * | dGtlc3 joined #nim |
22:02:40 | * | lritter quit (Quit: Leaving) |
22:04:54 | rayman22201 | ๐ |
22:23:23 | * | krux02 quit (Remote host closed the connection) |
22:30:57 | AlexMax | w #zig |
22:31:28 | AlexMax | mistype (and sorry, I'm in a lot of upcoming language channels ;)) |
22:34:53 | rayman22201 | lol |
22:46:15 | dom96 | huh, guards/locks sections are experimental? |
22:47:15 | * | drewr joined #nim |
22:51:20 | Araq | it's not battle-tested afaik. Nim doesn't use shared memory so locks are rarely used |
23:07:31 | * | d10n-work quit (Quit: Connection closed for inactivity) |
23:11:13 | FromDiscord_ | <SychoRyn> People are telling me I should learn Julia |
23:11:23 | FromDiscord_ | <SychoRyn> Whatโs so great about Julia? |
23:12:23 | dom96 | Why don't you ask in a Julia channel? |
23:12:52 | FromDiscord_ | <SychoRyn> Idk this is the only programming Discord Iโm in |
23:22:34 | FromGitter | <zetashift> @SychoRyn Julia is a nice language if you're heavy into data science and Python/R just doesn't cut it for you, but Nim is stronger as a general purpose language and hopefully one day also data science |
23:24:29 | FromDiscord_ | <SychoRyn> Ah cool |
23:24:44 | FromDiscord_ | <SychoRyn> I like nim so far so Iโm gonna stick with it |
23:24:57 | FromGitter | <zetashift> Wise decision!(I'm biased though) |
23:26:00 | FromDiscord_ | <SychoRyn> Iโm surprised of how small nimโs community is. |
23:26:53 | * | abm joined #nim |
23:29:33 | FromGitter | <zetashift> Well even though it's small(for certain reasons) it still pumps out a lot of great contributions |
23:30:53 | rayman22201 | @Dom96, or anybody else who wants to chime in, I have been reading into async a bit more. What are your thoughts on this idea: make an async api for Channels, then use that to make an implementation of FlowVar? |
23:36:07 | * | Jesin quit (Quit: Leaving) |
23:38:33 | * | Jesin joined #nim |
23:38:40 | * | Acid147 quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
23:42:52 | * | elrood quit (Remote host closed the connection) |
23:51:55 | * | envoyt quit (Ping timeout: 268 seconds) |