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:29 | FromGitter | <raydf> Hello |
00:45:38 | FromGitter | <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:00 | FromGitter | <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:49 | FromDiscord | <sealmove> You can iterate varargs with a `for` statement and store the items in an array |
03:34:59 | FromDiscord | <sealmove> But varargs kind of IS an array |
03:35:12 | FromDiscord | <sealmove> Why do you need to convert? |
03:57:36 | FromGitter | <kayabaNerve> I thought you could pass a seq to varargs |
03:58:24 | FromGitter | <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:11 | FromGitter | <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:48 | FromGitter | <kdheepak> This is the result I get: ⏎ ⏎ ```1, 1, 1 ⏎ 10, 1, 1``` [https://gitter.im/nim-lang/Nim?at=5c9860803dd817114948be50] |
05:01:56 | FromGitter | <kdheepak> Can someone explain to me what I'm doing wrong here? |
05:04:23 | FromGitter | <kdheepak> This example appears to work fine: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c986157f3dbbd230cb1b0eb] |
05:04:47 | FromGitter | <kayabaNerve> Both the menu and the app have a state |
05:04:50 | FromGitter | <kdheepak> I have no idea what is going on here? |
05:05:00 | FromGitter | <kayabaNerve> You print the app's state but update the menu's |
05:05:15 | FromGitter | <Varriount> And a tuple is copied on assignment |
05:05:18 | FromGitter | <kdheepak> Yes, I was assuming that if I pass by reference they will point to the same |
05:05:19 | FromGitter | <kayabaNerve> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c98618f49fdaa0d810f8d22] |
05:05:51 | FromGitter | <Varriount> @kdheepak A `tuple` type is an `object` structure, not a `ref`. |
05:06:01 | FromGitter | <kdheepak> @Varriount my second example has an assignment but it is not being copied. |
05:06:13 | FromGitter | <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:36 | FromGitter | <kayabaNerve> Objects assignments are copies. |
05:06:40 | FromGitter | <kayabaNerve> Copies are copies. |
05:07:02 | FromGitter | <kayabaNerve> Coding is copying. |
05:07:06 | FromGitter | <kayabaNerve> :thinking: |
05:07:38 | FromGitter | <Varriount> @kayabaNerve We copy information from the computer screen into our brains. :O |
05:07:38 | FromGitter | <kdheepak> Okay that makes sense, but if I make `State = ref tuple` how do I create an instance of state? |
05:07:44 | FromGitter | <kdheepak> ```code paste, see link``` |
05:07:47 | FromGitter | <kayabaNerve> So either define a ref object with the tuple as a member or change the typedef to a ref tuple. |
05:07:59 | FromGitter | <kayabaNerve> @kdheepak Allocate via new and then use the [] to dereference |
05:08:07 | FromGitter | <kayabaNerve> @Varriount Humanity is copying |
05:08:24 | FromGitter | <kayabaNerve> *anyone here see the RvB Robot Optionals scene? |
05:08:31 | FromGitter | <kdheepak> > So either define a ref object with the tuple as a member |
05:08:40 | FromGitter | <kdheepak> @kayabaNerve may I not doing this already? |
05:08:49 | FromGitter | <kdheepak> ``` Menu = ref object ⏎ state: State``` [https://gitter.im/nim-lang/Nim?at=5c98626149fdaa0d810f8fe5] |
05:09:01 | FromGitter | <kayabaNerve> You define state as a type alias to a tuple |
05:09:07 | FromGitter | <kayabaNerve> Define state as a type alias to a ref tuple |
05:09:13 | FromGitter | <kayabaNerve> One sec, I'll provide an example |
05:09:41 | FromGitter | <Varriount> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c9862956a3d2e230d1e8dc4] |
05:09:56 | FromGitter | <kdheepak> Okay. Thanks. Sorry, I'm still struggling to understand the semantics of ref, object, var in Nim. |
05:10:48 | FromGitter | <kdheepak> Interesting. |
05:10:52 | FromGitter | <kdheepak> Okay that worked. |
05:11:18 | FromGitter | <kayabaNerve> ```code paste, see link``` [https://gitter.im/nim-lang/Nim?at=5c9862f552c7a91455ef72e9] |
05:11:39 | FromGitter | <Varriount> @kayabaNerve :P |
05:11:40 | FromGitter | <kayabaNerve> Variount beat me to it because I tried using nicer ref constructors :( |
05:12:22 | FromGitter | <kayabaNerve> I only use new when \I define a ref primitive :P |
05:12:37 | FromGitter | <Varriount> @kdheepak Nim picks the best way to pass parameters to functions behind the scenes. |
05:12:38 | FromGitter | <kayabaNerve> I try to abstract away from it as much as possible |
05:12:50 | FromGitter | <kayabaNerve> @Varriount Sounds like Skynet |
05:13:12 | FromGitter | <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:14 | FromGitter | <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:20 | FromGitter | <kdheepak> What if you want to do the first? |
05:13:47 | FromGitter | <Varriount> @kdheepak @kayabaNerve and my examples were the second approach, yes. |
05:14:36 | FromGitter | <kayabaNerve> ```type State = ref object ⏎ myTuple: tuple[x:int, y:int, z: int]``` [https://gitter.im/nim-lang/Nim?at=5c9863bc81b15c5e4b80e16a] |
05:14:45 | FromGitter | <kdheepak> Can you provide an example of the first, for pedagogical purposes. |
05:14:57 | FromGitter | <kayabaNerve> Just did :P |
05:15:00 | FromGitter | <kdheepak> I see. |
05:15:07 | FromGitter | <kdheepak> Thanks! |
05:15:12 | FromGitter | <kayabaNerve> @Varriount Quick Q |
05:15:16 | FromGitter | <Varriount> Yeah? |
05:15:23 | FromGitter | <kayabaNerve> Does it hurt to define `of RootObj` if it's not needed? |
05:15:39 | FromGitter | <Varriount> You only need RootObj if you're going to use inheritance. |
05:15:52 | FromGitter | <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:56 | FromGitter | <kayabaNerve> Yeah |
05:16:11 | FromGitter | <Varriount> It doesn't hurt. Or if it does, it's very minor. |
05:16:18 | FromGitter | <kayabaNerve> K :thinking: |
05:16:40 | FromGitter | <kayabaNerve> I'm working on a very OOP codebase, but Inheritance doesn't come up too often, |
05:17:00 | FromGitter | <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:01 | FromGitter | <kayabaNerve> I think the only place I use it is when I need to store multiple object types in a single seq. |
05:17:23 | FromGitter | <kayabaNerve> So an extra couple bytes of RAM per instance? |
05:17:38 | FromGitter | <kayabaNerve> Eh. I'm cleaning up my codebase in a few weeks. I'll remove it then. |
05:17:46 | FromGitter | <kayabaNerve> Thanks |
05:17:56 | FromGitter | <Varriount> @kayabaNerve It might affect run-time-type data generation |
05:18:18 | * | I_Right_I quit (Remote host closed the connection) |
05:18:20 | FromGitter | <Varriount> But if RTTI isn't used in your program, I believe it's removed anyway. |
05:18:44 | FromGitter | <Varriount> @kayabaNerve Let me check |
05:21:51 | * | rnrwashere joined #nim |
05:22:03 | FromGitter | <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:05 | FromGitter | <Varriount> @kayabaNerve An extra 4344 bytes of information was generated in the binary that was generated using `RootObj` |
05:28:16 | FromGitter | <Varriount> Oddly enough, the extra data is all zeroes. |
05:37:15 | FromGitter | <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:37 | FromGitter | <kdheepak> (https://files.gitter.im/nim-lang/Nim/HeIX/animation.gif) |
05:41:39 | FromGitter | <kdheepak> Thanks for the help! Passing around the state tuple as a reference was the final piece in connecting the different components. |
06:22:29 | FromGitter | <Varriount> @kdheepak How are you interfacing with the iOS APIs? |
06:23:30 | FromGitter | <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:05 | Zevv | kdheepak: your url gives access denied |
06:32:54 | narimiran | remove ) |
06:50:22 | * | solitudesf joined #nim |
06:55:25 | FromGitter | <kdheepak> @Zevv which url? |
06:55:42 | FromGitter | <kdheepak> This is the gif I linked in gitter earlier: https://files.gitter.im/nim-lang/Nim/HeIX/animation.gif |
06:56:41 | FromGitter | <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:42 | FromGitter | <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:08 | FromGitter | <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:58 | FromGitter | <danielecook> Is there a way to set a parameter as optional in a `proc`? |
07:13:12 | FromGitter | <danielecook> @kdheepak that is awesome |
07:15:10 | FromGitter | <kayabaNerve> @Varriount Thanks for all the info. |
07:15:35 | FromGitter | <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:26 | FromGitter | <bwkenny321> Can anyone help? I follow the instruction refer to "https://github.com/nim-lang/Nim" but I still cannot install properly. |
07:42:23 | FromGitter | <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:16 | FromGitter | <kayabaNerve> 1) We'd need the error. ⏎ 2 |
07:45:25 | PMunch | bwkenny321, easiest is to install through choosenim |
07:45:40 | PMunch | If you can't find in it apt there is a script to install it on the website |
07:45:47 | FromGitter | <kayabaNerve> PMunch: I just edited my message on Gitter to include that :P |
07:45:52 | FromGitter | <kayabaNerve> That was the "2" |
07:46:10 | PMunch | Ah, edits don't carry over to IRC |
07:46:46 | FromGitter | <kayabaNerve> `curl https://nim-lang.org/choosenim/init.sh -sSf | sh` |
07:46:51 | FromGitter | <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:54 | salewski | Do we have an iterator that gives us pairs like: [1, 2, 3] => (1, 2) (2, 3) (3, 1) |
08:56:46 | Araq | repeat(s, 2).zip() ? |
08:57:10 | * | Senketsu joined #nim |
08:57:23 | salewski | Thanks, will try that. Bye. |
08:59:58 | * | salewski quit (Quit: WeeChat 2.3) |
09:02:19 | narimiran | salewski: use `windowed` iterator from https://github.com/narimiran/itertools ;) |
09:03:19 | narimiran | or for making pairs, not arbitrary-length tuples: `pairwise` |
09:04:14 | * | salewski joined #nim |
09:05:23 | salewski | narimiran, thanks. That itertools module was indeed what I was looking for! |
09:05:55 | narimiran | salewski: please report any problems you find with it, i haven't really tested/used it |
09:06:54 | salewski | First problem was to find it. I had the feeling that what I was looking for was available, |
09:07:07 | salewski | but did not find it in standard module set. |
09:08:05 | salewski | I really think I saw your itertools already some months ago, but I did not remembered well... |
09:08:07 | salewski | Bye. |
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:20 | PMunch | narimiran, 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:00 | narimiran | PMunch: 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:12 | FromGitter | <mratsim> does iterator chaining works in your itertools? |
10:12:37 | narimiran | probably not, haven't tried it :D |
10:15:10 | FromGitter | <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:46 | krux02 | iterator chaining shouldn't be that much of a problem, just create an iterator that yields the elements from two other iterators |
10:24:02 | krux02 | the only problem is that recursive chaining can't work |
10:25:47 | FromGitter | <mratsim> I mean for x in countup(1, 10).filter(x => x mod 2) |
10:26:03 | FromGitter | <mratsim> (dumb example but it shows what I mean) |
10:26:16 | krux02 | yea |
10:26:45 | krux02 | I got used to write it is ``for x in countup(1, 10): if x mod 2: ... |
10:27:05 | krux02 | (if x mod 2 would be a legal boolean expression) |
10:27:28 | FromGitter | <mratsim> yes right |
10:29:16 | FromGitter | <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:19 | krux02 | I 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:25 | FromGitter | <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:06 | krux02 | coocheenin: you can publish to nimble whatever you want. It doesn't need to be "useful" |
10:30:22 | FromGitter | <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:54 | krux02 | the problem is, it's not that simple |
10:31:11 | krux02 | yes Rust does a good job with that |
10:31:49 | krux02 | but then you have to deal with all these "once" values and stuff |
10:32:33 | krux02 | it 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:50 | FromGitter | <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:09 | Araq | I simply use for loops instead, FP is like epicycles of programming, you always need more stuff |
10:34:32 | Araq | there is nothing wrong with nesting for loops anyway. |
10:35:05 | Araq | it's simple, it works, it "scales", it's debuggable code |
10:35:27 | FromGitter | <mratsim> for ML, both functional and for loop approach don't scale :/ |
10:35:40 | Araq | not naming the intermediate steps tends to be terrible for debugging |
10:35:55 | Araq | but then ok, you don't debug FP code because it's correct. |
10:36:06 | krux02 | yes |
10:36:28 | krux02 | and you still can name the intermediate steps if you want |
10:37:24 | Araq | but then the first-class thing comes in and bites you. you need to materialize the result for this explicit name. |
10:38:16 | Araq | the difference between f(g(x)) and 'let tmp = g(x); f(tmp)' is big. |
10:38:56 | FromGitter | <alehander42> i agree with mratsim |
10:39:22 | FromGitter | <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:12 | FromGitter | <alehander42> having names for steps is a completely different issue |
10:40:32 | FromGitter | <alehander42> one can write unreadable/hardtodebug code with loops too |
10:40:34 | krux02 | Araq: Well the problem is also when you try to debug functional programming with a debugger designed for imperative programs. |
10:40:39 | krux02 | There are other debuggers |
10:40:59 | krux02 | For example the emacs-lisp debugger in emacs is expression based, not line based |
10:40:59 | FromGitter | <alehander42> that's a tooling problem: nim people often say "we wouldnt do X in the language just because tools suck" |
10:41:16 | krux02 | you get the the intermeditate values of f(g(x)) |
10:41:25 | krux02 | or better said (f (g x)) |
10:42:39 | FromGitter | <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:16 | krux02 | in nim the debugger is very detached from the ide :P |
10:43:36 | FromGitter | <alehander42> yeah but its a similar kind of thinking :P |
10:44:08 | Araq | it's perfectly fair to say "I wait with FP until the tooling is ready" |
10:44:23 | krux02 | yes it is |
10:44:35 | Araq | and then "I wait with FP until it doesn't cause slow allocations everywhere" |
10:44:56 | FromGitter | <mratsim> well, right now we don't have inline iterator chaining so no FP :P |
10:45:00 | krux02 | but there is also little effort to improve tooling explicity designed around nim FP style |
10:45:24 | Araq | and then also "I wait with FP until my coworkers are familiar with it, the tooling is there and the performance problems disappeared" |
10:45:29 | krux02 | mratsim: what is the problem with that? |
10:46:15 | FromGitter | <mratsim> it's a feature mentionned in the manual |
10:46:23 | Araq | and even then FP needs to have merits of its own to justify the switch. And tbh the merits exist. |
10:46:52 | Araq | but that's for FP. For OOP the merits never existed. Ymmv. |
10:46:55 | FromGitter | <mratsim> See: https://github.com/nim-lang/Nim/issues/4516 |
10:47:11 | krux02 | Well I like FP enough to improve the tooling and the Language to the point where I see it is worth it. |
10:47:41 | krux02 | But I don't plan to make Nim the functional programming laguage of choise, I that that one isn't worth the effort. |
10:48:46 | FromGitter | <mratsim> I want usable iterators that can be composed with minimal perf overhead (and certainly not intermediate alloc overhead) |
10:50:23 | krux02 | mratsim: for me it would be ``zip`` on iterators. I really miss that one |
10:50:35 | FromGitter | <mratsim> yes |
10:50:44 | FromGitter | <mratsim> that's the most needed I agree |
10:51:24 | FromGitter | <mratsim> Well now I've written several macros to work around that for my use cases |
10:51:40 | krux02 | for zip I usually fall back to indices |
10:52:06 | krux02 | that doesn't work for stuff that doesn't use indices, yes. But I am lucky I use stuff with indices |
10:52:29 | FromGitter | <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:09 | krux02 | well then you have to take the stride into account as well, but it does work afaik |
10:53:23 | krux02 | but sparse could be a problem |
10:53:44 | FromGitter | <mratsim> I didn't implement sparse tensors yet. |
10:53:52 | krux02 | everything that isn't uniformly structured |
10:55:10 | Araq | before I wrote "lambda lifting" I looked at Haskell's deforestation and tried to apply it to Nim. I failed. |
10:55:19 | FromGitter | <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:46 | Araq | and deforestation is a killer optimization IMO. |
10:56:14 | Araq | happily removing all kinds of intermediate data structures |
10:56:33 | Araq | including whole trees on the heap. |
10:57:12 | FromGitter | <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:58 | FromGitter | <mratsim> ugh made a mess of links |
10:58:12 | FromGitter | <mratsim> https://medium.com/@olxc/catamorphisms-and-f-algebras-b4e91380d134 |
10:58:27 | FromGitter | <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:28 | krux02 | mratsim: what is that link? |
11:09:42 | krux02 | I can.t see it. I only see a login wall |
11:10:12 | FromGitter | <mratsim> http://scholarpublishing.org/index.php/TMLAI/article/download/3397/1944 <- this should work |
11:11:01 | FromGitter | <mratsim> It's an implementation of attribute grammars in scala to traverse various operations without intermediate allocation |
11:11:05 | krux02 | yes it does, but it also warns me that the connection isn't secure |
11:11:29 | krux02 | what is an attribute grammar? |
11:12:40 | FromGitter | <mratsim> it's a tree traversal techniques, mostly used for compiler construction |
11:12:55 | FromGitter | <mratsim> You have simple examples here: http://ps.informatik.uni-tuebingen.de/2014/10/23/presentation-at-oopsla/slides.pdf |
11:13:14 | krux02 | tree traversal was the performance killer for my Game engine that I wrote in Scala |
11:13:32 | krux02 | (in 2012) |
11:15:28 | FromGitter | <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:04 | FromGitter | <mratsim> I'm deep into tree traversals for my ML compiler :/ |
11:16:19 | krux02 | well I don't understand it |
11:16:37 | krux02 | but it's a cold start for me |
11:16:59 | krux02 | why do you write an ML compier? |
11:17:13 | FromGitter | <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:47 | FromGitter | <mratsim> my reasons are here: https://github.com/mratsim/Arraymancer/issues/347#issuecomment-459351890 |
11:18:29 | FromGitter | <mratsim> Loop fusion and SIMD. |
11:18:40 | FromGitter | <mratsim> then gradient |
11:19:13 | FromGitter | <mratsim> also compiler with CPU, Cuda, OpenCL, Vulkan, OpenGL, anything supported by LLVM backends |
11:20:58 | FromGitter | <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:25 | krux02 | cool |
11:23:15 | FromGitter | <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:11 | FromGitter | <mratsim> The author of LLVM is also doing that (but in Swift) I think. |
11:24:38 | * | dddddd joined #nim |
11:25:04 | Araq | mratsim: have you looked into "burg" for code generation? |
11:26:23 | FromGitter | <mratsim> not at all, thanks for the name |
11:27:16 | Araq | and how do you do register allocation in your JIT? |
11:27:50 | Araq | graph coloring? linear? |
11:29:17 | FromGitter | <mratsim> generate LLVM IR and let it deal with it |
11:29:48 | FromGitter | <mratsim> or at compile-time, generate Nim code |
11:29:56 | FromGitter | <mratsim> which is what I'm starting with |
11:31:39 | Araq | oh you generate LLVM. then why do you mention 'mov' and its variants? |
11:32:29 | FromGitter | <mratsim> where? |
11:33:38 | FromGitter | <mratsim> ah you means here in the written from scratch section? https://github.com/mratsim/Arraymancer/issues/347 |
11:33:59 | FromGitter | <mratsim> that's just exhaustively putting implementation possibilities |
11:34:19 | FromGitter | <mratsim> I have a jit assembler in Nim that works |
11:34:41 | FromGitter | <mratsim> but it's mentionned in the bottom, that they are significant challenges like register allocations ;) |
11:36:14 | FromGitter | <mratsim> not even talking about jitting for GPU ... |
11:41:39 | Araq | ok |
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:37 | FromGitter | <alehander42> do we support /^[[:digit:][:upper:]_]+$/.freeze |
13:14:45 | FromGitter | <alehander42> :digit: etc in our regexes |
13:15:05 | FromGitter | <alehander42> posix character class |
13:22:22 | Araq | no idea, I would guess that PCRE supports that |
13:25:53 | * | salewski joined #nim |
13:28:00 | salewski | Question: procs have default result variable. I guess iterators not? Is that fact documented somewhere? Can not find currently. |
13:31:29 | salewski | OK, was documented in tut1: Iterators have no implicit result variable. |
13:31:41 | Araq | not good enough, the manual needs to say it |
13:32:10 | salewski | Yes, would be better, I searched in manual first :-) |
13:32:36 | salewski | And maybe say WHY also. |
13:32:43 | salewski | Bye. |
13:33:10 | * | salewski quit (Quit: WeeChat 2.3) |
13:58:50 | PMunch | What would the result variable in an iterator do? |
13:59:44 | * | vlad1777d joined #nim |
14:00:40 | * | sealmove joined #nim |
14:01:42 | Araq | it would contain the value for an empty 'yield' |
14:01:59 | Araq | but we also don't have empty yields, so ... *shrug* |
14:06:39 | PMunch | Ah, 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:28 | FromGitter | <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:32 | FromGitter | <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:46 | FromGitter | <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:01 | Araq | it gives us a named return value optimization whether you accept it or not. |
14:59:12 | * | sentreen quit (Ping timeout: 245 seconds) |
14:59:43 | FromGitter | <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:01 | Araq | and 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:53 | rockcavera | Hello! How do I compile for win32 using mingw64 and nim64? |
15:04:19 | rockcavera | nim c --cpu:i386 has given error |
15:04:38 | Araq | via --os:windows --cpu:i386 and a mingw that can handle it |
15:06:25 | rockcavera | still giving error |
15:06:49 | * | PMunch quit (Remote host closed the connection) |
15:07:06 | Araq | what error? and why can't you simply a 32bit Nim? it runs on your 64bit machine. |
15:08:03 | rockcavera | uhum |
15:08:59 | rockcavera | Error: 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:01 | rockcavera | In file included from C:\Users\Jose\Desktop\nim\nimcache\debug\stdlib_parseutils.c:10:0: |
15:09:01 | rockcavera | D:\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:02 | rockcavera | typedef int Nim_and_C_compiler_disagree_on_target_architecture[sizeof(NI) == sizeof(void*) && NIM_INTBITS == sizeof(NI)*8 ? 1 : -1]; |
15:09:02 | rockcavera | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
15:09:41 | Araq | yeah, 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:06 | FromGitter | <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:06 | FromGitter | ... `auto` return type and just return whatever, but that's not satisfactory either. |
15:17:48 | FromGitter | <dawkot> Is there any way to get the name of the type underlying a type alias? |
15:20:03 | * | rockcavera joined #nim |
15:20:06 | FromGitter | <iffy> What's the opposite of `nimble develop`? |
15:21:51 | FromGitter | <arnetheduck> `make` and git submodules :) that's where we are, as we start to abandon nimble |
15:24:34 | Araq | make? that's so sad. |
15:25:11 | Araq | why not 'tup' or scons or ... |
15:28:47 | Araq | iffy: you can remove the symlink emulation in your $nimbleDir |
15:28:58 | Araq | to undo 'nimble develop' |
15:29:10 | * | clyybber joined #nim |
15:29:16 | Araq | whether there is also a nimble command I don't know :-) |
15:30:45 | FromGitter | <iffy> k, thanks :) |
15:31:59 | FromGitter | <iffy> Nim is abandoning nimble? Or just you for a particular thing, @arnetheduck |
15:33:37 | Araq | he speaks about Nimbus, not Nim. |
15:34:08 | FromGitter | <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:10 | Araq | ok. I would use a small Nim program instead but whatever. |
15:36:22 | FromGitter | <arnetheduck> @iffy yeah, it's just for a project we're working on |
15:36:30 | FromGitter | <iffy> phew |
15:37:17 | FromGitter | <arnetheduck> the "small" nim programs add up, in terms of maintenance. |
15:37:28 | Araq | so do makefiles |
15:38:14 | Araq | and 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:15 | FromGitter | <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:53 | clyybber | Has anybody done something with midi in nim yet? |
15:52:57 | FromGitter | <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:01 | Araq | lots 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:20 | FromGitter | <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:30 | Araq | ok, I wasn't meant to start a fight. Just for the record besides reproducible builds what does Nimble lack for your needs? |
16:40:39 | Araq | *I didn't mean |
16:46:37 | * | rnrwashere joined #nim |
16:56:59 | shashlick | I'd be interested to understand this as well - I hope to ramp up on nimble and make some useful contributions |
16:57:30 | FromGitter | <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:02 | FromGitter | <mratsim> i386 and amd64 |
17:06:24 | FromGitter | <mratsim> the defines are different for arm and mips though |
17:07:02 | Araq | there is defined(cpu32) vs cpu64 iirc but I always use when sizeof(int) == 4 |
17:07:08 | Araq | so I don't remember |
17:09:17 | FromGitter | <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:17 | FromGitter | ... 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:24 | FromGitter | <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:24 | FromGitter | ... 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:49 | FromGitter | <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:00 | shashlick | thanks for taking the time to type that out |
17:14:12 | shashlick | here'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:20 | FromGitter | <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:30 | shashlick | so I need help to identify specific changes that will improve nimble |
17:15:56 | shashlick | one which bothered me personally is the inbuilt nim compiler which I am looking into removing and leveraging nim directly |
17:17:48 | Araq | shashlick: that would already solve many problems, it's fine to focus on that |
17:18:19 | shashlick | I don't see that solving any of the concerns raised by @mratsim and @arnetheduck |
17:18:32 | Araq | ha ha ha :-) |
17:19:09 | shashlick | second one was a per project nimble workflow, which is perhaps somewhat supported already with --nimbleDir |
17:19:40 | shashlick | i think that might help some, but curious on your feedback on that one |
17:20:04 | Araq | was about to say that. |
17:26:19 | FromGitter | <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:21 | FromGitter | <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:21 | FromGitter | ... get started.. |
17:26:48 | FromGitter | <mratsim> need nim stable, it will not compile in devel ;) |
17:27:12 | FromGitter | <arnetheduck> well, the build instructions are *supposed* to take care of that :) |
17:29:33 | FromGitter | <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:17 | shashlick | @mratsim is your showcasing comment about nimble verbosity? |
17:31:19 | FromGitter | <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:56 | FromGitter | <mratsim> no, it's about incompatible/outdated versions installed |
17:32:28 | shashlick | that'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:37 | shashlick | any reason why you haven't picked up 0.19.2 and 4? |
17:33:17 | shashlick | @mratsim - so you mean remove all older packages lying around when doing updates |
17:33:46 | FromGitter | <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:26 | clyybber | how does nimble deal with multiple versions of packages that provide binaries? |
17:35:52 | shashlick | i think it just keeps the last one you installed |
17:36:37 | FromGitter | <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:39 | shashlick | @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:20 | shashlick | okay, so how about requiring specific versions of packages as dependencies? beacon_chain.nimble has no versions specified other than for nim itself |
17:38:27 | FromGitter | <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:32 | FromGitter | <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:44 | shashlick | so for b) why not just require a specific hash |
17:40:51 | shashlick | git commit hash |
17:42:47 | FromGitter | <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:31 | FromGitter | <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:08 | FromGitter | <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:01 | shashlick | just 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:43 | clyybber | arnetheduck 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:20 | clyybber | Where a lockfile is just a list of package/version pairs |
17:50:35 | * | krux02 joined #nim |
17:50:42 | FromGitter | <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:22 | FromGitter | <mratsim> nimble freeze command would be helpful |
17:51:50 | FromGitter | <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:57 | FromGitter | <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:23 | FromGitter | <mratsim> @dawkot that's an array of typedesc, it's not a concrete type |
17:52:45 | FromGitter | <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:47 | FromGitter | <mratsim> at compile-time you can probably do magic with it though :p |
17:53:01 | clyybber | arnetheduck Yeah I agree |
17:53:23 | FromGitter | <mratsim> (`update` which doesn't exist) |
17:53:31 | shashlick | okay so effectively, if the lock file doesn't exist, do what nimble does by default |
17:53:39 | shashlick | but at the end of it, nimble generates a lock file which can be checked in |
17:53:48 | FromGitter | <mratsim> I'm regularly nuking my nimble install instead of going through the dependency uninstalling/updating mess |
17:53:52 | shashlick | and if a lock file exists, then follow that to pull deps |
17:54:00 | clyybber | If you explicity tell it to generate a lock file |
17:54:12 | clyybber | only then it should generate one |
17:54:27 | shashlick | i think this also needs per project repos to work correctly |
17:54:39 | FromGitter | <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:17 | shashlick | so a lock file can also be seen as a dependency cache of sorts |
17:55:39 | clyybber | I think so |
17:55:46 | FromGitter | <arnetheduck> that's one way to look at it, though cache is a weak word for it |
17:56:03 | shashlick | only as far as running nimble several times a day is concerned |
17:57:07 | * | narimiran_ is now known as narimiran |
17:59:05 | clyybber | so 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:09 | FromGitter | <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:31 | FromGitter | <arnetheduck> clyybber, yeah, but without all that syntax, please |
17:59:47 | shashlick | see that's the challenge - do we expand nimble or leverage an existing pm |
18:00:04 | shashlick | cause this is all the same problem solved again and again |
18:02:04 | clyybber | arnetheduck 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:38 | FromGitter | <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:38 | FromGitter | ... ever changing) etc |
18:06:44 | clyybber | How can I instruct the compile pragma to compile cpp when generating to C? |
18:07:19 | shashlick | I've put together a high-level workflow for this - https://gist.github.com/genotrance/03465051162d70dd48f938f103201104 |
18:07:24 | shashlick | feedback appreciated |
18:08:21 | shashlick | I've not considered how existing .nimble file requires fit into this yet |
18:08:24 | clyybber | I thin per project nimbleDir belongs in the .nible file |
18:09:33 | FromGitter | <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:32 | FromGitter | <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:22 | clyybber | arnetheduck 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:00 | shashlick | okay some homework, will look into it |
18:16:04 | FromGitter | <arnetheduck> you also need to create it if it doesn't exist yet |
18:16:15 | shashlick | appreciate any feedback on my notes so far too |
18:16:15 | clyybber | yeah of course |
18:17:07 | shashlick | now $0.02 question - there's 132 open issues with nimble - what's the priority of these when compared to this requirement |
18:19:05 | clyybber | Many of those issues are kind of unneccessary IMO, like for example the license enforcing. |
18:23:25 | FromGitter | <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:14 | FromGitter | <mratsim> in that regards, the way choosenim allows to switch 0.17, 0.18, 0.19, devel is good. |
18:32:02 | FromGitter | <arnetheduck> well, yeah, though I actually prefer python's approach where the venv takes over that as well |
18:32:42 | FromGitter | <arnetheduck> the less something infects my whole computer and shell, the better, as long as the UX is acceptable |
18:33:38 | FromGitter | <mratsim> Cargo doesn't allow virtual envs though? there is a cargo.toml with versions/commit defined. |
18:33:55 | FromGitter | <mratsim> you can put Nim version/commits in there as well |
18:37:21 | FromGitter | <arnetheduck> no, cargo doesn't |
18:37:45 | FromGitter | <arnetheduck> they have rustup which is the spiritual equivalent of choosenim |
18:39:55 | FromGitter | <arnetheduck> they then version the toolchain via rustup: https://github.com/rust-lang/rustup.rs#the-toolchain-file |
18:40:10 | FromGitter | <mratsim> wellchoosenim is inspired by rustup |
18:40:19 | clyybber | I'm struggling to wrap RtMidi... the compiler shouldn't complain about undefined references when linking the appropriate object files right? |
18:40:52 | FromGitter | <mratsim> no it shouldn't, what are the missing references? |
18:41:05 | FromGitter | <mratsim> Maybe you miss basic things like libm |
18:42:54 | clyybber | theres a lot of undefined references to __cxxabi stuff |
18:43:13 | clyybber | so the problem is probably that RtMidi is a CPP thing |
18:43:30 | shashlick | either you need to link with g++ or nim cpp |
18:43:50 | clyybber | and it has a C api which wraps the CPP api |
18:44:01 | clyybber | so what I did was wrap the C api. |
18:44:34 | shashlick | here's what I had to work with C++ mixed in with C for nitmerop |
18:44:35 | shashlick | https://github.com/nimterop/nimterop/blob/master/config.nims |
18:44:45 | clyybber | thx shashlick |
18:45:41 | shashlick | in what planet is this a good idea - https://www.reddit.com/r/programming/comments/7q6ida/jai_libraries_discussion/dsnu6ls/ |
18:46:30 | FromGitter | <mratsim> Nim also adds a unique suffix to all symbols |
18:46:34 | * | narimiran quit (Ping timeout: 246 seconds) |
18:47:00 | clyybber | I 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:47 | shashlick | ya but I meant having multiple versions of the same library in your binary |
18:47:52 | shashlick | i guess life isn't always so easy |
18:47:58 | FromGitter | <mratsim> as long as your functions have the proper name and not the YZNOXB garbage that C++ generates you're ok |
18:48:17 | FromGitter | <mratsim> Mac also had fat binaries for PPC+x86 |
18:48:57 | clyybber | I'm kind of inclined to scrap those midi wrappers and just use alsa-sequencer or jack or coremidi directly |
18:49:03 | FromGitter | <mratsim> and for Laser I'm also producing fat binaries for SSE, SSE2, SSE3, SSE4, SSE4.1, AVX, AVX+FMA, AVX2, AVX512 |
18:49:22 | clyybber | And write a *pure* nim midi library |
18:50:20 | FromGitter | <mratsim> when you mean versions like Python 2 and Python 3, yeah that sounds like overkill |
18:51:24 | clyybber | anyone got a good pun involving nim and midi ? |
18:51:52 | Araq | nimidi |
18:51:59 | shashlick | anyone have any ideas for this one? https://paste.ofcode.org/GdkqFFWRpWQfzu7Q23h5k |
18:52:12 | shashlick | nimbase.h and oratypes.h have the same `string` type that conflict |
18:52:42 | Araq | ah sux. gotta fix Nim for that one |
18:54:47 | clyybber | Araq: Sounds a bit bavarian |
18:55:00 | clyybber | more bavarian variant: "nimdi" |
18:55:07 | clyybber | though I guess that looses midi |
18:59:47 | FromGitter | <alehander42> can i get the path of the macro instantiation file? |
18:59:57 | FromGitter | <alehander42> the file where an instantation expands |
19:00:11 | * | Senketsu joined #nim |
19:00:22 | FromGitter | <mratsim> fun fact, Midi 1.0 was in 1996 and Midi 2.0 was announced in january 2019 |
19:00:41 | FromGitter | <arnetheduck> no way, there's a midi2?? |
19:00:58 | FromGitter | <alehander42> currentSourcePath returns the original one |
19:01:03 | FromGitter | <alehander42> maybe i can generate it actually |
19:01:07 | clyybber | Yeah, 32bit for a lot of things that were previously 8bit integers basically |
19:02:48 | clyybber | but its not been released yet. They are currently prototyping it. |
19:03:51 | * | pacujo joined #nim |
19:04:54 | pacujo | Are these declarations of A identical: |
19:04:54 | pacujo | type |
19:04:54 | pacujo | B = ref object of RootObj |
19:04:54 | pacujo | A = ref object of B |
19:04:54 | pacujo | type |
19:04:55 | pacujo | B = object of RootObj |
19:04:55 | pacujo | 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:12 | FromGitter | <Varriount> pacujo: Structurally, yes |
19:11:50 | pacujo | That'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:18 | pacujo | I'm trying to get a feel whether to declare a "class" on object or a ref object |
19:18:24 | pacujo | Declaring everything ref is the easy way out, and it would work |
19:18:58 | FromGitter | <Varriount> Well, ref object would be the only way runtime polymorphism would work. |
19:19:57 | FromGitter | <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:12 | FromGitter | <Varriount> Er, I mean, parent type |
19:20:45 | * | Vladar quit (Remote host closed the connection) |
19:22:12 | pacujo | Looking at the source code of tables.nim doesn't make the principles very clear |
19:22:53 | pacujo | Everything is duplicated for ref and plain objects |
19:23:53 | * | rnrwashere quit (Remote host closed the connection) |
19:24:01 | pacujo | For example, |
19:24:04 | pacujo | proc len*[A, B](t: Table[A, B]): int = |
19:24:16 | pacujo | why not t: var Table[A, B] |
19:25:49 | pacujo | From 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:25 | FromGitter | <Varriount> pacujo: Object types are passed using a pointer |
19:29:45 | * | narimiran joined #nim |
19:30:32 | pacujo | Oh? |
19:30:49 | * | jjido joined #nim |
19:31:03 | pacujo | Missed the memo |
19:31:46 | FromGitter | <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:26 | FromGitter | <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:34 | pacujo | That's clear, but a very different statement |
19:33:02 | pacujo | I don't suppose proc len*[A, B](t: Table[A, B]): int can alter t |
19:33:45 | pacujo | (or the changes would only apply to the "copy") |
19:35:56 | FromGitter | <Varriount> You can't really directly modify a perimeter and nim, unless it is a var or ref parameter. |
19:36:11 | FromGitter | <Varriount> *parameter in Nim |
19:36:59 | pacujo | Ok, shrewd |
19:37:24 | * | rnrwashere joined #nim |
19:37:26 | Araq | pacujo, the code duplication is only for the people coming from Python |
19:37:29 | FromGitter | <Varriount> pacujo: I might just be misunderstanding you |
19:37:49 | Araq | so that we also offer TableRef semantics |
19:38:05 | pacujo | Oh, please, Araq |
19:38:27 | Araq | oh please? |
19:38:48 | pacujo | Placating 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:10 | pacujo | Anyway, Varriount, if the parameters are immutable, it gives lots of optimizing leeway to the compiler (no unnecessary copying) |
19:40:22 | FromGitter | <Varriount> Yes. |
19:40:29 | * | rnrwashere quit (Remote host closed the connection) |
19:40:35 | * | zyklon joined #nim |
19:40:59 | FromGitter | <Varriount> And little need for the whole addressof operator and friends |
19:41:34 | pacujo | Which 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:35 | pacujo | Plain means embeddable and potentially slightly faster |
19:44:01 | pacujo | But 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:49 | FromGitter | <Varriount> Pacujo: can you explain what your object model is, or what your objects are going to do? |
19:46:54 | pacujo | I'm just learning about nim by porting some of my own code. In this case, I'm porting my avltree to nim |
19:48:58 | pacujo | So |
19:48:58 | pacujo | AVLTree[K, V] = ref object of RootObj |
19:48:58 | pacujo | or |
19:48:58 | pacujo | AVLTree[K, V] = object of RootObj |
19:49:46 | pacujo | (I'm thinking the former) |
19:49:55 | Araq | AVLTree[K, V] = ref object # no of. |
19:51:02 | pacujo | Some page I read recommended basing every object on RootObj |
19:51:25 | pacujo | I don't exactly know why |
19:51:35 | Araq | don't do it |
19:52:05 | pacujo | Nim's own stdlib does it |
19:52:18 | Araq | not often |
19:52:37 | pacujo | But... why or why not? |
19:52:42 | Araq | don't do what I do, do what I say. |
19:54:35 | pacujo | https://nim-lang.org/0.18.0/tut2.html#object-oriented-programming-objects |
19:54:53 | pacujo | If an object type has no suitable ancestor, RootObj can be used as its ancestor, but this is only a convention. |
19:55:07 | pacujo | ^^that's a quote^ |
19:57:10 | pacujo | That's a bit of an enigmatic statement |
20:00:32 | * | lf-araujo joined #nim |
20:04:49 | pacujo | Another interesting observation: you can't declare a `[]` that would do the "right thing" both as a setter and as a getter |
20:05:08 | narimiran | `[]=` |
20:07:05 | FromGitter | <alehander42> you can define a macro that lets you do it, something like attr_accessor |
20:07:32 | FromGitter | <alehander42> but with a piece of logic |
20:07:42 | FromGitter | <alehander42> i forgot attr_accessor is only 🔣 |
20:07:49 | FromGitter | <alehander42> :sym \ |
20:08:07 | pacujo | Thanks, narimiran. |
20:09:13 | pacujo | If there are both |
20:09:13 | pacujo | proc `[]`*[A, B](t: OrderedTableRef[A, B], key: A): var B = |
20:09:13 | pacujo | and |
20:09:13 | pacujo | proc `[]=`*[A, B](t: var OrderedTable[A, B], key: A, val: B) = |
20:09:13 | pacujo | how does nim decide which to call? |
20:09:38 | narimiran | one is getter, other is setter |
20:09:47 | narimiran | echo foo[a] |
20:09:53 | narimiran | foo[a] = 5 |
20:12:55 | pacujo | So it's the syntactic presence of "=" that decides |
20:14:44 | FromGitter | <alehander42> you can say foo[a] = is syntactic sugar for `[]=`(foo, a, 5) |
20:16:13 | pacujo | I guess that's sound |
20:16:47 | * | nsf quit (Quit: WeeChat 2.4) |
20:17:30 | * | rnrwashere joined #nim |
20:17:47 | pacujo | However, if you didn't define `[]=`, I suppose `[]` would be called instead |
20:19:02 | * | krux02 joined #nim |
20:19:36 | FromGitter | <alehander42> no |
20:19:40 | FromGitter | <alehander42> why |
20:19:44 | FromGitter | <alehander42> `[]` is for access |
20:19:49 | FromGitter | <alehander42> `[]=` is for setting |
20:20:31 | FromGitter | <alehander42> they don't have much to do one with the other |
20:20:47 | FromGitter | <alehander42> if you don't define `[]=`, it just doesnt compile |
20:21:23 | pacujo | `[]` above returns var B so I can pass the return value as an argument to a function which sets the value, right? |
20:22:00 | Araq | right but the compiler doesn't use it in t[x] = y |
20:22:20 | * | rnrwashere quit (Ping timeout: 272 seconds) |
20:22:40 | pacujo | Got it |
20:25:03 | * | rnrwashere joined #nim |
20:25:31 | pacujo | Tested: |
20:25:31 | pacujo | proc f(a: var int): var int = a |
20:25:31 | pacujo | var a: int |
20:25:31 | pacujo | f(a) = 7 |
20:25:31 | pacujo | echo a |
20:26:03 | pacujo | Worked as expected |
20:26:48 | * | uvegbot joined #nim |
20:27:15 | pacujo | Then: |
20:27:15 | pacujo | proc `[]`(a: var int, i: int): var int = a |
20:27:15 | pacujo | var a: int |
20:27:15 | pacujo | `[]`(a, 0) = 7 |
20:27:15 | pacujo | echo a |
20:27:20 | pacujo | Still worked |
20:27:49 | pacujo | But a[0] = 7 didn't work |
20:28:20 | pacujo | Interesting |
20:29:30 | * | rnrwashere quit (Ping timeout: 250 seconds) |
20:32:43 | FromGitter | <alehander42> [] just doesnt have anything to do with []= |
20:33:09 | FromGitter | <alehander42> a[0] = 7 isnt compiled to |
20:33:12 | FromGitter | <alehander42> (a[0]) = 7 |
20:33:15 | FromGitter | <alehander42> its compiled to |
20:33:19 | FromGitter | <alehander42> a ([]=) 7 |
20:33:43 | pacujo | Yeah, thanks |
20:46:44 | Zevv | what 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:53 | Zevv | and - 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:24 | Zevv | ah, 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:42 | FromGitter | <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:30 | Zevv | I'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:10 | Zevv | that must be pretty common I guess? |
21:09:40 | Zevv | hm 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:42 | Zevv | back to the drawing board |
21:10:12 | FromGitter | <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:10 | FromGitter | <brentp> ok. found it: `-d:useSysAssert -d:useGcAssert` |
21:18:21 | Zevv | where 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:41 | FromGitter | <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:30 | Zevv | YEah, 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:02 | I_Right_I | Zevv: 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:32 | Zevv | y.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:54 | FromDiscord | <Skaruts> var position_components:Table < -- error: invalid type 'Table' for var |
22:31:59 | FromDiscord | <Skaruts> ?? |
22:33:19 | * | rnrwashere quit (Remote host closed the connection) |
22:34:00 | FromDiscord | <Skaruts> is there a way to create an empty table? |
22:34:26 | * | rnrwashere joined #nim |
22:35:02 | Zevv | var x = initTable[Tkey,Tvalue]() |
22:37:27 | FromDiscord | <Skaruts> should I replace TKey and Tvalue with something? |
22:37:37 | FromDiscord | <Skaruts> they're undeclared identifiers |
22:37:53 | FromDiscord | <Skaruts> or am I supposed to import something else other than 'tables'? |
22:40:32 | solitudesf | yes, you should replace them key type and value type of your table |
22:40:36 | Zevv | What 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:02 | FromDiscord | <Skaruts> oh they're the types |
22:41:03 | FromDiscord | <Skaruts> thanks |
22:41:24 | Zevv | I learned that In nimland capital T usually means something with type |
22:41:33 | FromDiscord | <Skaruts> yea it's basically [string, Component] |
22:41:35 | Zevv | It is common idiom with generics |
22:41:45 | * | rnrwashere quit (Remote host closed the connection) |
22:42:08 | Zevv | One thing that bothers me still with Nim is that tables need explict newTable or initTable |
22:42:11 | FromDiscord | <Skaruts> yea I still have't gotten that far, though I've seen that a lot (also in C++) |
22:42:18 | Zevv | So simply defining a type as a Table is not enough: |
22:42:25 | Zevv | var t: Table[int,string] |
22:42:30 | Zevv | is just fine |
22:42:30 | Zevv | but you can't use it |
22:42:45 | Zevv | you need var t = initTable[int,string]() |
22:42:55 | Zevv | AND DONT DARE TO FORGET THE BRACKETS AT THE END |
22:43:00 | Araq | Zevv, there is an RFC covering it... |
22:43:00 | Zevv | that happened to me *so* many times |
22:43:05 | Zevv | Araq: \o/ you say! |
22:43:24 | Zevv | for Tables only? |
22:43:34 | Zevv | how would that work |
22:43:48 | FromDiscord | <Skaruts> RFC? |
22:43:54 | Araq | like it would for @[] |
22:44:05 | Zevv | but @[] is a language builtin |
22:44:11 | Zevv | RFC = request for comments |
22:44:20 | FromDiscord | <Skaruts> ah thanks |
22:44:20 | Araq | []= and 'add' would create a table if it's not init'ed explicitly |
22:44:35 | Araq | nothing hard, no language change required either |
22:44:56 | * | rnrwashere joined #nim |
22:45:08 | Zevv | That makes sense, simple and sweet |
22:45:09 | * | solitudesf quit (Ping timeout: 245 seconds) |
22:45:40 | * | NimBot joined #nim |
22:45:58 | FromDiscord | <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:12 | FromDiscord | <Skaruts> I suppose I can add/remove from tables? |
22:46:18 | Zevv | of course |
22:46:25 | Araq | Skaruts: for an ECS I have some ideas... |
22:46:34 | Zevv | adding is done by simply assigning to the [] element. |
22:46:51 | FromDiscord | <Skaruts> hmm, like with dictionaries in python? |
22:46:56 | Zevv | just so |
22:47:04 | FromDiscord | <Skaruts> just adding like that creates a new entry, ok |
22:47:38 | FromDiscord | <Skaruts> and to remove? |
22:47:39 | Zevv | delete with t.del(key) |
22:47:47 | Zevv | ha almost beat you to it |
22:47:52 | FromDiscord | <Skaruts> 😃 |
22:47:55 | Zevv | https://nim-lang.org/docs/tables.html |
22:48:06 | FromDiscord | <Skaruts> I was just opening that too 😃 |
22:48:11 | Araq | don't use Tables for an ECS there are far more performant solutions |
22:48:19 | FromDiscord | <Skaruts> tell me more 😃 |
22:48:20 | Zevv | indexing a non-existent key will trow |
22:48:41 | Zevv | use `t.contains(k)` or `k in t` to test |
22:49:39 | Araq | type EntityId = distinct int; type Position = object v: vec3; id: EntityId |
22:50:17 | Araq | var positions: seq[Position] |
22:51:05 | Araq | var phys: seq[Physics] |
22:51:06 | Araq | # etc. |
22:51:16 | Araq | add an entity: |
22:51:23 | FromDiscord | <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:33 | Araq | positions.add Position(id: myId, ...) |
22:51:40 | Zevv | skaruts: you can update lenght on the fly |
22:51:55 | Araq | # delete: |
22:52:13 | Araq | positionsDel.add myId |
22:52:17 | Araq | # iteration: |
22:52:25 | Araq | if positionsDel.len > 0: |
22:52:51 | FromDiscord | <Skaruts> what if you need to access the position component of a specific entity by id |
22:53:17 | Araq | for p in positions: if p.id in positionsDel: del(p) else: process(p) |
22:53:18 | Araq | else: |
22:53:29 | Araq | for p in positions: process(p) # common case |
22:53:47 | FromDiscord | <Skaruts> yea I was trying avoid having to iterate through it looking for each id I need |
22:54:22 | Araq | deletion is not the same as a positions.byId(id) lookup |
22:56:08 | Araq | if you need a more general byId lookup you can keep a Table[id, positionIndex] around |
22:57:06 | FromDiscord | <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:26 | FromDiscord | <Skaruts> or else if I could fill a seq with nils and replace them with components using ids as indices |
22:58:54 | Araq | Table iteration is slower than seq iteration though and usually that's what you need to optimize for |
22:59:35 | FromDiscord | <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:54 | FromDiscord | <Skaruts> so I tend to think in terms of avoiding too many loops |
23:01:39 | FromDiscord | <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:36 | Zevv | how do I get the codepoint of a Rune? |
23:04:20 | Zevv | no, wrong word. |
23:04:40 | Zevv | oh, right word |
23:05:03 | Araq | skaruts: that's what Quad- and Octrees are for |
23:05:31 | FromDiscord | <Skaruts> oooh I'm not that versed in those |
23:05:38 | Araq | https://gamedevelopment.tutsplus.com/tutorials/quick-tip-use-quadtrees-to-detect-likely-collisions-in-2d-space--gamedev-374 |
23:05:59 | FromDiscord | <Skaruts> I've implemented a binary tree for dungeon generations, but that was about it |
23:08:29 | Araq | Zevv, convert it to int? no idea what you mean |
23:08:46 | Zevv | yeah, I can just convert to int, but that is not explicit in the docs |
23:08:54 | Zevv | I had to lookup the RuneImpl in the code |
23:09:27 | Zevv | thanks |
23:10:08 | FromDiscord | <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:56 | FromDiscord | <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) |