00:00:08 | radagast | Instead of methods, is it wise to use a lot of overloaded (friend functions/) procedures ? |
00:07:18 | FromGitter | <zacharycarter> it's best not to do OOP with Nim |
00:09:44 | FromGitter | <mratsim> Is there a way to require that a field must be initialized in the constructor and cannot be left to its default value (here 0) ⏎ ⏎ ```type ⏎ Gate*[TT] = ref object {.inheritable.} ⏎ arity*: int``` [https://gitter.im/nim-lang/Nim?at=5a3afbc80163b028105fc30a] |
00:09:46 | FromGitter | <zacharycarter> I mostly avoid dynamic dispatch when writing Nim |
00:10:35 | FromGitter | <Varriount> @mratsim The only way I can think of is to make the type private, and only return it from a constructor. |
00:10:47 | FromGitter | <Varriount> But then you run into issues with variable declaration. |
00:11:28 | FromGitter | <zacharycarter> what's the difference between |
00:11:44 | FromGitter | <zacharycarter> `````` [https://gitter.im/nim-lang/Nim?at=5a3afc3f5355812e57fdb2a3] |
00:11:47 | * | yglukhov quit (Remote host closed the connection) |
00:12:13 | FromGitter | <mratsim> mmmh I see, well maybe a `int not default` in the future :P |
00:13:27 | FromGitter | <mratsim> @zacharycarter to be honest I don’t know if that makes a difference in practice. I just don’t see why I would inherit from a global RootObj while I ha a very specific use case |
00:13:45 | FromGitter | <mratsim> and I guess there is one less layer of indirection |
00:16:07 | FromGitter | <zacharycarter> gotcha |
00:23:58 | radagast | Damn |
00:24:06 | radagast | I'm so used to the abstractions of OOP |
00:24:16 | radagast | Especially coming from C++ |
00:32:25 | FromGitter | <Varriount> radagast: Better than coming from Java |
00:32:50 | radagast | At least you are used to RootObj |
00:35:58 | GitDisc | <treeform> radagast, i found this video useful to get a way from OOP: https://www.youtube.com/watch?v=QM1iUe6IofM |
00:38:46 | FromGitter | <zacharycarter> Just spend a few weeks / months writing C |
00:38:52 | FromGitter | <zacharycarter> you won't miss OOP |
00:41:38 | * | radagast quit (Quit: radagast) |
00:48:25 | * | SenasOzys quit (Remote host closed the connection) |
00:55:56 | FromGitter | <ephja> nah just other language features invented after 1980 :p |
01:00:09 | FromGitter | <data-man> Macros can do anything. Well, almost everything. :-) |
01:02:38 | FromGitter | <mratsim> Java OOP is not abstraction it's overabstraction full of Visitors of Factories |
01:06:10 | FromGitter | <mratsim> By the way is there a progress bar package for Nim, something like Python tqdm for iterators: https://github.com/tqdm/tqdm |
01:07:11 | FromGitter | <mratsim> Ah found one |
01:12:38 | FromGitter | <zacharycarter> Godot has a major flaw in its design / approach to popularizing itself |
01:12:52 | FromGitter | <zacharycarter> I've come to conclude anyway |
01:14:51 | FromGitter | <zacharycarter> it attempts to appeal to the lowest common denominator of "game developers" so basically people without any programming background |
01:16:43 | FromGitter | <zacharycarter> and it allows for this to influence design decisions, for instance : ```Implementing a job system in Godot was too challenging, unfortunately. While for high-end game engines this makes sense, usability would end up severely affected. As Godot aims to be an easy to use engine, users would have too many challenges with a system like this``` |
01:16:59 | FromGitter | <zacharycarter> and they don't offer any real substantiation behind these types of claims |
01:18:40 | FromGitter | <zacharycarter> most of the potential crowd godot attracts first ask the question - what successful games have been built with the engine? and the answer is none really |
01:20:27 | FromGitter | <zacharycarter> so you're building a piece of technology to cater to novices, but you expect / hope to popularize your technology by showcasing advanced applications of said technology |
01:20:31 | FromGitter | <zacharycarter> doesn't really make a lot of sense to me |
01:21:16 | FromGitter | <zacharycarter> GMS would be the most popular choice for engines if this expectation was realistic |
01:22:16 | FromGitter | <tulayang> OOP is useful for GUI programming, bug only GUI programming. OOP is clumsy to deal with data processing. |
01:22:33 | FromGitter | <tulayang> OOP is useful for GUI programming, but only GUI programming. OOP is clumsy to deal with data processing. |
01:27:16 | FromGitter | <data-man> @zacharycarter: Is OGRE not popular? For example, Rigs of Rods uses OGRE. |
01:28:13 | FromGitter | <zacharycarter> @data-man I think OGRE lost a lot of steam when Urho3D came out, and then I think Urho3D lost steam when Atomic was forked |
01:28:53 | FromGitter | <zacharycarter> and everything seems to be losing steam to godot, but not for any logical reason I can conclude |
01:31:02 | * | vivus quit (Quit: Leaving) |
01:32:56 | drs | we did GUI programming before OOP too. The best examples, while possibly considered "legacy" would be Win32 and/or Motif. |
01:34:43 | FromGitter | <data-man> @zacharycarter: Oh, thanks! I did not know about Atomic. And which is the best in your opinion? |
01:35:46 | FromGitter | <zacharycarter> @data-man UE4 / Unity |
01:37:01 | FromGitter | <zacharycarter> if you want to leverage an FOSS engine maybe look at https://github.com/BearishSun/BansheeEngine or https://github.com/nem0/LumixEngine |
01:37:17 | FromGitter | <zacharycarter> I doubt either are as full featured as godot atm, but I also question many of godot's design decisions |
01:43:18 | * | MJCaley joined #nim |
01:46:58 | FromGitter | <tulayang> OOP gives me the feeling that you can associate a bunch of objects and then handle all the window events in the same place by a mediator. Of course, it is also can be done to use a structure to save the pointers of all the event functions instead of using OOP. |
01:59:55 | * | sz0 quit (Quit: Connection closed for inactivity) |
02:04:44 | * | geocar_ joined #nim |
02:04:51 | * | LyndsySimon_ joined #nim |
02:05:59 | * | chemist69 quit (Ping timeout: 265 seconds) |
02:06:59 | * | arecacea1 joined #nim |
02:07:14 | * | geocar quit (*.net *.split) |
02:07:15 | * | arecaceae quit (*.net *.split) |
02:07:15 | * | kunev quit (*.net *.split) |
02:07:16 | * | dyce[m] quit (*.net *.split) |
02:07:16 | * | m712 quit (*.net *.split) |
02:07:16 | * | d10n quit (*.net *.split) |
02:07:16 | * | nathanj quit (*.net *.split) |
02:07:16 | * | LyndsySimon quit (*.net *.split) |
02:07:17 | * | geocar_ is now known as geocar |
02:07:31 | * | LyndsySimon_ is now known as LyndsySimon |
02:08:18 | * | d10n joined #nim |
02:08:18 | * | d10n quit (Changing host) |
02:08:19 | * | d10n joined #nim |
02:08:19 | * | m712 joined #nim |
02:08:27 | * | kunev joined #nim |
02:08:30 | * | dyce[m] joined #nim |
02:08:44 | * | nathanj joined #nim |
02:09:41 | * | craigger quit (Ping timeout: 260 seconds) |
02:11:13 | * | yglukhov joined #nim |
02:12:14 | * | craigger joined #nim |
02:15:49 | * | yglukhov quit (Ping timeout: 268 seconds) |
02:18:21 | shashlick | is it possible to read from stdin in a non-blocking fashion? wondering how to read info optionally piped into process, where data is not always expected |
02:19:25 | * | chemist69 joined #nim |
02:25:04 | FromGitter | <RedBeard0531> @shashlick its a bit of a hack, but `0.AsyncFD.newAsyncFile` should do the trick. Just don't cross the streams and mix async and sync handling of stdin |
02:25:18 | FromGitter | <RedBeard0531> assuming you are on posix |
02:25:23 | FromGitter | <RedBeard0531> no idea about windows |
02:25:55 | FromGitter | <RedBeard0531> There is probably a named constant that you can use instead of 0, but 0 is what I remember :) |
02:27:44 | FromGitter | <RedBeard0531> Does anyone know if finalizers are allowed to be closures? I *think* that is what this error message is telling me, but it's not the pinnacle of clarity. |
02:45:23 | FromGitter | <Varriount> @RedBeard0531 What's the error message? |
02:47:48 | FromGitter | <RedBeard0531> ifaddrs.nim(50, 19) Error: type expected ⏎ ifaddrs.nim(50, 15) Error: 'typedesc' metatype is not valid here; typed '=' instead of ':'? ⏎ ifaddrs.nim(51, 9) Error: type mismatch: got (ref seq[ifaddrs], proc (_: ref seq[ifaddrs]){.closure, noSideEffect ⏎ , gcsafe, locks: 0.}) ⏎ but expected one of: ... [https://gitter.im/nim-lang/Nim?at=5a3b20d4a2be466828c8663e] |
02:48:36 | FromGitter | <RedBeard0531> the actual exression was `(_: ref seq[ifaddrs]) => freeifaddrs(addrs)` where addrs was a closure capture |
02:51:10 | FromGitter | <data-man> @zacharycarter : Thanks! Banshee & Lumix are already in my bookmarks :-) |
02:54:10 | FromGitter | <RedBeard0531> I decided it'll be easier to just write an iterator than to try to return a seq, so that solved my problem for now |
03:09:46 | * | vlad1777d_ quit (Ping timeout: 260 seconds) |
03:10:10 | * | MJCaley quit (Quit: MJCaley) |
03:13:36 | * | SenasOzys joined #nim |
03:33:50 | shashlick | @RedBeard0531: I'll try thanks, though this is windows so wish me luck! |
03:35:27 | FromGitter | <RedBeard0531> It may work anyway, but I can't promise it wont do something bad. linux only has one type of file handle, but windows seems to have tons. |
03:38:53 | * | marenz_ joined #nim |
03:42:39 | * | marenz__ quit (Ping timeout: 265 seconds) |
03:48:17 | shashlick | Hold, async isn't really equivalent to non blocking right? It may come back in the future, but I only care now, not in the future |
03:53:53 | FromGitter | <tekjar> Hi. Just curious. Is 1.0 happening this month? |
04:03:16 | * | sz0 joined #nim |
04:09:27 | * | dddddd quit (Quit: Hasta otra..) |
04:21:00 | * | nim|83243 joined #nim |
04:23:10 | * | nim|83243 quit (Client Quit) |
04:23:16 | * | nim|83243 joined #nim |
04:25:53 | * | nim|83243 quit (Client Quit) |
04:50:35 | FromGitter | <nitely> @shashlick if you are doing async stuff, you could have a thread blocking on reading the stdin then feeding the input into a queue that the main thread (doing async) is awaiting on. However I dunno if that's even possible coz I haven't done anything with async in Nim :P |
04:54:12 | FromGitter | <nitely> 1) is awaiting on, while it does other stuff without blocking the main thread |
04:59:51 | FromGitter | <nitely> or you would have to check if there is something in the queue from time to time (not awaiting). Not sure. Depends on what you are doing |
05:00:43 | shashlick | I think I pulled it off quite simply, testing to verify it really works :) |
05:00:45 | FromGitter | <nitely> if the latter then there's no need for async really |
05:06:00 | FromGitter | <nitely> for each question someone asks there's almost always an easier answer hidden in the missing context :D |
05:13:57 | FromGitter | <nitely> @shashlick let us kown how you solved it |
05:15:16 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
05:57:19 | * | marenz_ quit (Ping timeout: 248 seconds) |
06:04:05 | * | yglukhov joined #nim |
06:05:48 | * | sz0 quit (Quit: Connection closed for inactivity) |
06:07:37 | shashlick | never mind, it doesn't really work yet |
06:08:31 | * | yglukhov quit (Ping timeout: 256 seconds) |
06:19:05 | * | nsf joined #nim |
06:26:09 | * | LyndsySimon quit (*.net *.split) |
06:26:09 | * | geocar quit (*.net *.split) |
06:26:10 | * | xkapastel quit (*.net *.split) |
06:26:11 | * | surma quit (*.net *.split) |
06:26:11 | * | Nikky quit (*.net *.split) |
06:31:43 | shashlick | @RedBeard0531, @nitely, no luck on windows with the stdin.getFileHandle().AsyncFD.newAsyncFile() method, just says handle is invalid |
06:31:49 | * | LyndsySimon joined #nim |
06:31:49 | * | geocar joined #nim |
06:31:49 | * | xkapastel joined #nim |
06:31:49 | * | surma joined #nim |
06:31:49 | * | Nikky joined #nim |
06:33:20 | * | BitPuffin|osx joined #nim |
06:48:29 | * | LyndsySimon quit (*.net *.split) |
06:48:29 | * | geocar quit (*.net *.split) |
06:48:29 | * | xkapastel quit (*.net *.split) |
06:48:30 | * | surma quit (*.net *.split) |
06:48:30 | * | Nikky quit (*.net *.split) |
07:08:32 | * | skrylar joined #nim |
07:13:39 | FromGitter | <mratsim> @shashlick there is a chapter in dom96 book about that, check his repo with non-blocking messaging example for the book. |
07:20:17 | * | solitudesf joined #nim |
07:24:48 | * | surma joined #nim |
07:24:53 | * | Nikky joined #nim |
07:25:05 | * | geocar joined #nim |
07:25:30 | * | xkapastel joined #nim |
07:26:37 | * | LyndsySimon joined #nim |
07:26:48 | * | SenasOzys_ joined #nim |
07:27:12 | * | SenasOzys quit (Read error: Connection reset by peer) |
07:29:51 | * | marenz_ joined #nim |
07:34:35 | * | marenz_ quit (Ping timeout: 252 seconds) |
07:58:57 | * | skrylar scratches head. Now why did nim build another 20 seconds slower just because of a js backend fix |
08:10:46 | skrylar | seems like using a piece table would lead to some strangeness |
08:10:59 | skrylar | since you have to apply a whole chain of diffs just to render the document |
08:13:51 | * | SenasOzys_ quit (Ping timeout: 248 seconds) |
08:21:32 | * | claudiuinberlin joined #nim |
08:30:33 | * | SenasOzys_ joined #nim |
08:32:18 | * | vlad1777d_ joined #nim |
08:33:57 | * | floppydh joined #nim |
08:33:57 | FromGitter | <mratsim> @andreaferretti @skrylar I got convolutional neuralnet working end to end on MNIST! (but only on 0.17.2, the new Nim allocator chokes when passing a Tensor of 10000x28x28) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3b71f40163b0281061983c] |
08:34:15 | FromGitter | <mratsim> (https://files.gitter.im/nim-lang/Nim/6xtN/2017-12-21_09-31-30.png) |
08:34:33 | FromGitter | <mratsim> 61% accuracy after 1 epoch! yeah =) |
08:40:43 | FromGitter | <mratsim> (for everyone else, MNIST is a database of 70k handwritten digits, you train on 60k and are tested on 10k, 1 epoch is one round of training on the 60k example). |
08:41:19 | skrylar | i still need to actually finish my GRU port and do something with convents |
08:50:40 | * | xkapastel quit (Quit: Connection closed for inactivity) |
09:04:05 | * | gmpreussner quit (Ping timeout: 252 seconds) |
09:05:25 | * | gmpreussner joined #nim |
09:09:16 | FromGitter | <alehander42> great stuff, @mratsim ! |
09:11:43 | * | PMunch joined #nim |
09:15:08 | * | yglukhov joined #nim |
09:15:09 | * | yglukhov quit (Read error: Connection reset by peer) |
09:15:43 | * | yglukhov joined #nim |
09:17:03 | * | yglukhov quit (Read error: Connection reset by peer) |
09:17:16 | * | yglukhov joined #nim |
09:18:21 | * | radagast joined #nim |
09:18:37 | ftsf | hmm cannot evaluate `sizeof(ObjectVariantType)` |
09:19:25 | FromGitter | <andreaferretti> @mratsim very cool! |
09:19:42 | FromGitter | <andreaferretti> I see you are more or less following the approach of pytorch, I like it! |
09:20:34 | FromGitter | <andreaferretti> The only thing I don't like very much is having to pass all optimizable parameters to newSGD |
09:21:18 | FromGitter | <andreaferretti> maybe it would make more sense to make models some kind of object which know what trainable parameters they have |
09:22:08 | FromGitter | <andreaferretti> like in pytorch you have a model `m` where you can call `m.forward(...)` (which is akin to your `model` function) |
09:22:21 | FromGitter | <mratsim> It's just the low-level SGD API, I wanted a quick win. |
09:22:25 | FromGitter | <andreaferretti> but also `m.parameters()` to get something you can pass to an optimizer |
09:22:50 | FromGitter | <andreaferretti> yeah, I agree, nicer interfaces can be done later with some metaprogramming |
09:22:53 | FromGitter | <mratsim> I will use a high level similar to PyTorch for the optimizer as well |
09:22:59 | FromGitter | <andreaferretti> in any case, great work! |
09:23:44 | FromGitter | <mratsim> And for the model* settings weights right now is a bit strange |
09:24:21 | FromGitter | <mratsim> Now the critical things is debugging my issue with the new Nim allocator. |
09:28:52 | * | skrylar quit (Remote host closed the connection) |
09:35:19 | * | Arrrr joined #nim |
09:35:19 | * | Arrrr quit (Changing host) |
09:35:20 | * | Arrrr joined #nim |
09:35:35 | * | solitudesf quit (Ping timeout: 252 seconds) |
10:09:25 | * | vlad1777d_ quit (Ping timeout: 268 seconds) |
10:32:41 | * | SenasOzys__ joined #nim |
10:33:42 | * | SenasOzys_ quit (Read error: Connection reset by peer) |
10:52:58 | * | solitudesf joined #nim |
10:55:43 | * | mostly-harmless quit (Read error: Connection reset by peer) |
11:02:45 | * | nc-x joined #nim |
11:10:11 | * | Arrrr quit (Read error: Connection reset by peer) |
11:10:17 | nc-x | Is this code expected to work? https://gist.github.com/anonymous/53dd1d63928e1ade3a7938e3834fc996 |
11:11:41 | nc-x | because it doesn't. It crashes the compiler itself. `koch temp c file.nim` gives `Stack overflow FAILURE` as the last two lines of error. |
11:12:23 | nc-x | (Replacing `echo x` with `echo x.repr` doesn't crash the compiler) |
11:16:19 | Araq | old, known, important bug |
11:16:31 | Araq | will work eventually |
11:17:51 | nc-x | Okay |
11:18:03 | nc-x | So no need to open an issue? |
11:18:05 | Araq | dom96, 'nimble develop websocket' gives me a git clone that cannot be teached about any existing branches |
11:18:17 | Araq | nc-x, no it's been reported twice at least already |
11:18:35 | nc-x | Araq: Okay, thanks! |
11:20:39 | * | arecacea1 quit (Remote host closed the connection) |
11:20:58 | * | arecacea1 joined #nim |
11:23:07 | * | dddddd joined #nim |
11:23:26 | * | Arrrr joined #nim |
11:25:26 | * | Yardanico joined #nim |
11:26:34 | * | nc-x quit (Quit: Page closed) |
11:26:55 | Araq | websocket\websocket\client.nim(26, 63) Error: cannot open 'securehash' |
11:26:57 | Araq | oh ffs |
11:27:41 | Araq | I'm moving it back into the stdlib |
11:31:32 | Yardanico | lol |
11:35:31 | Araq | it's only a name anyway, "securehash" |
11:35:38 | Araq | doesn't have to be secure |
11:35:52 | Araq | there are operating systems out there that don't "operate" either. |
11:37:05 | * | SenasOzys__ quit (Ping timeout: 248 seconds) |
11:37:33 | FromGitter | <mratsim> There are Rust and Crystal programing language that don't rust or crystallize as well ;) |
11:40:17 | Araq | VSCode now doesn't know about some files in my project like ospaths.nim |
11:40:22 | Araq | any ideas? |
11:40:44 | Yardanico | make an issue on their github an rollback to older version? :P |
11:44:49 | Yardanico | or maybe they've changed something in extensions API so nim extension doesn't work properly? |
11:45:02 | * | SenasOzys__ joined #nim |
11:45:39 | FromGitter | <mratsim> or you gitignored them :? |
11:46:23 | Araq | control+P is not affected by the Nim extension |
11:51:55 | * | nsf quit (Ping timeout: 256 seconds) |
12:00:34 | abeaumont | it'd make more sense to have other variants of SecureHash there though (sha2, sha3), wouldn't it? |
12:03:31 | dom96 | Araq: A git clone that cannot be teached about any existing branches? |
12:04:10 | dom96 | I think I already have that in my issues |
12:04:15 | dom96 | (https://github.com/nim-lang/nimble/issues/436) |
12:05:22 | Araq | sure but how hard is it to exec "git clone packageUrl" |
12:05:49 | * | NimBot joined #nim |
12:05:59 | Araq | dom96, because it needs a deprecation path |
12:06:29 | dom96 | I reused the same cloning functionality that 'install' uses. |
12:07:32 | Araq | idea: make nimble packages declare their versioning system: semver/none |
12:07:59 | Araq | if 'none' nimble uses HEAD |
12:09:05 | dom96 | Too many options |
12:09:25 | Araq | nimble install websocket.nim doesn't work btw |
12:09:35 | Araq | it's 'nimble install websocket' |
12:09:56 | Araq | and it installs a version that doesn't compile with Nim devel :-) |
12:10:53 | dom96 | I'm pretty sure you cannot have dots in package names |
12:12:04 | Araq | yes but that git url sucks |
12:12:30 | dom96 | okay, that's not my problem |
12:18:21 | Araq | do we want a check that checks the URL matches the package name? |
12:23:36 | GitDisc | <Yardanico> Discord bridge may now be offline for a bit of time (I'll link #nim-offtopic with discord offtopic) |
12:23:40 | yglukhov | haha, why securehash is back after i've switched 4 packages away from it? =) |
12:23:55 | * | GitDisc quit (Remote host closed the connection) |
12:24:13 | * | nsf joined #nim |
12:24:32 | * | GitDisc joined #nim |
12:24:40 | * | GitDisc quit (Remote host closed the connection) |
12:24:51 | * | GitDisc joined #nim |
12:25:01 | Araq | yglukhov, my bad, wasn't aware it's widely used |
12:26:31 | yglukhov | fyi, there's sha1 nimble package which is almost a drop in replacement |
12:26:54 | FromGitter | <alehander42> btw does nimble collect some kind of stats how many downloads packages have etc? |
12:27:24 | dom96 | nope |
12:27:51 | yglukhov | huh. it would be an interesting feature to automatically star downloaded packages |
12:27:51 | * | Snircle joined #nim |
12:27:53 | * | Vladar joined #nim |
12:28:19 | yglukhov | would also popularize nim on gihub |
12:28:32 | dom96 | We need to integrate more with http://nimble.directory/ |
12:30:19 | PMunch | yglukhov, that would require people to be logged into GitHub though.. |
12:30:26 | FromGitter | <mratsim> @yglukhov nimble would need the github token |
12:30:27 | FromGitter | <alehander42> I meant statistics, not stars, but that's an interesting idea :D (but not really applicable I think, except from a "nimblebot" account, which wouldnt make sense) |
12:30:47 | FromGitter | <alehander42> and I wouldnt want a package manager to start stuff for me, never |
12:33:55 | FromGitter | <mratsim> In archlinux there is an optional package called “aurvote” that allows autovoting of non-official libraries (AUR for Arch User Repository) that you install. |
12:34:58 | FromGitter | <mratsim> Is there a documentation page for the new “rand” library that replaces random? |
12:36:11 | Araq | it's still random.nim with new procs |
12:36:50 | fvs | given nim's interop with c, is static linking against c lib.a files a possiblity? |
12:37:27 | FromGitter | <alehander42> I often search for new nim libs in github trending nim, but it seems very broken (often I dont see actual libs I saw eg on forum, e.g. this week yglukhov's Python has 19 stars but its missing) |
12:38:06 | FromGitter | <mratsim> @fvs, yes it is. I could static link with Intel MKL in Arraymancer for example. |
12:39:37 | fvs | mratsim, build scripts on your github? |
12:40:07 | FromGitter | <mratsim> @fvs here: https://github.com/mratsim/Arraymancer/blob/99be4a5766778f3e05af052396dc2cfbe688fe65/nim.cfg#L71-L80 |
12:44:13 | dom96 | Maybe I'll add the same thing that I added to choosenim |
12:44:17 | dom96 | Google Analytics |
12:45:31 | FromGitter | <alehander42> is it opt-in or opt-out in choosenim ? |
12:45:55 | Yardanico | opt-in AFAIK |
12:46:03 | Yardanico | well it asks you on installation |
12:46:10 | FromGitter | <alehander42> good |
12:46:20 | Yardanico | https://github.com/dom96/choosenim/blob/master/analytics.md |
12:46:48 | FromGitter | <alehander42> :D I've seen too many drama threads last year of people afraid of analytic tools enabled by default |
12:47:20 | Yardanico | that's why there's this document :) |
12:49:20 | FromGitter | <mratsim> So Travis OSX build is broken again *sigh* ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3badd00163b0281062e74f] |
13:07:52 | FromGitter | <alehander42> some kind of chainable assert would be cool for some variant cases ⏎ eg ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3bb228ffa3e37919648b48] |
13:08:44 | FromGitter | <alehander42> (eg you *know* in this object, this chain is valid, and you don't want to litter with `if a.kind == / assert a.kind == ` on several lines) |
13:12:41 | * | yglukhov quit (Remote host closed the connection) |
13:16:43 | * | yglukhov joined #nim |
13:26:09 | * | jjido joined #nim |
13:32:50 | FromGitter | <mratsim> That's the Rust unwrap hell all over again. |
13:35:12 | FromGitter | <mratsim> I don't think there is a nim library to print images in CLI right? (Or an approximation using ASCII art). I'd like to have rough image display in Arraymancer for debugging without having to go through saving to jpg/png. |
13:36:44 | PMunch | mratsim, there is drawille-nim |
13:40:08 | Arrrr | you could use sdl |
13:44:10 | FromGitter | <mratsim> I don't want to depend on a shared lib. |
13:45:28 | FromGitter | <mratsim> @pmunch thanks for drawille, I checked their xkcd example it seems a bit rough, (set pixel to black if value < 128 or white >=128. |
13:45:50 | FromGitter | <mratsim> For curve though it seems pretty good. |
13:47:28 | PMunch | The Nim version works a bit differently |
13:47:36 | PMunch | For better or worse :P |
13:48:15 | * | gokr quit (Remote host closed the connection) |
13:48:32 | FromGitter | <mratsim> Or @Arrrr if a shared library an ubiquitous one (libjpeg, libpng) but for my use case I think only ffmpeg compiled with libcaca would be considered "ubiquitous" |
13:49:24 | FromGitter | <mratsim> And even then that requires framebuffer support I think. |
13:54:25 | PMunch | mratsim, you could always add colours to drawille-nim :) |
13:54:37 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
13:55:10 | PMunch | It would be per 2x8 "pixel" block but depending on your scenario it might work |
13:55:38 | PMunch | Then you could do something like this: https://raw.githubusercontent.com/yaronn/blessed-contrib/HEAD/docs/images/truload.png |
13:56:25 | FromGitter | <mratsim> =}. Basically my images are a seq[uint8] either grayscale or RGB with 3x uint8 per pixel. |
13:58:02 | FromGitter | <mratsim> That's nice! |
13:59:30 | * | fvs left #nim ("ERC (IRC client for Emacs 25.3.1)") |
14:14:37 | Arrrr | i think you can compile glfw statically |
14:16:05 | FromGitter | <andreaferretti> I used this (https://github.com/unicredit/neurotic/blob/master/neurotic/viz.nim) in neurotic |
14:16:15 | FromGitter | <andreaferretti> with nim png |
14:17:30 | * | Vladar quit (Quit: Leaving) |
14:24:02 | * | nsf quit (Quit: WeeChat 1.9.1) |
14:28:39 | * | Vladar joined #nim |
14:29:16 | * | MJCaley joined #nim |
14:35:09 | * | sendell joined #nim |
14:42:49 | * | nc-x joined #nim |
14:43:06 | nc-x | What is the equivalent of rust's match guards https://rustbyexample.com/flow_control/match/guard.html in nim? |
14:44:17 | * | fvs joined #nim |
14:48:10 | * | nc-x quit (Quit: Page closed) |
14:48:15 | FromGitter | <mratsim> @nc-x nothing though patty can do some. |
14:48:53 | fvs | how can i generate a unique reference for a variable - here it doesn't change: |
14:49:26 | fvs | for i in 0 .. 10: |
14:49:26 | fvs | var a = i; echo repr a.addr |
14:49:26 | fvs | |
14:50:38 | FromGitter | <mratsim> iirc there is a pragma to make sure the mangled name of a variable (and so it's memory reference) is unique. |
14:51:17 | FromGitter | <zacharycarter> http://libdill.org/index.html |
14:51:24 | FromGitter | <mratsim> But it's expected for the compiler to reuse a memory location that is valid only inside a loop. |
14:52:49 | FromGitter | <mratsim> What you can do otherwise is an unrolling macro. |
14:53:23 | * | happycoder joined #nim |
14:53:48 | * | happycoder quit (Quit: Yaaic - Yet another Android IRC client - http://www.yaaic.org) |
14:54:23 | * | happycoder joined #nim |
14:54:35 | FromGitter | <mratsim> Or even simpler use an array and assign each value to a different cell of the array. |
14:56:27 | fvs | won't all array repr a[i] = i have the same pointer as well? |
15:04:59 | * | marenz_ joined #nim |
15:11:50 | * | MJCaley quit (Quit: MJCaley) |
15:13:52 | * | arecacea1 quit (Remote host closed the connection) |
15:14:15 | * | arecacea1 joined #nim |
15:21:19 | * | Senketsu quit (Remote host closed the connection) |
15:23:10 | * | couven92 joined #nim |
15:29:13 | * | Senketsu joined #nim |
15:30:41 | * | happycoder quit (Ping timeout: 248 seconds) |
15:36:29 | * | SenasOzys__ quit (Read error: Connection reset by peer) |
15:42:40 | GitDisc | <NopeDK> What does the "incompleteStruct" do exactly? It mentions "sizeof" but there is no clear explanation for what it actually does behind the scenes. I have seen several libraries with and without it... |
15:47:04 | * | MJCaley joined #nim |
15:52:54 | * | SenasOzys joined #nim |
15:54:58 | Araq | it's rarely required |
15:55:26 | Araq | it means that the C library uses typedef struct s s; and then only pointers to s |
15:55:42 | Araq | that's an "incomplete" struct, sizeof() fails on it |
16:08:02 | * | xkapastel joined #nim |
16:11:09 | * | nyeaa joined #nim |
16:12:44 | GitDisc | <NopeDK> I see, thanks. |
16:13:17 | FromGitter | <mratsim> @fvs no, `assert addr a[i] != addr a[i+1]` |
16:15:34 | * | jxy joined #nim |
16:16:31 | * | sz0 joined #nim |
16:16:50 | * | jxy left #nim (#nim) |
16:20:22 | * | claudiuinberlin quit (Quit: Textual IRC Client: www.textualapp.com) |
16:34:05 | * | jxy joined #nim |
16:36:25 | * | yglukhov quit (Remote host closed the connection) |
16:37:05 | * | PMunch quit (Ping timeout: 240 seconds) |
16:38:17 | * | jjido joined #nim |
16:41:51 | * | vivus joined #nim |
16:56:45 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
16:58:09 | * | jxy quit (Quit: Changing server) |
17:00:06 | * | floppydh quit (Quit: WeeChat 2.0) |
17:00:18 | Arrrr | wow, compiler now gives error context, how cool |
17:00:19 | * | jjido joined #nim |
17:00:36 | Arrrr | it should print the lines on the left |
17:00:41 | Arrrr | *too |
17:04:44 | * | jjido quit (Client Quit) |
17:05:30 | Arrrr | 'expression: one(two)' -> 'L100: one(two)' |
17:07:33 | * | jxy joined #nim |
17:12:18 | Yardanico | Arrrr, what?! |
17:12:23 | Yardanico | you mean with exceptions? |
17:12:27 | Yardanico | ah |
17:12:41 | Yardanico | I saw that Araq improved stack traces for macros/templates recently |
17:18:14 | * | Trustable joined #nim |
17:21:55 | FromGitter | <alehander42> o.O really, I didn't notice. on `devel`? |
17:22:34 | * | yglukhov_ joined #nim |
17:25:32 | Arrrr | For example https://pastebin.com/YmQfQ0Cv |
17:25:55 | Arrrr | sometimes it spans through several lines |
17:26:11 | * | Jesin joined #nim |
17:32:37 | * | Serenitor joined #nim |
17:34:51 | * | jjido joined #nim |
17:35:20 | * | solitudesf quit (Quit: solitudesf) |
17:38:08 | * | jjido quit (Client Quit) |
17:41:02 | Serenitor | I am getting a compiler error from the generated C code when calling an object's variable "far"... |
17:41:02 | Serenitor | nimcache\sdl_gpu.c:1022:44: error: expected identifier before ')' token |
17:41:02 | Serenitor | TM_dAik9b2yZPusK9c5ut8ZHLhg_0[65].offset = offsetof(tyObject_Camera_u4yS1OvANkfX5LEExWHpeA, far); |
17:41:02 | Serenitor | ^ |
17:41:15 | Serenitor | has anyone an idea what might be going on there? |
17:43:02 | Arrrr | without context, impossible |
17:43:25 | FromGitter | <mratsim> do you perhaps have a `far.nim`file in your project? |
17:44:31 | * | sendell quit (Remote host closed the connection) |
17:45:20 | FromGitter | <RedBeard0531> `far` is a keyword in some c dialects |
17:45:33 | FromGitter | <RedBeard0531> `near` as well |
17:46:43 | FromGitter | <RedBeard0531> Based on that error I assume far is a member of the Camera object. Try renaming that var, and file a ticket on github that nim's c codegen should mangle the names `near` and `far`. |
17:47:15 | FromGitter | <RedBeard0531> @Serenitor ^ |
17:52:20 | Serenitor | @Arrrr can only provide my context by linking the file https://github.com/Serenitor/sdl2_nim/blob/master/sdl2/sdl_gpu.nim#L437 |
17:52:20 | Serenitor | @mratsim nope, no far.nim |
17:52:20 | Serenitor | @RedBeard053 sadly it's a variable from a C lib's wrapped object so can't really choose, but I'll try asking for mangling thing, thanks |
17:54:02 | Araq | Serenitor: iirc Nim knows 'far' and 'near' are keywords but if you importc it the compiler has no choice and must obey |
17:54:07 | * | MJCaley quit (Quit: MJCaley) |
17:57:34 | FromGitter | <RedBeard0531> Maybe I'm missing something, but I don't see an importc pragma on that type. Is there supposed to be one? I'd be somewhat surprised if a widely used c lib used far as a member name. |
17:59:46 | Serenitor | right, just realised that I lied actually, I'm using importc only for the functions, the types are recreated in nim. |
17:59:52 | Serenitor | here's original: https://github.com/grimfang4/sdl-gpu/blob/master/include/SDL_gpu.h#L308 |
18:00:17 | Serenitor | maybe I should suggest to the maintainer to change it |
18:06:02 | FromGitter | <mratsim> @Araq, I think I’ve found the culprit in the Nim allocator issue. Managed to get the issue in a different context. Find the common point: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5a3bf80a5355812e570299d5] |
18:07:10 | FromGitter | <mratsim> argh actually removing my `data=` proc only delayed the issue :/ |
18:07:51 | FromGitter | <mratsim> I could load, unload, reload tensor then crash, instead of load, unload then crash. |
18:08:08 | Araq | just give me something I can run |
18:08:16 | Araq | I probably already know the bug |
18:08:41 | Araq | you don't disable the cycle collector, do you? |
18:08:49 | FromGitter | <mratsim> no I don't |
18:09:15 | Araq | disable it and the bug will disappear if my hypothesis is correct |
18:10:07 | Araq | Serenitor: if you import the header, the full header is processed by the C compiler |
18:25:39 | FromGitter | <mratsim> @Araq GC_disableMarkAndSweep() helped for one case (big seq of size 10000x28x28x4 (float32)), for the other, I had to remove all usage of this `proc data =` anyway to use direct assignation instead as my memory was inflating 160MB by 160MB. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ So there might be 2 bugs, one with the cycle collector that you know of, and another one with `setter= ` proc that I will try to |
18:25:39 | FromGitter | ... provide a test case for. [https://gitter.im/nim-lang/Nim?at=5a3bfca3232e79134d799ee6] |
18:28:23 | * | fvs left #nim ("ERC (IRC client for Emacs 25.3.1)") |
18:32:54 | * | SenasOzys quit (Remote host closed the connection) |
18:37:29 | GitDisc | <treeform> Araq, would you be against of adding some thing like this to the json module? https://gist.github.com/treeform/d0e0c53aa107657241fa2fbcc74ee54a |
18:41:27 | FromGitter | <RedBeard0531> Why did unary < get deprecated? It actually seems really nice, especially with strided-countup like countup(0, <x.len, 2). x.len-1 and x.len.pred just don't feel as natural after getting used to 0..<x.len |
18:41:52 | * | yglukhov_ quit (Remote host closed the connection) |
18:51:02 | FromGitter | <mratsim> too many unwanted bugs. |
18:51:09 | FromGitter | <mratsim> there is a forum thread about it |
18:51:35 | FromGitter | <mratsim> you can use x.high instead |
18:54:10 | * | obadz quit (Quit: WeeChat 1.9.1) |
19:02:33 | * | derlafff quit (Remote host closed the connection) |
19:02:49 | * | derlafff joined #nim |
19:02:58 | * | natrys joined #nim |
19:16:56 | * | Arrrr quit (Ping timeout: 252 seconds) |
19:21:14 | Araq | well "too many", it was 2 in 10 years or something |
19:21:31 | Araq | but *shrug* the customer is always right ... or something like that |
19:22:21 | Araq | treeform, I don't like it, use data["count"] = %12 instead |
19:24:28 | Araq | so ... my DFA pass is starting to work :-) |
19:31:27 | * | Leeky_ joined #nim |
19:36:04 | Leeky_ | hello, here to ask a question about js output: is there a (not emiting code) way of checking if a value (or function) is undefined? |
19:36:31 | * | yglukhov joined #nim |
19:37:22 | Araq | proc isundef[T](x: T): bool {.importcpp: "(# === undefined)".} |
19:37:53 | Araq | or whatever JS's syntax is for that, it's not a Nim concept, I never needed it |
19:41:00 | Leeky_ | thank you very much! my question was more a "is there a already existent function in a default package/import" but I guess that solved it in an ideal way |
19:42:10 | dom96 | A more elegant way might be to wrap `undefined` somehow |
19:44:47 | Leeky_ | hmm.. can I somehow unquote a string within the importcpp? something like isundef("obj.value") |
19:45:15 | Leeky_ | ah nvm wouldn't work for nim variables I guess |
19:54:56 | * | jjido joined #nim |
19:56:48 | Leeky_ | proc isundef[T](x: T,s: cstring): bool {.importcpp: "#[@] === undefined".} worked for me |
19:56:54 | Leeky_ | thank you very much everyone! :D |
19:59:19 | FromGitter | <cooldome> Hi Araq, I have a question regarding https://github.com/nim-lang/Nim/pull/6954. Do you think it makes sense to skip calls to no return functions as wekk? It is not a problem to check for call kinds and symbols sfNoReturn flag, but it bothers that compiler does not enforce noreturn on procs declared noreturn |
20:00:12 | Araq | it's a good idea anyway, I think |
20:00:24 | FromGitter | <cooldome> ok, will do |
20:00:27 | Araq | one can always add noReturn for important stdlib things |
20:02:02 | * | claudiuinberlin joined #nim |
20:02:29 | * | Vladar quit (Quit: Leaving) |
20:03:16 | * | solitudesf joined #nim |
20:07:03 | * | couven92 quit (Quit: Disconnecting) |
20:17:51 | * | yglukhov quit (Remote host closed the connection) |
20:18:23 | * | yglukhov joined #nim |
20:19:21 | * | yglukhov quit (Remote host closed the connection) |
20:19:33 | * | yglukhov joined #nim |
20:19:40 | * | nsf joined #nim |
20:21:20 | FromGitter | <alehander42> yeah `isUndefined` and `isDefined` are useful for js code sometimes |
20:23:16 | FromGitter | <RedBeard0531> re noreturn: yes please! I often use `quit "some message"` in similar cases |
20:23:55 | * | yglukhov quit (Read error: Connection reset by peer) |
20:24:31 | * | yglukhov joined #nim |
20:33:15 | GitDisc | <NopeDK> No matter what I do, all my importc structs with fields that are pointers, are "nil". Minimal code: https://pastebin.com/wb2MQCL3 . Anyone knows what might be happening? |
20:36:18 | GitDisc | <NopeDK> The code is compiled as a shared library import by uwsgi at runtime. |
20:39:46 | Leeky_ | Next question: How do I escape the $ in this statement? . importcpp: "$(#)[0]" . |
20:40:33 | GitDisc | <NopeDK> It is like accessing "uwsgi" accesses a new variable instead of the extern one though the resulting c code does indeed show it as "extern struct uwsgi_server uwsgi". All fields are essentially nil or 0. |
20:45:36 | * | BitPuffin|osx quit (Ping timeout: 272 seconds) |
20:48:25 | Leeky_ | ah ok so escaping $ works with $$, is there a documentation for that? |
20:50:40 | GitDisc | <NopeDK> Not documented under the "importcpp" pragma but it is documented under the "importc" pragma: https://nim-lang.org/docs/manual.html#foreign-function-interface-importc-pragma |
20:52:29 | Leeky_ | thank you! |
20:53:40 | * | vlad1777d_ joined #nim |
21:14:48 | * | Yardanico quit (Read error: Connection reset by peer) |
21:16:01 | * | nsf quit (Quit: WeeChat 1.9.1) |
21:35:31 | * | jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…) |
21:36:04 | FromGitter | <RedBeard0531> Is there a helper to convert from a uint32 bitfield to set[FlagEnum] or vice-versa? |
21:39:52 | * | yglukhov quit (Read error: Connection reset by peer) |
21:40:24 | * | yglukhov joined #nim |
21:47:06 | FromGitter | <RedBeard0531> Is there a better way to embed newlines in a fmt-string: `echo fmt"""Host: {msg.hostId}{"\n"}{msg.msg}{"\n"}"""` |
21:58:44 | FromGitter | <Yardanico> I don't think so |
21:58:59 | FromGitter | <Yardanico> It's the same in Python :) |
21:59:19 | Araq | fmt("Host: {msg.hostId}\n") |
21:59:40 | Araq | nothing special about 'fmt' just learn Nim's string literals, there are three of them |
21:59:51 | Araq | "ordinary with \hookers" |
21:59:59 | FromGitter | <Yardanico> Ah I didn't see his triple quotes |
22:00:02 | Araq | r"raw string" |
22:00:17 | Araq | (that extends to identifier"raw string") |
22:00:26 | Araq | and """triple quoted strings""" |
22:01:29 | Araq | """{"\n"}""" is cute though, never thought of it |
22:02:05 | FromGitter | <RedBeard0531> I added triple quotes to make it easy to embed the " since '\n' isn't valid. While I knew it in the back of my head, I somehow forgot that fmt("blah\n") was valid |
22:04:35 | FromGitter | <Varriount> Araq: What state machine? |
22:06:32 | Araq | I mean "data flow analysis" not "deterministic finite automaton" |
22:07:56 | GitDisc | <treeform> I was looking at your data flow analysis patch. I want to learn more. |
22:13:32 | FromGitter | <RedBeard0531> How would you feel about making fmt parse escape sequences in the "string" parts (not in the {expr} parts obviously) and having rawfmt"..." or fmtr"..." for the cases where you don't want expansion? Then the mental model is that `fmt"a {b} c"` === `"a " & format(b) & " c` and `fmtr"a {b} c"` === `r"a " & format(b) & r" c"` |
22:16:47 | FromGitter | <RedBeard0531> In fact, I just reread the docs and the example implies that the former is how it works since it doesn't put the r prefix on the transformed strings |
22:17:49 | Araq | huh? what do you mean? the last thing we need is another syntax for string literals |
22:18:23 | Araq | treeform, what do you want to know? I'm still tinkering with these algorithms myself |
22:19:57 | GitDisc | <treeform> It looks like it only used to find non initialized vars and initialize them? |
22:20:14 | GitDisc | <treeform> Past algo used graphs and phi but this is a linear apprach? |
22:20:26 | GitDisc | <treeform> https://github.com/nim-lang/Nim/blob/c2d91771bc1593fc8432392a75223dc1106bcfa3/compiler/dfa.nim#L296 |
22:20:50 | GitDisc | <treeform> ^ it does not look like there is enough case of statements to do the whole language, but it looks like its enough? |
22:21:20 | GitDisc | <treeform> https://github.com/nim-lang/Nim/blob/c2d91771bc1593fc8432392a75223dc1106bcfa3/compiler/dfa.nim#L37 |
22:21:45 | FromGitter | <RedBeard0531> It wouldn't be a separate syntax. The docs say: an expression like `fmt"{key} is {value:arg} {{z}}"` is transformed into ... `format(" is ", temp)` ... |
22:22:06 | GitDisc | <treeform> ^ i have never seen this case of in a type object declaration before... is there only 7 nodes types in your dfa array? |
22:23:00 | GitDisc | <treeform> Does that make like a C union? |
22:23:49 | FromGitter | <RedBeard0531> I'm proposing that `fmt"a\nb"` is transformed to `format("a\nb", temp)` where the '\n' would be interpreted. You could use an almost identical fmtr macro if you want it to generate `format(r"a\nb")` |
22:24:48 | Araq | RedBeard0531 but then the fmt macro would interpret \, currently it is only concerned with {} |
22:25:01 | Araq | treeform: well it's a "case object" |
22:25:14 | FromGitter | <RedBeard0531> That is how the python f-strings that strformat is based on works: https://www.python.org/dev/peps/pep-0498/#raw-f-strings |
22:25:26 | Araq | it is implemented as a union but that's more an implementation detail |
22:26:45 | Araq | RedBeard0531, how about we add const nl* = "\n" to strformat, then you can write "{nl}" |
22:27:36 | GitDisc | <treeform> Never seen case objects before. Thats pretty cool. |
22:27:37 | Araq | treeform, I doubt I got the semantics of exceptions right but the pass deals with full Nim, not with a subset |
22:27:57 | FromGitter | <RedBeard0531> Couldn't that be done by having fmt emit nnkStrLit and fmtr emit nnkRStrLit? I assume that they would both be thin wrappers around a common impl that just takes a param for which lit type to use. |
22:29:00 | GitDisc | <NopeDK> After adding another cross compilation option to the nim.cfg and trying to use it with the --cpu and --os I get errors with "unknown os" and "unknown cpu". What am I doing wrong? Added two lines, "arm.raspbian.gcc.exe = " and "arm.raspbiab.gcc.linkerexe = ". |
22:29:12 | Araq | the IR only captures the important aspects though, that's why I only have 5 different instructions |
22:29:29 | Araq | 'raspbian' is not an OS Nim knows about |
22:29:34 | FromGitter | <RedBeard0531> If you do that, you'd need to do that for all the escapes which seems annoying. Especially if they have slightly different names like \n vs nl |
22:29:57 | dom96 | Regarding raw string literals, IMO we should change it to the same way that Python handles it. |
22:29:57 | Araq | RedBeard0531, meh ok, go for it |
22:30:11 | GitDisc | <treeform> neat. So it transforms everything its a simple 5 instruction code, that only interested in finding uninitalized state. |
22:30:13 | GitDisc | <NopeDK> How would you add a custom cross compilation target then? The example I found just required adding the two lines to Nim.cfg. |
22:30:17 | dom96 | The current rule of `blahblah"this is a raw string"` literal captures too much |
22:30:24 | GitDisc | <treeform> Araq, can you do go style escape analysis with it too? |
22:30:35 | * | solitudesf quit (Ping timeout: 240 seconds) |
22:30:37 | GitDisc | <treeform> for memory management? |
22:31:02 | Araq | treeform, no. :-) |
22:31:14 | Araq | for that we need more or different instructions |
22:31:30 | dom96 | fmt"" shouldn't be a raw string literal |
22:31:39 | * | yglukhov quit (Read error: Connection reset by peer) |
22:32:03 | Araq | dom96: Redbeard0531 already found a solution that doesn't butcher the language |
22:32:11 | * | yglukhov joined #nim |
22:32:23 | dom96 | what's the solution? using fmt()? |
22:33:08 | Araq | fmtr vs fmt |
22:35:39 | dom96 | Isn't that a bit ... inconsistent? :P |
22:36:53 | GitDisc | <treeform> Araq, after playing around the the SQL parser, I wrote my own parser for thirft at work: https://gist.github.com/treeform/15b34df51794e0dd8f57d286f1b369bb I wanted to have good error messages so I cart file name and line number and offset with every token. Is there a better way to do it? It makes my tokens huge! Then when I create nodes out of tokens i copy that info which makes nodes huge... How <message clipped> |
22:37:08 | GitDisc | <treeform> .thrift* |
22:37:12 | Araq | you just suggested to hack another special rule into the lexer |
22:37:36 | Araq | and then you dare using the word "consistency" |
22:38:50 | GitDisc | <treeform> I tried to base my parser on how the SQL parser works, loop and create tokens, loop again and create nodes, then profit! |
22:39:08 | dom96 | yeah, meh. Never mind what I'm saying. |
22:39:19 | dom96 | if it's inconsistent people will complain |
22:39:45 | dom96 | "Message clipped" |
22:39:53 | dom96 | The discord bridge needs improvement |
22:40:09 | GitDisc | <treeform> which message? |
22:40:30 | dom96 | https://irclogs.nim-lang.org/21-12-2017.html#22:36:53 |
22:40:57 | GitDisc | <treeform> ... would you do it? |
22:41:12 | GitDisc | <treeform> |
22:41:13 | GitDisc | <treeform> https://cdn.discordapp.com/attachments/371759389889003532/393533393360650261/image.png |
22:42:21 | Araq | treeform: in the compiler I use line, col: int16; fileIndex: int32 to cut the size |
22:43:25 | FromGitter | <RedBeard0531> but what if the line is more than 32k bytes ;) |
22:43:40 | GitDisc | <treeform> fileIndex indexes into a file array? But its still the same idea? |
22:44:01 | GitDisc | <treeform> I was thinking of there is some way not to store that info, like you inferring the line numbers by iterating the tokens or some thing? |
22:44:16 | GitDisc | <treeform> You only need line numbers if there is an error... |
22:45:14 | GitDisc | <treeform> but it only works if you use pointers to tokens or some thing |
22:45:33 | * | natrys quit (Quit: natrys) |
22:46:05 | Araq | you don't want to be clever in your line information handling, trust me |
22:46:25 | GitDisc | <treeform> ok ill trust you! Creating a file name array is a good idea. I will use that. |
22:46:35 | FromGitter | <alehander42> a.k.a. you dont want errors in the way you show errors |
22:47:01 | Araq | my way is "Only" 64 bits, it's acceptable |
22:47:19 | GitDisc | <treeform> do you need to use packed pragma for that? |
22:47:23 | Araq | no |
22:48:04 | GitDisc | <treeform> I remember (but not very well) C compilers are really bad at packing things, and will blow your 16 bit numbers to full 32 bits, nim handles that? |
22:48:33 | Araq | compilers use "natural" alignment an 16bit type is aligned at a 2 byte boundary, etc |
22:49:00 | Araq | C compilers are ok at packing things it's just that C programmers are bad at programming |
22:49:49 | GitDisc | <treeform> another thrift question, so normally thrift generate code that you then include, but in nim case it should be all macros right? |
22:50:24 | GitDisc | <treeform> you should not need to generate thrift bindings? or do you think it still should be done thrift way? |
22:50:43 | Araq | right. carefully crafted macros keep the input line information, ordinary code generation doesn't |
22:50:54 | GitDisc | <NopeDK> Finally... Found the reason why nothing was working for me... Too much abstraction hid multiple flags necessary for proper interfacing. Had to slightly modify the helper program to output the needed info... (zacharycarter) |
22:51:12 | * | claudiuinberlin quit (Quit: Textual IRC Client: www.textualapp.com) |
22:52:27 | * | Trustable quit (Remote host closed the connection) |
22:53:33 | * | MJCaley joined #nim |
22:54:02 | GitDisc | <treeform> Araq, do you recommend copying the file, line and offset into to the nodes as well? |
22:54:20 | Araq | yes |
22:54:42 | GitDisc | <treeform> One other though I had is to keep the tokens inside nodes, but that seemed harder. |
22:54:47 | Araq | you can be a bit more clever and use your Node type for Token too |
22:55:04 | GitDisc | <treeform> Would you recommend doing that? |
22:55:28 | Araq | never tried it but it should be fine if your lexer allocates a new node for every token |
22:55:45 | Araq | or at least for every token that will end up in the AST |
22:56:22 | GitDisc | <treeform> I have tokens as non-ref objects, means they are copied all the time. |
22:56:38 | GitDisc | <treeform> But I could not do Nodes are non-ref objects because they can contain each other? |
22:56:47 | GitDisc | <treeform> Is that the right way to do this or I am missing some thing? |
22:57:13 | Araq | actually you can have Node = object kids: seq[Node] since the 'seq' uses a hidden pointer for you |
22:57:45 | Araq | but then you need to be careful to move objects via shallowCopy to get good performance |
22:57:58 | GitDisc | <treeform> hmm would that be better? |
22:57:59 | Araq | something which you already seem bad at :P |
22:58:14 | GitDisc | <treeform> how would I get better at this? |
22:59:54 | GitDisc | <treeform> Can I tell the compiler to only allow shallowCopy? Then use some sort of copy keyword to get around it? So that I know what is going on? |
23:00:32 | GitDisc | <treeform> The pointer inside seq[Node] is not ref counting right? Because seq copy there is no need to ref count it? |
23:00:43 | GitDisc | <treeform> Its a ptr not a ref? |
23:01:54 | dom96 | Be careful, things become dangerous when using shallowCopy/ptr |
23:02:10 | GitDisc | <treeform> in what way? how? |
23:02:52 | Araq | you can do that via {.shallow.} ... |
23:03:01 | Araq | Pegs uses it |
23:03:07 | dom96 | You are then managing memory yourself. |
23:03:39 | Araq | originally I used it for my ASTs but it became cumbersome |
23:03:50 | GitDisc | <treeform> Oh and Pegs is another one of these case objects neat |
23:04:09 | GitDisc | <treeform> Araq, do you use ref Nodes now? |
23:04:25 | Araq | in the compiler they are everywhere |
23:05:00 | Araq | nowadays I would probably try and not use an AST at all... |
23:05:15 | GitDisc | <treeform> Really? How would you do it now? |
23:05:39 | Araq | as a seq of abstract tokens |
23:05:48 | Araq | but I have never done that before :P |
23:06:10 | Araq | well I would lay an API on top of it |
23:06:14 | Araq | emulating a tree |
23:06:19 | Araq | but stored sequentially |
23:06:23 | GitDisc | <treeform> So back to your packed JSON idea? |
23:06:29 | GitDisc | <treeform> but packed AST instead? |
23:06:40 | Araq | yes, wow you remember |
23:07:44 | GitDisc | <treeform> At pushbullet we had our own datatype, called string-only json where only [] {} and "" was allowed. |
23:07:56 | Araq | but for SQL'ish things it would be overkill, how big do you think the programs are? |
23:08:15 | GitDisc | <treeform> I was thinking maybe writing a json like parser for this subset of json. |
23:09:11 | GitDisc | <treeform> You are right, parsing for any language like SQL or Thrift it does not matter. Its so fast and so small anyways. |
23:09:39 | GitDisc | <treeform> The only place you need high performance parsing is JSON or XML. Because those files can be terabytes. |
23:09:45 | Araq | I would start with 'case ref object's and then try to remove the 'ref' and add .shallow if you need more speed (though it could easily be slower too) |
23:10:14 | Araq | and only after that I would attempt my "packed" trees. |
23:10:33 | GitDisc | <treeform> Interesting. |
23:11:10 | GitDisc | <treeform> Right now the slower parts in nim compilation are the C compilers and the C linker right? |
23:11:34 | Araq | but note that the versions without 'ref' have the big benefit that you get trees by construction |
23:11:50 | Araq | there is no way they turn into cyclic monsters accidentically |
23:12:46 | GitDisc | <treeform> yeah I can return ref's objects, and they are quick to return. If I used shallow, then they would copy the whole tree right? |
23:12:54 | GitDisc | <treeform> All the seqs inside? |
23:13:04 | Araq | well no, it would be a shallow copy |
23:13:25 | GitDisc | <treeform> Yeah sorry I think I had that confused. |
23:13:38 | GitDisc | <treeform> shallow copy shares ptr's in in the seq? |
23:13:50 | Araq | yes |
23:14:12 | GitDisc | <treeform> So if you are not careful you can end up with two shallow copies and do a free, then double free etc... |
23:14:30 | Araq | you don't free them, they are still GC'ed |
23:15:08 | GitDisc | <NopeDK> There is a note on the Compiler's docs that compiling as a shared library requires you to use "-d:useNimRTL", is that still the case? What happens if you don't use the RTL? |
23:15:36 | Araq | in Nim v2 shallowCopy will be *move* and eliminate the harmful aliasing |
23:15:47 | GitDisc | <treeform> I think I need to go play with shallowCopy a bit more. |
23:15:51 | GitDisc | <treeform> To get it. |
23:16:40 | Araq | NopeDK: still the case. it is required so that every Nim DLL shares the nim GC wich resides in nimrtl.dll |
23:16:56 | Araq | if you only have one DLL you can avoid it |
23:17:19 | Araq | but that's not tested properly so there be dragons |
23:18:17 | Araq | treeform: usually Nim compilation speed is the bottleneck for me |
23:18:52 | Araq | C results are cached and incrementally updated |
23:19:02 | GitDisc | <treeform> Do you use a debugger to step through the code or print statements? |
23:19:28 | GitDisc | <treeform> If so which one? gdb? |
23:20:07 | GitDisc | <NopeDK> And if I go hunting dragons, does the GC survive forks? Basically one master program loading the dll then summons multiple workers based on the dll. |
23:20:50 | GitDisc | <treeform> Do people still use the old BSD fork mechanism? I though everyone did some thing else now? |
23:23:17 | GitDisc | <NopeDK> It might be doing something else but the quality of the documentation is severely lacking so I am learning by crash and burn until success. |
23:26:14 | FromGitter | <RedBeard0531> @Araq: Microsoft tried the "we don't need an AST, a stream of tokens is enough for anybody!" approach and the result was MSVC++. You don't want nim to become MSVC++ do you? |
23:27:10 | Araq | treefrom; I don't write code lines that are not covered so my code "works" unless it doesn't and then I need an 'if cond: debug(x)' |
23:27:39 | Araq | and debuggers are very bad at conditional breakpoints IME so I don't miss them |
23:29:24 | GitDisc | <treeform> what does debug(x) do? Is there a doc for that? |
23:30:01 | GitDisc | <treeform> so you use test coverage mostly? |
23:32:01 | Araq | no, I write code that is executed thousands of times since there is system.nim and the hole stdlib I can import in my test program :P |
23:32:39 | Araq | debug(x) is compiler specific |
23:33:24 | Araq | NopeDK: I think everything works with 'fork' except OSX's Cocoa |
23:36:31 | GitDisc | <NopeDK> Awesome, thanks Araq |
23:37:13 | Miguelngel[m] | is readAll suitable to read a whole binary file and then transform the string to a seq of bytes or similar, or is there is something that might be wrong due passing through a string? |
23:37:50 | Araq | treeform: People love 'fork' and memory overcommitment, reliability is for whiners |
23:39:27 | Araq | Miguelngel[m]: it's fine when you never make me read your code |
23:43:30 | Miguelngel[m] | That's a really good point then. One of the things that surprised me is that I found a lot of procs in the standard library implemented for strings that it would also make sense to me for binary streams. For example the base64 module, and the "readAll", "readFile", etc. I was thinking if the lack of seq[u8] or similar versions was because string was meant to handle binary data or some other thing. |
23:44:43 | Araq | hey, string handles binary data just fine and most protocols are ascii/utf-8/byte hybrids |
23:45:16 | Araq | or underspecified (what's an environment var, utf-8?) |
23:46:56 | * | Snircle quit (Quit: Textual IRC Client: www.textualapp.com) |
23:54:13 | * | MJCaley quit (Quit: MJCaley) |