<< 31-01-2023 >>

00:01:48FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mEJ
00:02:08FromDiscord<Elegantbeef> Make an iterator
00:02:54FromDiscord<sOkam!> how do you yield a modifiable item in an iterator?
00:03:01FromDiscord<sOkam!> like mitems does
00:03:31FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mEK
00:03:35FromDiscord<leorize> you can do exactly what mitems does \:p
00:03:53FromDiscord<Elegantbeef> For all of Nim's jagged edges it's very user space extensible
00:04:40FromDiscord<leorize> unless there's a `magic` somewhere in a nim proc/iter/whatever definition, it's likely the exact code you need to reimplement the same thing
00:05:38FromDiscord<sOkam!> kk
00:05:49FromDiscord<sOkam!> where does magic process come from, btw?
00:06:30FromDiscord<sOkam!> i assume the code must be somewhere, but always wondered where that is stored (out of curiosity)
00:06:41FromDiscord<leorize> it's usually in the compiler
00:06:52FromDiscord<Elegantbeef> magic is implemented in the compiler, cause it cannot be done in userspace
00:06:53FromDiscord<leorize> search `m<Magic name>` to find it
00:07:25FromDiscord<Elegantbeef> Generally it's just base operations or backend specific operations
00:08:54FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mEL
00:10:25FromDiscord<Elegantbeef> `0..<height` but yes
00:25:31*genpaku quit (Remote host closed the connection)
00:28:43*genpaku joined #nim
00:29:44*lumo_e joined #nim
00:32:30FromDiscord<PunchCake> how would i program the esp32 with nim?
00:33:55FromDiscord<Elegantbeef> #embedded would help more. But you can use the same C compiler required for the chip and faff with cmake if you want
00:33:59FromDiscord<Elegantbeef> No clue if ratel supports that chip
00:34:29FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mEP
00:34:49FromDiscord<Elegantbeef> "sub iterators"?
00:35:10FromDiscord<Elegantbeef> You cannot chain iterators if that's what you mean
00:35:14FromDiscord<PunchCake> sent a code paste, see https://play.nim-lang.org/#ix=4mEQ
00:43:35FromDiscord<sOkam!> In reply to @PunchCake "are you making a": game of life
00:43:44FromDiscord<sOkam!> In reply to @Elegantbeef "You cannot chain iterators": kk ✍️
01:21:22FromDiscord<Pusha> Could someone give me a simple explanation of the main difference between templates and macros in Nim?
01:21:54FromDiscord<Elegantbeef> Templates are code substitution which means they just replace the AST where your parameters are. Macros evaluate code on the VM and can operate on the input.
01:22:02FromDiscord<Elegantbeef> This means template are vastly simpler to read/write/reason
01:37:23FromDiscord<Goat> How do I read data thats being piped or redirected into my program?
01:37:43FromDiscord<Elegantbeef> `stdin`
01:37:47FromDiscord<Elegantbeef> I'd imagine
01:52:25FromDiscord<Goat> Yeah, I figured that, but I don't understand how I use it for that purpose
01:54:20FromDiscord<Elegantbeef> Should just be `readAll()`
01:55:45FromDiscord<Elegantbeef> Or `readLine` depending
01:57:56FromDiscord<auxym> hm, any way to list files in a directory at compile-time? `listFiles` doesn't seem to work (Error: undeclared identifier: 'listFiles')
01:58:09FromDiscord<auxym> https://nim-lang.org/docs/nimscript.html#listFiles%2Cstring
01:58:24FromDiscord<Elegantbeef> If you can `import std/os` you can use `walkFiles`
01:58:30FromDiscord<Elegantbeef> `listFiles` is only for nimVm
02:01:23FromDiscord<auxym> walkFiles was giving me cannot importc at compile-time
02:02:29FromDiscord<auxym> /home/francis/.choosenim/toolchains/nim-1.6.10/lib/pure/os.nim(2124, 11) Error: cannot 'importc' variable at compile time; glob
02:03:09FromDiscord<Elegantbeef> Walkdirs perhaps
02:04:46FromDiscord<Elegantbeef> Dont recall which are supported at CT
02:05:59FromDiscord<auxym> k, ill try
02:26:32FromDiscord<tfp> is there a way to turn an X to a ref X
02:27:27FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mF7
02:27:37FromDiscord<Elegantbeef> `ref` in Nim is heap allocated so no there is not a way to make a stack value a ref
02:31:05FromDiscord<tfp> the syntax around ref objects is pretty janky ngl
02:31:25FromDiscord<Elegantbeef> I find it fine
02:31:42FromDiscord<tfp> it's definitely fine but it's dangerous
02:32:00FromDiscord<tfp> at least by most modern lang standards
02:32:22FromDiscord<tfp> the constructor syntax for non ref types with noInit is nice
02:32:32FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mF8
02:32:50FromDiscord<tfp> ye but standards help a language scale u know
02:32:50FromDiscord<Elegantbeef> ref objects have the same semantics though
02:32:54FromDiscord<tfp> and then everyone benefits from network effects
02:32:57FromDiscord<Elegantbeef> `(ref MyType)(a: 100)` works as does `MyRefType(a: 100)`
02:33:16FromDiscord<Elegantbeef> The aforementioned ref syntax is only needed for primitives or similar really
02:34:31FromDiscord<tfp> the first one looks nice
02:34:33FromDiscord<tfp> let me tryt hat
02:34:50FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mF9
02:35:06FromDiscord<tfp> i mean it's ok
02:35:16FromDiscord<tfp> but also won't benefit from network effect because it's not really standard
02:35:29FromDiscord<Elegantbeef> I dont see the network effect you're talking about
02:35:38FromDiscord<tfp> if nim was cut down and had syntax that was more appealing to systems level programmers i think it would take off
02:35:52FromDiscord<Elegantbeef> It'd also be Zig 😄
02:36:06FromDiscord<tfp> kind of, zig is okay
02:36:06FromDiscord<Elegantbeef> Or Odin more accurately
02:36:34FromDiscord<tfp> i think orc with move semantics plus the strong metaprogramming is the killer app
02:36:38FromDiscord<Elegantbeef> but Nim is not C or C derived so it will be odd to people that havent written pascallian languages
02:37:05FromDiscord<tfp> but what i mean by network effect is, common patterns should be kind of standardized, so they can be operated over generically + understood immediately by other programmers
02:37:17FromDiscord<tfp> that enables network effect and helps the lang scale up better with libs and such
02:37:22FromDiscord<tfp> rust nailed that imo
02:38:39FromDiscord<Elegantbeef> I mean most people have a `type MyRef = ref object` or `type MyType = object` and unless you really care it you dont need any other semantics
02:38:48FromDiscord<tfp> well
02:38:52FromDiscord<Elegantbeef> A single type alias is pretty conventional
02:38:54FromDiscord<tfp> like for example none of these patterns work except the first one because patty generates the constructors for my enums
02:39:05FromDiscord<Elegantbeef> Why wouldnt they work?
02:39:40FromDiscord<Elegantbeef> Ah nvm i see
02:39:47FromDiscord<tfp> because i can't replace the constructors with versions that give me a RefTy
02:40:10FromDiscord<Elegantbeef> That's on patty imo
02:40:14FromDiscord<tfp> nooo way
02:40:16FromDiscord<tfp> it's on the language
02:40:37FromDiscord<Elegantbeef> It's on patty, it doesnt have a mechanism to define a `ref` constructor if you want, or a ref variant
02:41:12FromDiscord<tfp> why should it have to think about that? should every lib have to think about that?
02:41:18FromDiscord<Elegantbeef> Nim doesnt even have the concept of constructors aside from `MyType(a: ..., b: ...)`
02:41:44FromDiscord<Elegantbeef> There isnt even any desire from an large amount of the community for them aside from default values
02:42:05FromDiscord<tfp> well i am definitely spoiled by rust
02:43:01FromDiscord<Elegantbeef> Araq does seem interested in type bound operations, so perhaps one day user defined constructors will be a feature tacked onto types, but presently there isnt much but making constructors more succinct
02:44:08FromDiscord<Elegantbeef> I mean in rust how do you make a new RC with a given value?
02:44:09FromDiscord<Elegantbeef> I assume it has a `RC<T>.new(args)`?
02:44:32FromDiscord<tfp> Rc::new(value on the stack)
02:44:44FromDiscord<tfp> ::new is a pretty standard pattern
02:44:59FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mFb
02:45:07FromDiscord<Elegantbeef> Ok so the same thing i provided
02:45:25FromDiscord<Elegantbeef> So make an PR/RFC to make it apart of the stdlib is all i can really say
02:45:49FromDiscord<tfp> i also kind of think newX initX is a worse version
02:45:57FromDiscord<tfp> because it also suffers from no network effect
02:45:59FromDiscord<Elegantbeef> Most sane people agree
02:46:02FromDiscord<Elegantbeef> It's not generic
02:46:04FromDiscord<tfp> ye
02:46:23FromDiscord<Elegantbeef> I still think network effect is a silly term. 😄
02:46:45FromDiscord<tfp> i like it because it encompasses the ability to operate over it generically + programmers grokking it immediately
02:47:08FromDiscord<tfp> the term is used a lot in other contexts but i bring it here because i like it
02:47:28FromDiscord<Elegantbeef> I prefer just talking about sane design 😛
02:47:43FromDiscord<tfp> mm
02:47:43FromDiscord<Elegantbeef> embedding the type into the procedure name means you have 0 capability to compose
02:48:06FromDiscord<Elegantbeef> It neuters one of Nim's best features it's generic interfaces
02:48:35FromDiscord<tfp> i think the reason rust didn't make it a trait or something is because the argument list can be different
02:48:43FromDiscord<tfp> so it can't really be operated on generically anyway
02:48:53FromDiscord<tfp> but they do have Default which basically means a 0-arg ctor, which can be operated on generically
02:49:03FromDiscord<Elegantbeef> It can be
02:49:17FromDiscord<tfp> ye like for initializing empty lists, things like that, it's a quite nice trait to have
02:49:27FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mFc
02:49:36FromDiscord<Elegantbeef> Like you can require a specific type of constructor
02:49:45FromDiscord<tfp> ah yeah i think concepts are interesting
02:49:51FromDiscord<tfp> no dynamic dispatch for them is disappointing but i get it
02:50:11FromDiscord<tfp> honestly the main reason i'm using nim is because the metaprogramming is insanely powerful and i like ORC
02:50:15FromDiscord<Elegantbeef> Insert my dumb traitor package here
02:50:22FromDiscord<tfp> i'm using iface 🙂
02:50:27FromDiscord<tfp> i think i looked at traitor though
02:50:47FromDiscord<tfp> nim is the closest thing to a language i would have made myself, but i don't really have the skills or resources to make one yet
02:50:53FromDiscord<Elegantbeef> Yea it's basically traits as the name implies, but i think i need to rewrite it
02:51:44FromDiscord<Elegantbeef> I very much love concepts, I'm quite annoyed by libraries that force using specific types
02:52:09FromDiscord<Elegantbeef> https://github.com/beef331/truss3d/blob/master/src/truss3D/shaders.nim#L132-L225
02:52:23FromDiscord<Elegantbeef> I do want to expand this to my entire API
02:52:46FromDiscord<tfp> https://media.discordapp.net/attachments/371759389889003532/1069812454034526312/image.png
02:52:51FromDiscord<tfp> 😭
02:53:01FromDiscord<Elegantbeef> lol
02:53:42FromDiscord<Elegantbeef> Think a normal variant makes more sense there 😛
02:53:54FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mFe
02:54:38FromDiscord<tfp> oh i see
02:54:48FromDiscord<tfp> i figured that would have the same problem
02:55:37FromDiscord<Rika> it doesnt
02:55:43FromDiscord<Rika> theyre all in the same branch
02:55:51FromDiscord<Rika> the field isnt redefined in such case
02:58:10FromDiscord<tfp> i still have the issue between VecX and Mat now but its ok
02:58:43FromDiscord<tfp> one day i will rewrite everything in my own language, one day 🙂
03:15:04FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4mFi
03:16:51FromDiscord<sOkam!> i guess i would need to continue up towards the first loop to do that↵is it possible to go out of the outer in some way, from the inner?
03:17:28FromDiscord<sOkam!> (edit) "go" => "continue to next step" | "continue to next stepout of the outer ... ininside" added "loop" | "out of the outerloopin some way, from ... the" added "inside"
03:17:39FromDiscord<sOkam!> (edit) removed "out"
03:17:53FromDiscord<Elegantbeef> `break`
03:18:08FromDiscord<sOkam!> doesn't break break both?
03:18:25FromDiscord<Elegantbeef> Breaks out of the nearest `block` `while` or `for`
03:18:32FromDiscord<sOkam!> kk, that solves it then
04:12:42*LuxuryMode joined #nim
04:20:48*lumo_e quit (Quit: Quit)
04:52:40*arkurious quit (Remote host closed the connection)
05:00:03*derpydoo quit (Remote host closed the connection)
05:16:06*GreaseMonkey quit (Remote host closed the connection)
05:17:12*greaser|q joined #nim
06:13:21*deadmarshal_ quit (Ping timeout: 265 seconds)
06:22:26*LuxuryMode quit (Quit: Connection closed for inactivity)
06:27:41*deadmarshal_ joined #nim
06:35:11*LuxuryMode joined #nim
06:44:24*junaid_ joined #nim
06:46:51*junaid_ quit (Remote host closed the connection)
07:04:21*kenran` joined #nim
07:47:36*PMunch joined #nim
08:53:31*greaser|q quit (Changing host)
08:53:31*greaser|q joined #nim
08:53:36*greaser|q is now known as GreaseMonkey
09:05:59FromDiscord<UrNightmaree> is there a way to set `--os` flag through environment variable?
09:06:36FromDiscord<UrNightmaree> (edit) "is there a way to set `--os` flag ... through" added "option"
09:12:38FromDiscord<Phil> In reply to @UrNightmaree "is there a way": Yes.↵I assume you created your project with nimble init?↵Then you'll have noticed that you have a config.nims file in there
09:13:40FromDiscord<Phil> That's where you can write nimscript that will execute every time you compile the project.↵If you set a compiler flag in there (basically by just writing it as `--os:<whatevervalue>`, no frills) it'll get applied to the subsequent compilation command.
09:14:32FromDiscord<Phil> Nimscript is a subset of nim, so it can do a lot (though not everything) from nim.↵To read in an environmental variable there, use `getEnv` (https://nim-lang.org/docs/nimscript.html#getEnv%2Cstring%2Cstring)
09:14:54FromDiscord<UrNightmaree> In reply to @Isofruit "Yes. I assume you": > I assumed you created your project with nimble init?↵↵nope, i tried to package up Arturo which uses Nim to compile
09:15:23FromDiscord<UrNightmaree> i tried to add Arturo into Termux-packages repository
09:15:41FromDiscord<Phil> Ahh, check. See if there's a `config.nims` file.↵Alternatively, see if in the `.nimble` file there is a nimble task defined that defines how it should get compiled
09:15:47*azimut quit (Ping timeout: 255 seconds)
09:17:29FromDiscord<Phil> Nimble tasks are basically nimscript excerpts that you can use like functions and call from the outside with `nimble <task>`, so you can just change the compilation command based on if/when in the nimble task
09:18:07FromDiscord<Phil> (edit) "outside" => "shell"
09:18:59FromDiscord<UrNightmaree> In reply to @Isofruit "Ahh, check. See if": here, i found `config.nims` file↵<https://github.com/arturo-lang/arturo/blob/master/config.nims>
09:19:51FromDiscord<UrNightmaree> i only found switch statement for checking if `cc` environment variable is valid CC compiler
09:20:38FromDiscord<UrNightmaree> i might want to check `build.nims` as well
09:20:44FromDiscord<Phil> At a glance that cc looks more like it's for checking if the commandline parameter cc is set with gcc
09:20:49FromDiscord<UrNightmaree> since its a script for building the binary
09:21:21FromDiscord<Phil> The `get` proc is not the same as `getEnv`:↵> Retrieves a configuration 'key' like 'gcc.options.always'.
09:22:48FromDiscord<Phil> sent a long message, see http://ix.io/4mGd
09:23:11FromDiscord<Phil> (edit) "http://ix.io/4mGd" => "http://ix.io/4mGe"
09:23:31FromDiscord<Phil> (edit) "http://ix.io/4mGe" => "http://ix.io/4mGf"
09:23:41FromDiscord<UrNightmaree> im new to Nim (and it's ecosystem) 😅
09:24:00FromDiscord<UrNightmaree> anyway, i found this <https://github.com/arturo-lang/arturo/blob/v0.9.80/build.nims#L51>
09:24:41FromDiscord<UrNightmaree> seems its for targeting armv7/aarch64
09:24:58FromDiscord<UrNightmaree> instead x86 and x86_64
09:25:01*redj quit (Ping timeout: 252 seconds)
09:25:12FromDiscord<Phil> God damn that's a complex build setup
09:25:47*redj joined #nim
09:26:04FromDiscord<Elegantbeef> Techincally arturo's build also installs it
09:26:23FromDiscord<Elegantbeef> It's actually quite nice to develop on, though it's a big script
09:27:01FromDiscord<Phil> I'm not seeing it set any os flag
09:27:21FromDiscord<UrNightmaree> i only found the `arm` and `arm64` argument
09:27:28FromDiscord<UrNightmaree> i also checks it workflow for Raspberry Pi
09:27:36FromDiscord<UrNightmaree> also uses the argument above
09:27:57FromDiscord<Phil> That's for the CPU flags. You wanted to set the os flag, which seems unset so you're... slightly less likely to break something by manipulating this
09:28:33FromDiscord<Phil> You should be able to get away with just adding an if/when statement near the bottom that sets that flag
09:28:41FromDiscord<UrNightmaree> i could just create `.patch` for it
09:28:53FromDiscord<UrNightmaree> patching some parts of the script
09:29:08FromDiscord<UrNightmaree> anyway thanks for the help
09:29:14FromDiscord<Phil> .patch files are a thing?
09:29:19FromDiscord<UrNightmaree> In reply to @Isofruit ".patch files are a": yes
09:29:21FromDiscord<Phil> For nimscript I mean
09:29:38FromDiscord<Elegantbeef> They're trying to package arturo for termux
09:29:46*tinytoast joined #nim
09:29:48FromDiscord<UrNightmaree> In reply to @Elegantbeef "They're trying to package": that's correct
09:30:36FromDiscord<Phil> Yeah but wasn't it "compile arturo to C , proceed with compiling and packaging with normal C tools" ?
09:30:42FromDiscord<Phil> (edit) "," => "then,"
09:30:51FromDiscord<Phil> (edit) "C then," => "C,then"
09:31:02FromDiscord<Elegantbeef> I'm uncertain what's wrong with the current setup though
09:31:37FromDiscord<UrNightmaree> In reply to @Elegantbeef "I'm uncertain what's wrong": i need to get it working on all architecture that Termux are supported
09:32:01FromDiscord<UrNightmaree> currently Termux supports arm, aarch64, x64_86 and i686
09:32:10*Batzy quit (Ping timeout: 260 seconds)
09:32:10*tinystoat quit (Ping timeout: 260 seconds)
09:32:19*Batzy joined #nim
09:33:02FromDiscord<Elegantbeef> Is this cross compiled?
09:34:56FromDiscord<Elegantbeef> On second though given i have 0 clue the path required, i'll shush
09:42:05FromDiscord<UrNightmaree> In reply to @Elegantbeef "Is this cross compiled?": yes
10:12:26*LuxuryMode quit (Quit: Connection closed for inactivity)
11:15:28FromDiscord<Phil> Can you alias a proc?
11:16:38FromDiscord<Phil> Nevermind, doing a variable assignment is essentially aliasing of a proc
11:16:46FromDiscord<Phil> (edit) "Nevermind, doing a variable assignment ... is" added "to that proc"
11:28:55PMunch@Phil, except for generics
12:08:06FromDiscord<turbo> For strutils, why does `val.parseEnum[MyType]()` not compile, but `parseEnum[MyType](val)` does?
12:10:54FromDiscord<Phil> Huh that one I didn't have before, maybe a generic limitation
12:11:09FromDiscord<ringabout> Documented in the Nim Manual, the limitation of method call syntax; use `val.parseEnum[:MyType]()` instead
12:11:49FromDiscord<Phil> https://nim-lang.org/docs/manual.html#templates-limitations-of-the-method-call-syntax↵The section for it
12:12:15FromDiscord<Phil> As well as: https://nim-lang.org/docs/manual.html#procedures-method-call-syntax
12:13:10FromDiscord<ringabout> > The method call syntax conflicts with explicit generic instantiations: p[T](x) cannot be written as x.p[T] because x.p[T] is always parsed as (x.p)[T].
12:13:49FromDiscord<ringabout> > The [: ] notation has been designed to mitigate this issue: x.p[:T] is rewritten by the parser to p[T](x), x.p[:T](y) is rewritten to p[T](x, y). Note that [: ] has no AST representation, the rewrite is performed directly in the parsing step.
12:28:39*jmdaemon quit (Ping timeout: 252 seconds)
12:33:48*dnh joined #nim
12:47:28*ltriant quit (Ping timeout: 248 seconds)
12:49:13*ltriant joined #nim
12:54:19*ltriant quit (Ping timeout: 252 seconds)
12:59:09FromDiscord<sOkam!> If I have a `type Thing = ref object of RootObj`, and I want it to be linked in two spots, where one modifies the other, do I need to define it inside the other places as `ref Thing` or can it just be `Thing` and be linked with the others directly? 🤔
13:26:14PMunchNope, Thing is now a ref object and will be passed by reference (what you call linking)
13:30:43*ltriant joined #nim
13:32:36*fallback quit (Remote host closed the connection)
13:43:47FromDiscord<ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4mHd
13:46:24*fallback joined #nim
14:23:38FromDiscord<fabricio> is this a bug?
14:25:59FromDiscord<fabricio> sent a code paste, see https://play.nim-lang.org/#ix=4mHh
14:28:50FromDiscord<ringabout> `static: main()` works. Looks like a known bug or needs a better error message.
14:30:05FromDiscord<ringabout> In reply to @fabricio "is this a bug?": See also https://github.com/nim-lang/Nim/issues/20545
14:32:02FromDiscord<fabricio> ah yes I see, I forgot `const`s are a compile time thing
14:36:41FromDiscord<pietroppeter> there might be a nim related post (barely) on HN front page...
14:38:17FromDiscord<ringabout> sent a code paste, see https://play.nim-lang.org/#ix=4mHj
14:39:45PMunch@pietroppeter, neat. I might've commented
14:39:58PMunchOf course not the happiest topic..
14:40:43*advesperacit joined #nim
14:42:59FromDiscord<pietroppeter> yeah, although a topic which might actually benefit from the additional visibility...
14:54:00FromDiscord<fabricio> sent a code paste, see https://play.nim-lang.org/#ix=4mHo
14:54:20FromDiscord<ringabout> No problem
15:10:48PMunch@pietroppeter, most definitely
15:12:11FromDiscord<auxym> this I assume? https://news.ycombinator.com/item?id=34594743
15:12:24FromDiscord<auxym> IMO it's a very good thing that it gets more visibility
15:12:33PMunch@pietroppeter, by the way I believe Nim should compile under MSVC, at least my friend spent a lot of time making it work a while ago
15:13:43FromDiscord<ringabout> The compile time of VCC is much more than mingw for the same Nim program.
15:14:38FromDiscord<ringabout> So sometimes I don't even want to debug VCC related issues reported.
15:14:49FromDiscord<ringabout> (edit) "want to debug" => "feel like debugging"
15:15:54*PMunch quit (Quit: Leaving)
15:28:40FromDiscord<pietroppeter> In reply to @auxym "this I assume? https://news.ycombinator.com/item?id": yeah, we do not usually post the link here to avoid votes coming from clicking being flagged in some way
15:29:27FromDiscord<pietroppeter> In reply to @PMunch "<@869267093110026320>, by the way": good to know, in desperate case having an additional option to test is good
15:46:03*LuxuryMode joined #nim
15:49:29*arkurious joined #nim
15:52:31FromDiscord<auxym> ah sorry, wasn't aware
16:05:00FromDiscord<Nerve> Need some static introspection help. I want to compare the fields of two similar types, and transfer the fields with the same name and type. How would I go about it?
16:05:08FromDiscord<Nerve> (edit) "Need some static introspection help. I want to compare the fields of two similar ... types," added "object"
16:08:07FromDiscord<Phil> Why not just 2 nested loops using the fieldPairs operator and a when statement that assigns one field to the other if the names are identical?
16:08:35FromDiscord<Nerve> Is that really the simplest way to do it? Alright then
16:11:12FromDiscord<Nerve> How do I do the assignment? I have a string of a field name, how do I key into the object field?
16:11:30FromDiscord<Hourglass [She/Her]> In reply to @Isofruit "Nevermind, doing a variable": Templates can always be used for one, and then there's also `const myAlias = myProc` I think
16:11:56FromDiscord<Hourglass [She/Her]> Oh was already answered
16:13:26FromDiscord<Phil> I'm on the go, so somebody else will have to do if you want explicit examples, but basically you can just take the field variable from the iterator and assign to it like it was a normal mutable variable
16:13:44FromDiscord<Nerve> Okay I'll give it a try
16:14:07FromDiscord<Nerve> Interesting, `nim check` appears to like it
16:14:20FromDiscord<Nerve> So `fieldPairs` does indeed yield mutable references
16:15:09arkanoidhttps://nim-lang.org/docs/manual.html#foreign-function-interface-packed-pragma == packed with 1-byte alignment?
16:16:56FromDiscord<Phil> In reply to @Nerve "So `fieldPairs` does indeed": It's strictly speaking the compiler writing obj.fieldname for you for every field on the object
16:17:05FromDiscord<Phil> That's why it works and is mutable
16:17:39FromDiscord<Phil> So in truth there isn't even iteration going on, the compiler unrolls that loop at compile time
16:21:28FromDiscord<huantian> it might be worth it to make a macro though
16:21:53FromDiscord<huantian> actually hmm I assumed it would be O(n^2) even thought it's rolled out but actually it's probably not
16:22:06FromDiscord<huantian> because you use compile time comparisons to check if the fields are equal
16:29:21*kenran` quit (Remote host closed the connection)
17:33:05*azimut joined #nim
17:45:38*jmdaemon joined #nim
18:17:07FromDiscord<Nerve> sent a long message, see http://ix.io/4mIj
18:17:15FromDiscord<Nerve> (edit) "http://ix.io/4mIj" => "http://ix.io/4mIk"
18:17:45FromDiscord<Nerve> (edit) "http://ix.io/4mIk" => "http://ix.io/4mIm"
18:19:36FromDiscord<Nerve> The advantages of Nim are obvious here, I can distribute a dependency-free executable we can use on servers or hand around for local use on workstations. The Python story was woefully inadequate on that front; Nuitka amazingly worked but it did not produce particularly fast code, and the binaries were quite large.
18:20:04FromDiscord<Nerve> (edit) "The advantages of Nim are obvious here, I can distribute a dependency-free executable we can use on servers or hand around for local use on workstations. The ... Pythonpackaging" added "standard" | "standardPython ... story" added "packaging"
18:20:28FromDiscord<Nerve> I have a roughly 10x reduction in speed and binary size with Nim
18:20:40FromDiscord<Nerve> (edit) "reduction" => "increase" | "increasein speed and ... binary" added "reduction in"
18:20:53FromDiscord<Nerve> (edit) "10x" => "10-100x" | "10-100xincrease in speed and ... reduction" added "10x"
18:28:58FromDiscord<Phil> sent a long message, see http://ix.io/4mIp
18:29:32FromDiscord<Arathanis> In reply to @Nerve "Software engineering philosophy question.": It sounds like you could leverage `std/jsonutils` and its `fromJsonHook` and `toJsonHook` (de)serialization hooks to get to the concrete types you want.↵↵Combined with `fusion/matching` you can have a lot of expressive power to convert to concrete types.
18:29:38FromDiscord<Phil> (edit) "http://ix.io/4mIp" => "http://ix.io/4mIq"
18:30:31FromDiscord<Phil> In reply to @Nerve "Software engineering philosophy question.": I also generally do not recommend messing around with JsonNode.↵You just lose out on one of the things that makes nim beneficial over python: You get free sanity checking via the types.↵JsonNode takes that away from you.
18:30:58FromDiscord<Phil> That's why I wouldn't go with std/json in the first place and go straight to jsony since I'd want to avoid JsonNode anyway and have a bunch of static types everywhere.
18:32:01FromDiscord<Phil> (edit) "In reply to @Nerve "Software engineering philosophy question.": I also generally do not recommend messing around with JsonNode.↵You just lose out on one of the things that makes nim beneficial over python: You get free sanity checking ... via" added "at compile time"
18:32:45FromDiscord<ShalokShalom> @Phil in F#, you get typed JSON, just by reading it from the file ↵↵does something exist for Nim too?↵We call it type providers
18:33:13FromDiscord<Phil> In reply to @ShalokShalom "<@180601887916163073> in F#, you": I'm not familiar with such a thing existing.↵Really tbh, I just beat all my JSON problems with jsony and writing a lot of types
18:33:34FromDiscord<ShalokShalom> yeah, you get all the types inferred, this way
18:34:05FromDiscord<ShalokShalom> typescript has this also, I just see
18:34:11FromDiscord<Phil> Yeah, that would be pretty neat to have more convenience that way.↵Writing the types out imo is an acceptable amount of work.↵Yeah it's a lot of typing, but in the end the clarity is worth it.
18:34:30FromDiscord<Phil> In reply to @ShalokShalom "typescript has this also,": ?
18:34:57FromDiscord<ShalokShalom> although only for JSON, and not yet for html, csv, xml, custom ones, etc
18:35:39FromDiscord<ShalokShalom> In reply to @Isofruit "?": Typescript has this feature also, called Type Providers
18:35:46FromDiscord<Phil> Ohhhh in the sense that you can basically "import json" and it imports the json as an object
18:35:49FromDiscord<ShalokShalom> Although just for one data type
18:36:02FromDiscord<Phil> (edit) "Ohhhh in the sense that you can basically "import json" and it imports the json as an object ... " added "with inferred types and IDE type hints etc."
18:36:33FromDiscord<ShalokShalom> In reply to @Isofruit "Ohhhh in the sense": yeah, you get autocompletion when you work with the document and it is just fully typed out of the box
18:37:05FromDiscord<ShalokShalom> FSharp has that for basically any important data type and then some
18:39:07FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4mIv
18:39:50FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4mIv" => "https://play.nim-lang.org/#ix=4mIw"
18:40:05FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4mIw" => "https://play.nim-lang.org/#ix=4mIx"
18:40:17FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4mIx" => "https://play.nim-lang.org/#ix=4mIv"
18:42:15FromDiscord<Phil> sent a long message, see http://ix.io/4mIA
18:42:50FromDiscord<Phil> (edit) "http://ix.io/4mIA" => "http://ix.io/4mIC"
18:43:56FromDiscord<Phil> (edit) "http://ix.io/4mIC" => "http://ix.io/4mID"
18:45:18FromDiscord<Phil> And the nice side-effect of jsony is that it's even faster than std/json by a pretty significant margin (like, roughly factor 5-6x faster)
18:45:34FromDiscord<Arathanis> How does it handle heterogeneous data?
18:45:40FromDiscord<Arathanis> I am looking at it now, it looks nice.
18:46:21FromDiscord<Phil> define heterogeneous data?↵It basically forces you into "static" json-patterns.↵You want a different field, you'll need a different type
18:46:51FromDiscord<Phil> That's because it parses json directly to a type, it does not use object variants as an intermediary the way std/json does
18:47:00FromDiscord<Phil> (edit) "That's because it parses json directly to a type, it does not use object variants ... as" added "(JsonNode)"
18:47:17FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4mIE
18:47:31FromDiscord<jmgomez> In reply to @ShalokShalom "<@180601887916163073> in F#, you": Nim is like in another league in that regard :nim1:
18:47:52FromDiscord<jmgomez> You can do a "type provider" from chat gpt if you wish so 😛
18:48:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mIF
18:48:52FromDiscord<Arathanis> In reply to @Isofruit "Hmm let me see": sweet, I appreciate it
18:48:58FromDiscord<Phil> Basically I'd need to deal with "oh god" having possibly either string, int or float values?
18:49:40FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4mIG
18:49:42FromDiscord<Phil> Wait, that's not valid json!
18:49:48FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4mIG" => "https://play.nim-lang.org/#ix=4mIH"
18:49:50FromDiscord<Phil> because string and 10 aren't key value pairs
18:50:00FromDiscord<Arathanis> oh sorry it was supposed to be a list!
18:50:01FromDiscord<Arathanis> let me edit it
18:50:16FromDiscord<Arathanis> still consuming my morning coffee haha
18:50:49FromDiscord<Phil> Ohhhh in that case I get it more
18:51:28FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4mII
18:51:36FromDiscord<Arathanis> (edit) "https://play.nim-lang.org/#ix=4mII" => "https://play.nim-lang.org/#ix=4mIJ"
18:51:40FromDiscord<Arathanis> i would never structure my JSON this way if I could help it
18:51:51FromDiscord<Arathanis> but the world doesn't follow what i would consider best practices
18:51:59FromDiscord<Arathanis> ive had to ingest some nonsense haha
18:52:06FromDiscord<Arathanis> its important that my JSON library be able to handle this
18:52:14FromDiscord<Phil> In reply to @Arathanis "still consuming my morning": Yeah that's the kind of thing where std/json basically does better or rather in a smaller-scale you'll partially rebuilding a less "liberal" version of std/json↵You'll have to define an object variant type for that list, which defines what is allowed in there and what isn't, and then you can define json hook and parsehook for it for to-json and from-json conversions
18:52:31FromDiscord<Phil> "Does better" in the sense of being more convenient
18:52:36FromDiscord<Arathanis> i appreciate you taking the time to look at this.
18:52:59FromDiscord<Phil> jsony likely will still be faster because of the direct conversion, but you'll end up with a type containing an object variant
18:52:59FromDiscord<Arathanis> If you can find a good way to leverage jsony to do this id love to see it.
18:54:16FromDiscord<alexb> sent a code paste, see https://play.nim-lang.org/#ix=4mIL
18:54:17FromDiscord<alexb> sent a code paste, see https://paste.rs/35R
18:54:40FromDiscord<alexb> Could you please help me to fix this
18:55:59FromDiscord<Ayano> https://media.discordapp.net/attachments/371759389889003532/1070054857702113390/image.png
18:56:19FromDiscord<Ayano> (edit) "" => "what am i doing wrong"
18:56:27FromDiscord<Hourglass [She/Her]> sent a long message, see http://ix.io/4mIM
18:56:40FromDiscord<Hourglass [She/Her]> In reply to @Ayano "what am i doing": `r` needs to be defined in a variable
18:56:57FromDiscord<Hourglass [She/Her]> `reader: var Reader` means that it needs a mutable `Reader` instance
18:57:19FromDiscord<Hourglass [She/Her]> In reply to @Hourglass, When the Hour Strikes "`r` needs to be": (I mean, `var` instead of using `let` or `constant`)
18:57:30FromDiscord<Ayano> https://media.discordapp.net/attachments/371759389889003532/1070055237836091392/image.png
18:57:57FromDiscord<Ayano> https://media.discordapp.net/attachments/371759389889003532/1070055351761764492/image.png
18:58:12FromDiscord<Ayano> it should be var right
18:58:29FromDiscord<Hourglass [She/Her]> Huh yeah it should be... I'm not sure then, sorry
18:58:37FromDiscord<Ayano> yea same here
18:59:07FromDiscord<Nerve> In reply to @Isofruit "I also generally do": Part of my issue is that I'm converting from a binary format which somewhat messily and ambiguously stores these variant formats (values that serve double uses, arrays that have varying lengths depending), to well-structured JSON that reflects the variant of data it contains.
18:59:10FromDiscord<Phil> In reply to @Ayano "": Does that error also pop up when compiling?
18:59:48FromDiscord<Ayano> yes
18:59:52FromDiscord<Ayano> https://media.discordapp.net/attachments/371759389889003532/1070055832693243914/image.png
19:00:06FromDiscord<Arathanis> In reply to @Nerve "Part of my issue": does my example help you at all with this? It sounds like it might be just what you need.
19:00:07FromDiscord<ShalokShalom> In reply to @jmgomez "You can do a": how do you mean?
19:01:30FromDiscord<jmgomez> In reply to @ShalokShalom "how do you mean?": type providers are code generators, in Nim you can modify the AST therefore generate code based on any input
19:01:40FromDiscord<Nerve> In reply to @Arathanis "does my example help": Like I just mentioned, my issue isn't switching from existing JSON, it's switching from an existing binary format; your hook solution only comes in after the data is already in JSON format
19:01:47*sommerjan joined #nim
19:02:02FromDiscord<Arathanis> In reply to @Nerve "Like I just mentioned,": ohhh i understand now
19:02:44FromDiscord<ShalokShalom> In reply to @jmgomez "type providers are code": sure, and does this include some type provider like behavior is already present, or just relatively simple to make
19:02:51FromDiscord<ShalokShalom> like, can I use this now?
19:03:57FromDiscord<jmgomez> `import std/[macros, genasts]` should have you covered 😛
19:04:10FromDiscord<jmgomez> what do you want to do?
19:05:58FromDiscord<ShalokShalom> just the default behavior of a type provider
19:06:23FromDiscord<ShalokShalom> without me having to write a macro for it. i
19:06:34FromDiscord<ShalokShalom> would imagine, there is already one, maybe?
19:06:43sommerjanHi, I'm trying to do something like let x = case optional_result of Some(@x): "some" of None(): "none". I'm using fusion/matching with {.experimental: "caseStmtMacros".}. The error I'm getting is that expression '"some"' is of type 'string' and has to be used (or discarded). Can anyone point me in the right direction?
19:11:24FromDiscord<Arathanis> In reply to @Hourglass, When the Hour Strikes "Hey y'all, I'm struggling": One thing I've noticed out of the gate is your catch for semicolon appear to be matching colon: https://media.discordapp.net/attachments/371759389889003532/1070058738129575996/image.png
19:19:05FromDiscord<crow> In reply to @Hourglass, When the Hour Strikes "Hey y'all, I'm struggling": you're not gonna get the text found a semicolon, since semicolon is in Symbols, so it will go down the if in 53 and skip over the elif at 73
19:19:39FromDiscord<crow> In reply to @Hourglass, When the Hour Strikes "Hey y'all, I'm struggling": I generally ignore whitespace before tokens by the way
19:19:42FromDiscord<crow> when writing lexers
19:20:20FromDiscord<crow> it makes more sense to have a lex function that matches exactly one token, which I achieve by always skipping whitespace before trying to lex, and eventually creating an EOF token after the whitespace after the last token
19:21:27FromDiscord<crow> (edit) "that" => "where every step of the loop, it"
19:28:35FromDiscord<jmgomez> In reply to @ShalokShalom "would imagine, there is": not sure, I bet people just write then down if they need to. I can give you an example if you give me a few minutes. Im finishing something else
19:28:47FromDiscord<jmgomez> but it isnt really too much code, you will see
19:31:35FromDiscord<Phil> sent a code paste, see https://paste.rs/cnW
19:31:47FromDiscord<Hourglass [She/Her]> In reply to @Arathanis "One thing I've noticed": That was just a test, I forgot to remove it after the commit
19:32:39FromDiscord<Hourglass [She/Her]> It's the `case` block that should actually be catching the semicolon but unsure why it isn't when it's at the wnd of the file (which seems to be the only issue it has?)
19:32:52FromDiscord<Phil> Actually, my browser just corrected me, the string `"{3: 4}"` is valid json, I'm not sure how one would parse that tbh
19:33:07FromDiscord<Phil> (edit) "Actually, my browser just corrected me, the string `"{3: 4}"` is valid json, I'm not sure how one would parse that ... tbh" added "in general"
19:35:23FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mJ0
19:36:15FromDiscord<Hourglass [She/Her]> In reply to @Isofruit "Actually, my browser just": In Python it'd just be `myDict[3]`
19:36:18FromDiscord<Hourglass [She/Her]> It's just key values
19:36:21FromDiscord<Phil> In reply to @alexb "Hello everyone. I'm absolute": Hmmm there's nothing fundamentally wrong with this code.↵I can run your copy-pasted example just fine, the route even responds correctly.↵Does the error immediately happen after running the binary?
19:36:27FromDiscord<Hourglass [She/Her]> It should be the same in JS
19:36:48FromDiscord<alexb> In reply to @Isofruit "Hmmm there's nothing fundamentally": Yes, the error happens immediately. I showed the full output
19:36:56FromDiscord<ShalokShalom> In reply to @jmgomez "but it isnt really": yeah, I am sure homoiconicity helps
19:37:09FromDiscord<huantian> what if you just have jsony parse to a JsonNode and then do the rest of the parsing yourself
19:37:25FromDiscord<ShalokShalom> i still think, it could help the ecosystem to provide such macros out of the box
19:37:42FromDiscord<ShalokShalom> people coming to the language will hardly start to write macros
19:37:56FromDiscord<Phil> In reply to @Ayano "yes": okay, make a `var reader2 = reader` assignment before that line and use that, does it still error out? Because now I'm curious
19:38:39FromDiscord<Phil> (edit) "that," => "that in `newPackage`,"
19:39:15FromDiscord<huantian> then you don't have to do any manual string parsing yourself
19:39:53FromDiscord<Phil> In reply to @alexb "Yes, the error happens": Huh, you're using nim 1.9.1? ↵Try 1.6.10, does that resolve the issue?↵(If you have choosenim that should be `choosenim 1.6.10`
19:40:43FromDiscord<Phil> In reply to @huantian "what if you just": Was that to me? I'm going through the backlog of messages while I was dealing with the "mixed datatype example"
19:41:22FromDiscord<alexb> Let me try
19:41:23FromDiscord<alexb> sent a code paste, see https://play.nim-lang.org/#ix=4mJ2
19:41:26FromDiscord<Arathanis> In reply to @Isofruit "If that's deemed unacceptable,": FWIW that kind of heinous structure will get me to look for an alternative service before trying to parse that nonsense lol
19:41:33FromDiscord<Arathanis> so i dont mind glossing over it a bit
19:41:48FromDiscord<Arathanis> if a service I was actually trying to use returned data that way i'd give it a 😬
19:42:07FromDiscord<Phil> In reply to @Arathanis "if a service I": I mean it's basically telling you that it wants nothing to do with Java 😛
19:42:21FromDiscord<Arathanis> In reply to @Isofruit "I mean it's basically": > my life is painful and I want company
19:42:35FromDiscord<Phil> (Which I'm bringing up because java is the most wide-spread backend language I'm aware of)
19:42:49FromDiscord<Arathanis> In reply to @Isofruit "(Which I'm bringing up": this server is supposed to be safe for work
19:43:07FromDiscord<Arathanis> you can't bring up cosmic horrors like that
19:43:08FromDiscord<Arathanis> 😉
19:43:09FromDiscord<Phil> In reply to @Arathanis "this server is supposed": See, it is safe for work, java is type safe!
19:44:01FromDiscord<Phil> But yeah, I'm all for shitting on java, though tbh I find the community it cultivated and the mindset that lead to things like spring much more offensive than the language itself
19:44:41FromDiscord<Arathanis> In reply to @Isofruit "But yeah, I'm all": I got an ultrawide screen monitor so I can finally read java class names on a single line w/o scrolling
19:45:05FromDiscord<Phil> I don't know why but these jokes still make me laugh out loud xD
19:45:34FromDiscord<Array in ∀ Matrix> kek↵(@Arathanis)
19:46:06FromDiscord<Array in ∀ Matrix> java is verbose for what?
19:46:14FromDiscord<Array in ∀ Matrix> zig lang also is similar
19:46:24FromDiscord<Arathanis> im convinced java class names are descided on by throwing 5~10 numbered darts at a dart board covered in buzz words and then determining the name in dart order.↵↵AbstractClassFactoryAbstractionLayerFactory
19:46:54FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mJ5
19:47:12FromDiscord<Ayano> In reply to @Isofruit "okay, make a `var": this doesnt work either https://media.discordapp.net/attachments/371759389889003532/1070067745560985671/image.png
19:47:39FromDiscord<Phil> now that is fascinating, are you sure both of those Reader types are the same and you don't have a name collision somewhere?
19:48:12FromDiscord<Phil> Like, is there possibly a second type called `Reader` somewhere and newPacket expects that instead of the type you're generating?
19:48:24FromDiscord<Phil> (edit) "generating?" => "providing?"
19:49:22FromDiscord<Arathanis> GOOD question
19:49:23FromDiscord<Ayano> In reply to @Isofruit "now **that** is fascinating,": https://media.discordapp.net/attachments/371759389889003532/1070068295086129192/image.png
19:49:25FromDiscord<Arathanis> excellent thing to check
19:49:32FromDiscord<Ayano> when i control click both in vs code
19:49:33FromDiscord<Phil> In reply to @sommerjan "Hi, I'm trying to": You know how in a lot of other languages you can have a function that returns 5, then you call that in your code like `get5()` and it doesn't matter if you make use of it or not?
19:49:38FromDiscord<Ayano> they get to the same class
19:50:13FromDiscord<Ayano> but i include it like this https://media.discordapp.net/attachments/371759389889003532/1070068504092491857/image.png
19:50:15FromDiscord<Ayano> could that be it?
19:50:20FromDiscord<Phil> INCLUDE
19:50:25FromDiscord<Phil> The evil has arisen!
19:50:49FromDiscord<Arathanis> i didnt even know you can do that, what does it do semantically?
19:50:53FromDiscord<Phil> Include is a way to copy-paste the code that is in those packages.↵Meaning if you included that file elsewhere as well, you now have 2 reader types
19:51:01FromDiscord<Arathanis> OH GOD
19:51:14FromDiscord<Phil> Like, include is basically "copy paste the contents of that file into my file"
19:51:15FromDiscord<Arathanis> its just like C/C++ include?
19:51:52FromDiscord<Phil> And that's, ladies and gentlemen, is why you should avoid includes unless you know what you're doing and are building your project structure around it or sth.
19:52:05FromDiscord<Phil> `import` is the way to go, 99.999% of the time
19:52:15FromDiscord<Arathanis> im struggling to tihnk of a reason to use include at all
19:52:23sommerjan@Phil yes, but I'd like the value to get assigned to my variable without having to create a procedure
19:52:26FromDiscord<Phil> Me as well, maybe c++ interop or sth
19:52:47FromDiscord<Arathanis> sent a code paste, see https://play.nim-lang.org/#ix=4mJ6
19:52:50FromDiscord<Phil> In reply to @sommerjan "<@180601887916163073> yes, but I'd": Ah, shit, I forgot to finish my reply to you
19:53:03FromDiscord<Phil> Nim doesn't like calling procedures and then ignoring what they return, at all
19:53:36FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mJ7
19:53:55FromDiscord<Arathanis> i love that feature actually, you must explicitly ignore a value, usually from a procedure
19:53:57FromDiscord<Phil> In line 2 I called get5, I told that proc to give me whatever it calculates so the compiler assumes for me that I wanted to do something with what it returns
19:54:42FromDiscord<Phil> sent a code paste, see https://paste.rs/AqU
19:55:25FromDiscord<Phil> In reply to @Array in ∀ Matrix "java is verbose for": java is verbose for everything ever
19:55:37FromDiscord<Ayano> https://media.discordapp.net/attachments/371759389889003532/1070069865211252976/image.png
19:55:39FromDiscord<Ayano> uhm
19:55:44FromDiscord<Ayano> (edit) "uhm" => "umm"
19:55:49FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mJ8
19:55:59sommerjan@Phil The problem isn't that I want values that should be discarded. My example works if I don't use Optional and just initialize based on a boolean value. Something like let x = case bool_value of true: "works" of false: "all good"
19:56:03FromDiscord<Phil> In reply to @Ayano "": New error means progress!
19:56:20FromDiscord<Ayano> yes...
19:56:34FromDiscord<Phil> In reply to @sommerjan "<@180601887916163073> The problem isn't": Your example code sadly gets completely mangled to me, I'll need a bit to even parse that as it all gets pumped out as a single-line string to me
19:57:35FromDiscord<Ayano> In reply to @Ayano "": @Jonas, his code btw
19:58:27FromDiscord<Arathanis> @Hourglass [She/Her] do you have example input / bootstrapping code so I can execute your lexer/
19:58:29FromDiscord<Arathanis> (edit) "lexer/" => "lexer?"
19:58:35FromDiscord<Arathanis> I'd like to see the error you are encountering
19:59:38FromDiscord<Hourglass [She/Her]> Yep I do up here ^^ also in the `tests` folder
19:59:48FromDiscord<Phil> In reply to @sommerjan "Hi, I'm trying to": Ohhh you're ... trying to do a case macro magic thing?↵Well, I assume that based on https://nim-lang.org/docs/manual_experimental.html#case-statement-macros↵That's elegantbeef teritory
19:59:48FromDiscord<Hourglass [She/Her]> Uh i forgot to reply
19:59:51FromDiscord<Hourglass [She/Her]> In reply to @Hourglass, When the Hour Strikes "Hey y'all, I'm struggling": Here:
20:00:26FromDiscord<Hourglass [She/Her]> Probably fixable by duplicating the last character in the source but that's just a hack
20:00:52FromDiscord<Phil> In reply to @Ayano "yes...": For the most part that means you have some funky async code somewhere.↵That one's a bit trickier.↵When I get these kinds of errors it's typically because I'm not using async/await/waitFor correctly
20:01:27sommerjan@Phil bingo
20:01:52sommerjan@Phil It's likely not ready for primetime yet
20:02:34FromDiscord<Phil> In reply to @Ayano "<@473566840132730889>, his code btw": Could you copy paste the full stacktrace?↵Generally reading the text properly is easier on the eyes + the full stacktrace (and seeing the lines around the code-sections that are blowing up) is pretty helpfull
20:03:42FromDiscord<Phil> In reply to @sommerjan "<@180601887916163073> It's likely not": To be fair, that stuff is in experimental ^^
20:04:58FromDiscord<Hourglass [She/Her]> In reply to @Arathanis "<@909883978717204561> do you have": Also, to compile the code, you should do `nim c --run src/main.nim tests/test1.mlx -p`
20:05:12FromDiscord<Hourglass [She/Her]> The `-p` flag makes it print out the tokens
20:05:29FromDiscord<Arathanis> In reply to @Hourglass, When the Hour Strikes "Also, to compile the": i see what the issue is
20:05:41FromDiscord<Arathanis> sorry ive been parsing the code, i actually like lexing and parsing a lot
20:05:46*LuxuryMode quit (Quit: Connection closed for inactivity)
20:05:48FromDiscord<Hourglass [She/Her]> Nah dw xD
20:06:06FromDiscord<Arathanis> or maybe I should say
20:06:09FromDiscord<Arathanis> "i think I see the problem"
20:06:13FromDiscord<Arathanis> let me keep looking briefly
20:06:13FromDiscord<Arathanis> :P
20:06:30FromDiscord<Hourglass [She/Her]> Alright aha
20:06:33FromDiscord<alexb> sent a code paste, see https://play.nim-lang.org/#ix=4mJc
20:06:52FromDiscord<alexb> macos runs some shit on port 5000 on my macbook
20:16:52FromDiscord<Arathanis> @Hourglass [She/Her] the problem is two fold. The reason you are missing the final ":" is because your notAtEndOfLine check is using `len - 1` instead of `len` so it will always cause you to skip the final character. If you remove the `-1` you will be able to see the final character. If you do that now though, you will endlessly loop any Symbols because the Symbol path does not call `Lexer.increment`
20:17:23FromDiscord<Arathanis> (edit) "@Hourglass [She/Her] the problem is two fold. The reason you are missing the final ":" is because your notAtEndOfLine check is using `len - 1` instead of `len` so it will always cause you to skip the final character. If you remove the `-1` you will be able to see the final character. If you do that now though, you will endlessly loop any Symbols because the Symbol path does not call `Lexer.increment` ... " added "so it never
20:17:25FromDiscord<Phil> In reply to @alexb "Configured choosenim and finally": Less for you specifically, just need a link to your message there for @ringabout ↵Is that known behaviour?↵Should an issue be opened?
20:17:44FromDiscord<Phil> (edit) "↵Is" => "↵For ringabout:↵Is"
20:17:55FromDiscord<Arathanis> (edit) "notAtEndOfLine check" => "`notAtEndOfLine` procedure"
20:18:14FromDiscord<Hourglass [She/Her]> In reply to @Arathanis "<@909883978717204561> the problem is": Aaaah, that explains it, thank you! ^^
20:18:20FromDiscord<Arathanis> You are very welcome.
20:18:22FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4mJh
20:18:33FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4mJh" => "https://play.nim-lang.org/#ix=4mJi"
20:22:01FromDiscord<Hourglass [She/Her]> In reply to @Arathanis "<@909883978717204561> the problem is": God this was such a simple fix i didn't notice xD
20:22:28FromDiscord<Arathanis> its one of the easiest issues to look passed. off by one errors
20:31:48FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4mJm
20:32:26FromDiscord<jmgomez> (edit) "https://play.nim-lang.org/#ix=4mJm" => "https://play.nim-lang.org/#ix=4mJp"
20:33:10FromDiscord<jmgomez> (edit) "https://play.nim-lang.org/#ix=4mJp" => "https://play.nim-lang.org/#ix=4mJq"
20:36:14FromDiscord<Hourglass [She/Her]> In reply to @Arathanis "its one of the": Yepp
20:53:57FromDiscord<ShalokShalom> sent a code paste, see https://play.nim-lang.org/#ix=4mJy
20:54:02FromDiscord<ShalokShalom> if it really works this way
20:54:19FromDiscord<ShalokShalom> do you have experience with tp?
20:56:30FromDiscord<jmgomez> https://media.discordapp.net/attachments/371759389889003532/1070085184696893530/Screenshot_2023-01-31_at_20.55.11.png
20:57:42FromDiscord<jmgomez> Nim suggest doesnt suggest though, it may be have a bug somewhere because that should definitely work. I have way more complicated ASTs with suggestions
21:01:31FromDiscord<deech> I did something like this for a talk about type introspection I gave a few years ago. https://github.com/deech/LambdaWorldCadiz2019-WhatFPCanLearnFromStaticIntrospection/blob/master/json_reflection.nim
21:01:38FromDiscord<jmgomez> In reply to @ShalokShalom "do you have experience": I used them in the past and did one, like 10+ years ago
21:03:55FromDiscord<jmgomez> In reply to @deech "I did something like": I think I told you but I was present there on that talk and I was the guy that said that yes, F# type providers are similar. First time I heard about Nim was there. Last year I was looking for a low level lang to do the UE plugin and after trying Rust I remembered Nim, rewatched the talk and started to play with it
21:07:41FromDiscord<deech> Oh haha, I totally forgot. Sorry.
21:12:00FromDiscord<Nerve> In reply to @deech "Oh haha, I totally": Oh, look who it is! Do you have the code lying around for the macro that diffs types from your "Nim Nuggets" presentation?
21:15:24FromDiscord<deech> In reply to @Nerve "Oh, look who it": This is the demo code (https://github.com/deech/NimNuggets/blob/master/backup/migration.nim) and this is the implementation (https://github.com/deech/NimNuggets/blob/master/backup/migrationmacros.nim).
21:15:43FromDiscord<Nerve> Thanks much
21:25:06*LuxuryMode joined #nim
21:26:44FromDiscord<Nerve> Does anyone have experience cross-compiling with Nimja?
21:27:05FromDiscord<Nerve> sent a code paste, see https://play.nim-lang.org/#ix=4mJK
21:27:54FromDiscord<Nerve> Trying to instantiate templates for a Windows build using mingw leads to this error
21:28:56FromDiscord<Nerve> My template call, which works on Linux, is↵`compile_template_file(get_script_dir() / "company_project" / "templates" / "a_template.nimja")`
21:30:20FromDiscord<Nerve> I'd imagine it has something to do with backslashes and the assumed mingw drive root
21:42:54FromDiscord<ShalokShalom> In reply to @jmgomez "Nim suggest doesnt suggest": well, we know nimsuggest
21:44:45FromDiscord<ShalokShalom> In reply to @Nerve "Does anyone have experience": dont try to hijack your request, did you know you can use Zig to cross compile?
21:45:04FromDiscord<ShalokShalom> it seems to be the most successful way
21:45:20FromDiscord<ShalokShalom> https://github.com/enthus1ast/zigcc
22:14:15FromDiscord<T0lk1en> yoo
22:14:29FromDiscord<T0lk1en> does anyone wanna help me out rq.
22:14:43FromDiscord<T0lk1en> need to see if my server is working.
22:16:10FromDiscord<ShalokShalom> how?
22:17:41FromDiscord<T0lk1en> ncat into it
22:17:47FromDiscord<T0lk1en> ill share ip and port
22:18:18FromDiscord<Hourglass [She/Her]> In reply to @T0lk1en "ncat into it": Sure
22:18:22FromDiscord<T0lk1en> ncat 192.168.1.76 443
22:18:32FromDiscord<Arathanis> that definitely isnt going to work
22:18:42FromDiscord<T0lk1en> how so?
22:18:45FromDiscord<Arathanis> that is a local IP
22:18:47FromDiscord<Arathanis> on your LAN
22:18:50FromDiscord<T0lk1en> ah
22:19:04FromDiscord<Arathanis> only machines on your network will see it
22:19:11FromDiscord<Arathanis> we would need your external IP
22:19:14FromDiscord<Hourglass [She/Her]> Yeah lmao
22:19:20FromDiscord<Hourglass [She/Her]> And you'd need to port forward it
22:19:20FromDiscord<Arathanis> and you need to forward port 443 to that machine in your router
22:19:32FromDiscord<T0lk1en> and then ittl work?
22:19:41FromDiscord<Arathanis> that gets us to "maybe"
22:19:46FromDiscord<T0lk1en> ty
22:19:48FromDiscord<Arathanis> yup
22:19:52FromDiscord<Arathanis> good luck, my friend
22:19:58FromDiscord<Arathanis> networking is... something else
22:20:14FromDiscord<Hourglass [She/Her]> Doesn't IPv6 solve this stuff? Or?
22:20:22FromDiscord<T0lk1en> gotta learn it. Thats the whole point of this project
22:20:51FromDiscord<Arathanis> In reply to @Hourglass, When the Hour Strikes "Doesn't IPv6 solve this": pretty sure it still does local IPs
22:21:13FromDiscord<Hourglass [She/Her]> I thought external IPv6 addresses didn't require port forwarding
22:21:14FromDiscord<Arathanis> I think its because its a little easier to configure things with some network abstractions
22:21:43FromDiscord<Arathanis> oh i tihnk that is true
22:22:24FromDiscord<Arathanis> cause a device can basically have as many ipv6 addresses as it wishes
22:22:36FromDiscord<Arathanis> and you can use that in lieu of ports
22:25:26FromDiscord<T0lk1en> are there any default forworded ports?
22:25:43FromDiscord<Arathanis> depends on your router
22:25:48FromDiscord<Arathanis> (edit)
22:25:52FromDiscord<Arathanis> but you best hope the answer to that is "no"
22:26:16FromDiscord<Arathanis> you do not want your computer exposed to the internet "by default"
22:26:23FromDiscord<T0lk1en> 🥲
22:26:34FromDiscord<T0lk1en> gotcha
22:26:54FromDiscord<Arathanis> you can ping your own server using `localhost:443` or `127.0.0.1:443` or w/ your local ip you provided earlier
22:27:02FromDiscord<Arathanis> if it works for you, it would work for us with the proper external network config
22:27:32FromDiscord<T0lk1en> yeah ive been doing that
22:27:45FromDiscord<T0lk1en> what about free online hosting? any places like that>
22:27:47FromDiscord<T0lk1en> ?
22:27:51FromDiscord<crow> In reply to @Hourglass, When the Hour Strikes "I thought external IPv6": I think it depends on the contract with your ISP
22:28:00FromDiscord<crow> and firewall settings on your router too
22:28:22FromDiscord<crow> actually, im pretty sure port forwarding is only about firewall settings of the router
22:28:23FromDiscord<Arathanis> In reply to @T0lk1en "what about free online": im sure some still exist but my old go-to answer for this recently discontinued free hosting cause it was being abused
22:28:35FromDiscord<Arathanis> you would have to look around
22:28:41FromDiscord<T0lk1en> gotcha
22:28:52FromDiscord<Arathanis> cant get into the router, huh?
22:28:53FromDiscord<crow> (edit) "actually, im pretty sure port forwarding is only about firewall settings of the router ... " added "mainly (and of course which computer on LAN to forward to)"
22:29:37FromDiscord<T0lk1en> family router. Dont know password and owner is out of town
22:29:42FromDiscord<Arathanis> ahh
22:29:53FromDiscord<Arathanis> you could have them do it when they get back
22:29:57FromDiscord<Arathanis> otherwise you can look for hosting options.
22:30:02FromDiscord<T0lk1en> ofc but im impatient lol
22:31:14FromDiscord<crow> there might be "tunnels" you can use to connect a local address with a (sub)domain
22:31:33FromDiscord<crow> there are services that offer that, even some freemium ones possibly
22:31:45FromDiscord<T0lk1en> gotcha
22:31:58FromDiscord<crow> I won't advertise any of them though
22:32:09FromDiscord<T0lk1en> what about suggest one?
22:32:18FromDiscord<crow> I don't know of a non shady one actually
22:32:19FromDiscord<crow> sorry
22:32:32*dnh quit (Ping timeout: 248 seconds)
22:32:36FromDiscord<crow> but I haven't really looked
22:32:57FromDiscord<T0lk1en> goctha
22:33:50FromDiscord<crow> alternatively technically tor hidden services are the same things, but then at an onion address
22:34:09FromDiscord<crow> but it's probably more trouble than good i guess
22:34:43FromDiscord<T0lk1en> ive used tor before. Even spun up vanity addresses just never hosted
22:34:57FromDiscord<crow> idk if hosting is different traffic than just using it
22:35:08FromDiscord<crow> I would assume not
22:35:22FromDiscord<T0lk1en> maybe eepsite
22:35:38FromDiscord<crow> but if hosting is identifiable by ISPs, might not be a good idea
22:36:42FromDiscord<T0lk1en> dont plan too host forever. Just as a proof of concept
22:39:10FromDiscord<crow> it's still more trouble than the proxies i mentioned
22:39:22FromDiscord<T0lk1en> gotcha
22:39:55FromDiscord<T0lk1en> ill just wait to port forword
22:53:08FromDiscord<Nilts> how do i slice a cstring like `[1..^1]`
22:57:03FromDiscord<Elegantbeef> You dont
22:57:57FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4mK3
22:59:27FromDiscord<Nilts> In reply to @Elegantbeef "If you know the": i mean, couldn't you just use `len`?
22:59:40FromDiscord<Elegantbeef> `len` on a cstring is got iteratively
22:59:50*advesperacit quit ()
23:00:22FromDiscord<Elegantbeef> So... you could, but in that case you might aswell just copy to the string
23:00:26Amun-Ra.len works unless there's '\x00' somewhere in the middle
23:00:49FromDiscord<Nilts> In reply to @Elegantbeef "So... you could, but": so is there a better way to slice it?
23:01:01Amun-RaNilts: ($s)[1..^1]
23:01:18FromDiscord<Elegantbeef> Only better if you dont care about performance
23:01:23Amun-Ramhm
23:01:27FromDiscord<Elegantbeef> That allocates multiple strings
23:01:45FromDiscord<Nilts> In reply to @Elegantbeef "Only better if you": Well, since i'm using the js backend, which one would assume to be slower, i do care
23:02:14FromDiscord<Elegantbeef> Wait this is JS, if so len is free
23:02:24FromDiscord<Elegantbeef> so then `myCstring[i..^1]` is cheap as
23:02:32Amun-Rawriting JS backend is real fun; check this: var s = newstring 5; echo s.repr
23:03:23Amun-Rahmm
23:04:06FromDiscord<Nilts> In reply to @Elegantbeef "so then `myCstring[i..^1]` is": how do i implement this, or do i use native imports
23:04:16Amun-Ranevermind, I had a weird problem with that yesterday; I have to find what was the real problem
23:04:43Amun-Raah, right, I forgot to set js backend ;)
23:05:20Amun-Rait fails to run on nodejs
23:05:20FromDiscord<Elegantbeef> The best thing to do in JS land is what amun gave i guess
23:05:27FromDiscord<Elegantbeef> Since JS strings are not utf8 encoded
23:05:56Amun-Racstrings on JS are kind of easier to work on than strings
23:06:49FromDiscord<Elegantbeef> Unlike C they're not encoded the same as Nim strings so in many cases you want to avoid converting to string if you can
23:08:35FromDiscord<Elegantbeef> C strings can atleast be converted using `toOpenArray` if you know the length and `cstring myString` is free
23:09:34Amun-Raand JS target does not have problem with null terminators inside cstring and getting the length
23:10:07FromDiscord<Elegantbeef> Yep the joy of pascal strings
23:24:11*oprypin quit (Quit: Bye)
23:24:21*oprypin joined #nim
23:29:04FromDiscord<Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4mKc
23:30:11FromDiscord<Elegantbeef> Your list is empty
23:31:39FromDiscord<Nilts> In reply to @Elegantbeef "Your list is empty": but, i made a if stmt ensuring that it was not.
23:32:53FromDiscord<Nilts> nvm, i just needed to re-arrange the checks
23:33:29FromDiscord<Elegantbeef> Hey you can argue with me all day long, the code says you're wrong 😛
23:34:59FromDiscord<Nilts> In reply to @Elegantbeef "Hey you can argue": nice rhyme
23:53:04*jmdaemon quit (Ping timeout: 248 seconds)