00:31:49 | * | [R] joined #nim |
00:56:53 | * | thunder quit (Remote host closed the connection) |
01:03:15 | * | thunder joined #nim |
01:20:14 | * | thunder quit (Remote host closed the connection) |
01:20:40 | * | thunder joined #nim |
01:33:00 | nrds | <Prestige99> that's interesting |
01:33:26 | nrds | <Prestige99> oh you can still use $ with decimals, cool |
01:37:45 | * | arkurious quit (Quit: Leaving) |
01:40:26 | FromDiscord | <Elegantbeef> Prestige impressed with the oddest thing |
01:41:29 | FromDiscord | <theangryepicbanana> In reply to @@bracketmaster-5a708063d73408ce4 "I know `$` is": isn't `$` already `toString` thought? |
01:41:31 | FromDiscord | <theangryepicbanana> (edit) "thought?" => "though?" |
01:42:23 | FromDiscord | <Elegantbeef> Hey i found it odd, but i just showed them how \:D |
01:42:43 | FromDiscord | <theangryepicbanana> fair enough |
01:43:43 | FromDiscord | <Elegantbeef> Sometimes i should say the "but why" instead of just giving a solution |
01:43:43 | FromDiscord | <Elegantbeef> Sometimes i should say the |
01:46:43 | * | rockcavera joined #nim |
01:46:43 | * | rockcavera quit (Changing host) |
01:46:43 | * | rockcavera joined #nim |
01:57:14 | * | auxym quit (Ping timeout: 258 seconds) |
02:02:21 | nrds | <Prestige99> :) |
03:05:17 | * | krux02 quit (Remote host closed the connection) |
03:09:58 | * | thunder quit (Remote host closed the connection) |
03:16:06 | * | thunder joined #nim |
03:31:46 | * | rockcavera quit (Remote host closed the connection) |
03:32:44 | FromDiscord | <Rika> The |
03:35:02 | FromDiscord | <Elegantbeef> quick |
04:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
04:06:34 | * | supakeen joined #nim |
06:19:02 | FromDiscord | <ynfle (ynfle)> Is this a bug https://play.nim-lang.org/#ix=3uX7? Why can't a NimNode's kind be determined at compile time. Its' only ever available then |
06:21:58 | FromDiscord | <Elegantbeef> Except when that procedure is instantiated there is no way to reason what x.kind is |
06:23:38 | FromDiscord | <ynfle (ynfle)> I'm not sure what that means? |
06:24:04 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=3uX8 this might work for you |
06:25:29 | FromDiscord | <Elegantbeef> Well let's look what you're asking, you call a procedure providing an argument, so that means everytime you invoke this procedure `x.kind` would need to be changed since `{.error.}` only takes consts |
06:26:10 | FromDiscord | <ynfle (ynfle)> But at compile time, all of the instantiations are known |
06:26:27 | FromDiscord | <Elegantbeef> There is only one instantiation of this procedure |
06:26:34 | FromDiscord | <ynfle (ynfle)> It is a minified example |
06:26:49 | FromDiscord | <Elegantbeef> It doesnt matter what you do to it |
06:26:49 | FromDiscord | <ynfle (ynfle)> Oh |
06:27:01 | FromDiscord | <ynfle (ynfle)> So the error message isn't acurate |
06:27:12 | FromDiscord | <Elegantbeef> Well it is |
06:27:20 | FromDiscord | <Elegantbeef> Or sorta is |
06:27:21 | FromDiscord | <ynfle (ynfle)> Why? |
06:27:42 | FromDiscord | <Elegantbeef> Cause it cannot reason what x in a constant frame |
06:28:24 | FromDiscord | <Elegantbeef> It knows it'll be a Nimnode but has 0 clue what it could contain |
06:29:21 | FromDiscord | <Elegantbeef> I suppose if NimNodes were treated as a `static` it'd enable that, but the implications would be weird |
06:29:38 | FromDiscord | <Elegantbeef> Plus i might be spewing some amount of inconsistencies š |
06:30:33 | * | thunder quit (Quit: Leaving) |
06:34:22 | FromDiscord | <ynfle (ynfle)> https://play.nim-lang.org/#ix=3uX9 |
06:35:58 | FromDiscord | <Elegantbeef> I said "if they were treated" |
06:37:19 | FromDiscord | <Elegantbeef> sent a code paste, see https://paste.rs/zj5 |
06:37:34 | FromDiscord | <Elegantbeef> I still just say use expect kinds where you need to or assertions |
06:42:49 | FromDiscord | <ynfle (ynfle)> I have a proc that uses a case statement and I want to produce a useful error message |
06:44:57 | FromDiscord | <ynfle (ynfle)> For when a node was passed in that isn't part of the case statement |
06:45:58 | FromDiscord | <ynfle (ynfle)> If I use expectkind, I'd have to manually collect all of the NimNode possibilities |
06:51:06 | * | neceve joined #nim |
06:53:42 | FromDiscord | <Elegantbeef> To steal some logic from CPS https://play.nim-lang.org/#ix=3uXe |
06:54:48 | FromDiscord | <Elegantbeef> Plus error doesnt really do what you want https://play.nim-lang.org/#ix=3uXf |
06:58:10 | FromDiscord | <ynfle (ynfle)> Is there a reason that the example in https://nim-lang.github.io/Nim/manual_experimental.html#case-statement-macros doesn't compile? |
06:58:28 | FromDiscord | <ynfle (ynfle)> @elegantbeef\:matrix.org it's not exactly what I need |
06:59:04 | FromDiscord | <Elegantbeef> those are devel logs, replace `case` with `match` |
06:59:24 | * | max22- joined #nim |
07:00:05 | FromDiscord | <Elegantbeef> Notice it doesnt use `{.error.}` it uses `error(msg)` |
07:01:01 | FromDiscord | <Elegantbeef> As such you dont have that compile time issue since it's not in a pragma https://play.nim-lang.org/#ix=3uXh |
07:03:20 | FromDiscord | <ynfle (ynfle)> Ohhh |
07:03:49 | FromDiscord | <ynfle (ynfle)> \:facepalm |
07:27:40 | FromDiscord | <ynfle (ynfle)> Thanks for the help @elegantbeef\:matrix.org |
07:34:26 | FromDiscord | <zygon.sisyphus> hi |
07:36:23 | FromDiscord | <zygon.sisyphus> how possible is to use zig / zig cc as compiler for nim ? also, is possible to generate zig instead of c as intermediate lang ? |
07:36:35 | FromDiscord | <zygon.sisyphus> or combine c + zig |
07:37:01 | FromDiscord | <Elegantbeef> People have used the zig compiler as the C compiler and no Nim doesnt have a zig backend |
07:37:04 | FromDiscord | <zygon.sisyphus> how dificult will be to implement this ? |
07:37:12 | FromDiscord | <ynfle (ynfle)> Zig compiler, yes. generate zig, yes, but it'd require tons of work |
07:37:50 | FromDiscord | <Elegantbeef> What'd even be the benefit to using nim -\> zig |
07:38:01 | FromDiscord | <Elegantbeef> We already have nlvm so seems more sensiible to work on that |
07:38:18 | FromDiscord | <zygon.sisyphus> is cleaner than c and integrates better with libs |
07:38:36 | FromDiscord | <zygon.sisyphus> as cross platform target |
07:38:42 | FromDiscord | <Elegantbeef> Again what's the benefit over nlvm |
07:39:39 | FromDiscord | <zygon.sisyphus> nlvm ? |
07:39:53 | FromDiscord | <Elegantbeef> https://github.com/arnetheduck/nlvm |
07:39:56 | nrds | <R2D299> itHub: 7"LLVM-based compiler for the Nim language" |
07:41:07 | FromDiscord | <zygon.sisyphus> thx, i didn't know about nlvm |
07:44:20 | FromDiscord | <ynfle (ynfle)> 1) the nim c instead supposed to be read. 2) using the zig compiler with nim c, it becomes cross platform |
07:47:27 | FromDiscord | <Elegantbeef> Well also Zig's compiler for C is mostly just clang isnt it? |
07:47:30 | FromDiscord | <zygon.sisyphus> the "advantages" are on front page https://ziglang.org |
07:47:50 | FromDiscord | <zygon.sisyphus> sent a long message, see http://ix.io/3uXw |
07:47:55 | FromDiscord | <Elegantbeef> but how is that a benefit over using C as an IR |
07:48:05 | FromDiscord | <Elegantbeef> C has a compiler for almost every cpu |
07:48:31 | FromDiscord | <Elegantbeef> So if you have a CPU you can most likely run Nim |
07:48:45 | FromDiscord | <zygon.sisyphus> today the development is more than just the compiler |
07:48:53 | FromDiscord | <ynfle (ynfle)> That's only an issue for writing programs not generating |
07:49:59 | FromDiscord | <zygon.sisyphus> is about libs, package mangement, dependecy management, crossplatform, static analysis |
07:50:18 | FromDiscord | <Elegantbeef> But Nim already does most of that |
07:50:29 | FromDiscord | <zygon.sisyphus> at hi level |
07:51:06 | FromDiscord | <zygon.sisyphus> it was just an idea |
07:51:08 | FromDiscord | <ynfle (ynfle)> Right |
07:51:18 | FromDiscord | <Elegantbeef> I'm just trying to see the benefits |
07:51:20 | FromDiscord | <ynfle (ynfle)> Why do we need low level if we have high level? |
07:52:00 | FromDiscord | <zygon.sisyphus> it was based on my experience on testing some c projects |
07:52:15 | FromDiscord | <Elegantbeef> No one is writing the generated C code, so almost all of those aforementioned benefits are not actually needed |
07:52:20 | FromDiscord | <zygon.sisyphus> is as bad as was 20 year ago |
07:52:29 | FromDiscord | <Elegantbeef> But nim isnt C |
07:53:32 | FromDiscord | <zygon.sisyphus> but most of the time is necessary to have low level integration and most OS Api today are desined based on libc |
07:54:03 | FromDiscord | <zygon.sisyphus> so an middle level that can solve some issues is an idea |
07:54:16 | FromDiscord | <ynfle (ynfle)> Which issues? |
07:54:34 | FromDiscord | <ShalokShalom> How does have Nim implemented the effects tracking, to say if func is pure or not? |
07:54:34 | FromDiscord | <zygon.sisyphus> package/libs management |
07:54:42 | FromDiscord | <Elegantbeef> How does zig solve that |
07:54:44 | FromDiscord | <zygon.sisyphus> header management |
07:54:50 | FromDiscord | <zygon.sisyphus> references |
07:55:34 | FromDiscord | <haxscramper> In reply to @ShalokShalom "How does have Nim": Each procedure is either manually annotated with effects, or they are computed based on its body. |
07:56:22 | FromDiscord | <haxscramper> Some "root" procedures like echo has manual side effect annotation, which then propagates through the callers |
07:57:30 | FromDiscord | <haxscramper> https://github.com/nim-lang/Nim/blob/devel/compiler/sempass2.nim#L1338 |
07:57:32 | * | xet7 quit (Remote host closed the connection) |
07:58:21 | FromDiscord | <haxscramper> This has nothing to do with low-level backend, features. |
07:58:33 | FromDiscord | <zygon.sisyphus> I think the same apply to rust |
07:58:35 | * | xet7 joined #nim |
07:58:45 | FromDiscord | <zygon.sisyphus> but rust is to llvm dependent |
07:59:44 | FromDiscord | <ynfle (ynfle)> What applies to rust? |
08:01:17 | FromDiscord | <haxscramper> I think we have a misunderstanding, because I'm also having hard time figuring out how zig backend would affect anything you listed earlier |
08:01:18 | FromDiscord | <zygon.sisyphus> use rust/zig instead of plain c |
08:01:56 | FromDiscord | <Elegantbeef> Feel free to make a `ziggen.nim` file in the compiler to get the rewards |
08:01:58 | FromDiscord | <haxscramper> Why this would be better? Compiling to rust is probably useless idea in the first place |
08:02:09 | FromDiscord | <haxscramper> Like, really useless |
08:02:19 | FromDiscord | <zygon.sisyphus> the idea is to combine an hi level lang with GC with low level no GC |
08:02:19 | FromDiscord | <Elegantbeef> Yea you still havent said why it's beneficial clearly |
08:02:24 | FromDiscord | <Elegantbeef> But that's not what nim is |
08:02:24 | * | max22- quit (Ping timeout: 276 seconds) |
08:02:28 | FromDiscord | <haxscramper> C/js? |
08:03:16 | FromDiscord | <haxscramper> I mean C does have a package management solutions (usually they are a distro PM but anyway) |
08:03:41 | FromDiscord | <haxscramper> And C is almost universal language for interop |
08:03:43 | FromDiscord | <zygon.sisyphus> for big projects c is dificult to read and allow to many errors |
08:03:51 | FromDiscord | <haxscramper> Yes, but nim is not C |
08:03:52 | FromDiscord | <Elegantbeef> Which is why we say write Nim |
08:03:58 | FromDiscord | <haxscramper> Nim generates C |
08:04:08 | FromDiscord | <zygon.sisyphus> this is ok |
08:04:11 | FromDiscord | <Elegantbeef> You arent using C + Nim, you're using Nim |
08:04:29 | FromDiscord | <zygon.sisyphus> until you need to interact with other libs, usualy c/c++ |
08:04:38 | FromDiscord | <Elegantbeef> And you still arent using C/C++ |
08:04:46 | FromDiscord | <zygon.sisyphus> because OS needs c/libc |
08:04:56 | FromDiscord | <Elegantbeef> You write bindings and then use Nim |
08:05:00 | FromDiscord | <Elegantbeef> Have you actually used Nim? |
08:05:10 | FromDiscord | <zygon.sisyphus> not yet |
08:05:18 | FromDiscord | <zygon.sisyphus> just try some demo |
08:05:28 | FromDiscord | <zygon.sisyphus> just try some samples |
08:05:44 | FromDiscord | <ynfle (ynfle)> Of nim? |
08:05:50 | FromDiscord | <zygon.sisyphus> need an good IDE with debug support |
08:05:54 | FromDiscord | <haxscramper> Nim can interface with c and c++ without having to actually write C/c++ code |
08:06:25 | FromDiscord | <Elegantbeef> You do need to write/generate bindings, but that can be slightly automated using `c2nim` and `nimterop` |
08:06:36 | FromDiscord | <Elegantbeef> But many popular libraries already have bindings |
08:06:57 | FromDiscord | <zygon.sisyphus> compared to crates.io ? |
08:07:02 | FromDiscord | <zygon.sisyphus> how many ? |
08:07:10 | FromDiscord | <zygon.sisyphus> how stable ? |
08:07:35 | FromDiscord | <Elegantbeef> Am i supposed to grab a stick and count? |
08:07:53 | FromDiscord | <Elegantbeef> They're rather stable since most C libraries are rather concreted as APIs |
08:07:59 | emery | i heard that most crates were garbage |
08:08:03 | FromDiscord | <zygon.sisyphus> no, I was just curios what popular is |
08:08:30 | FromDiscord | <zygon.sisyphus> crates is better than npmjs |
08:08:42 | FromDiscord | <Elegantbeef> Sdl, Opengl, Glfw, Imgui, X, WinApi, Gtk, Qt is a small selection |
08:08:48 | FromDiscord | <haxscramper> > qt |
08:08:52 | FromDiscord | <haxscramper> Qt qml |
08:08:55 | FromDiscord | <haxscramper> Lest be honest here |
08:09:01 | FromDiscord | <zygon.sisyphus> ssl, cypto, libuv ? |
08:09:10 | FromDiscord | <Elegantbeef> openssl, bearssl |
08:09:29 | FromDiscord | <zygon.sisyphus> how about serialization ? cbor, xml, json ? |
08:09:38 | FromDiscord | <Elegantbeef> xml and json are stdlib |
08:10:13 | FromDiscord | <zygon.sisyphus> pessagepack ? |
08:10:14 | FromDiscord | <Elegantbeef> https://nimble.directory/ probably more beneficial |
08:10:15 | FromDiscord | <zygon.sisyphus> messagepack ? |
08:10:57 | FromDiscord | <zygon.sisyphus> ok, thx ( https://nimble.directory/ ) |
08:10:57 | FromDiscord | <zygon.sisyphus> probabli I don't know all about nim |
08:10:58 | FromDiscord | <zygon.sisyphus> need more info |
08:11:03 | emery | cbor is outside stdlib |
08:11:09 | FromDiscord | <Elegantbeef> Well you're talking about non problems \:D |
08:11:22 | FromDiscord | <zygon.sisyphus> I didn't say is a problam |
08:11:26 | FromDiscord | <zygon.sisyphus> I didn't say is a problaem |
08:11:38 | FromDiscord | <zygon.sisyphus> I didn't say is a problem |
08:11:48 | FromDiscord | <Elegantbeef> Well you suggested using zig to solve problems which is what i was referencing |
08:11:57 | FromDiscord | <zygon.sisyphus> It was just an idea |
08:12:25 | FromDiscord | <Elegantbeef> Hey i'm not going to hold it against you, i just jest |
08:12:26 | FromDiscord | <zygon.sisyphus> I just like zig more than c/c++ |
08:14:40 | FromDiscord | <zygon.sisyphus> that is why I switch to c# |
08:14:40 | FromDiscord | <haxscramper> Compiling to smart languages is harder |
08:14:40 | FromDiscord | <zygon.sisyphus> now I'm investigating alternatives like nim, vala ,... |
08:14:40 | FromDiscord | <haxscramper> Compiling to C is easy because it is dumb as brick |
08:14:40 | FromDiscord | <Elegantbeef> Nim isnt an alternative to C# per se |
08:14:40 | FromDiscord | <zygon.sisyphus> is not |
08:14:40 | FromDiscord | <Elegantbeef> It's a systems language so it's capable of what C/Zig/C++ can do |
08:14:40 | FromDiscord | <zygon.sisyphus> I agree |
08:15:41 | FromDiscord | <zygon.sisyphus> c is not easy to replace |
08:17:24 | FromDiscord | <zygon.sisyphus> nim is opensouce, so if somebody want to implemnt zig backed is possible |
08:17:40 | FromDiscord | <Elegantbeef> Yes |
08:21:20 | FromDiscord | <Elegantbeef> You also have the jsgen and cgen modules as reference |
08:21:21 | FromDiscord | <zygon.sisyphus> ok |
08:21:21 | FromDiscord | <zygon.sisyphus> this is the info I need |
08:21:22 | FromDiscord | <zygon.sisyphus> just need to add an new one |
08:21:22 | FromDiscord | <zygon.sisyphus> cgen is for c++ also\\ |
08:21:23 | FromDiscord | <zygon.sisyphus> cgen is for c++ also? |
08:21:23 | FromDiscord | <zygon.sisyphus> the backend is modular and independent |
08:21:24 | FromDiscord | <Elegantbeef> I dont know |
08:55:54 | * | max22- joined #nim |
09:05:33 | FromDiscord | <ShalokShalom> @haxscramper In regards to func:āµāµHow do you that with higher order functions? |
09:05:48 | FromDiscord | <ShalokShalom> To ensure no side effects |
09:06:02 | FromDiscord | <Rika> the type of a func is `proc (...): ... {.noSideEffects.}` |
09:07:27 | FromDiscord | <ShalokShalom> Because the approach of having a single keyword means you cannot express "this function is pure if it's arguments are pure" |
09:07:38 | FromDiscord | <ShalokShalom> @Rika I know |
09:07:50 | FromDiscord | <ShalokShalom> The question is, how higher order functions work on that |
09:07:52 | arkanoid | any news on the "code coverage" topic? |
09:07:58 | FromDiscord | <haxscramper> no |
09:08:13 | FromDiscord | <haxscramper> In reply to @ShalokShalom "Because the approach of": https://github.com/nim-lang/RFCs/issues/404 https://github.com/nim-lang/RFCs/issues/403 |
09:08:38 | FromDiscord | <haxscramper> Right now effects are inferred based on callback effectrs |
09:09:00 | FromDiscord | <haxscramper> but ultimately you can put anything in the callback, and it is not possible to fully track |
09:09:25 | FromDiscord | <haxscramper> So `cb: proc()` means `{.raises: [Any], effects: [AllEffects].}` roughly speking |
09:09:51 | FromDiscord | <haxscramper> In reply to @arkanoid "any news on the": at least nothing changed since the last time |
09:10:06 | FromDiscord | <ShalokShalom> So there is no guarantee? |
09:11:07 | FromDiscord | <Rika> cant you enforce raises: [] and effects: [] in a type? |
09:11:36 | FromDiscord | <haxscramper> yes, you can |
09:11:40 | arkanoid | sad, nim really deserves a native code coverage tool |
09:11:58 | arkanoid | I enforce no exceptions and no effects all the time |
09:12:16 | FromDiscord | <haxscramper> In reply to @arkanoid "sad, nim really deserves": https://github.com/binhonglee/coco/issues/19 |
09:12:27 | arkanoid | "func can raise side effects" is my favorite error |
09:14:56 | FromDiscord | <haxscramper> execution traces PR looks really promising |
09:16:11 | FromDiscord | <ShalokShalom> "Side effects are allowed in nosideeffect functions if the effect is passed as a parameter"āµāµ So you just dont care? |
09:16:38 | arkanoid | haxscramper, I'm already getting nim coverage but is quite convoluted |
09:16:39 | FromDiscord | <ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=3uXT |
09:17:20 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uXU |
09:17:27 | FromDiscord | <haxscramper> So yeah, you need to be explicit in that case |
09:18:09 | FromDiscord | <haxscramper> In reply to @arkanoid "<@608382355454951435>, I'm already getting": Are you using gcc coverage options? I do that as well, but they don't have perfect results |
09:18:13 | FromDiscord | <ShalokShalom> Aha, ok. |
09:18:17 | FromDiscord | <haxscramper> As they are based on `#line` in generated code |
09:18:28 | FromDiscord | <ShalokShalom> So why not preventing by default? |
09:18:35 | FromDiscord | <ShalokShalom> And letting the people choose a proc |
09:18:45 | FromDiscord | <ShalokShalom> I mean, that is the whole point of func |
09:18:46 | FromDiscord | <Rika> because when you say `proc()` it means proc and not func |
09:19:00 | FromDiscord | <haxscramper> yes, if you need no side effect you say so |
09:19:02 | FromDiscord | <Rika> same thing why you can do `x: var int` i guess |
09:19:10 | FromDiscord | <Rika> but it's "backwards" |
09:19:10 | arkanoid | haxscramper, exactly |
09:19:24 | FromDiscord | <haxscramper> It would be really weird if `proc(cb: proc())` and `func(cb: proc())` would mean different things |
09:19:33 | FromDiscord | <Rika> since you're being less "funcy" by specifying less instead of more "funcy" for specifying less |
09:19:51 | FromDiscord | <ShalokShalom> In reply to @haxscramper "yes, if you need": isnt this, by using func? |
09:19:55 | FromDiscord | <Rika> no |
09:20:02 | FromDiscord | <Rika> think of it this way |
09:20:10 | FromDiscord | <ShalokShalom> š |
09:20:14 | FromDiscord | <Rika> the `func` is no side effects because you said so |
09:20:25 | FromDiscord | <haxscramper> Though I still don't understand why |
09:20:25 | FromDiscord | <Rika> but if you ask for a `proc()` you didnt say you wanted no side effects |
09:20:26 | FromDiscord | <haxscramper> `Error: func keyword is not allowed in type descriptions, use proc with {.noSideEffect.} pragma instead` |
09:20:31 | FromDiscord | <ShalokShalom> yeah, I understand that |
09:20:37 | FromDiscord | <Rika> In reply to @haxscramper "`Error: func keyword is": i was gonna say that' |
09:20:40 | FromDiscord | <haxscramper> FFS what was the reasoning for explicitly disallowing |
09:20:46 | FromDiscord | <Rika> func keyword for type would be super nice |
09:20:58 | FromDiscord | <haxscramper> yes, `{.noSideEffect.}` is just super verbose |
09:21:02 | FromDiscord | <Elegantbeef> There is a PR somewhere the enables it iirc |
09:21:09 | FromDiscord | <ShalokShalom> yeah, so passing in as parameters only happens at type definitions? |
09:21:26 | FromDiscord | <Rika> ? |
09:21:40 | FromDiscord | <Rika> wdym' |
09:21:54 | FromDiscord | <Rika> parameters, when not specified as no side effects, can have side effects |
09:22:26 | FromDiscord | <Rika> no matter if the thing the parameter is part of is a func or a proc |
09:51:27 | arkanoid | I keep having issues with vscode + nim, autocompletion just works for first 5 minutes, then I have to restart |
10:13:29 | FromDiscord | <konsumlamm> which plugin do you use? |
10:50:10 | arkanoid | nimsaem one |
10:50:46 | arkanoid | whoa, HashSet dosn't work with type aliases |
10:52:07 | arkanoid | https://play.nim-lang.org/#ix=3uYb |
10:52:10 | FromDiscord | <Rika> type alias -> distinct or |
10:52:36 | arkanoid | no, not distinct, just plain alias |
10:52:38 | FromDiscord | <Rika> you're `=` |
10:52:42 | FromDiscord | <Rika> `:` |
10:53:09 | FromDiscord | <Rika> and add is wrong i believe |
10:53:43 | FromDiscord | <Rika> its not add, its `incl` |
10:54:01 | FromDiscord | <Rika> https://play.nim-lang.org/#ix=3uYc |
10:59:33 | arkanoid | oh! thanks |
11:25:28 | * | krux02 joined #nim |
11:29:16 | * | max22- quit (Ping timeout: 250 seconds) |
12:06:02 | * | supakeen quit (Quit: WeeChat 3.2) |
12:06:35 | * | supakeen joined #nim |
12:12:31 | * | max22- joined #nim |
12:16:11 | arkanoid | how do I set a default for a var argument? |
12:16:57 | arkanoid | if I do myproc(foo: var HashSet[string] = HashSet[string]()) it complains that wants a var thing |
12:18:31 | FromDiscord | <exelotl> I don't think you can, as a var argument needs to be something that exists outside the called proc and is mutable |
12:22:08 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=3uYt |
12:26:46 | FromDiscord | <haxscramper> `proc q(a: var int = (var tmp = 12; tmp)) = discard` |
12:28:34 | arkanoid | thanks |
12:28:50 | arkanoid | it's for a recursive function that returns a collection |
12:29:18 | arkanoid | so first call wants an empty collection, default arg seems a correct choice here |
12:30:24 | FromDiscord | <haxscramper> I'd rather doāµāµfunc main() ... func aux(it\: var int)\` |
12:30:31 | FromDiscord | <Rika> why would you need a var param then? |
12:30:36 | FromDiscord | <haxscramper> And this `var tmp = 12; tmp` is a horrible hack |
12:30:54 | FromDiscord | <haxscramper> Like, yes it is possible, but don't do this, there are better ways |
12:45:59 | * | max22- quit (Ping timeout: 250 seconds) |
12:57:22 | * | arkurious joined #nim |
13:01:36 | FromDiscord | <haxscramper> I have a large project that uses jsony to write `JsonNode` to a file (along with multiple other fields). If json node is `nil` it silently crashes, without any stacktrace. When launched it under gdb I found out the crash happens after `switch ((v).kind) {` which is pretty unsurprising. I tried to reproduce the same issue at a smaller scale, but failed to do this - `import jsony, std/json; echo toJson(cast[JsonNode](nil))` generated |
13:02:20 | FromDiscord | <haxscramper> I did all the testing in the same directory, so if there is a configuration file that disabled stracktraces it should've affected both (not to mention all other exceptions are fine) |
13:02:55 | FromDiscord | <haxscramper> sent a code paste, see https://paste.rs/r4U |
13:03:16 | FromDiscord | <haxscramper> In both cases - for a large project, and for a smaller one |
13:04:12 | FromDiscord | <haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3uYG |
13:04:32 | FromDiscord | <haxscramper> Failure happens in the same function, the only difference is how it is called - directly by `toJson`, or from other `.dumpHook()` |
13:17:28 | arkanoid | haxscramper thanks for the suggestion, I've refactored the code |
13:17:56 | FromDiscord | <StefanSalewski (StefanSalewski)> For the var parameter default value we can also use the cast[ptr t](http://nil)[] hack as suggested by https://github.com/StefanSalewski/gintro/issues/102#issuecomment-726454448 |
13:18:05 | FromDiscord | <StefanSalewski (StefanSalewski)> We use that for gintro. |
13:20:08 | arkanoid | thanks StefanSalewski, but I think that I can skip hacks here, as it's pure nim code. It's just up to find out how. I'd prefer to avoid var and mutability and get back to pure func |
13:20:28 | arkanoid | probably with some copying I can do this |
13:22:08 | FromDiscord | <StefanSalewski (StefanSalewski)> logout |
13:24:15 | arkanoid | do you know why there's a merge function for Countable but not for Table? |
13:25:20 | FromDiscord | <Rika> which value should be chosen when you encounter two duplicates of a key |
13:37:38 | arkanoid | well, first or second table |
13:37:49 | arkanoid | like others do |
13:38:26 | arkanoid | or if fancier: mergeLeft mergeRight |
13:38:42 | FromDiscord | <Rika> then i guess it is a matter of prs welcome |
13:58:20 | * | max22- joined #nim |
14:59:42 | * | max22- quit (Ping timeout: 276 seconds) |
15:04:56 | * | max22- joined #nim |
15:14:57 | * | neceve quit (Ping timeout: 258 seconds) |
15:15:31 | * | stkrdknmibalz quit (Quit: WeeChat 3.0.1) |
15:46:06 | * | max22- quit (Ping timeout: 272 seconds) |
15:47:11 | * | max22- joined #nim |
16:06:39 | * | max22- quit (Ping timeout: 276 seconds) |
16:13:56 | * | max22- joined #nim |
16:19:10 | * | max22- quit (Ping timeout: 250 seconds) |
16:21:46 | * | max22- joined #nim |
17:24:57 | * | neceve joined #nim |
18:31:08 | arkanoid | is there an xml serialization/deserialization lib in nim? |
18:33:42 | FromDiscord | <haxscramper> If you want to test your luck - https://github.com/haxscramper/nimtraits/blob/master/src/nimtraits/trait_xml.nim , and https://github.com/haxscramper/haxdoc/blob/master/src/haxdoc/docentry_io.nim |
18:34:29 | FromDiscord | <haxscramper> It is no longer necessary to explicitly instantiate serialization procedures, the example has somewhat outdated API |
18:34:53 | FromDiscord | <haxscramper> Otherwise there is nothing for working with XML in automated manner |
18:37:59 | arkanoid | I've dived into xml xsd world in the last 48 hours and I've found madness |
18:38:14 | arkanoid | it is exactly how I imaged hell in my mind |
18:40:02 | FromDiscord | <haxscramper> So you want to store a date? Here is 10+ built-in date types |
18:41:45 | arkanoid | why declare types just in one place, when you can include,import,ref,declare inline,make them anonymous |
18:42:17 | arkanoid | and when you think that you can map into a type system, you have to deal with sequence vs attribute |
18:42:29 | arkanoid | and there you have the impossible type |
18:44:16 | arkanoid | so here I have a wsdl from an international well-known thing that I'm struggling to work with nim as just declaring types is much harder than expected |
18:44:20 | * | max22- quit (Ping timeout: 250 seconds) |
18:45:04 | arkanoid | I'll probably give up working with metaprogramming and type-system and just hack SOAP messages with strings |
18:45:12 | arkanoid | it's probably much quicker |
18:46:16 | FromDiscord | <haxscramper> It is quicker, though I did some automatic xsd2nim converters as well. But I did it because I need to parse tons of XML from doxygen |
18:46:47 | FromDiscord | <haxscramper> Otherwise it is easier to use string |
18:48:33 | arkanoid | yea but this was kinda like my testbed on nim metaprogramming. I kinda succeeded with it (even with compiler/ast thanks to you!) but now I feel down as I feel that the effort has been useless |
18:51:15 | arkanoid | how did you deal with complexTypes that have both sequence and attributes? |
18:52:34 | FromDiscord | <haxscramper> I have `{.Attr.}` annotation |
18:53:13 | FromDiscord | <haxscramper> And then I just write attributes first, then fields |
18:53:23 | FromDiscord | <haxscramper> s/fields/sequence |
18:55:13 | FromDiscord | <haxscramper> For reading I either manually write code like this https://github.com/haxscramper/hmisc/blob/master/src/hmisc/hasts/xml_ast.nim#L959 , or generate checks |
18:55:19 | arkanoid | wise! know nothing abount annotations, are them in nim manual? |
18:56:03 | FromDiscord | <haxscramper> https://nim-lang.org/docs/manual.html#userminusdefined-pragmas-custom-annotations |
18:56:23 | FromDiscord | <haxscramper> For parsing I generate loops like this, based on the earlier structure https://github.com/haxscramper/hcparse/blob/master/src/hcparse/dox_compound.nim#L2269 |
18:56:58 | arkanoid | I like your use of vertical space while writing code. I should give some more space too |
18:57:25 | FromDiscord | <haxscramper> Note that actually checking whether field is annotated with `{.Attr.}` requires very convoluted setup, you can see how it is implemented in https://github.com/nim-lang/Nim/blob/version-1-4/lib/core/macros.nim#L1484 |
18:58:12 | FromDiscord | <haxscramper> You can use `hasCustomPragma`, but it is not available in the macros, so you need to adapt implementation |
18:58:12 | FromDiscord | <haxscramper> At least that's what I did for hnimast |
19:00:12 | FromDiscord | <haxscramper> Or you can just use `getObjectStructure()` to get all object parsed and checked for attributes |
19:00:29 | arkanoid | why are you saying that hasCustomPragma is not available in the macros? |
19:00:53 | arkanoid | is this broken? https://github.com/nim-lang/Nim/blob/44e653a9314e1b8503f0fa4a8a34c3380b26fff3/lib/core/macros.nim#L1557 |
19:01:21 | FromDiscord | <haxscramper> because you can do `macro test(field: typed) = if hasCustomPragma(field, "Attr")` |
19:01:26 | FromDiscord | <haxscramper> What you linked is a `macro` |
19:01:36 | FromDiscord | <haxscramper> You can't call macro during macro execution |
19:02:10 | arkanoid | oh! ok, you're doing it at runtime. Is this necessary? |
19:03:02 | arkanoid | I mean, once you've parsed the types (with annotations), then you create the required encoding/decoding functions still at macro/ast time |
19:03:04 | FromDiscord | <haxscramper> yes? well, you take `typedesc` of an object you want to write/load to/from xml, so you have a macro runtime, which has to execute all kind of checks |
19:03:25 | FromDiscord | <haxscramper> And `hasCustomPragma` cannot be used for these checks |
19:04:14 | FromDiscord | <haxscramper> All macros like this must be implemented in form of procs IMO |
19:04:17 | FromDiscord | <haxscramper> So you would have `macro hasCustomPragma(a: typed): untyped = newLit(hasCustomPragmaImpl(a))` |
19:04:29 | FromDiscord | <haxscramper> Where `proc hasCustomPragmaImpl(a: NimNode): bool` implements logic |
19:04:45 | FromDiscord | <haxscramper> But sadly there is almost no macros in stdlib that follow this pattern |
19:05:54 | FromDiscord | <haxscramper> And why `proc customPragmaNode(n: NimNode): NimNode =` is not exposed to the user API? I mean, we have `import {.all.}` hack now, but this should not be the reason to hide parts of an API |
19:05:58 | arkanoid | when you say "macro runtime" you mean just "runtime"? |
19:06:44 | FromDiscord | <haxscramper> when macro is executed |
19:07:06 | FromDiscord | <haxscramper> It is hard to pinpoint what exactly "runtime" and "compile-time" means when you talk about macros |
19:08:08 | arkanoid | well, if you're talking to post-expansion and nim compiler process is not running, it's just runtime |
19:09:10 | arkanoid | whatever, I'm surely the one who's not getting it completely here, probably. I see a huge knowledge gap between your code and what I can do |
19:12:41 | FromDiscord | <Elegantbeef> Yea that's the best pattern hax, enables the most code reuse |
19:12:45 | arkanoid | how did you takle the xml/xsd/namespace/types madness, in general? I mean, which order/strategy did you used? |
19:14:31 | FromDiscord | <haxscramper> Namespaces - they weren't needed so I ignored that part. But if I had to use them, I would just concatenate type name and namespace. |
19:14:53 | FromDiscord | <haxscramper> Xsd type is mapped to nim type almost 1:1, or at least I try to do it as close as possible |
19:15:15 | nrds | <Prestige99> Hey beef |
19:15:25 | FromDiscord | <Elegantbeef> Hello |
19:15:28 | * | max22- joined #nim |
19:15:43 | FromDiscord | <haxscramper> When converting xsd to nim types I don't differentiate between attributes and sequence, this is done at parser level |
19:15:54 | nrds | <Prestige99> What was your question from earlier? |
19:16:21 | FromDiscord | <Elegantbeef> Drawing window frames, how is that done? I did see a function that seems like it might do that but i'm uncertain |
19:16:43 | nrds | <Prestige99> like, creating a new window? Or a border? |
19:16:51 | arkanoid | so you just annotate which is sequence and which is attribute with pragmas, and then on reader/writer do what's needed |
19:16:53 | FromDiscord | <Elegantbeef> Border |
19:17:09 | nrds | <Prestige99> XSetWindowBorderWidth(display, this.window, this.borderWidth.cuint) |
19:17:28 | FromDiscord | <Elegantbeef> Ah wasnt certain that was actually what it was for š |
19:17:30 | FromDiscord | <Elegantbeef> Well that makes live easy |
19:17:33 | nrds | <Prestige99> and XSetWindowBorder |
19:20:30 | FromDiscord | <haxscramper> In reply to @arkanoid "so you just annotate": Correct. |
19:20:58 | arkanoid | now I'm really curious how you read pragmas back at runtime! |
19:21:24 | FromDiscord | <haxscramper> I don't. What do you mean by "read pragmas" anyway? |
19:33:16 | * | rockcavera joined #nim |
19:33:16 | * | rockcavera quit (Changing host) |
19:33:17 | * | rockcavera joined #nim |
20:19:18 | FromDiscord | <undersquire> Hi |
20:22:59 | FromDiscord | <Elegantbeef> Hello |
20:23:23 | FromDiscord | <@bracketmaster-5a708063d73408ce4> hi |
20:23:32 | FromDiscord | <undersquire> why does it say BOT next to everyones name |
20:23:35 | FromDiscord | <Elegantbeef> I know that name it's the person from reddit with the memory allocation post! |
20:23:41 | FromDiscord | <undersquire> In reply to @Elegantbeef "I know that name": yep |
20:23:42 | FromDiscord | <undersquire> lol |
20:23:42 | FromDiscord | <Elegantbeef> Cause i'm on matrix |
20:23:45 | FromDiscord | <undersquire> Ah |
20:23:48 | FromDiscord | <undersquire> ok that makes more sense lol |
20:24:03 | FromDiscord | <Elegantbeef> Or i'm a sophisticated bot |
20:24:03 | FromDiscord | <@bracketmaster-5a708063d73408ce4> also, apparently, you can't form a string that start with a doublequote using rawstring in nim |
20:24:05 | FromDiscord | <Elegantbeef> Though i'm not that sophisticated |
20:24:25 | FromDiscord | <@bracketmaster-5a708063d73408ce4> I'm pretty sure I'm the only human on here |
20:24:26 | FromDiscord | <undersquire> you are self aware robot and you live in a virtual reality |
20:24:36 | FromDiscord | <Elegantbeef> !eval echo """""yes you can""" |
20:24:38 | NimBot | ""yes you can |
20:24:40 | FromDiscord | <@bracketmaster-5a708063d73408ce4> As you can clearly see, I have a profile picture |
20:24:51 | FromDiscord | <undersquire> In reply to @@bracketmaster-5a708063d73408ce4 "As you can clearly": Lol yes only humans have profile pictures |
20:25:01 | FromDiscord | <@bracketmaster-5a708063d73408ce4> !eval echo """I feel dumb""" |
20:25:05 | NimBot | I feel dumb |
20:27:29 | FromDiscord | <undersquire> wait isnt Matrix a protocol? |
20:27:47 | FromDiscord | <undersquire> or is it a client |
20:31:37 | nrds | <Prestige99> protocol |
20:31:57 | nrds | <Prestige99> Element is the official client |
20:34:14 | FromDiscord | <undersquire> ok maybe ill give it a try |
20:34:26 | FromDiscord | <undersquire> https://element.io this one? |
20:34:51 | nrds | <Prestige99> yep that's it |
21:24:35 | arkanoid | haxscramper, I'm spending some time reading your code on github. It's advanced code for me but I feel the flow, but I also know that I'm lacking knowledge about parsing where you seem very solid. I'd like to ask you if you have any reference that you'd suggest reading to understand your approach, expecially for xml_ast.nim and xsd_ast.nim |
21:26:50 | * | neceve quit (Ping timeout: 272 seconds) |
21:45:37 | FromDiscord | <lamersc.com š§> Is it possible to use nim script as a secure interface for say an extension system for a game server? |
21:45:54 | FromDiscord | <lamersc.com š§> Such as only allowing specific calls and such, disabling network and file access |
21:46:47 | FromDiscord | <Elegantbeef> Yea you can pretty well sandbox the nimVm + modules |
21:47:21 | FromDiscord | <Elegantbeef> I do have nimscripter which enables scripted programs but i presently have a rewrite that needs to be done before i'm overly happy with it š |
21:50:01 | FromDiscord | <lamersc.com š§> In reply to @Elegantbeef "I do have nimscripter": That seems like an interesting project š nim seems to be very capable for scripted programs |
22:03:34 | * | max22- quit (Quit: Leaving) |
23:24:53 | * | auxym joined #nim |
23:41:00 | FromDiscord | <dom96> wow https://forum.nim-lang.org/t/8297 |