<< 29-04-2025 >>

00:37:54FromDiscord<leorize> nope
00:45:09*SchweinDeBurg joined #nim
00:46:40FromDiscord<theloserscandy> In reply to @leorize "nope": I was afraid that would be the answer. Thanks anyway!
00:50:59FromDiscord<lady_be_good> `exceptions` in nim are just like `errors` in js right?
00:53:26FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=fJdKXyKg
00:55:30FromDiscord<Elegantbeef> Yes they're exceptions
00:56:00FromDiscord<lady_be_good> Am i missing something here? Are nim `exceptions` fancier than js `errors`?
00:56:37FromDiscord<lady_be_good> `exceptions` do sound more exceptional than `errors` afterall.
00:56:41FromDiscord<Elegantbeef> They're the same principle, stop code rewind until you have a handler
00:56:57FromDiscord<Elegantbeef> No handler? You panic
00:57:23FromDiscord<lady_be_good> And the code basically `quit(1)` right?
00:57:41FromDiscord<lady_be_good> That's how I've been handling error this far
00:57:51FromDiscord<lady_be_good> (edit) "error" => "errors"
00:57:53FromDiscord<Elegantbeef> Well if not handled it prints the stack trace then quits
00:57:57FromDiscord<Elegantbeef> If it's handled it does whatever the handler does
01:31:50FromDiscord<lady_be_good> sent a long message, see http://pasty.ee/gOotzjBp
01:34:05FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=YWiYGsSA
01:35:22FromDiscord<Elegantbeef> Raise an exception and catch that exception instead
01:37:33FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=lTzNWUqU
01:38:01FromDiscord<Elegantbeef> Why would you raise an exception and handle it defeating the purpose
01:39:33FromDiscord<lady_be_good> "Raise an exception and catch that exception" (?)
01:40:09FromDiscord<Elegantbeef> sent a code paste, see http://play.nim-lang.org/#pasty=WiLJKpUC
01:42:02FromDiscord<lady_be_good> But i don't want stack trace in my error message 😿
01:42:37FromDiscord<Elegantbeef> So then write your own unhandled exception hook
01:43:23FromDiscord<Elegantbeef> Or implement a flag for testing that doesn't quit and gives you some way of getting messages
01:44:10FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=qDrSmMrc
01:44:20FromDiscord<Elegantbeef> How does that work it does nothing
01:44:29FromDiscord<Elegantbeef> You handle the error you raise so you did nothing
01:44:44FromDiscord<lady_be_good> I echoed it (?)
01:44:57FromDiscord<lady_be_good> The message
01:45:01FromDiscord<Elegantbeef> Right so what is the point of the exception if you're raising it then unpacking it
01:45:11FromDiscord<Elegantbeef> You added code that overall does nothing
01:45:25FromDiscord<lady_be_good> No stack trace, just the message
01:45:36FromDiscord<Elegantbeef> But you're not using the exception
01:45:40FromDiscord<Elegantbeef> It's the exact same code as just echo
01:47:09FromDiscord<lady_be_good> But i can test it, right?
01:47:13FromDiscord<lady_be_good> Wait, i can't???
01:47:36FromDiscord<Elegantbeef> Of course not you don't let the error bubble
01:47:50FromDiscord<Elegantbeef> You added complexity that does nothing different
01:48:36FromDiscord<michaelb.eth> do you see the stack trace if you compile with -d:release, without try/except I mean
01:48:51FromDiscord<lady_be_good> Wait lemme see
01:48:52FromDiscord<Elegantbeef> sent a code paste, see http://play.nim-lang.org/#pasty=vgDoZZGf
01:50:38FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=ghWDKTOC
01:52:07FromDiscord<michaelb.eth> it’s quite good that it tells you the exception is unhandled
01:52:11*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
01:52:28FromDiscord<michaelb.eth> because that’s some buggy shit 💩 you should fix 🔨
01:52:47FromDiscord<Elegantbeef> Not good if you're trying to use this to raise errors in tooling and you are going to use an exception to quit the program
01:53:12FromDiscord<lady_be_good> sent a code paste, see http://play.nim-lang.org/#pasty=jjZdtyRp
01:53:25FromDiscord<Elegantbeef> I just gave you the solution
01:53:48FromDiscord<lady_be_good> Yes I'm trying to understand it
01:58:05FromDiscord<lady_be_good> Wait, you're overriding the default `unhandledExceptionHook`?
01:58:13FromDiscord<Elegantbeef> Yes
01:59:00FromDiscord<lady_be_good> Is this recommended? Looks like it might cause unknown behaviour later? I don't want to go into advanced nim
02:00:27FromDiscord<Elegantbeef> Wrap it with `when isMainModule:` then you can use this as a library run lox code in any program without crashing, but you can run it standalone just fine
02:02:34FromDiscord<Elegantbeef> The thing with hard coding `quit` into the code is that it forces the program to die, so using an exception makes the code more reusable and testable in this case
02:13:34FromDiscord<lady_be_good> Oh wait, i can just create an illegal token 😹
02:14:26FromDiscord<lady_be_good> With the error message as its lexeme
02:14:59FromDiscord<Elegantbeef> That is the best way of bubbling up then you throw it in an error handler
02:22:52FromDiscord<lady_be_good> Yep, working now. Thanks for the help 😼👍🏻
02:52:04*rockcavera quit (Remote host closed the connection)
03:48:55*SchweinDeBurg joined #nim
03:54:19*alexdaguy joined #nim
04:24:45*ntat joined #nim
06:34:18*ntat quit (Quit: leaving)
06:35:23*ntat joined #nim
06:45:01*ntat quit (Quit: leaving)
07:26:18*skippy8 joined #nim
07:32:41*ntat joined #nim
07:35:58*ntat quit (Client Quit)
08:28:35*ntat joined #nim
08:58:45*ntat quit (Quit: leaving)
09:40:17*amadaluzia joined #nim
09:45:42*beholders_eye joined #nim
09:54:55*skippy8 quit (Quit: WeeChat 4.4.2)
09:57:03FromDiscord<kcvinker5420> What is the signature to overload `=` operator ?
09:58:08*advesperacit joined #nim
10:01:15advesperacitAm I using datetime format wrong or is this a bug? http://play.nim-lang.org/#pasty=JdWFyoDb
10:11:41Amun-Raadvesperacit: you're using it wrong, hint: HH
10:12:07Amun-RaHH is for 24h clock, hh is for redneck one
10:12:16FromDiscord<lady_be_good> Yes, HH fixes it
10:14:19FromDiscord<lady_be_good> In reply to @kcvinker5420 "What is the signature": I don't think you can overload `=`
10:14:29advesperacitThat's very embarrasing, I spent way to much time failing to figure that out.. thank you!
10:14:49FromDiscord<kcvinker5420> In reply to @lady_be_good "I don't think you": Is it ?
10:16:04Amun-Raadvesperacit: no worries, happens to everyone :)
10:16:36FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=uPIYXabV
10:18:19FromDiscord<lady_be_good> I guess, older versions of nim did allow `=` to be overloaded
10:18:35FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=vLcWPTPn
10:18:44*skippy8 joined #nim
10:19:20FromDiscord<lady_be_good> "= is the assignment operator. The assignment operator can be overloaded. "↵http://nim-lang.github.io/Nim/tut1.html#the-assignment-statement
10:19:57FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=yDDmkFqb
10:20:16FromDiscord<kcvinker5420> Then compiler says `Error: invalid indentation`
10:21:04FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=yHmbRYXn
10:21:11Amun-Raproc[T: Font](…)
10:21:17FromDiscord<kcvinker5420> Where do we write the proc name ?
10:21:19FromDiscord<lady_be_good> Try making it a generic proc
10:21:27Amun-Raproc procname[T: Font](…)
10:21:44FromDiscord<kcvinker5420> In reply to @Amun-Ra "proc procname[T: Font](…)": Ah, now it's okay
10:21:45FromDiscord<lady_be_good> ^ Yes this one
10:25:30FromDiscord<lady_be_good> Why does typescript compiler have 3 different template literal syntaxkinds? What's the purpose of the middle one
10:26:00FromDiscord<janakali> @kcvinker5420 http://nim-lang.org/docs/manual.html#procedures-type-bound-operators↵this explains how overriding works for assignment
10:26:05FromDiscord<lady_be_good> Oh sorry, i was asking this to chatGPT
10:26:11FromDiscord<lady_be_good> I guess I'll sleep now
10:26:36FromDiscord<kcvinker5420> In reply to @janakali "<@633714482572689449> http://nim-lang.org/docs/man": Thank you @janakali, Let me check that.
10:34:18FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=hIiOYrgY
10:36:41Amun-Raproc `=copy`[Font](lhs: var Font, rhs: Font) looks weird
10:37:19FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=XJSLVcEZ
10:37:57FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=CiayGlOb
10:39:18FromDiscord<kcvinker5420> Both didn't worked
10:40:06FromDiscord<kcvinker5420> Ah, this is so frustrating...
10:40:45FromDiscord<kcvinker5420> Let me do one thing, adjust with a normal proc and forget about operator overloading.
10:42:23FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=vjyrHZiI
10:59:14*ntat joined #nim
11:03:52*xet7 quit (Remote host closed the connection)
11:06:42*xet7 joined #nim
11:17:28*ntat quit (Read error: Connection reset by peer)
11:23:08*ntat joined #nim
11:31:42*ntat quit (Quit: leaving)
12:06:54FromDiscord<xtrayambak> In reply to @kcvinker5420 "Or should I write": Is `Font` a generic type?
12:07:17FromDiscord<xtrayambak> sent a code paste, see http://play.nim-lang.org/#pasty=LAfDctzJ
12:07:36FromDiscord<xtrayambak> sent a code paste, see http://play.nim-lang.org/#pasty=SOueUxfi
12:38:51FromDiscord<rasmolaxsus> sent a code paste, see http://play.nim-lang.org/#pasty=GpXpDroS
12:39:10FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=EoixeNCe
12:39:33FromDiscord<kcvinker5420> Font is not generic.
12:39:52FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=kSUPTxCh
12:41:54FromDiscord<demotomohiro> In reply to @rasmolaxsus "Hello, so am a": You need to use `typed` parameter.
12:42:47FromDiscord<demotomohiro> Or the type of procedure the macro takes.
12:43:28*ntat joined #nim
12:52:16FromDiscord<rasmolaxsus> that worked thanks
13:04:44FromDiscord<xtrayambak> In reply to @kcvinker5420 "This is my signature": Can you show me `Font`'s signature?
13:04:54FromDiscord<kcvinker5420> In reply to @xtrayambak "Can you show me": Sure
13:05:53FromDiscord<xtrayambak> actually, I don't think it matters since it should work regardless
13:07:44FromDiscord<kcvinker5420> sent a code paste, see http://play.nim-lang.org/#pasty=KibIYVzS
13:08:39FromDiscord<xtrayambak> In reply to @kcvinker5420 "<@498088092406644736> here it is,": Try removing `ref`
13:08:56FromDiscord<kcvinker5420> Okay
13:10:40FromDiscord<kcvinker5420> In reply to @xtrayambak "Try removing `ref`": Oh, that will take time, because Font is using in so many places.
13:11:08FromDiscord<kcvinker5420> Better making a dummy type and try
13:11:18FromDiscord<xtrayambak> In reply to @kcvinker5420 "Oh, that will take": Yeah, but I don't think you can use move semantics with ref counted types
13:11:38FromDiscord<kcvinker5420> Oh I see.
13:12:00FromDiscord<kcvinker5420> This type contains members which need shallow copy except the HFONT handle
13:14:31FromDiscord<kcvinker5420> @xtrayambak ↵Yeat it worked without using `ref`
13:14:55FromDiscord<kcvinker5420> So what's the take? I can't use a ref object in `=copy` ?
13:15:12FromDiscord<solitudesf> yes, it literally says so in the signature `T: object`
13:15:22FromDiscord<kcvinker5420> Oh I see
13:15:43FromDiscord<kcvinker5420> So how do you overload an operator for a ref type ?
13:19:30FromDiscord<solitudesf> you can't overload `=` for ref.
13:24:38FromDiscord<kcvinker5420> Really!
13:29:51FromDiscord<kapendev> sent a code paste, see http://play.nim-lang.org/#pasty=dCFeoNhF
13:30:27FromDiscord<kapendev> (edit) "http://play.nim-lang.org/#pasty=yKOmvyFi" => "http://play.nim-lang.org/#pasty=ILLqhmGW"
13:31:54FromDiscord<kcvinker5420> In reply to @kapendev "But what if... 🤯": Don't know, but looks strange. BTW, using Font as normal object is okay form, just need to add `var`keyword in some function signatures, that's it.
13:32:08FromDiscord<kcvinker5420> (edit) "form," => "for me,"
13:32:32FromDiscord<kapendev> Mostly a joke.
13:33:29FromDiscord<kcvinker5420> AFAIK, ref objects in Nim are similar to cpp classes and objects are cpp structs, right
13:33:34FromDiscord<kcvinker5420> (edit) "AFAIK, ref objects in Nim are similar to cpp classes and objects are cpp structs, right ... " added "?"
13:33:55FromDiscord<leorize> not at all
13:34:01FromDiscord<kcvinker5420> Oh I see
13:35:33FromDiscord<kcvinker5420> In reply to @leorize "not at all": You mean the diff in default access level ?
13:35:44*delvarus joined #nim
13:37:29FromDiscord<leorize> it's a different concept altogether
13:38:24FromDiscord<leorize> C++ classes bundle operations with structure, allowing for tricks like vtable dispatch
13:38:28FromDiscord<leorize> nim has none of that
13:39:14*beholders_eye quit (Ping timeout: 265 seconds)
13:40:33FromDiscord<leorize> objects are closer to C structs than C++
13:41:12FromDiscord<leorize> sent a code paste, see http://play.nim-lang.org/#pasty=zezzgHDW
13:41:20FromDiscord<leorize> there's no difference otherwise
13:48:10FromDiscord<demotomohiro> `ref` types including `ref object` are similar to `std::shared_ptr` in cpp.
14:02:30FromDiscord<frusadev> What are they exactly?
14:05:16*beholders_eye joined #nim
14:38:12*SchweinDeBurg quit (Remote host closed the connection)
15:32:56*SchweinDeBurg joined #nim
15:34:09FromDiscord<jmgomez> In reply to @kcvinker5420 "AFAIK, ref objects in": I think you are referring to cpp classes usually being passed as pointers and structs as value but thats just a sort of convention. In practical terms, there are no difference between them other than default visibility. For instance, the nim codegen always generate structs when targeting c++ even if you are inheriting from a c++ class
15:44:07*zgasma joined #nim
15:54:39*delvarus quit (Quit: Leaving)
16:19:54FromDiscord<kcvinker5420> sent a long message, see http://pasty.ee/xwQayier
16:24:14*alexdaguy quit (Quit: ded)
16:26:55FromDiscord<jmgomez> sent a code paste, see http://play.nim-lang.org/#pasty=KtbmwEgs
16:30:32FromDiscord<kcvinker5420> In reply to @jmgomez "yep, this is a": Yeah, I got it. I am assuming that you are not using GC for this game and I wonder if there is any dedicated allocators like arena allocators to gain performance.
16:32:25FromDiscord<jmgomez> UE does have a GC that acts on UObjects
16:39:32FromDiscord<kcvinker5420> Oh I see.
16:41:43*skippy8 quit (Quit: WeeChat 4.4.2)
16:46:09FromDiscord<treeform> @xtrayambak and @kcvinker5420 if you are dealing with fonts have you seen our http://github.com/treeform/pixie library?
16:50:05*beholders_eye quit (Ping timeout: 272 seconds)
16:57:47*SchweinDeBurg quit (Quit: WeeChat 4.7.0-dev)
17:04:57FromDiscord<xtrayambak> In reply to @treeform "<@498088092406644736> and <@633714482572689449>": Hiya, again. I actually was helping that person out. I use pixie for a lot of my tasks and it's pretty neat. I appreciate your work on it! :^)
17:11:05FromDiscord<threefour> Is pointer arithmetic just not a thing in Nim?
17:13:59Amun-Rathreefour: UncheckedArray supports pointer arithmetic
17:14:36Amun-Ralet's say you have ptr to bytes, cast it to ptr UncheckedArray[byte]
17:15:12FromDiscord<threefour> That's probably what I need
17:15:20FromDiscord<threefour> Been using nasty cast chains lol
17:15:25Amun-Ra:>
17:18:34Amun-Raand don't forget to keep index inside array bounds ;)
17:18:45Amun-Raor magic things will happen
17:19:08FromDiscord<Elegantbeef> Your code will run at least 3% faster
17:19:51FromDiscord<treeform> In reply to @xtrayambak "Hiya, again. I actually": Cool thanks!
17:21:58Amun-Rahttp://dpaste.com/GB4BUTXFP
17:22:02Amun-Ra\o/
17:22:47FromDiscord<Elegantbeef> This SUM language seems to be tied for your favourite
17:23:13Amun-Ra:D
17:23:32Amun-RaI think I'm tired - I had to read this twice ;)
17:27:06FromDiscord<threefour> sent a code paste, see http://play.nim-lang.org/#pasty=AymsxdWC
17:27:25FromDiscord<Elegantbeef> the cstring is in rodata
17:27:33FromDiscord<Elegantbeef> It's static at runtime you cannot mutate it
17:27:36FromDiscord<threefour> Ah right
17:28:25Amun-Rasame with var s = "string"; you need to call prepare_mutation first
17:28:34FromDiscord<Elegantbeef> sent a code paste, see http://play.nim-lang.org/#pasty=ZJetvEYg
17:28:35FromDiscord<Elegantbeef> There you go
17:31:53Amun-Raor http://play.nim-lang.org/#pasty=PzlXXfSf
17:32:14FromDiscord<Elegantbeef> That's the same thing
17:32:28Amun-Rawith one less step
17:32:31FromDiscord<Elegantbeef> Why do `str[0].addr` when `cstring` is right there 😄
17:32:45Amun-Rahmm, I got used to write this way :>
17:32:54FromDiscord<Elegantbeef> Hey I'm not going to rewrite all their code that sounds like work
17:33:02Amun-Rathreefour: btw, watch out for string lifetime
17:33:06Amun-Ratru
17:33:08Amun-Ratrue*
17:34:19FromDiscord<threefour> Yeah, was just a toy example. Getting used to writing what would otherwise be straightforward in C, in Nim.
17:35:38Amun-Ratry not to write nim code like C ;)
17:36:13FromDiscord<threefour> Well when I'm interfacing with a C library I don't a lot of choicw
17:36:18FromDiscord<threefour> (edit) "choicw" => "choice"
17:36:32FromDiscord<Elegantbeef> I only write my Nim code like C `var c = C().c().cccc(cc, cccc, cccccc).ccccc(cc)`
17:36:47FromDiscord<threefour> Looks good to me
17:36:58Amun-RaI give it 10/10
17:37:13FromDiscord<Elegantbeef> Yardanico forever ago had an obfuscator which converted all identifiers to `v` it was the true V-lang
17:38:14FromDiscord<threefour> Is it still around
17:38:25FromDiscord<Elegantbeef> Yardanico has disappeared so nope
17:38:29Amun-Rawith that code style you don't have to call uglifyjs anymore for js target
17:38:46FromDiscord<Elegantbeef> Wayback machine might have it
17:39:12FromDiscord<kcvinker5420> In reply to @treeform "<@498088092406644736> and <@633714482572689449>": Good to see that library. Just bookmarked for read later. But my font usage in this case is limited. It's just an HFONT for some windows controls.
17:49:32FromDiscord<treeform> I see. HFONT is a ptr or a int... I think?
17:54:56Amun-RaHFONT is an alias for HANDLE
17:55:53Amun-Raand HANDLE is a ptr
17:59:22Amun-Rait's defined in winlean as int: http://nim-lang.org/docs/winlean.html#Handle
17:59:39Amun-Rait's PVOID in winapi: http://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types
19:11:44*m5zs7k quit (Ping timeout: 268 seconds)
19:14:04*m5zs7k joined #nim
19:48:03FromDiscord<user2m> sent a code paste, see http://play.nim-lang.org/#pasty=KqHqLjzo
19:49:03FromDiscord<0xfab_10> In reply to @user2m "sorry can you clarify?": the type is `range[1..int.high]`
19:49:31Amun-Raint.high is a scalar value not a type
19:49:47FromDiscord<user2m> In reply to @fabric.input_output "the type is `range[1..int.high]`": Ahhh thank you!
19:49:52FromDiscord<0xfab_10> also this looks like a bug
19:50:22FromDiscord<0xfab_10> why is it complaining about `int.high` not being a type instead of the `...` or trying to instantiate `int` as a generic
19:51:49Amun-Ralooks ok
19:53:25*xet7 quit (Ping timeout: 248 seconds)
19:53:49*xet7 joined #nim
20:07:57*amadaluzia quit (Quit: Hi, this is Paul Allen. I'm being called away to London for a few days. Meredith, I'll call you when I get back. Hasta la vista, baby.)
20:17:45*zgasma quit (Read error: Connection reset by peer)
20:54:10*advesperacit quit ()
21:09:32*rockcavera joined #nim
21:12:00*skippy8 joined #nim
21:33:15*ntat quit (Quit: leaving)
21:50:44*beholders_eye joined #nim
22:44:26*beholders_eye quit (Ping timeout: 265 seconds)
23:05:44*skippy8 quit (Quit: WeeChat 4.4.2)