00:19:19 | * | Guest24175 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
00:22:52 | * | skrylar_ quit (Ping timeout: 260 seconds) |
00:28:53 | Sentreen | Is it intended behaviour that a proc with the following signature: `proc foo(a: int, b: int = procWithSideEffect())` will call `procWithSideEffect` for every call with foo where b is not provided? |
00:29:59 | * | yglukhov quit (Remote host closed the connection) |
00:30:02 | Sentreen | I know that in python the value of the optional will be cached for later use. So I was just wondering about the rationale behind the choice :) |
00:32:13 | * | Vi- quit (Ping timeout: 260 seconds) |
00:36:02 | * | xet7 quit (Quit: Leaving) |
00:38:00 | * | yglukhov joined #nim |
00:39:42 | * | yglukhov quit (Remote host closed the connection) |
00:39:46 | * | nsf quit (Quit: WeeChat 1.7.1) |
00:40:15 | * | yglukhov joined #nim |
00:44:27 | * | yglukhov quit (Ping timeout: 240 seconds) |
00:49:35 | * | ludocode_ quit (Ping timeout: 240 seconds) |
00:49:58 | * | Vi- joined #nim |
00:50:24 | * | Vi- quit (Read error: Connection reset by peer) |
00:52:20 | * | ludocode_ joined #nim |
01:02:43 | * | smt__ quit (Ping timeout: 276 seconds) |
01:11:40 | * | Snircle joined #nim |
01:15:46 | * | v17d quit (Remote host closed the connection) |
01:20:07 | FromGitter | <ephja> has anyone had asyncnet.connect not result in an error when it can't connect? |
01:24:30 | * | chemist69 quit (Ping timeout: 240 seconds) |
01:35:26 | FromGitter | <ephja> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5969715ebf7e6af22cdcbe68] |
01:38:39 | * | chemist69 joined #nim |
01:51:25 | FromGitter | <watzon> Does num have union types or something similar? For instance, if I wanted to make a multi dimensional table in a language like Typescript I'd do: ⏎ ⏎ ```type MultiDimTable = TableRef[string, string | int | float | MultiDimTable]``` [https://gitter.im/nim-lang/Nim?at=5969751dc101bc4e3a87812e] |
01:51:39 | FromGitter | <watzon> But that doesn't seem to work in Nim |
01:54:26 | FromGitter | <ephja> @watzon https://nim-lang.org/docs/manual.html#types-object-variants |
02:04:25 | * | skrylar joined #nim |
02:11:20 | FromGitter | <watzon> @ephja So that's the only way to have a parameter with multiple possible types? |
02:13:30 | FromGitter | <ephja> @watzon you mean at compile time? |
02:15:39 | FromGitter | <watzon> @ephja yeah, something like c++'s `union` http://www.cplusplus.com/doc/tutorial/other_data_types/#unions |
02:18:28 | FromGitter | <ephja> a variant is the equivalent of that except that it's strongly typed |
02:19:29 | FromGitter | <ephja> https://github.com/andreaferretti/patty this lib simplies it, but I dunno if it will work with your particular compiler version |
02:41:41 | * | yglukhov joined #nim |
02:43:15 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
02:43:59 | skrylar | ah nim unions. those are 'case types' iirc |
02:45:16 | skrylar | i think nim lacks those on account of garbage collector safety. there is a way to force them with the {.union.} tag iirc, but those have restrictions against GC types being in them |
02:46:05 | * | yglukhov quit (Ping timeout: 240 seconds) |
03:14:57 | * | skrylar quit (Ping timeout: 240 seconds) |
04:43:37 | * | yglukhov joined #nim |
04:47:57 | * | yglukhov quit (Ping timeout: 240 seconds) |
05:10:05 | FromGitter | <Varriount> Nim has tagged unions (otherwise known as type variants). |
06:12:01 | * | skrylar joined #nim |
06:15:36 | * | andrzejku joined #nim |
06:22:12 | * | ShalokShalom joined #nim |
06:33:05 | * | skrylar quit (Ping timeout: 240 seconds) |
06:45:43 | * | yglukhov joined #nim |
06:46:56 | * | v17d joined #nim |
06:51:13 | * | yglukhov quit (Ping timeout: 248 seconds) |
07:16:26 | * | yglukhov joined #nim |
07:22:21 | * | skrylar joined #nim |
07:44:36 | * | Trustable joined #nim |
07:59:23 | FromGitter | <Varriount> I wonder how feasible it would be to have a "carray" type for sequences, on par with the cstring type |
08:24:08 | * | yglukhov quit (Remote host closed the connection) |
08:25:55 | * | Vladar joined #nim |
08:43:59 | * | yglukhov joined #nim |
08:45:05 | * | v17d quit (Ping timeout: 240 seconds) |
09:09:05 | * | gokr joined #nim |
09:20:05 | gokr | skrylar: The Red/System duality is similar to what I envision with Spry/Nim. |
09:20:40 | gokr | Eventually I am also contemplating partial compilation - for deployment. Have a small article exploring that a bit. |
09:21:21 | gokr | Spry is also meant to be very DSL friendly, since it borrows a similar flexibility in "syntaxlessness" that Rebol (and also Smalltalk) has. |
09:21:26 | gokr | Ok, off to the pool. |
09:33:45 | FromGitter | <watzon> Anyone know why I'd be getting an error while trying to create a sequence with more than 10 items? I'm trying to do this : ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but the linter is giving me an error: `Identifier expected, but found '".ttf"'` [https://gitter.im/nim-lang/Nim?at=5969e179f5b3458e304b9632] |
09:34:18 | FromGitter | <watzon> Never mind |
09:34:32 | FromGitter | <watzon> I'm stupid |
09:46:48 | Zevv | Is there a way to make the nim compiler less verbose. I'd prefer no output at all when everything is OK |
09:46:57 | Zevv | all these 'hints' are a bit cluttering |
09:47:45 | Zevv | --verbosity:0 does not seem to help |
09:49:00 | Zevv | Oh, --hints:off does the job. Sorry for asking first and reading later :/ |
09:51:44 | * | couven92 joined #nim |
10:03:46 | * | Matthias247 joined #nim |
10:15:42 | * | tankfeeder_ joined #nim |
10:16:00 | * | tankfeeder_ quit (Client Quit) |
10:17:26 | * | Ven joined #nim |
10:17:33 | * | Ven quit (Client Quit) |
10:20:02 | Zevv | g/c |
10:20:43 | * | v17d joined #nim |
10:24:17 | * | v17d quit (Remote host closed the connection) |
10:32:40 | * | skrylar quit (Ping timeout: 246 seconds) |
10:39:53 | FromGitter | <zacharycarter> o/ morning all |
10:53:37 | * | dddddd joined #nim |
10:56:40 | * | sz0 quit (Quit: Connection closed for inactivity) |
10:56:47 | * | skrylar joined #nim |
11:15:52 | FromGitter | <watzon> Is there an easy way to turn an object into a string for logging purposes? |
11:16:01 | skrylar | repr |
11:24:29 | FromGitter | <watzon> Thanks skrylar |
11:27:52 | * | Sentreen quit (Ping timeout: 260 seconds) |
11:38:34 | * | nsf joined #nim |
11:40:18 | * | Ven joined #nim |
11:40:41 | * | Ven is now known as Guest52311 |
11:41:45 | * | Sentreen joined #nim |
11:43:32 | FromGitter | <TiberiumN> Hmmm, currently I have "modules" in my app, and all modules are compiled with main application in one .exe. ⏎ I want to split my modules to different .dlls, but here's the problem: My application and my modules are async, and my modules can call main application (for api call). ⏎ Is it possible to split my modules to dlls in such use case? |
11:44:00 | skrylar | i don't know that nim likes DLLs |
11:44:19 | FromGitter | <TiberiumN> I mean I know that I'll need to use something for wrapping |
11:44:31 | FromGitter | <TiberiumN> but main problem is that I need my app and my modules be fully async |
11:46:51 | FromGitter | <TiberiumN> and I need to call some procedures which are defined in my main app from my modules (and asynchronously) |
11:48:18 | * | Sentreen quit (Ping timeout: 260 seconds) |
11:56:36 | * | Trustable quit (Remote host closed the connection) |
11:58:23 | * | nsf quit (Quit: WeeChat 1.7.1) |
12:00:40 | * | Sentreen joined #nim |
12:12:57 | * | Sentreen quit (Ping timeout: 240 seconds) |
12:19:36 | Zevv | I want to get a key from a table or fallback to 'nil' if it does not exist, what is the idiom for this? |
12:19:59 | yglukhov | Zevv: getOrDefault? |
12:20:10 | Zevv | Thanks |
12:22:01 | Zevv | I guess that what I would *really* need is a JSON 'to' which allows for optional fields |
12:24:43 | * | Tiberium joined #nim |
12:24:49 | skrylar | ah the wonders of needing nillable types :\ |
12:25:00 | Zevv | Yeah I just found my first SIGSEGV on nim |
12:25:34 | skrylar | Nitpick about json serialization: you would need to have something like haskells Maybe type. as the lack of a value in a table sometimes has separate semantics to that value being assigned to nil. |
12:25:51 | Zevv | True, true |
12:25:54 | Zevv | I'm not nitpicking |
12:26:02 | skrylar | doing up Maybe is not hard. hacking the json serializer to support it? dunno |
12:26:17 | skrylar | you'd have to either vendor it or get araq onboard. though i think he's already for nillable types at some point? |
12:26:26 | * | Sentreen joined #nim |
12:26:37 | Zevv | There is no single right answer |
12:26:55 | Zevv | I'm very nil-aware because of my C/Lua background, so I'm basically fine |
12:27:18 | skrylar | you can define your own tags on fields of objects and then {.mystuff.} it on there |
12:27:28 | Zevv | although having the magical-mystical type system solve all my problems would be sweet, of course |
12:27:44 | skrylar | so iirc its already possible to have your own {.optional: somedefault.} type tag, and a macro to generate a serializer to support it |
12:29:09 | skrylar | go also supports this but you have to do runtime reflection to extract the attributes. nim has you do compile-time reflection to do it |
12:29:27 | skrylar | so AFAIK what you want is possible so long as someone did the macro :3 |
12:30:12 | Zevv | Hmjeah, I get about 60% of what you're talking about here at this point. For now I'm adding my own method to JsonObject to extract a value only if it is there, that does the job for me |
12:33:32 | dom96 | Zevv: That's planned (optional fields in 'to') |
12:33:56 | dom96 | we have an Option[T] type in the stdlib for this |
12:34:02 | Zevv | \o/ |
12:34:57 | Zevv | And another one: is there a way to define default values for object members without having to explicitely assign those in the constructor? |
12:36:00 | Zevv | Oh the Option[T] is basically a Maybe |
12:37:00 | dom96 | nope |
12:38:05 | Zevv | ok |
12:45:17 | * | skrylar quit (Quit: My iMac has gone to sleep. ZZZzzz…) |
12:48:08 | Zevv | Is there a pretty-printer for 'arbritary' data in the standard library? |
12:48:23 | Zevv | like repr(), but multi-line with indenting, etc? |
12:53:15 | * | skrylar joined #nim |
12:53:30 | FromGitter | <lateefj> Hello. I think I found a bug in the Freebsd thread code and patch it in my fork (https://github.com/lateefj/Nim/tree/fix_freebsd_threadid_call). Should I submit this as a PR to the devel branch? |
12:57:19 | Araq | yup |
12:59:35 | FromGitter | <lateefj> Thanks |
13:00:53 | * | Snircle joined #nim |
13:02:35 | * | Sentreen quit (Ping timeout: 246 seconds) |
13:06:22 | * | gokr quit (Quit: Leaving.) |
13:08:05 | * | ShalokShalom quit (Ping timeout: 240 seconds) |
13:08:58 | * | ShalokShalom joined #nim |
13:15:13 | * | skrylar quit (Ping timeout: 260 seconds) |
13:15:49 | * | Sentreen joined #nim |
13:16:48 | * | ShalokShalom quit (Ping timeout: 258 seconds) |
13:24:36 | * | nsf joined #nim |
13:27:50 | * | Sentreen quit (Ping timeout: 240 seconds) |
13:37:07 | dom96 | Araq: This no longer compiles: https://gist.github.com/dom96/7e97d02f974b391e9e60d157f461b225 |
13:37:25 | dom96 | It's in my book and I'm fairly sure it did compile at some point in time. |
13:37:36 | dom96 | Perhaps pre 0.16.0 even |
13:37:52 | Araq | it never was supposed to work, afaict |
13:37:52 | dom96 | Any chance this is a regression? |
13:38:15 | Araq | yeah, but once T is inferred to 'int', there is no back tracking to make it 'float' |
13:38:30 | dom96 | hrm, okay |
13:38:35 | dom96 | I'll just remove this example from the book then |
13:38:37 | Araq | however, maybe we can infer it to 'int literal' and then mutate it to 'float' like it once was |
13:39:11 | Araq | but these implicit conversions just suck |
13:39:26 | Araq | they always bite back, sooner rather than later |
13:41:08 | Araq | dom96: no need to remove the example, all you need to do is to replace 5 by 5.0 |
13:41:13 | * | Sentreen joined #nim |
13:41:29 | dom96 | The example is to show that Nim infers types well |
13:41:35 | dom96 | 5.0 doesn't make sense |
13:52:41 | yglukhov | Araq: how does gc work in threadpool? say, i've allocated lots of crap in a threadpool, and went back to main thread, and never going to use threadpool again. is that memory reclaimed? |
13:53:22 | Araq | the threads linger on keeping their heaps |
13:53:57 | yglukhov | and i suspect GC_fullCollect on the main thread will not help here, right? |
13:54:08 | Araq | you need to call GC_fullcollect() in the respective thread |
13:54:17 | dom96 | another thing that doesn't work anymore: https://gist.github.com/dom96/745b42a06ee46c14d34f260e4bd9c343 |
13:54:27 | dom96 | That surely is a regression |
13:54:53 | dom96 | bbl |
13:54:58 | yglukhov | Araq ok, thanks |
13:55:00 | Araq | dom96: no doubt it's a regression |
13:55:17 | yglukhov | Araq: but something should be done about it, imo |
13:56:15 | Araq | seems hard, not even the threadpool has access to the heaps |
13:58:30 | yglukhov | Araq: maybe at least i could spawn a proc on all available threads? |
13:59:12 | yglukhov | i mean, guaranteed way =) |
13:59:21 | Araq | he, that's awesome |
13:59:45 | yglukhov | and then the threadpool.sync could do that e.g. |
13:59:50 | yglukhov | implicitly |
13:59:59 | yglukhov | or explicitly, whatever |
14:00:13 | Araq | pass a "cleanup = false" flag to sync |
14:00:23 | yglukhov | ok |
14:00:31 | yglukhov | but how do i do that? ) |
14:00:47 | yglukhov | i don't see a way currently |
14:15:00 | * | Guest52311 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
14:15:17 | Araq | yglukhov: not sure, but you'll figure out |
14:15:59 | * | Ven joined #nim |
14:15:59 | * | Ven quit (Client Quit) |
14:17:02 | * | gmpreussner quit (Quit: kthxbye) |
14:21:36 | * | gmpreussner joined #nim |
14:21:39 | * | Matthias247 quit (Read error: Connection reset by peer) |
14:21:46 | * | jsgrant_ joined #nim |
14:21:49 | * | nhywyll joined #nim |
14:52:41 | * | smt joined #nim |
15:04:15 | * | Arrrr joined #nim |
15:04:32 | * | Arrrr quit (Changing host) |
15:04:32 | * | Arrrr joined #nim |
15:17:49 | * | byte512 joined #nim |
15:18:04 | * | gangstacat quit (Ping timeout: 240 seconds) |
15:20:16 | * | Ven joined #nim |
15:20:40 | * | Ven is now known as Guest99595 |
15:22:04 | * | Arrrr quit (Ping timeout: 240 seconds) |
15:22:58 | * | gangstacat joined #nim |
15:40:48 | * | Sentreen quit (Ping timeout: 260 seconds) |
15:43:57 | * | ShalokShalom joined #nim |
15:47:20 | * | gokr joined #nim |
15:54:36 | * | Sentreen joined #nim |
15:58:32 | * | gokr quit (Ping timeout: 260 seconds) |
15:59:50 | * | Sentreen quit (Ping timeout: 240 seconds) |
16:03:00 | * | v17d joined #nim |
16:11:32 | * | v17d quit (Remote host closed the connection) |
16:13:01 | * | Sentreen joined #nim |
16:13:54 | * | Guest99595 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
16:13:56 | * | v17d joined #nim |
16:14:38 | * | Ven joined #nim |
16:15:01 | * | Ven is now known as Guest27471 |
16:16:20 | * | v17d quit (Remote host closed the connection) |
16:16:21 | * | Guest27471 quit (Client Quit) |
16:17:06 | * | v17d joined #nim |
16:19:36 | * | v17d quit (Remote host closed the connection) |
16:21:06 | * | v17d joined #nim |
16:43:40 | * | v17d quit (Remote host closed the connection) |
16:44:53 | * | v17d joined #nim |
16:47:55 | * | Jesin quit (Quit: Leaving) |
16:51:49 | * | Jesin joined #nim |
17:07:16 | * | Ven_ joined #nim |
17:11:25 | * | nsf quit (Quit: WeeChat 1.7.1) |
17:11:44 | * | def-pri-pub joined #nim |
17:17:29 | * | Ven_ quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
17:19:07 | * | xet7 joined #nim |
17:29:37 | * | couven92 quit (Ping timeout: 248 seconds) |
17:35:08 | * | ShalokShalom quit (Ping timeout: 260 seconds) |
17:38:05 | Araq | ugh, I am beginning to hate stdlib deps |
17:38:17 | Araq | the compiler uses json, unicode, etc etc |
17:38:45 | Araq | that's a pain for the experiments I want to do... now I have to port all this to my immutable strings branch |
17:54:05 | * | Sentreen quit (Ping timeout: 240 seconds) |
17:56:07 | * | xet7_ joined #nim |
17:56:19 | * | smt quit (Read error: Connection reset by peer) |
17:56:27 | * | smt joined #nim |
17:56:48 | * | xet7 quit (Read error: Connection reset by peer) |
18:04:05 | * | def-pri-pub quit (Quit: leaving) |
18:07:09 | * | Sentreen joined #nim |
18:13:10 | * | spkpp joined #nim |
18:15:18 | wishi | does anyone know how to make a sequence of Tables? like var records = newSeq[Table]() |
18:15:36 | FromGitter | <TiberiumN> yes we know |
18:15:56 | wishi | great |
18:16:03 | FromGitter | <TiberiumN> var recors = newSeqTable[string, string () |
18:16:16 | FromGitter | <TiberiumN> and you need to import "tables" |
18:16:39 | FromGitter | <TiberiumN> or another approach: ⏎ var records: seq[Table[string, string]] = @[] |
18:18:02 | wishi | let me try this. I am trying to put individual json records into something like a dict, to extend nimdataframe |
18:19:02 | FromGitter | <TiberiumN> oh |
18:19:15 | FromGitter | <TiberiumN> also, if you want string to string table |
18:19:24 | FromGitter | <TiberiumN> you might want to use "strtabs" |
18:19:48 | wishi | oh yes, thanks TiberiumN |
18:24:23 | * | Matthias247 joined #nim |
18:34:53 | wishi | https://pastebin.com/pmMr80x5 I am running into some syntax errors. somehow key values pairs in Nim do not seem to be a [key, value] expression |
18:37:19 | Araq | add doesn't take a pair at all, use mytab.add(key, val) |
18:37:36 | Araq | or mytab[key] = val |
18:37:59 | Araq | and newStringTable(string) also doesn't compile |
18:39:11 | wishi | hmh that did compile, but not work. I am just getting started |
18:50:46 | FromGitter | <ephja> what was the solution for using await in a template? |
18:53:06 | FromGitter | <ephja> could you query the AST as if it had already been expanded? |
18:54:09 | * | nsf joined #nim |
18:57:00 | * | couven92 joined #nim |
19:03:45 | * | spkpp quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
19:08:48 | wishi | I seem to be too dumb to do that. https://pastebin.com/Kh6tMRam - I don't understand this add method. or I may just misunderstand some docs ;) |
19:10:11 | * | nhywyll quit (Quit: nhywyll) |
19:14:59 | * | Tiberium quit (Remote host closed the connection) |
19:15:51 | * | Ven joined #nim |
19:16:14 | * | Ven is now known as Guest59775 |
19:16:28 | FromGitter | <ephja> wishi: there's no 'add' in that module, but maybe you want to use this https://nim-lang.org/docs/strtabs.html#[]=,StringTableRef,string,string |
19:17:29 | wishi | I thought I was already using that. |
19:18:14 | wishi | oh there is no .add wow |
19:18:24 | wishi | never trust an IDE |
19:20:09 | FromGitter | <ephja> the 'tables' module has 'add' |
19:21:52 | * | Vladar quit (Quit: Leaving) |
19:26:03 | * | Guest59775 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
19:26:19 | * | spkpp joined #nim |
19:27:01 | * | salewski joined #nim |
19:28:53 | salewski | Araq, I just did a nimble install c2nim. It seems that c2nim adds for all C structs the bycopy pragma. |
19:29:21 | Araq | yes, that was a bugfix/improvement |
19:29:23 | salewski | There is no way to avoid that? And nimble can not install an older c2nim? |
19:29:35 | FromGitter | <ephja> wishi: btw, "for k, v in x" should also invoke 'pairs' |
19:29:35 | Araq | what's wrong with this feature? |
19:31:08 | salewski | Maybe useful for https://forum.nim-lang.org/t/2978#18780 |
19:31:55 | Araq | salewski: yes. I can add a switch in order to not emit it, but why does it hurt? |
19:32:10 | salewski | But for most C sources that was not necessary. And the Nim output of c2nim looks differently now. |
19:33:08 | salewski | As you know, for the old legacy GTK files I did postprocessing with scripts, and that needs changes now. |
19:33:20 | FromGitter | <ephja> wishi: you can return nothing ("void") from main if you want |
19:34:05 | salewski | At least for the cairo files I have to fix it, for the old GTK 3.20 it does not hurt, no one really cores for that. |
19:34:47 | salewski | For cairo i still need c2nim, as it it nort well supported by gobject-introspection. |
19:35:19 | FromGitter | <ephja> I sometimes return an exit code (int) and do "quit main()" |
19:35:26 | salewski | Well, I will see how difficult it is to change my scripts, or I will see where I can get an older c2nim- |
19:35:59 | salewski | In each case the bycopy pragma adds a lot of noise! |
19:36:13 | Araq | don't spend too much time on it, I can make bycopy generation optional |
19:36:39 | salewski | Yes. I would be grateful. Thanks. |
19:36:51 | Araq | yeah, noise ... shrug, I don't read generated source code anyway ;-) |
19:37:03 | FromGitter | <ephja> I'd rather have object meta data at compile time like with Eo for EFL. then you just have to parse the metadata and generate code |
19:37:18 | salewski | Bye. |
19:37:22 | * | salewski quit (Quit: WeeChat 1.4) |
19:37:38 | spkpp | started with Nim and macros. I have this snippet: https://pastebin.com/5MrgbABx. I created a macro that generates a simple 'echo' proc that takes one arg, but when I try and use the macro, I get undeclared identifier. Do I need to explicitly add genSym nodes? |
19:37:50 | spkpp | Sorry for the lengthy question |
19:39:06 | Araq | spkpp: use 'body: untyped' in the macro header |
19:39:36 | spkpp | Lovely, thank you! |
19:40:40 | Zevv | What do I do with a message like: Error: internal error: (filename: semobjconstr.nim, line: 47) |
19:40:57 | Zevv | is this caused by me doing something wrong, or is there really an internal error? |
19:42:26 | FromGitter | <ephja> a compiler bug |
19:43:03 | FromGitter | <ephja> https://github.com/nim-lang/Nim/search?q=semobjconstr&state=open&type=Issues&utf8=%E2%9C%93 |
19:43:58 | Zevv | ok, clear |
19:49:45 | * | gokr joined #nim |
19:51:26 | FromGitter | <ephja> is the lack of suggestions for partial unqualified names an editor limitation or a nimsuggest limitation? |
19:52:42 | FromGitter | <TiberiumN> what do you mean? |
19:53:13 | FromGitter | <ephja> foo.bar usually yields suggestions, but 'bar' doesn't |
19:53:33 | FromGitter | <TiberiumN> VSCode does it for me |
19:53:44 | FromGitter | <TiberiumN> you mean like this? |
19:53:45 | FromGitter | <TiberiumN> (https://files.gitter.im/nim-lang/Nim/CQTJ/image.png) |
19:55:19 | wishi | ephja... ah ok |
19:55:23 | wishi | learning by doing ;) |
19:55:34 | wishi | thanks |
19:57:37 | FromGitter | <TiberiumN> @epja here's my VSCode settings: https://paste.ee/p/pVI4I |
19:57:40 | wishi | btw. for that tutorial https://nim-lang.org/docs/tut1.html - do I have to be concerned about a stack buffer overflow like in C? when I get the input and it's too long |
19:58:03 | FromGitter | <TiberiumN> I use 1ms delay because nimsuggest checks the file only after it's saved to disk |
19:58:16 | FromGitter | <TiberiumN> I mean checks it for errors |
19:58:40 | dom96 | wishi: Rule of thumb is: only worry about such things when using Nim's unsafe features (ptr, addr, cast). |
19:59:40 | FromGitter | <ephja> @TiberiumN isn't that a 1-ms delay? ;) |
19:59:47 | FromGitter | <TiberiumN> yes it is :) |
20:00:29 | FromGitter | <TiberiumN> nimsuggest doesn't check for errors if I don't save the file |
20:00:32 | FromGitter | <TiberiumN> you can set it to 1sec |
20:00:43 | FromGitter | <TiberiumN> (maybe this is Nim plugin bug, not nimsuggest limitation) |
20:01:25 | FromGitter | <TiberiumN> and about my terminal .bat script - it just automatically loads Visual Studio vcvarsall.bat |
20:01:27 | * | yglukhov quit (Remote host closed the connection) |
20:01:33 | FromGitter | <TiberiumN> because I mainly use VCC |
20:02:41 | * | yglukhov joined #nim |
20:03:44 | FromGitter | <ephja> I just get a bunch of local symbols |
20:05:07 | FromGitter | <TiberiumN> strange |
20:05:17 | FromGitter | <TiberiumN> did you check that nimsuggest is in PATH? |
20:06:00 | FromGitter | <ephja> it works when I qualify with the module name |
20:06:10 | FromGitter | <TiberiumN> ehmm, I don't know |
20:06:15 | FromGitter | <TiberiumN> also, maybe you're not using latest Nim? |
20:06:21 | FromGitter | <TiberiumN> because I always use devel |
20:06:29 | FromGitter | <ephja> me too |
20:20:32 | * | Ven joined #nim |
20:20:56 | * | Ven is now known as Guest16543 |
20:21:10 | FromGitter | <ephja> @TiberiumN how old is your nimsuggest build? |
20:23:56 | FromGitter | <TiberiumN> I can't check now sadly :( |
20:24:00 | FromGitter | <TiberiumN> Only tomorrow |
20:24:41 | FromGitter | <TiberiumN> But I update with choosenim, and it rebuilds all tools including nimsuggest |
20:25:33 | FromGitter | <ephja> not that old then I assume |
20:29:35 | * | jsgrant_ quit (Ping timeout: 258 seconds) |
20:29:50 | Zevv | [noob question] What's the idiomatic way to work with objects and passing them to functions? Use 'foo: var Foo' or 'foo: ref Foo'? |
20:31:37 | yglukhov | Zevv: 'foo: Foo'. less words - more idiomatic ;) |
20:31:51 | Zevv | But then I'm not allowed to modify the object, am I? |
20:32:28 | yglukhov | Zevv: if your object is ref type (ala C#, Java, D), then you are. |
20:32:39 | yglukhov | if it is value type, then you're not |
20:34:01 | Zevv | hm ok let me check that out |
20:34:33 | FromGitter | <ephja> if you dereference the reference then it will work with 'var' too |
20:34:44 | Zevv | That makes sense |
20:35:17 | FromGitter | <ephja> 'var' will be sufficient in most cases where you need mutability, it's just that you have to dereference manually unless you enable experimental features |
20:36:09 | Zevv | The 'ref type' object just made sense to me |
20:36:39 | Zevv | I really look forward to receiving my Nim book, the manual is still terse |
20:37:07 | Zevv | Reading the nim compiler source is quite helpful, but that's all the way on the other side of the complexity spectrum |
20:37:24 | Zevv | I would benefit from some simple idiomatic snippets to get the hang of the lingo |
20:37:55 | FromGitter | <ephja> I suppose you could infer everything by looking at the compiler code ;) |
20:38:05 | Zevv | I bet :) |
20:38:23 | * | jsgrant joined #nim |
20:38:27 | Zevv | given enough time and a large enough head |
20:38:34 | yglukhov | yes, from those coming from either scripting languahes or C#/Java/D/... ref type is more familiar |
20:38:45 | yglukhov | * for those |
20:39:16 | Zevv | I come from C and Lua; in C there's pointers, in Lua everything is a ref. I never really understood the buzz of references in C++ I guess :) |
20:39:44 | Zevv | Anyway, my object is now a ref, I dropped all the 'ref' and 'var' stuff and all is clear and simple and nice and sweet |
20:40:11 | yglukhov | Zevv: then ref type is a pointer in terms of C (but traced by nim's GC), while non-ref type is a struct. |
20:40:28 | yglukhov | tuple is a struct as well |
20:40:44 | Zevv | Yeah, that makes sense |
20:41:20 | Zevv | s/ref/*/g |
20:41:36 | Zevv | also in the type definitions |
20:41:44 | yglukhov | yeah, kinda. |
20:41:58 | Zevv | I was having troubles passing my objects to {.async.} functions, but that's ok now |
20:42:38 | yglukhov | you cant pass by var to closures, because closures can't capture them if you think of it |
20:42:59 | yglukhov | and {.async.} functions use closure iterators under the hood |
20:43:11 | Zevv | yeah, I figured that |
20:43:13 | FromGitter | <ephja> Araq: The compiler is apparently aware of the fact that cint is int32, so couldn't it be aliased to it? that would solve the (int32, int32) -> (cint, cint) issue |
20:44:01 | Zevv | yglukhov: ok, now I'm the noob again. 'pass by var', how is that different from 'passing by reference' |
20:44:15 | Zevv | You either get the object, or a reference to the object |
20:44:18 | Zevv | what's the third option? |
20:44:23 | yglukhov | pass by var is somewhat equivalent to |
20:44:32 | yglukhov | pass by C++ & |
20:44:32 | FromGitter | <ephja> I can't remember where it determined that those types are compatible |
20:45:00 | Zevv | Can you explain the difference in Nim in one sentence between the two? |
20:46:46 | yglukhov | what do you mean? |
20:46:49 | FromGitter | <ephja> fixed int types makes a lot more sense |
20:47:16 | Zevv | Yeah that was definately a crooked sentence. I mean the difference between passing by var or passing by ref |
20:47:25 | Zevv | It sounds like the same thing |
20:47:42 | FromGitter | <ephja> for one you don't have to query the underlying compiler, which probably involves some kind of hack |
20:48:17 | yglukhov | Zevv: if you have a non-ref type, you can't pass it "by ref". it's either by var, or by itself =) |
20:48:51 | FromGitter | <ephja> yeah non-refs are not allocated on the GC heap and traced |
20:49:44 | yglukhov | if you have a ref type, you can pass it "by ref" (actually you're just passing the value of reference), by var (if you dereference it upon call, normally you don't wanna do that), or by value (if you dereference it upon call, normally you don't wanna do that as well) |
20:49:58 | FromGitter | <ephja> pointers also point to some memory location, but "ptr T" instances are not reference counted |
20:50:26 | yglukhov | ptr T may point to anywhere, including to inside of some other object, or stack |
20:50:28 | FromGitter | <ephja> so they will never be implicitly freed |
20:50:38 | yglukhov | ref T may point only to the root of the heap cell |
20:51:13 | Zevv | Ok, thanks for clearing that up |
20:51:16 | Zevv | that helps |
20:52:01 | Zevv | I was indeed dereferencing my object at call time |
20:52:18 | Zevv | which resulted in the non-idiomatic mess I got tangled up in |
20:52:31 | yglukhov | ptr T may hold arbitrary values, it's your responsibility to handle them correctly. just like you would with pointers in c/c++. refs can hold only valid values, otherwise gc will crash on it on the nearest scan |
20:52:34 | FromGitter | <ephja> (ref Foo)()[] -> Foo, (ptr Foo)()[] -> Foo |
20:52:50 | FromGitter | <ephja> though only the former is actually valid |
20:53:25 | Zevv | Yeah, normal C pointers have no mysteries to me, I'm not afraid of int ***a; |
20:55:17 | FromGitter | <ephja> I was baffled by pointers at first |
20:55:37 | Zevv | I started with assembly on the 6502 as a kid |
20:55:46 | Zevv | pointers come naturally if you start bottom up |
20:55:47 | FromGitter | <ephja> even functions |
20:58:20 | Zevv | Anyway, I'm pretty much thrilled by what I've seen of Nim so far. For me this feels like the cross bread of my two favourites, C meets Lua. Strict typing, closures (!), no runtime, cross compilation, garbage collection. All sweet. |
20:58:34 | Zevv | Thanks for taking the time to educate a noob, nice to find a friendly community |
20:59:25 | FromGitter | <ephja> We are friendly to anyone who is not a COBOL apologist |
20:59:45 | Zevv | I'm old, but not *that* old |
21:01:44 | spkpp | I have a nim file with the contents "var test: seq[proc] = @[]". It fails to compile for me. Are there special restrictions to using proc as a type? |
21:01:53 | * | Trustable joined #nim |
21:02:47 | Zevv | var test: seq[proc()] = @[] ? |
21:03:10 | spkpp | Does that handle generic procs? |
21:03:32 | Zevv | honsetly, I have no clue, I better just keep my mouth shut |
21:03:44 | spkpp | no not all, that compiled |
21:03:46 | FromGitter | <ephja> no, but generics are compile time constructs |
21:04:58 | spkpp | Gotcha, the intent was to call a bunch of procedures with varying type signatures |
21:05:14 | spkpp | I think proc(anything) restricts to the one type I specify |
21:05:19 | FromGitter | <ephja> I assume you don't want to store procs with different signatures, but if you do then there are various approaches that you can take |
21:05:20 | dom96 | 'proc' is a type class |
21:05:25 | dom96 | You can't have a list of it |
21:05:51 | dom96 | This is a common thing for people to get confused about, we need a better error for it |
21:06:12 | spkpp | Yeah, I think I've run into it a few times and the compiler mentioned getting a stack trace from koch |
21:06:18 | FromGitter | <ephja> spkpp: are the different signatures known in advance? |
21:06:19 | spkpp | ephja that's what I want to do! |
21:06:46 | spkpp | ephja: I'm just messing around but I think ideally no, if possible? |
21:07:19 | FromGitter | <ephja> otherwise it'll be kind of difficult to call them. I've never needed this myself, but you can use variants for this https://nim-lang.org/docs/manual.html#types-object-variants |
21:08:40 | FromGitter | <ephja> or unions which are not type safe |
21:09:00 | yglukhov | spkpp: https://stackoverflow.com/questions/39232364/nim-stored-procedure-reference-in-tuple/39544532#39544532 |
21:09:21 | yglukhov | that should answer your question |
21:10:33 | spkpp | yglukhov: ooh that's perfect, thank you |
21:10:57 | spkpp | ephja: and thanks to you as well! |
21:14:12 | Zevv | I had a similar issue trying to pass arbitrary data to be passed back on a callback funcion. I ended up putting this into a closure as well, is there another way for this? Basically, I want to pass a reference to whatever, and get this reference back later. |
21:15:20 | yglukhov | spkpp, ephja, Zevv: i've written a variant type allowing to store values of any type within. https://github.com/yglukhov/variant |
21:16:04 | Zevv | ok, that takes some magic it seems |
21:16:06 | yglukhov | but like i said, in most cases, closures are the simplest and the most convenient solution |
21:16:58 | Zevv | It seems. I tried passing a ptr, but then I'd have to make sure I keep the GC from deleting my stuff before the callback happens |
21:17:05 | Zevv | closures are just fine for this |
21:18:34 | * | ShalokShalom joined #nim |
21:19:10 | yglukhov | true. nim keywords "ptr", "addr", "cast", "unsafeCast" are the last resort tools. normally you would need them for something really low-level, or some magic, or some heavy optimization tricks |
21:19:26 | FromGitter | <ephja> yglukhov: when do you use that rather than an algebraic type? |
21:20:15 | yglukhov | ephja: whan do i use what exactly? |
21:21:23 | FromGitter | <ephja> yglukhov: variants that don't accept only certain types |
21:21:33 | FromGitter | <ephja> looks neat though |
21:24:15 | yglukhov | ephja: well, consider a game engine and scene editor. scene editor has an inspector view that allows to edit component fields. the edit views are different for different types of component fields. |
21:24:26 | * | xet7__ joined #nim |
21:24:43 | yglukhov | if its vector3, you have 3 text fields, if its a texture, you have some image picker widget, and so on |
21:25:27 | yglukhov | in order to build the inspector, i enumerate editable fields of the component in runtime |
21:25:41 | yglukhov | setters and getters are packed to variants |
21:26:08 | yglukhov | then a proper editor is looked up based on variant type |
21:26:34 | yglukhov | and then it unpacks setters and getters to edit its specific property |
21:26:58 | yglukhov | to illustrate that: http://yglukhov.github.io/rod/livedemo/main.html |
21:27:19 | * | gokr quit (Ping timeout: 276 seconds) |
21:27:23 | yglukhov | if you select a node in the left view, the inspector will apear in the right view |
21:27:57 | yglukhov | thats just one use case, i have others, but i'll let you figure yourself ;) |
21:28:08 | * | xet7_ quit (Ping timeout: 260 seconds) |
21:29:04 | FromGitter | <ephja> is it not possible with tagged unions? |
21:29:08 | * | andrzejku quit (Quit: Textual IRC Client: www.textualapp.com) |
21:30:00 | yglukhov | ephja: if you have a fixed set of types - yes. but a game engine allows to write own components with own field types, and own editors for these types. |
21:31:24 | yglukhov | i mean, as a library, it allows other users to extend it. so taggen union will have to be altered. but you can't alter library code. |
21:32:28 | FromGitter | <ephja> isn't there a fixed number of property types? |
21:32:39 | yglukhov | no, it may be extended |
21:33:11 | yglukhov | that surely depends on you design. with my design, i allow users to create new field types |
21:36:55 | * | fredrik92 joined #nim |
21:37:09 | FromGitter | <ephja> at compile time? |
21:38:27 | yglukhov | variants are a lot like tagged unions, tagged by type. and they provide minimum overhead (but may allocate when value doesn't fit), so they are perfectly fine to use in any logic, except some dense code that cares about maximum performance. don't use them in 60fps drawing logic, and in btach processing logic, and you should be fine |
21:38:57 | yglukhov | ephja: yes, the type ids are generated at compile time, and are just 32bit ints. |
21:39:17 | yglukhov | just like a tag in tagged union |
21:39:34 | yglukhov | it doesn't pollute your binary with extra string or whatever |
21:39:52 | yglukhov | it boils down to just ints at the end of the day |
21:40:38 | * | Trustable quit (Remote host closed the connection) |
21:41:02 | yglukhov | you can try it and see the generated c code =) |
21:41:31 | FromGitter | <ephja> so no DLL extensions? |
21:42:25 | yglukhov | as long as dlls share the same type definition, the type ids will be equal in both dlls. |
21:43:22 | yglukhov | the type id is computed by first mangling a type, and then getting the hash of the mangled name. so the type ids are pretty stable. could even be used for serialization, but carefully =) |
21:45:05 | FromGitter | <ephja> you could have like a vendor prefix, but maybe it isn't necessary |
21:46:03 | yglukhov | noone complained yet, including myself ;) |
21:50:50 | * | fredrik92 quit (Ping timeout: 240 seconds) |
21:52:10 | * | ShalokShalom quit (Ping timeout: 240 seconds) |
21:53:26 | * | fredrik92 joined #nim |
21:53:41 | * | fredrik92 quit (Client Quit) |
21:53:54 | * | xet7_ joined #nim |
21:55:27 | * | xet7__ quit (Ping timeout: 240 seconds) |
21:59:47 | FromGitter | <ephja> I wonder if a callback approach would ever be faster. maybe when there are a lot of variations (more type ID comparisons) |
22:03:03 | FromGitter | <ephja> does the JS backend update more often than necessary? |
22:03:58 | * | Guest16543 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
22:05:40 | FromGitter | <ephja> allocations might be the biggest issue. first time profiling JS code |
22:05:44 | * | spkpp quit (Quit: http://www.kiwiirc.com/ - A hand crafted IRC client) |
22:06:53 | * | smt quit (Read error: Connection reset by peer) |
22:07:07 | * | smt joined #nim |
22:10:52 | yglukhov | ephja: the editor currently runs at 60fps. that's an issue to be fixed. |
22:11:57 | yglukhov | regarding variants, like i said earlier, if you can get away with tagged unions or callbacks, that would most likely be a better idea, because that's just simpler to reason about. |
22:13:08 | yglukhov | btw, js version of the editor is not the best. native one has more functions, such as open/save, for example =) |
22:16:44 | * | jsgrant quit (Read error: Connection reset by peer) |
22:38:39 | * | sz0 joined #nim |
22:42:23 | * | Jesin quit (Quit: Leaving) |
22:43:03 | * | Ven joined #nim |
22:43:26 | * | Ven is now known as Guest72659 |
22:45:46 | * | Jesin joined #nim |
22:57:25 | Zevv | s |
22:57:37 | FromGitter | <zacharycarter> ? |
23:03:18 | * | yglukhov quit (Remote host closed the connection) |
23:03:53 | * | xet7_ quit (Quit: Leaving) |
23:04:15 | * | xet7 joined #nim |
23:36:54 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
23:49:42 | * | Guest72659 quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |