<< 25-03-2019 >>

00:05:10*rnrwashere quit (Remote host closed the connection)
00:06:04*rnrwashere joined #nim
00:19:17*rnrwashere quit (Remote host closed the connection)
00:25:31*rnrwashere joined #nim
00:28:06*theelous3_ joined #nim
00:38:25*lf-araujo quit (Ping timeout: 246 seconds)
00:40:31*theelous3_ quit (Ping timeout: 255 seconds)
00:44:29FromGitter<raydf> Hello
00:45:38FromGitter<raydf> Is there any way to convert an array to varargs?. Ex: ⏎ ⏎ ```["test", "test2", "test3"] to varargs[string]``` [https://gitter.im/nim-lang/Nim?at=5c9824b2fcaf7b5f730c6552]
00:49:46*lf-araujo joined #nim
00:57:31*stefanos82 quit (Remote host closed the connection)
01:01:00FromGitter<raydf> Just a note to myself: Keep digging on the forums :). Article explaining openarrays > https://forum.nim-lang.org/t/4654
01:12:15*Tyresc quit (Quit: WeeChat 2.5-dev)
01:12:35*rnrwashere quit (Remote host closed the connection)
01:13:09*rnrwashere joined #nim
01:14:14*rnrwashe_ joined #nim
01:14:24*rnrwashere quit (Remote host closed the connection)
01:25:31*chimez joined #nim
01:25:38*chimez quit (Client Quit)
01:36:20*rockcavera quit (Remote host closed the connection)
01:40:50*rnrwashe_ quit (Remote host closed the connection)
01:41:34*rnrwashere joined #nim
01:46:00*rnrwashere quit (Ping timeout: 250 seconds)
01:49:54*rnrwashere joined #nim
02:08:06*rockcavera joined #nim
02:28:28*vlad1777d joined #nim
02:33:27*lritter quit (Quit: Leaving)
02:33:47*vlad1777d quit (Ping timeout: 245 seconds)
02:43:12*noeontheend quit (Ping timeout: 250 seconds)
02:49:56*vlad1777d joined #nim
02:50:13*rnrwashere quit (Remote host closed the connection)
03:03:22*dddddd quit (Remote host closed the connection)
03:03:26*lf-araujo quit (Ping timeout: 250 seconds)
03:05:57*banc quit (Quit: Bye)
03:17:35*rnrwashere joined #nim
03:27:08*banc joined #nim
03:33:49FromDiscord<sealmove> You can iterate varargs with a `for` statement and store the items in an array
03:34:59FromDiscord<sealmove> But varargs kind of IS an array
03:35:12FromDiscord<sealmove> Why do you need to convert?
03:57:36FromGitter<kayabaNerve> I thought you could pass a seq to varargs
03:58:24FromGitter<kayabaNerve> sealmove: I think they're trying to pass an array to a function with a varargs argument.
04:02:07*rnrwashere quit (Remote host closed the connection)
04:05:58*vlad1777d quit (Ping timeout: 246 seconds)
04:13:27*chemist69 quit (Ping timeout: 240 seconds)
04:15:54*chemist69 joined #nim
04:16:15*rnrwashere joined #nim
04:20:59*vlad1777d joined #nim
04:26:05*nsf joined #nim
04:31:32*vlad1777d quit (Ping timeout: 250 seconds)
04:40:26*rnrwashere quit (Remote host closed the connection)
05:00:11FromGitter<kdheepak> Hi all, I'm struggling to understand why the `var` does not lead to a pass by reference in this case: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c98605b52c7a91455ef61a0]
05:00:48FromGitter<kdheepak> This is the result I get: ⏎ ⏎ ```1, 1, 1 ⏎ 10, 1, 1``` [https://gitter.im/nim-lang/Nim?at=5c9860803dd817114948be50]
05:01:56FromGitter<kdheepak> Can someone explain to me what I'm doing wrong here?
05:04:23FromGitter<kdheepak> This example appears to work fine: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c986157f3dbbd230cb1b0eb]
05:04:47FromGitter<kayabaNerve> Both the menu and the app have a state
05:04:50FromGitter<kdheepak> I have no idea what is going on here?
05:05:00FromGitter<kayabaNerve> You print the app's state but update the menu's
05:05:15FromGitter<Varriount> And a tuple is copied on assignment
05:05:18FromGitter<kdheepak> Yes, I was assuming that if I pass by reference they will point to the same
05:05:19FromGitter<kayabaNerve> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c98618f49fdaa0d810f8d22]
05:05:51FromGitter<Varriount> @kdheepak A `tuple` type is an `object` structure, not a `ref`.
05:06:01FromGitter<kdheepak> @Varriount my second example has an assignment but it is not being copied.
05:06:13FromGitter<kayabaNerve> They don't have the state though as state isn't a ref. If you defined State as a ref tuple and had the App and the Menu share said ref tuple...
05:06:36FromGitter<kayabaNerve> Objects assignments are copies.
05:06:40FromGitter<kayabaNerve> Copies are copies.
05:07:02FromGitter<kayabaNerve> Coding is copying.
05:07:06FromGitter<kayabaNerve> :thinking:
05:07:38FromGitter<Varriount> @kayabaNerve We copy information from the computer screen into our brains. :O
05:07:38FromGitter<kdheepak> Okay that makes sense, but if I make `State = ref tuple` how do I create an instance of state?
05:07:44FromGitter<kdheepak> ```code paste, see link```
05:07:47FromGitter<kayabaNerve> So either define a ref object with the tuple as a member or change the typedef to a ref tuple.
05:07:59FromGitter<kayabaNerve> @kdheepak Allocate via new and then use the [] to dereference
05:08:07FromGitter<kayabaNerve> @Varriount Humanity is copying
05:08:24FromGitter<kayabaNerve> *anyone here see the RvB Robot Optionals scene?
05:08:31FromGitter<kdheepak> > So either define a ref object with the tuple as a member
05:08:40FromGitter<kdheepak> @kayabaNerve may I not doing this already?
05:08:49FromGitter<kdheepak> ``` Menu = ref object ⏎ state: State``` [https://gitter.im/nim-lang/Nim?at=5c98626149fdaa0d810f8fe5]
05:09:01FromGitter<kayabaNerve> You define state as a type alias to a tuple
05:09:07FromGitter<kayabaNerve> Define state as a type alias to a ref tuple
05:09:13FromGitter<kayabaNerve> One sec, I'll provide an example
05:09:41FromGitter<Varriount> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c9862956a3d2e230d1e8dc4]
05:09:56FromGitter<kdheepak> Okay. Thanks. Sorry, I'm still struggling to understand the semantics of ref, object, var in Nim.
05:10:48FromGitter<kdheepak> Interesting.
05:10:52FromGitter<kdheepak> Okay that worked.
05:11:18FromGitter<kayabaNerve> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c9862f552c7a91455ef72e9]
05:11:39FromGitter<Varriount> @kayabaNerve :P
05:11:40FromGitter<kayabaNerve> Variount beat me to it because I tried using nicer ref constructors :(
05:12:22FromGitter<kayabaNerve> I only use new when \I define a ref primitive :P
05:12:37FromGitter<Varriount> @kdheepak Nim picks the best way to pass parameters to functions behind the scenes.
05:12:38FromGitter<kayabaNerve> I try to abstract away from it as much as possible
05:12:50FromGitter<kayabaNerve> @Varriount Sounds like Skynet
05:13:12FromGitter<Varriount> If you look at the C code, you'll notice that, even with object types, Nim will usually pass them by pointer.
05:13:14FromGitter<kdheepak> So you said "So either define a ref object with the tuple as a member or change the typedef to a ref tuple.". This approach is the second?
05:13:20FromGitter<kdheepak> What if you want to do the first?
05:13:47FromGitter<Varriount> @kdheepak @kayabaNerve and my examples were the second approach, yes.
05:14:36FromGitter<kayabaNerve> ```type State = ref object ⏎ myTuple: tuple[x:int, y:int, z: int]``` [https://gitter.im/nim-lang/Nim?at=5c9863bc81b15c5e4b80e16a]
05:14:45FromGitter<kdheepak> Can you provide an example of the first, for pedagogical purposes.
05:14:57FromGitter<kayabaNerve> Just did :P
05:15:00FromGitter<kdheepak> I see.
05:15:07FromGitter<kdheepak> Thanks!
05:15:12FromGitter<kayabaNerve> @Varriount Quick Q
05:15:16FromGitter<Varriount> Yeah?
05:15:23FromGitter<kayabaNerve> Does it hurt to define `of RootObj` if it's not needed?
05:15:39FromGitter<Varriount> You only need RootObj if you're going to use inheritance.
05:15:52FromGitter<kayabaNerve> I define all of my objs like that out of habit. I also define all my objs ref which I know is bad 0_o
05:15:56FromGitter<kayabaNerve> Yeah
05:16:11FromGitter<Varriount> It doesn't hurt. Or if it does, it's very minor.
05:16:18FromGitter<kayabaNerve> K :thinking:
05:16:40FromGitter<kayabaNerve> I'm working on a very OOP codebase, but Inheritance doesn't come up too often,
05:17:00FromGitter<Varriount> From the manual: ⏎ ⏎ > Objects that have no ancestor are implicitly final and thus have no hidden type field. One can use the inheritable pragma to introduce new object roots apart from system.RootObj.
05:17:01FromGitter<kayabaNerve> I think the only place I use it is when I need to store multiple object types in a single seq.
05:17:23FromGitter<kayabaNerve> So an extra couple bytes of RAM per instance?
05:17:38FromGitter<kayabaNerve> Eh. I'm cleaning up my codebase in a few weeks. I'll remove it then.
05:17:46FromGitter<kayabaNerve> Thanks
05:17:56FromGitter<Varriount> @kayabaNerve It might affect run-time-type data generation
05:18:18*I_Right_I quit (Remote host closed the connection)
05:18:20FromGitter<Varriount> But if RTTI isn't used in your program, I believe it's removed anyway.
05:18:44FromGitter<Varriount> @kayabaNerve Let me check
05:21:51*rnrwashere joined #nim
05:22:03FromGitter<Varriount> @kayabaNerve Well, changing a type from `object` to `object of RootObj` changed the binaries (under both debug and release mode), so it changes something.
05:23:05FromGitter<Varriount> @kayabaNerve An extra 4344 bytes of information was generated in the binary that was generated using `RootObj`
05:28:16FromGitter<Varriount> Oddly enough, the extra data is all zeroes.
05:37:15FromGitter<kdheepak> I have a very early version of a comic book reader that is potentially cross platform, and it is built entirely in Nim :D I've tested it on Mac OSX and iOS at the moment.
05:39:37FromGitter<kdheepak> (https://files.gitter.im/nim-lang/Nim/HeIX/animation.gif)
05:41:39FromGitter<kdheepak> Thanks for the help! Passing around the state tuple as a reference was the final piece in connecting the different components.
06:22:29FromGitter<Varriount> @kdheepak How are you interfacing with the iOS APIs?
06:23:30FromGitter<Varriount> And would you be willing to write a forum (or blog post) on your experiences?
06:23:36*rnrwashere quit (Remote host closed the connection)
06:29:28*narimiran joined #nim
06:31:05Zevvkdheepak: your url gives access denied
06:32:54narimiranremove )
06:50:22*solitudesf joined #nim
06:55:25FromGitter<kdheepak> @Zevv which url?
06:55:42FromGitter<kdheepak> This is the gif I linked in gitter earlier: https://files.gitter.im/nim-lang/Nim/HeIX/animation.gif
06:56:41FromGitter<kdheepak> @Varriount if only it were that interesting... I'm just using SDL2, which has already abstracted away all the code to set up a window, get touch events etc on different platforms.
06:57:42FromGitter<kdheepak> I'll definitely be writing up a blog post at some point.
07:00:00*gmpreussner quit (Quit: kthxbye)
07:00:47*krux02 joined #nim
07:01:08FromGitter<kdheepak> The takeaway for me was that I can use Nim + SDL2 and develop on my laptop, and when I need to I can generate the appropriate iOS files and everything just works. I get to use the tools I'm comfortable with as well (zsh + vim + tmux), instead of using XCode.
07:04:58*gmpreussner joined #nim
07:05:35*Vladar joined #nim
07:12:58FromGitter<danielecook> Is there a way to set a parameter as optional in a `proc`?
07:13:12FromGitter<danielecook> @kdheepak that is awesome
07:15:10FromGitter<kayabaNerve> @Varriount Thanks for all the info.
07:15:35FromGitter<kayabaNerve> Congrats @kdheepak
07:17:52*PMunch joined #nim
07:21:45*jjido joined #nim
07:37:48*zyklon joined #nim
07:38:30*uvegbot quit (Ping timeout: 268 seconds)
07:40:31*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
07:41:26FromGitter<bwkenny321> Can anyone help? I follow the instruction refer to "https://github.com/nim-lang/Nim" but I still cannot install properly.
07:42:23FromGitter<bwkenny321> Here 's my code, ubuntu 18.04 ⏎ git clone https://github.com/nim-lang/Nim.git ⏎ cd Nim ⏎ git clone --depth 1 https://github.com/nim-lang/csources.git ⏎ cd csources ... [https://gitter.im/nim-lang/Nim?at=5c98865f5547f774485ff862]
07:45:16FromGitter<kayabaNerve> 1) We'd need the error. ⏎ 2
07:45:25PMunchbwkenny321, easiest is to install through choosenim
07:45:40PMunchIf you can't find in it apt there is a script to install it on the website
07:45:47FromGitter<kayabaNerve> PMunch: I just edited my message on Gitter to include that :P
07:45:52FromGitter<kayabaNerve> That was the "2"
07:46:10PMunchAh, edits don't carry over to IRC
07:46:46FromGitter<kayabaNerve> `curl https://nim-lang.org/choosenim/init.sh -sSf | sh`
07:46:51FromGitter<kayabaNerve> Yeah, I know.
08:04:46*Senketsu quit (Ping timeout: 252 seconds)
08:10:34*jjido joined #nim
08:24:38*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
08:53:13*salewski joined #nim
08:53:54salewskiDo we have an iterator that gives us pairs like: [1, 2, 3] => (1, 2) (2, 3) (3, 1)
08:56:46Araqrepeat(s, 2).zip() ?
08:57:10*Senketsu joined #nim
08:57:23salewskiThanks, will try that. Bye.
08:59:58*salewski quit (Quit: WeeChat 2.3)
09:02:19narimiransalewski: use `windowed` iterator from https://github.com/narimiran/itertools ;)
09:03:19narimiranor for making pairs, not arbitrary-length tuples: `pairwise`
09:04:14*salewski joined #nim
09:05:23salewskinarimiran, thanks. That itertools module was indeed what I was looking for!
09:05:55narimiransalewski: please report any problems you find with it, i haven't really tested/used it
09:06:54salewskiFirst problem was to find it. I had the feeling that what I was looking for was available,
09:07:07salewskibut did not find it in standard module set.
09:08:05salewskiI really think I saw your itertools already some months ago, but I did not remembered well...
09:08:07salewskiBye.
09:08:43*salewski quit (Client Quit)
09:16:04*seerix_ joined #nim
09:18:19*seerix quit (Ping timeout: 250 seconds)
09:19:06*Senketsu quit (Ping timeout: 268 seconds)
09:40:22*solitudesf quit (Ping timeout: 250 seconds)
09:58:20PMunchnarimiran, sounds like my libraries. I have a problem, spend lots of time creating a nice library to solve it, and then barely use it for anything else :P
09:59:00narimiranPMunch: yeah, i used it once for an AoC task, just so i can say i've used it at least once :D
10:08:52*kapil____ joined #nim
10:12:12FromGitter<mratsim> does iterator chaining works in your itertools?
10:12:37narimiranprobably not, haven't tried it :D
10:15:10FromGitter<mratsim> Apparently they are still supposed to be chained even though it has beenw orking for years :D https://nim-lang.org/docs/manual.html#iterators-and-the-for-statement-first-class-iterators
10:18:50*stefanos82 joined #nim
10:23:46krux02iterator chaining shouldn't be that much of a problem, just create an iterator that yields the elements from two other iterators
10:24:02krux02the only problem is that recursive chaining can't work
10:25:47FromGitter<mratsim> I mean for x in countup(1, 10).filter(x => x mod 2)
10:26:03FromGitter<mratsim> (dumb example but it shows what I mean)
10:26:16krux02yea
10:26:45krux02I got used to write it is ``for x in countup(1, 10): if x mod 2: ...
10:27:05krux02(if x mod 2 would be a legal boolean expression)
10:27:28FromGitter<mratsim> yes right
10:29:16FromGitter<coocheenin> Hi, Folks. Just wrote tiny package for sending emails from binaries. Like so: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ https://github.com/coocheenin/easymail [https://gitter.im/nim-lang/Nim?at=5c98ad7b0d7190505760faa6]
10:29:19krux02I like functional programming style, but I don't like the performance cost of it, so I construct my loops thinking functional, but writing it down as imperative code
10:29:25FromGitter<coocheenin> I will wonder if somebody will found it useful. If yes, i will type `nimble publish`. If a "tiny package" is not a problem :)
10:30:06krux02coocheenin: you can publish to nimble whatever you want. It doesn't need to be "useful"
10:30:22FromGitter<mratsim> The performance cost of functional programming is mostly due to intermediate allocations, if you can remove those you're in good shape, like what zero-functional and Rust does.
10:30:54krux02the problem is, it's not that simple
10:31:11krux02yes Rust does a good job with that
10:31:49krux02but then you have to deal with all these "once" values and stuff
10:32:33krux02it is just, you want to avoid complexity by going fully functional, then you want to eleminate the allocations and whoop the complexity rises again in move semantics.
10:33:50FromGitter<mratsim> I've compiled many optimisations approaches applicable to functional lang (mostly Ocaml, Scala and Haskell) here: https://github.com/mratsim/Arraymancer/issues/347#issuecomment-461009747 ⏎ ⏎ Most promising ones where catamorphisms, transducers and attribute grammars
10:34:09AraqI simply use for loops instead, FP is like epicycles of programming, you always need more stuff
10:34:32Araqthere is nothing wrong with nesting for loops anyway.
10:35:05Araqit's simple, it works, it "scales", it's debuggable code
10:35:27FromGitter<mratsim> for ML, both functional and for loop approach don't scale :/
10:35:40Araqnot naming the intermediate steps tends to be terrible for debugging
10:35:55Araqbut then ok, you don't debug FP code because it's correct.
10:36:06krux02yes
10:36:28krux02and you still can name the intermediate steps if you want
10:37:24Araqbut then the first-class thing comes in and bites you. you need to materialize the result for this explicit name.
10:38:16Araqthe difference between f(g(x)) and 'let tmp = g(x); f(tmp)' is big.
10:38:56FromGitter<alehander42> i agree with mratsim
10:39:22FromGitter<alehander42> the whole point of having a powerful language is that you can generate very optimal code even from abstractions like function chaining
10:40:12FromGitter<alehander42> having names for steps is a completely different issue
10:40:32FromGitter<alehander42> one can write unreadable/hardtodebug code with loops too
10:40:34krux02Araq: Well the problem is also when you try to debug functional programming with a debugger designed for imperative programs.
10:40:39krux02There are other debuggers
10:40:59krux02For example the emacs-lisp debugger in emacs is expression based, not line based
10:40:59FromGitter<alehander42> that's a tooling problem: nim people often say "we wouldnt do X in the language just because tools suck"
10:41:16krux02you get the the intermeditate values of f(g(x))
10:41:25krux02or better said (f (g x))
10:42:39FromGitter<alehander42> if we let current debuggers state dictate lang design choices, this should also affect all the "but I need this feature to help me when writing nim in a plain editor i dont want an IDE"
10:43:16krux02in nim the debugger is very detached from the ide :P
10:43:36FromGitter<alehander42> yeah but its a similar kind of thinking :P
10:44:08Araqit's perfectly fair to say "I wait with FP until the tooling is ready"
10:44:23krux02yes it is
10:44:35Araqand then "I wait with FP until it doesn't cause slow allocations everywhere"
10:44:56FromGitter<mratsim> well, right now we don't have inline iterator chaining so no FP :P
10:45:00krux02but there is also little effort to improve tooling explicity designed around nim FP style
10:45:24Araqand then also "I wait with FP until my coworkers are familiar with it, the tooling is there and the performance problems disappeared"
10:45:29krux02mratsim: what is the problem with that?
10:46:15FromGitter<mratsim> it's a feature mentionned in the manual
10:46:23Araqand even then FP needs to have merits of its own to justify the switch. And tbh the merits exist.
10:46:52Araqbut that's for FP. For OOP the merits never existed. Ymmv.
10:46:55FromGitter<mratsim> See: https://github.com/nim-lang/Nim/issues/4516
10:47:11krux02Well I like FP enough to improve the tooling and the Language to the point where I see it is worth it.
10:47:41krux02But I don't plan to make Nim the functional programming laguage of choise, I that that one isn't worth the effort.
10:48:46FromGitter<mratsim> I want usable iterators that can be composed with minimal perf overhead (and certainly not intermediate alloc overhead)
10:50:23krux02mratsim: for me it would be ``zip`` on iterators. I really miss that one
10:50:35FromGitter<mratsim> yes
10:50:44FromGitter<mratsim> that's the most needed I agree
10:51:24FromGitter<mratsim> Well now I've written several macros to work around that for my use cases
10:51:40krux02for zip I usually fall back to indices
10:52:06krux02that doesn't work for stuff that doesn't use indices, yes. But I am lucky I use stuff with indices
10:52:29FromGitter<mratsim> for tensors unfortunately you can't because sometimes you have a slice (or worse a slice with steps) and you can't use indices
10:53:09krux02well then you have to take the stride into account as well, but it does work afaik
10:53:23krux02but sparse could be a problem
10:53:44FromGitter<mratsim> I didn't implement sparse tensors yet.
10:53:52krux02everything that isn't uniformly structured
10:55:10Araqbefore I wrote "lambda lifting" I looked at Haskell's deforestation and tried to apply it to Nim. I failed.
10:55:19FromGitter<mratsim> the good thing with tensors is that I don't have to deal with "filter", basically every operation is a map or a reduction
10:55:46Araqand deforestation is a killer optimization IMO.
10:56:14Araqhappily removing all kinds of intermediate data structures
10:56:33Araqincluding whole trees on the heap.
10:57:12FromGitter<mratsim> deforestation is not always needed: see my links here https://github.com/mratsim/Arraymancer/issues/347 on catamorphisms, transducers and attribute grammar (http://sixty-north.com/blog/deriving-transducers-from-first-principles.html, https://github.com/mratsim/Arraymancer/issues/www.scholarpublishing.org/index.php/TMLAI/article/download/3397/1944https://medium.com/@olxc/catamorphisms-and-f-algebras-b4e91380d134)
10:57:58FromGitter<mratsim> ugh made a mess of links
10:58:12FromGitter<mratsim> https://medium.com/@olxc/catamorphisms-and-f-algebras-b4e91380d134
10:58:27FromGitter<mratsim> https://www.scholarpublishing.org/index.php/TMLAI/article/download/3397/1944
10:58:38*zyklon quit (Ping timeout: 244 seconds)
11:00:41*zyklon joined #nim
11:09:28krux02mratsim: what is that link?
11:09:42krux02I can.t see it. I only see a login wall
11:10:12FromGitter<mratsim> http://scholarpublishing.org/index.php/TMLAI/article/download/3397/1944 <- this should work
11:11:01FromGitter<mratsim> It's an implementation of attribute grammars in scala to traverse various operations without intermediate allocation
11:11:05krux02yes it does, but it also warns me that the connection isn't secure
11:11:29krux02what is an attribute grammar?
11:12:40FromGitter<mratsim> it's a tree traversal techniques, mostly used for compiler construction
11:12:55FromGitter<mratsim> You have simple examples here: http://ps.informatik.uni-tuebingen.de/2014/10/23/presentation-at-oopsla/slides.pdf
11:13:14krux02tree traversal was the performance killer for my Game engine that I wrote in Scala
11:13:32krux02(in 2012)
11:15:28FromGitter<mratsim> also related: object algebra in Nim (though that creates a mess in nested types) - https://github.com/mratsim/compute-graph-optim/blob/master/e01_obj_algebra.nim and typed tagless final in Nim: https://github.com/mratsim/compute-graph-optim/blob/master/e05_typed_tagless_final.nim
11:16:04FromGitter<mratsim> I'm deep into tree traversals for my ML compiler :/
11:16:19krux02well I don't understand it
11:16:37krux02but it's a cold start for me
11:16:59krux02why do you write an ML compier?
11:17:13FromGitter<mratsim> yeah, I think if you can get the video for those slides it would be great: http://ps.informatik.uni-tuebingen.de/2014/10/23/presentation-at-oopsla/slides.pdf
11:17:47FromGitter<mratsim> my reasons are here: https://github.com/mratsim/Arraymancer/issues/347#issuecomment-459351890
11:18:29FromGitter<mratsim> Loop fusion and SIMD.
11:18:40FromGitter<mratsim> then gradient
11:19:13FromGitter<mratsim> also compiler with CPU, Cuda, OpenCL, Vulkan, OpenGL, anything supported by LLVM backends
11:20:58FromGitter<mratsim> The Halide language I'm referring too in the post is a language for computational photography, which allows to decouple the algorithm from the optimisations, meaning I can test different way to parallelize/vectorize/introduce intermediate/precompute.
11:21:25krux02cool
11:23:15FromGitter<mratsim> ML compiler are a very activ area of research. I saw ads that Intel is recruiting for that for example. Facebook, Google, OpenAI have projects in that direction as well.
11:24:11FromGitter<mratsim> The author of LLVM is also doing that (but in Swift) I think.
11:24:38*dddddd joined #nim
11:25:04Araqmratsim: have you looked into "burg" for code generation?
11:26:23FromGitter<mratsim> not at all, thanks for the name
11:27:16Araqand how do you do register allocation in your JIT?
11:27:50Araqgraph coloring? linear?
11:29:17FromGitter<mratsim> generate LLVM IR and let it deal with it
11:29:48FromGitter<mratsim> or at compile-time, generate Nim code
11:29:56FromGitter<mratsim> which is what I'm starting with
11:31:39Araqoh you generate LLVM. then why do you mention 'mov' and its variants?
11:32:29FromGitter<mratsim> where?
11:33:38FromGitter<mratsim> ah you means here in the written from scratch section? https://github.com/mratsim/Arraymancer/issues/347
11:33:59FromGitter<mratsim> that's just exhaustively putting implementation possibilities
11:34:19FromGitter<mratsim> I have a jit assembler in Nim that works
11:34:41FromGitter<mratsim> but it's mentionned in the bottom, that they are significant challenges like register allocations ;)
11:36:14FromGitter<mratsim> not even talking about jitting for GPU ...
11:41:39Araqok
11:42:05*abm joined #nim
11:54:36*sentreen joined #nim
11:57:44*sentreen_ quit (Ping timeout: 250 seconds)
12:00:12*rusua joined #nim
12:14:34*a_b_m joined #nim
12:15:30*a_b_m quit (Client Quit)
12:15:49*sentreen_ joined #nim
12:18:14*abm quit (Ping timeout: 250 seconds)
12:18:47*sentreen quit (Ping timeout: 245 seconds)
12:21:33*seni joined #nim
12:22:01*sentreen joined #nim
12:25:26*sentreen_ quit (Ping timeout: 272 seconds)
12:35:13*sentreen_ joined #nim
12:37:28*sentreen1 joined #nim
12:38:28*sentreen quit (Ping timeout: 250 seconds)
12:40:20*sentreen_ quit (Ping timeout: 250 seconds)
12:43:06*sentreen1 quit (Quit: WeeChat 2.3)
12:43:23*sentreen joined #nim
12:44:56*solitudesf joined #nim
12:52:37*sentreen_ joined #nim
12:52:53*sentreen_ quit (Client Quit)
12:55:27*sentreen quit (Ping timeout: 245 seconds)
12:57:49*kapil____ quit (Quit: Connection closed for inactivity)
12:57:56*shashlick quit (Remote host closed the connection)
12:58:15*shashlick joined #nim
13:14:37FromGitter<alehander42> do we support /^[[:digit:][:upper:]_]+$/.freeze
13:14:45FromGitter<alehander42> :digit: etc in our regexes
13:15:05FromGitter<alehander42> posix character class
13:22:22Araqno idea, I would guess that PCRE supports that
13:25:53*salewski joined #nim
13:28:00salewskiQuestion: procs have default result variable. I guess iterators not? Is that fact documented somewhere? Can not find currently.
13:31:29salewskiOK, was documented in tut1: Iterators have no implicit result variable.
13:31:41Araqnot good enough, the manual needs to say it
13:32:10salewskiYes, would be better, I searched in manual first :-)
13:32:36salewskiAnd maybe say WHY also.
13:32:43salewskiBye.
13:33:10*salewski quit (Quit: WeeChat 2.3)
13:58:50PMunchWhat would the result variable in an iterator do?
13:59:44*vlad1777d joined #nim
14:00:40*sealmove joined #nim
14:01:42Araqit would contain the value for an empty 'yield'
14:01:59Araqbut we also don't have empty yields, so ... *shrug*
14:06:39PMunchAh, I guess that could be a useful feature
14:09:04*nsf quit (Quit: WeeChat 2.4)
14:09:33*rusua quit (Quit: Connection closed for inactivity)
14:28:18*cgfuh joined #nim
14:28:33*lritter joined #nim
14:47:06*sentreen joined #nim
14:49:28FromGitter<dawkot> Is it possible to get a different value (of whatever type) for each type, if that makes sense? I can't rely on hashing type names because of aliases and generics...
14:49:32FromGitter<arnetheduck> playing around with iterator a bit.. looks like it's not possible to implicitly return one, rings a bell? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c98ea7c9d9cc8114a1c56d8]
14:55:46FromGitter<arnetheduck> > What would the result variable in an iterator do? ⏎ ⏎ I still don't see what `result` for a proc would do, beyond save a line of code very rarely :)
14:57:01Araqit gives us a named return value optimization whether you accept it or not.
14:59:12*sentreen quit (Ping timeout: 245 seconds)
14:59:43FromGitter<arnetheduck> practically, right now, yes.. but we've already decided that's a moot point - it can be had without it. so, backwards compat remains the strongest argument now.
15:00:01Araqand saving a line like 'var result: typeof(thisProc)' also has some merit given that we don't have 'thisProc'
15:03:18*noeontheend joined #nim
15:03:53rockcaveraHello! How do I compile for win32 using mingw64 and nim64?
15:04:19rockcaveranim c --cpu:i386 has given error
15:04:38Araqvia --os:windows --cpu:i386 and a mingw that can handle it
15:06:25rockcaverastill giving error
15:06:49*PMunch quit (Remote host closed the connection)
15:07:06Araqwhat error? and why can't you simply a 32bit Nim? it runs on your 64bit machine.
15:08:03rockcaverauhum
15:08:59rockcaveraError: execution of an external compiler program 'gcc.exe -c -w -mno-ms-bitfields -DWIN32_LEAN_AND_MEAN -ID:\Nim-0.19.4\lib -o "C:\Users\Jose\Desktop\nim\nimcache\debug\stdlib_parseutils.c.o" "C:\Users\Jose\Desktop\nim\nimcache\debug\stdlib_parseutils.c"' failed with exit code: 1
15:09:01rockcaveraIn file included from C:\Users\Jose\Desktop\nim\nimcache\debug\stdlib_parseutils.c:10:0:
15:09:01rockcaveraD:\Nim-0.19.4\lib/nimbase.h:490:13: error: size of array 'Nim_and_C_compiler_disagree_on_target_architecture' is negative
15:09:02rockcaveratypedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1];
15:09:02rockcavera^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15:09:41Araqyeah, you need to change your config. Like the error tells you.
15:09:41*rockcavera quit (Remote host closed the connection)
15:10:48*rockcavera joined #nim
15:10:50*Trustable joined #nim
15:11:13*rockcavera quit (Remote host closed the connection)
15:11:57*sentreen joined #nim
15:13:06FromGitter<arnetheduck> for the function return type DRY problem, we've sometimes started using the style `func init(T: type Something, ..) T: T(init_field: y)` for constructors.. it's kind of sad though that you would have to use `type(result)` - an actual instance - to get compile time information of the return type. would be nice to have it available some other way so that it's available also when *not* using `result`.. one trick is
15:13:06FromGitter... `auto` return type and just return whatever, but that's not satisfactory either.
15:17:48FromGitter<dawkot> Is there any way to get the name of the type underlying a type alias?
15:20:03*rockcavera joined #nim
15:20:06FromGitter<iffy> What's the opposite of `nimble develop`?
15:21:51FromGitter<arnetheduck> `make` and git submodules :) that's where we are, as we start to abandon nimble
15:24:34Araqmake? that's so sad.
15:25:11Araqwhy not 'tup' or scons or ...
15:28:47Araqiffy: you can remove the symlink emulation in your $nimbleDir
15:28:58Araqto undo 'nimble develop'
15:29:10*clyybber joined #nim
15:29:16Araqwhether there is also a nimble command I don't know :-)
15:30:45FromGitter<iffy> k, thanks :)
15:31:59FromGitter<iffy> Nim is abandoning nimble? Or just you for a particular thing, @arnetheduck
15:33:37Araqhe speaks about Nimbus, not Nim.
15:34:08FromGitter<arnetheduck> Araq, because tup and scons and so on require more special tools and magic knowledge.. we'd rather stay within nim (and a nim-native build system) but if that's not possible, within whatever is generally known and available
15:35:12*leorize left #nim ("Kicked by @appservice-irc:matrix.org : issued !quit command")
15:36:10Araqok. I would use a small Nim program instead but whatever.
15:36:22FromGitter<arnetheduck> @iffy yeah, it's just for a project we're working on
15:36:30FromGitter<iffy> phew
15:37:17FromGitter<arnetheduck> the "small" nim programs add up, in terms of maintenance.
15:37:28Araqso do makefiles
15:38:14Araqand makefiles are super incomplete, in reality it's make+<shell script code within make> and then you have porting fun
15:41:36*rnrwashere joined #nim
15:43:15FromGitter<arnetheduck> well, whatever. if someone comes along and writes us a better alternative, I'm all for - the makefile we have in place right now turns out to be the least bad option. it boils mostly down to having repro builds ("if I can compile, so should you") - we have a longer and more detailed req:s list, but it's fairly standard, by modern tooling standards
15:51:53clyybberHas anybody done something with midi in nim yet?
15:52:57FromGitter<arnetheduck> point is, tuning a (collection of) scripts to do the right thing, and not regress on common use cases, is not a simple a task. if it was, there wouldn't be such a large collection build systems out there - sometimes multiple per language. of course, you can say "but this works for me, in my little bubble that I've set up" - that's kind of.. limited ;)
15:57:01Araqlots of systems not in touch with me migrated from make to something better.
15:57:07*rnrwashere quit (Remote host closed the connection)
16:02:05*leorize joined #nim
16:02:35*leorize left #nim (#nim)
16:03:21*leorize joined #nim
16:03:34*leorize is now known as leorize-otg
16:04:01*leorize-otg left #nim (#nim)
16:05:44*noeontheend quit (Ping timeout: 250 seconds)
16:15:20FromGitter<arnetheduck> I'm not saying it's not possible. I'm saying a random collection of half-baked scripts won't do better than make, and nimble isn't up to the task for *our* needs. longer term, we'll probably invest in something, which might include fixing nimble or whatever.. but *today*..
16:40:30Araqok, I wasn't meant to start a fight. Just for the record besides reproducible builds what does Nimble lack for your needs?
16:40:39Araq*I didn't mean
16:46:37*rnrwashere joined #nim
16:56:59shashlickI'd be interested to understand this as well - I hope to ramp up on nimble and make some useful contributions
16:57:30FromGitter<iffy> What is `defined` on 32bit vs 64bit?
16:57:49*rnrwashere quit (Remote host closed the connection)
16:58:26*rnrwashere joined #nim
17:02:56*rnrwashere quit (Ping timeout: 250 seconds)
17:06:02FromGitter<mratsim> i386 and amd64
17:06:24FromGitter<mratsim> the defines are different for arm and mips though
17:07:02Araqthere is defined(cpu32) vs cpu64 iirc but I always use when sizeof(int) == 4
17:07:08Araqso I don't remember
17:09:17FromGitter<mratsim> my top issues with nimble are: ⏎ ⏎ 1) a way to update installed packages without having #head #master #0.1.0 installed at the same time and giving me weird error ⏎ 2) requiring nimble packages at task level (very important for tests) ⏎ 3) please stop asking me to override when installing multiple projects which depends on the same package, just solve it once. It takes too much time o install nimbus even though
17:09:17FromGitter... there are only like 15 dependencies and our CI is getting very long because of nimble dependencies resolution. [https://gitter.im/nim-lang/Nim?at=5c990b3d2fb6800d807ca70a]
17:09:24FromGitter<arnetheduck> the short-list we discussed was: ⏎ ⏎ 1) better monorepo support - host multiple projects in single repo and version and reference accordingly (a bit like `nimble develop`, but within repo) - so we can publish smaller and more reusable libs for the community without paying the multi-repo tax ⏎ 2) side-by-side checkouts - different versions / branches / etc (== repro builds) ⏎ 3) avoid spurios rebuilds -
17:09:24FromGitter... build times are getting significant as we grow - arguably this is nim, but the line between nim and nimble is more blurred than other langs (which tend to have a more pure compiler and a more pure build&pm tool) - same as nim, we have a growing test suite, so it should smartly run only the necessary tests - an extension of de ... [https://gitter.im/nim-lang/Nim?at=5c990b442fb6800d807ca70e]
17:12:49FromGitter<iffy> @mratsim Araq: thanks! (I found this based on your answers: https://github.com/nim-lang/Nim/wiki/Consts-defined-by-the-compiler#cpu-architectures )
17:13:00shashlickthanks for taking the time to type that out
17:14:12shashlickhere's my challenge - there's 132 open issues in nimble, a whole legacy workflow which already exists and minimally understood by me, and zero so-called package manager experience on my side
17:14:20FromGitter<arnetheduck> most of these are for helping with coordination issues that happen when multiple developers are working on the same project, and that project starts growing.. we suddenly start facing problems that don't appear when you're soloing or working on a single thing.. same thing with `nimble install` which monopolizes the development environment
17:15:30shashlickso I need help to identify specific changes that will improve nimble
17:15:56shashlickone which bothered me personally is the inbuilt nim compiler which I am looking into removing and leveraging nim directly
17:17:48Araqshashlick: that would already solve many problems, it's fine to focus on that
17:18:19shashlickI don't see that solving any of the concerns raised by @mratsim and @arnetheduck
17:18:32Araqha ha ha :-)
17:19:09shashlicksecond one was a per project nimble workflow, which is perhaps somewhat supported already with --nimbleDir
17:19:40shashlicki think that might help some, but curious on your feedback on that one
17:20:04Araqwas about to say that.
17:26:19FromGitter<mratsim> one last thing is for showcasing in 2 scenarios: "the user has nothing" and "the user has an outdated versions of dependencies". We want to provide a "nimble showcase" command that deal with everything in the background. But there is regular back and forth with "oh this dependency was updated" (withoutgoing all the way into repro build)
17:26:21FromGitter<arnetheduck> so anyway, we'll soon be launching a public test network for the next version of ethereum (the project we're working on, a block chain) - if someone wants to join in as a tester, it's a pretty cool opportunity. we're busy ironing out the kinks in the process, but if anyone wants to try a preview or help test the instructions and provide feedback, https://github.com/status-im/nim-beacon-chain outlines the process to
17:26:21FromGitter... get started..
17:26:48FromGitter<mratsim> need nim stable, it will not compile in devel ;)
17:27:12FromGitter<arnetheduck> well, the build instructions are *supposed* to take care of that :)
17:29:33FromGitter<arnetheduck> on the upside, we've been hosting a status-im Nim branch against the eventuality that we'll need to critically patch Nim, but it's been locked at 0.19.0 for a good 6 months now, so things are not terrible in stable-land
17:30:07*natrys joined #nim
17:31:17shashlick@mratsim is your showcasing comment about nimble verbosity?
17:31:19FromGitter<arnetheduck> we try to keep it at as low a version as possible (so that people installing nim via distros and homebrew can work with it)
17:31:56FromGitter<mratsim> no, it's about incompatible/outdated versions installed
17:32:28shashlickthat's what I expect from most commercial endeavors, you pick a version and stick to it, so 0.19.x branch is required for stability
17:32:37shashlickany reason why you haven't picked up 0.19.2 and 4?
17:33:17shashlick@mratsim - so you mean remove all older packages lying around when doing updates
17:33:46FromGitter<arnetheduck> it didn't include fixes for any of the critical bugs we're waiting for to be fixed, and nobody bothered to switch (basically, we could, it's probably compatible, we just haven't)
17:34:26clyybberhow does nimble deal with multiple versions of packages that provide binaries?
17:35:52shashlicki think it just keeps the last one you installed
17:36:37FromGitter<arnetheduck> also, if we switch to 0.19.4, we'll no longer be testing 0.19 - that means that distros that ship 0.19 become vulnerable.. the same arguments can be made in the other direction, but that's less common
17:36:39shashlick@arnetheduck - sounds fair, you can if you want, only challenge is that packages you depend on could stop testing on older versions
17:37:38*sealmove quit (Quit: WeeChat 2.4)
17:38:20shashlickokay, so how about requiring specific versions of packages as dependencies? beacon_chain.nimble has no versions specified other than for nim itself
17:38:27FromGitter<arnetheduck> @shashlick that's why we so desperately want repro builds. we mostly don't care about (3rd party) packages getting updated, except if they solve some critical bug. it takes focus and time to keep up with them, and we'd rather focus on our product. eventually, we'll also have to audit them for security issues on every upgrade.
17:39:32FromGitter<arnetheduck> specific versions in nimble: ⏎ a) too much hassle ⏎ b) doesn't help with the more serious issues - version is a "soft thing", not secured by hash
17:40:44shashlickso for b) why not just require a specific hash
17:40:51shashlickgit commit hash
17:42:47FromGitter<arnetheduck> we still have nimble files around and some of our CI's still use them - here's a classic recent failure: https://travis-ci.org/status-im/nim-beacon-chain/jobs/510985154 - developer and CI had different nimble versions or maybe a different global .nimble dir where one of them was broken. 2-3 developers lose their morning sorting out if it's their fault, nimbles or nims, and we lose CI in the meantime.
17:43:31FromGitter<arnetheduck> shashlick, yes, that's what lock files tend to do.. you have a tool that records particular git hashes and commit that.. doing it manually is not feasible.
17:43:45*rnrwashere joined #nim
17:46:08FromGitter<arnetheduck> but I think if you want to improve nimble, you need to approach it with a bit more depth than trying to solve individual issues.. there's a lot of trees in the nimble issue tracker - to know which ones to fix and how to make them work well together, there's the whole forest and its life-cycle to consider
17:47:01shashlickjust for my understanding, how do you distinguish between creating lock files versus using lock files? you setup all packages as you want and then run some command? and if that specific flag is missing, it just uses existing checked in lock files?
17:47:11*narimiran_ joined #nim
17:49:10*narimiran quit (Ping timeout: 246 seconds)
17:49:43clyybberarnetheduck What do you think about something like this: `nimble build --lockIn "somelockfile"`, then to update all the dependencies you would do `nimble build --updateDeps --lockOut "somelockfile"` which would then generate the lock file "somelockfile" when the build succeeds.
17:50:18*krux02 quit (Remote host closed the connection)
17:50:20clyybberWhere a lockfile is just a list of package/version pairs
17:50:35*krux02 joined #nim
17:50:42FromGitter<arnetheduck> the creation involves looking at soft information like the nimble file to create a dependency resolution, if one exists. that's basically saying "find me packages that the devs think work together".. I record that in a log file and start testing... I audit all the code that the dep resolver gives me, and if if I'm happy, I save that work in a lock file so others can reproduce it.
17:51:22FromGitter<mratsim> nimble freeze command would be helpful
17:51:50FromGitter<arnetheduck> from that point onward, nobody and nothing should be allowed to change the dependency resolution without my explicit approval - if we use nimyaml and they release a new version, or different code under the same version name, that should not affect us.
17:51:57FromGitter<dawkot> is `var xs = [float, int, string]` allowed by design? It doesn't look like I can do anything with it
17:52:11*nsf joined #nim
17:52:23FromGitter<mratsim> @dawkot that's an array of typedesc, it's not a concrete type
17:52:45FromGitter<arnetheduck> that approval might come in the form of a `nimble update` command or whatever, but it should never happen automatically - then I'm no longer reproducing the build - I'm creating a new one.
17:52:47FromGitter<mratsim> at compile-time you can probably do magic with it though :p
17:53:01clyybberarnetheduck Yeah I agree
17:53:23FromGitter<mratsim> (`update` which doesn't exist)
17:53:31shashlickokay so effectively, if the lock file doesn't exist, do what nimble does by default
17:53:39shashlickbut at the end of it, nimble generates a lock file which can be checked in
17:53:48FromGitter<mratsim> I'm regularly nuking my nimble install instead of going through the dependency uninstalling/updating mess
17:53:52shashlickand if a lock file exists, then follow that to pull deps
17:54:00clyybberIf you explicity tell it to generate a lock file
17:54:12clyybberonly then it should generate one
17:54:27shashlicki think this also needs per project repos to work correctly
17:54:39FromGitter<arnetheduck> you probably want to create the lock file in that case. basically, you don't want to rerun the resolver on every build. you typically build your project dozens of time during the day - you don't want random changes to appear there for the vast majority of those builds
17:55:17shashlickso a lock file can also be seen as a dependency cache of sorts
17:55:39clyybberI think so
17:55:46FromGitter<arnetheduck> that's one way to look at it, though cache is a weak word for it
17:56:03shashlickonly as far as running nimble several times a day is concerned
17:57:07*narimiran_ is now known as narimiran
17:59:05clyybberso for a developer to update the dependencies he would do `nimble build --updateDeps --lockIn "somelockfile" --lockOut "somelockfile.out"`. This would try to update all dependencies and generate a new lockfile.
17:59:09FromGitter<arnetheduck> really - spend some time with some modern pm's like cargo or yarn - they've come pretty far, compared to make.. in this whole discussion, we're only scratching the surface
17:59:31FromGitter<arnetheduck> clyybber, yeah, but without all that syntax, please
17:59:47shashlicksee that's the challenge - do we expand nimble or leverage an existing pm
18:00:04shashlickcause this is all the same problem solved again and again
18:02:04clyybberarnetheduck My abbreviations could be better yeah. To add on my previous example an developer could also do `--updateDep:somepkg` to only update a specific package and `--updateDep:somepkg-0.1.23` to update(or downgrade) to a specific version.
18:06:38FromGitter<arnetheduck> clyybber, not just abbreviations, but what happens by default.. what developer experience do you get when you download a project and build it.. when you start a new project of your own.. when you have two closely related projects that both depend on some less related projects (like us, we have a bunch of projects that we work on every day, then there's a number of external projects that we just depend on without
18:06:38FromGitter... ever changing) etc
18:06:44clyybberHow can I instruct the compile pragma to compile cpp when generating to C?
18:07:19shashlickI've put together a high-level workflow for this - https://gist.github.com/genotrance/03465051162d70dd48f938f103201104
18:07:24shashlickfeedback appreciated
18:08:21shashlickI've not considered how existing .nimble file requires fit into this yet
18:08:24clyybberI thin per project nimbleDir belongs in the .nible file
18:09:33FromGitter<arnetheduck> shashlick, I'd strongly recommend you take two weeks to work and contribute to a) a rust project using cargo and b) a js project using yarn - that's likely going to be the best feedback in terms of getting up to speed with modern standards (nix follows the same principles as well, but more for distros)
18:11:34*rockcavera quit (Remote host closed the connection)
18:12:32FromGitter<arnetheduck> there's a lot of feedback already in https://github.com/nim-lang/nimble/issues/127 as well, if you want to dig into it
18:14:22clyybberarnetheduck I think a default for `--lockIn` should do? I think that --lockOut is neccessary, because you dont want to overwrite your previous lockfile, in case some test fails.
18:16:00shashlickokay some homework, will look into it
18:16:04FromGitter<arnetheduck> you also need to create it if it doesn't exist yet
18:16:15shashlickappreciate any feedback on my notes so far too
18:16:15clyybberyeah of course
18:17:07shashlicknow $0.02 question - there's 132 open issues with nimble - what's the priority of these when compared to this requirement
18:19:05clyybberMany of those issues are kind of unneccessary IMO, like for example the license enforcing.
18:23:25FromGitter<arnetheduck> the lock file thing is what causes us the most losses, in terms of meaninglessly spent developer time - it's one of those things that really should just work. I don't know about the other 131 issues, but there's a few about how nimble install monopolizes $HOME etc which are pretty concerning as well and hint at deeply rooted architectural problems
18:30:50*abm joined #nim
18:31:14FromGitter<mratsim> in that regards, the way choosenim allows to switch 0.17, 0.18, 0.19, devel is good.
18:32:02FromGitter<arnetheduck> well, yeah, though I actually prefer python's approach where the venv takes over that as well
18:32:42FromGitter<arnetheduck> the less something infects my whole computer and shell, the better, as long as the UX is acceptable
18:33:38FromGitter<mratsim> Cargo doesn't allow virtual envs though? there is a cargo.toml with versions/commit defined.
18:33:55FromGitter<mratsim> you can put Nim version/commits in there as well
18:37:21FromGitter<arnetheduck> no, cargo doesn't
18:37:45FromGitter<arnetheduck> they have rustup which is the spiritual equivalent of choosenim
18:39:55FromGitter<arnetheduck> they then version the toolchain via rustup: https://github.com/rust-lang/rustup.rs#the-toolchain-file
18:40:10FromGitter<mratsim> wellchoosenim is inspired by rustup
18:40:19clyybberI'm struggling to wrap RtMidi... the compiler shouldn't complain about undefined references when linking the appropriate object files right?
18:40:52FromGitter<mratsim> no it shouldn't, what are the missing references?
18:41:05FromGitter<mratsim> Maybe you miss basic things like libm
18:42:54clyybbertheres a lot of undefined references to __cxxabi stuff
18:43:13clyybberso the problem is probably that RtMidi is a CPP thing
18:43:30shashlickeither you need to link with g++ or nim cpp
18:43:50clyybberand it has a C api which wraps the CPP api
18:44:01clyybberso what I did was wrap the C api.
18:44:34shashlickhere's what I had to work with C++ mixed in with C for nitmerop
18:44:35shashlickhttps://github.com/nimterop/nimterop/blob/master/config.nims
18:44:45clyybberthx shashlick
18:45:41shashlickin what planet is this a good idea - https://www.reddit.com/r/programming/comments/7q6ida/jai_libraries_discussion/dsnu6ls/
18:46:30FromGitter<mratsim> Nim also adds a unique suffix to all symbols
18:46:34*narimiran quit (Ping timeout: 246 seconds)
18:47:00clyybberI think the problem is that I compiled the C api as cpp, but it has a extern "C" in it, so it shouldn't matter right?
18:47:47shashlickya but I meant having multiple versions of the same library in your binary
18:47:52shashlicki guess life isn't always so easy
18:47:58FromGitter<mratsim> as long as your functions have the proper name and not the YZNOXB garbage that C++ generates you're ok
18:48:17FromGitter<mratsim> Mac also had fat binaries for PPC+x86
18:48:57clyybberI'm kind of inclined to scrap those midi wrappers and just use alsa-sequencer or jack or coremidi directly
18:49:03FromGitter<mratsim> and for Laser I'm also producing fat binaries for SSE, SSE2, SSE3, SSE4, SSE4.1, AVX, AVX+FMA, AVX2, AVX512
18:49:22clyybberAnd write a *pure* nim midi library
18:50:20FromGitter<mratsim> when you mean versions like Python 2 and Python 3, yeah that sounds like overkill
18:51:24clyybberanyone got a good pun involving nim and midi ?
18:51:52Araqnimidi
18:51:59shashlickanyone have any ideas for this one? https://paste.ofcode.org/GdkqFFWRpWQfzu7Q23h5k
18:52:12shashlicknimbase.h and oratypes.h have the same `string` type that conflict
18:52:42Araqah sux. gotta fix Nim for that one
18:54:47clyybberAraq: Sounds a bit bavarian
18:55:00clyybbermore bavarian variant: "nimdi"
18:55:07clyybberthough I guess that looses midi
18:59:47FromGitter<alehander42> can i get the path of the macro instantiation file?
18:59:57FromGitter<alehander42> the file where an instantation expands
19:00:11*Senketsu joined #nim
19:00:22FromGitter<mratsim> fun fact, Midi 1.0 was in 1996 and Midi 2.0 was announced in january 2019
19:00:41FromGitter<arnetheduck> no way, there's a midi2??
19:00:58FromGitter<alehander42> currentSourcePath returns the original one
19:01:03FromGitter<alehander42> maybe i can generate it actually
19:01:07clyybberYeah, 32bit for a lot of things that were previously 8bit integers basically
19:02:48clyybberbut its not been released yet. They are currently prototyping it.
19:03:51*pacujo joined #nim
19:04:54pacujoAre these declarations of A identical:
19:04:54pacujotype
19:04:54pacujo B = ref object of RootObj
19:04:54pacujo A = ref object of B
19:04:54pacujotype
19:04:55pacujo B = object of RootObj
19:04:55pacujo A = ref object of B
19:08:29*krux02 quit (Remote host closed the connection)
19:09:05*seerix_ quit (Remote host closed the connection)
19:09:26*rnrwashere quit (Remote host closed the connection)
19:11:12FromGitter<Varriount> pacujo: Structurally, yes
19:11:50pacujoThat's what I thought
19:13:02*rnrwashere joined #nim
19:13:36*narimiran joined #nim
19:15:37*rnrwashere quit (Remote host closed the connection)
19:16:04*rnrwashere joined #nim
19:17:18pacujoI'm trying to get a feel whether to declare a "class" on object or a ref object
19:18:24pacujoDeclaring everything ref is the easy way out, and it would work
19:18:58FromGitter<Varriount> Well, ref object would be the only way runtime polymorphism would work.
19:19:57FromGitter<Varriount> If you use a plain object type, then when that type is passed to a procedure taking a subtype, it will be downcasted
19:20:12FromGitter<Varriount> Er, I mean, parent type
19:20:45*Vladar quit (Remote host closed the connection)
19:22:12pacujoLooking at the source code of tables.nim doesn't make the principles very clear
19:22:53pacujoEverything is duplicated for ref and plain objects
19:23:53*rnrwashere quit (Remote host closed the connection)
19:24:01pacujoFor example,
19:24:04pacujoproc len*[A, B](t: Table[A, B]): int =
19:24:16pacujowhy not t: var Table[A, B]
19:25:49pacujoFrom the looks of it, the definition of the proc would entail copying the whole table into the argument (at least conceptually)
19:27:26*rnrwashere joined #nim
19:29:17*narimiran quit (Remote host closed the connection)
19:29:25FromGitter<Varriount> pacujo: Object types are passed using a pointer
19:29:45*narimiran joined #nim
19:30:32pacujoOh?
19:30:49*jjido joined #nim
19:31:03pacujoMissed the memo
19:31:46FromGitter<Varriount> What I mean is, if you have two types, A and B. Both are object types, and B inherits from A. If you pass a B variable to a procedure expecting an A parameter, then semantically, that parameter is truly an A parameter.
19:32:25*rnrwashere quit (Remote host closed the connection)
19:32:26FromGitter<Varriount> If you attempt to use something like methods on the A parameter, the method implementation for the A type will be selected.
19:32:34pacujoThat's clear, but a very different statement
19:33:02pacujoI don't suppose proc len*[A, B](t: Table[A, B]): int can alter t
19:33:45pacujo(or the changes would only apply to the "copy")
19:35:56FromGitter<Varriount> You can't really directly modify a perimeter and nim, unless it is a var or ref parameter.
19:36:11FromGitter<Varriount> *parameter in Nim
19:36:59pacujoOk, shrewd
19:37:24*rnrwashere joined #nim
19:37:26Araqpacujo, the code duplication is only for the people coming from Python
19:37:29FromGitter<Varriount> pacujo: I might just be misunderstanding you
19:37:49Araqso that we also offer TableRef semantics
19:38:05pacujoOh, please, Araq
19:38:27Araqoh please?
19:38:48pacujoPlacating Pythonistas in standard nim libraries
19:39:02*rnrwashere quit (Remote host closed the connection)
19:39:18*rnrwashere joined #nim
19:39:40*zyklon quit (Ping timeout: 250 seconds)
19:40:10pacujoAnyway, Varriount, if the parameters are immutable, it gives lots of optimizing leeway to the compiler (no unnecessary copying)
19:40:22FromGitter<Varriount> Yes.
19:40:29*rnrwashere quit (Remote host closed the connection)
19:40:35*zyklon joined #nim
19:40:59FromGitter<Varriount> And little need for the whole addressof operator and friends
19:41:34pacujoWhich means, I still don't have a model in my head ot decide between ref and plain
19:42:07*zyklon quit (Client Quit)
19:42:35pacujoPlain means embeddable and potentially slightly faster
19:44:01pacujoBut then, proc(a: ref A) doesn't match A and proc(a: A) doesn't match ref A, leading to the duality of Table and TableRef.
19:45:49FromGitter<Varriount> Pacujo: can you explain what your object model is, or what your objects are going to do?
19:46:54pacujoI'm just learning about nim by porting some of my own code. In this case, I'm porting my avltree to nim
19:48:58pacujoSo
19:48:58pacujo AVLTree[K, V] = ref object of RootObj
19:48:58pacujoor
19:48:58pacujo AVLTree[K, V] = object of RootObj
19:49:46pacujo(I'm thinking the former)
19:49:55Araq AVLTree[K, V] = ref object # no of.
19:51:02pacujoSome page I read recommended basing every object on RootObj
19:51:25pacujoI don't exactly know why
19:51:35Araqdon't do it
19:52:05pacujoNim's own stdlib does it
19:52:18Araqnot often
19:52:37pacujoBut... why or why not?
19:52:42Araqdon't do what I do, do what I say.
19:54:35pacujohttps://nim-lang.org/0.18.0/tut2.html#object-oriented-programming-objects
19:54:53pacujoIf an object type has no suitable ancestor, RootObj can be used as its ancestor, but this is only a convention.
19:55:07pacujo^^that's a quote^
19:57:10pacujoThat's a bit of an enigmatic statement
20:00:32*lf-araujo joined #nim
20:04:49pacujoAnother interesting observation: you can't declare a `[]` that would do the "right thing" both as a setter and as a getter
20:05:08narimiran`[]=`
20:07:05FromGitter<alehander42> you can define a macro that lets you do it, something like attr_accessor
20:07:32FromGitter<alehander42> but with a piece of logic
20:07:42FromGitter<alehander42> i forgot attr_accessor is only 🔣
20:07:49FromGitter<alehander42> :sym \
20:08:07pacujoThanks, narimiran.
20:09:13pacujoIf there are both
20:09:13pacujoproc `[]`*[A, B](t: OrderedTableRef[A, B], key: A): var B =
20:09:13pacujoand
20:09:13pacujoproc `[]=`*[A, B](t: var OrderedTable[A, B], key: A, val: B) =
20:09:13pacujohow does nim decide which to call?
20:09:38narimiranone is getter, other is setter
20:09:47narimiranecho foo[a]
20:09:53narimiranfoo[a] = 5
20:12:55pacujoSo it's the syntactic presence of "=" that decides
20:14:44FromGitter<alehander42> you can say foo[a] = is syntactic sugar for `[]=`(foo, a, 5)
20:16:13pacujoI guess that's sound
20:16:47*nsf quit (Quit: WeeChat 2.4)
20:17:30*rnrwashere joined #nim
20:17:47pacujoHowever, if you didn't define `[]=`, I suppose `[]` would be called instead
20:19:02*krux02 joined #nim
20:19:36FromGitter<alehander42> no
20:19:40FromGitter<alehander42> why
20:19:44FromGitter<alehander42> `[]` is for access
20:19:49FromGitter<alehander42> `[]=` is for setting
20:20:31FromGitter<alehander42> they don't have much to do one with the other
20:20:47FromGitter<alehander42> if you don't define `[]=`, it just doesnt compile
20:21:23pacujo`[]` above returns var B so I can pass the return value as an argument to a function which sets the value, right?
20:22:00Araqright but the compiler doesn't use it in t[x] = y
20:22:20*rnrwashere quit (Ping timeout: 272 seconds)
20:22:40pacujoGot it
20:25:03*rnrwashere joined #nim
20:25:31pacujoTested:
20:25:31pacujoproc f(a: var int): var int = a
20:25:31pacujovar a: int
20:25:31pacujof(a) = 7
20:25:31pacujoecho a
20:26:03pacujoWorked as expected
20:26:48*uvegbot joined #nim
20:27:15pacujoThen:
20:27:15pacujoproc `[]`(a: var int, i: int): var int = a
20:27:15pacujovar a: int
20:27:15pacujo`[]`(a, 0) = 7
20:27:15pacujoecho a
20:27:20pacujoStill worked
20:27:49pacujoBut a[0] = 7 didn't work
20:28:20pacujoInteresting
20:29:30*rnrwashere quit (Ping timeout: 250 seconds)
20:32:43FromGitter<alehander42> [] just doesnt have anything to do with []=
20:33:09FromGitter<alehander42> a[0] = 7 isnt compiled to
20:33:12FromGitter<alehander42> (a[0]) = 7
20:33:15FromGitter<alehander42> its compiled to
20:33:19FromGitter<alehander42> a ([]=) 7
20:33:43pacujoYeah, thanks
20:46:44Zevvwhat is it called when a reference to an object allows it to be GC'ed if that reference is the only one referencing an object?
20:46:53Zevvand - more important - does Nim support that one way or the other?
20:49:20*rnrwashere joined #nim
20:49:45*I_Right_I joined #nim
20:53:23*pacujo quit (Ping timeout: 268 seconds)
20:57:24Zevvah, that would be a weak reference, right
21:00:28*cgfuh quit (Quit: WeeChat 2.3)
21:01:28*rnrwashere quit (Remote host closed the connection)
21:03:42FromGitter<arnetheduck> generally, weak, yeah, and you can have many of them.. the tricky part is detecting from your weak references whether they've been recycled or not (basically, turning them into strong references)
21:06:30ZevvI'm thinking of the cases where I want to keep a pool of objects for memoization so I can reuse them when I need the same object. But as soon as noone holds a reference to the object, it could (but not must) be dropped from the pool.
21:07:10Zevvthat must be pretty common I guess?
21:09:40Zevvhm but wait, I have another problem first I see. I want to do memoization at compile time, but I can't use a `var seq[T]` anyway: "cannot generate VM code for"
21:09:42Zevvback to the drawing board
21:10:12FromGitter<brentp> what are the `nim c` options for tracking memory errors? don't seem to be printed even with `--advanced`
21:10:26*rnrwashere joined #nim
21:13:10FromGitter<brentp> ok. found it: `-d:useSysAssert -d:useGcAssert`
21:18:21Zevvwhere did you find that?
21:18:23*rnrwashere quit (Remote host closed the connection)
21:18:51*rnrwashere joined #nim
21:22:42*rnrwashere quit (Remote host closed the connection)
21:22:48*rnrwashere joined #nim
21:24:41FromGitter<brentp> Araq told me it once on here and I couldn't find it, but as it goes, once I posted, I found it.
21:27:08*rnrwashere quit (Remote host closed the connection)
21:27:34*rnrwashere joined #nim
21:28:19*Trustable quit (Remote host closed the connection)
21:30:30ZevvYEah, this was what I was looking for: https://github.com/nim-lang/Nim/wiki/Hunting-crashes:-The-ultimate-guide
21:31:46*rnrwashere quit (Ping timeout: 246 seconds)
21:35:03*clyybber quit (Quit: WeeChat 2.4)
21:39:36*jjido quit (Quit: My MacBook has gone to sleep. ZZZzzz…)
21:40:45*rnrwashere joined #nim
21:41:42*rnrwashere quit (Remote host closed the connection)
21:54:02I_Right_IZevv: I am glad you posted that! I might find it helpful. Why IRC rocks.
21:59:20*narimiran quit (Ping timeout: 250 seconds)
22:00:32Zevvy.w.
22:01:14*rnrwashere joined #nim
22:01:22*lf-araujo quit (Read error: Connection reset by peer)
22:01:52*lf-araujo joined #nim
22:05:22*rnrwashere quit (Ping timeout: 246 seconds)
22:11:18*sentreen quit (Ping timeout: 245 seconds)
22:14:13*rnrwashere joined #nim
22:14:25*rnrwashere quit (Remote host closed the connection)
22:14:31*rnrwashere joined #nim
22:14:31*sentreen joined #nim
22:23:53*lf-araujo quit (Quit: lf-araujo)
22:31:54FromDiscord<Skaruts> var position_components:Table < -- error: invalid type 'Table' for var
22:31:59FromDiscord<Skaruts> ??
22:33:19*rnrwashere quit (Remote host closed the connection)
22:34:00FromDiscord<Skaruts> is there a way to create an empty table?
22:34:26*rnrwashere joined #nim
22:35:02Zevvvar x = initTable[Tkey,Tvalue]()
22:37:27FromDiscord<Skaruts> should I replace TKey and Tvalue with something?
22:37:37FromDiscord<Skaruts> they're undeclared identifiers
22:37:53FromDiscord<Skaruts> or am I supposed to import something else other than 'tables'?
22:40:32solitudesfyes, you should replace them key type and value type of your table
22:40:36ZevvWhat kind of table do you want to construct? A table maps one type to anther. So for example initTable[string,int]() will creat a table mapping strings to ints
22:41:02FromDiscord<Skaruts> oh they're the types
22:41:03FromDiscord<Skaruts> thanks
22:41:24ZevvI learned that In nimland capital T usually means something with type
22:41:33FromDiscord<Skaruts> yea it's basically [string, Component]
22:41:35ZevvIt is common idiom with generics
22:41:45*rnrwashere quit (Remote host closed the connection)
22:42:08ZevvOne thing that bothers me still with Nim is that tables need explict newTable or initTable
22:42:11FromDiscord<Skaruts> yea I still have't gotten that far, though I've seen that a lot (also in C++)
22:42:18ZevvSo simply defining a type as a Table is not enough:
22:42:25Zevvvar t: Table[int,string]
22:42:30Zevvis just fine
22:42:30Zevvbut you can't use it
22:42:45Zevvyou need var t = initTable[int,string]()
22:42:55ZevvAND DONT DARE TO FORGET THE BRACKETS AT THE END
22:43:00AraqZevv, there is an RFC covering it...
22:43:00Zevvthat happened to me *so* many times
22:43:05ZevvAraq: \o/ you say!
22:43:24Zevvfor Tables only?
22:43:34Zevvhow would that work
22:43:48FromDiscord<Skaruts> RFC?
22:43:54Araqlike it would for @[]
22:44:05Zevvbut @[] is a language builtin
22:44:11ZevvRFC = request for comments
22:44:20FromDiscord<Skaruts> ah thanks
22:44:20Araq[]= and 'add' would create a table if it's not init'ed explicitly
22:44:35Araqnothing hard, no language change required either
22:44:56*rnrwashere joined #nim
22:45:08ZevvThat makes sense, simple and sweet
22:45:09*solitudesf quit (Ping timeout: 245 seconds)
22:45:40*NimBot joined #nim
22:45:58FromDiscord<Skaruts> for my use case I'm basically building an ECS, and I'm storing different components in respective tables by entity id
22:46:12FromDiscord<Skaruts> I suppose I can add/remove from tables?
22:46:18Zevvof course
22:46:25AraqSkaruts: for an ECS I have some ideas...
22:46:34Zevvadding is done by simply assigning to the [] element.
22:46:51FromDiscord<Skaruts> hmm, like with dictionaries in python?
22:46:56Zevvjust so
22:47:04FromDiscord<Skaruts> just adding like that creates a new entry, ok
22:47:38FromDiscord<Skaruts> and to remove?
22:47:39Zevvdelete with t.del(key)
22:47:47Zevvha almost beat you to it
22:47:52FromDiscord<Skaruts> 😃
22:47:55Zevvhttps://nim-lang.org/docs/tables.html
22:48:06FromDiscord<Skaruts> I was just opening that too 😃
22:48:11Araqdon't use Tables for an ECS there are far more performant solutions
22:48:19FromDiscord<Skaruts> tell me more 😃
22:48:20Zevvindexing a non-existent key will trow
22:48:41Zevvuse `t.contains(k)` or `k in t` to test
22:49:39Araqtype EntityId = distinct int; type Position = object v: vec3; id: EntityId
22:50:17Araqvar positions: seq[Position]
22:51:05Araqvar phys: seq[Physics]
22:51:06Araq# etc.
22:51:16Araqadd an entity:
22:51:23FromDiscord<Skaruts> I could use sequences, but the only way I know how to do that is to fill them with all the way to some predetermined `max_entity_num` and then use entityIds to populate it as in positions[id] = bla bla
22:51:33Araqpositions.add Position(id: myId, ...)
22:51:40Zevvskaruts: you can update lenght on the fly
22:51:55Araq# delete:
22:52:13AraqpositionsDel.add myId
22:52:17Araq# iteration:
22:52:25Araqif positionsDel.len > 0:
22:52:51FromDiscord<Skaruts> what if you need to access the position component of a specific entity by id
22:53:17Araq for p in positions: if p.id in positionsDel: del(p) else: process(p)
22:53:18Araqelse:
22:53:29Araq for p in positions: process(p) # common case
22:53:47FromDiscord<Skaruts> yea I was trying avoid having to iterate through it looking for each id I need
22:54:22Araqdeletion is not the same as a positions.byId(id) lookup
22:56:08Araqif you need a more general byId lookup you can keep a Table[id, positionIndex] around
22:57:06FromDiscord<Skaruts> using tables I could iterate through them in the systems, and still if I need a specific one I could just ask for 'positions[id]'
22:58:26FromDiscord<Skaruts> or else if I could fill a seq with nils and replace them with components using ids as indices
22:58:54AraqTable iteration is slower than seq iteration though and usually that's what you need to optimize for
22:59:35FromDiscord<Skaruts> yea unless iterating though the entire thing every time I need a single component isn't demanding, I'm coming from python, which can takes ages to iterate
22:59:54FromDiscord<Skaruts> so I tend to think in terms of avoiding too many loops
23:01:39FromDiscord<Skaruts> but it seems to me that when I need to find a position from an enemy and compare to the position of the player or something, and then check if it can attack or whatever, seems like that would involve loads of "for p in positions: if p.id in positions..."
23:03:36*natrys quit (Quit: natrys)
23:03:36Zevvhow do I get the codepoint of a Rune?
23:04:20Zevvno, wrong word.
23:04:40Zevvoh, right word
23:05:03Araqskaruts: that's what Quad- and Octrees are for
23:05:31FromDiscord<Skaruts> oooh I'm not that versed in those
23:05:38Araqhttps://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374
23:05:59FromDiscord<Skaruts> I've implemented a binary tree for dungeon generations, but that was about it
23:08:29AraqZevv, convert it to int? no idea what you mean
23:08:46Zevvyeah, I can just convert to int, but that is not explicit in the docs
23:08:54ZevvI had to lookup the RuneImpl in the code
23:09:27Zevvthanks
23:10:08FromDiscord<Skaruts> hmm, I'll have to look into that, gonna keep the link, while I get the components working and see if I can get stuff showing on the screen
23:12:56FromDiscord<Skaruts> thanks for the helps btw
23:13:14*rnrwashere quit (Remote host closed the connection)
23:15:18*rnrwashere joined #nim
23:19:09*lf-araujo joined #nim
23:24:27*rnrwashere quit (Remote host closed the connection)
23:26:08*rnrwashere joined #nim
23:27:45*sentreen_ joined #nim
23:30:46*sentreen quit (Ping timeout: 255 seconds)
23:37:47*lf-araujo quit (Remote host closed the connection)
23:38:59*sentreen joined #nim
23:42:01*sentreen_ quit (Ping timeout: 255 seconds)
23:42:06*rnrwashere quit (Remote host closed the connection)
23:46:42*rnrwashere joined #nim
23:48:30*rnrwashe_ joined #nim
23:49:50*rnrwash__ joined #nim
23:50:56*rnrwashere quit (Ping timeout: 246 seconds)
23:52:25*rockcavera joined #nim
23:52:49*rnrwashe_ quit (Ping timeout: 246 seconds)
23:54:13*rnrwash__ quit (Ping timeout: 246 seconds)
23:56:14*sentreen_ joined #nim
23:57:34*rnrwashere joined #nim
23:59:14*sentreen quit (Ping timeout: 250 seconds)