<< 03-12-2022 >>

00:14:26*ltriant joined #nim
00:19:04*ltriant quit (Ping timeout: 256 seconds)
00:23:18*ltriant joined #nim
00:45:42*derpydoo quit (Ping timeout: 256 seconds)
00:46:44FromDiscord<voidwalker> awesome @Yepoleb let me know if you need sample code to run
00:46:54FromDiscord<Yepoleb> sample code is always good
00:59:32*ltriant quit (Ping timeout: 248 seconds)
01:03:06FromDiscord<TurtleP> sent a code paste, see https://play.nim-lang.org/#ix=4hxT
01:11:12*TakinOver quit (Ping timeout: 256 seconds)
01:11:35*TakinOver joined #nim
01:12:05FromDiscord<!!sharpcdf!!> not really nim but im matching in nim, why does `(?==\s?)\S+` match with `=` in `arg = hello` only?
01:12:13*arkanoid joined #nim
01:16:36arkanoidI have a project that does some float testing using math.almostEqual. I have a test that pass on a x86_64 ubuntu laptop, but fails on another x86_64 ubuntu laptop. If I dump the argument something quite weird happens: "check almostEqual(2.35619, 1.5708, 2^9)" fails on first machine, passes on the second
01:17:03arkanoidI will never develop satellite firmware with Nim :P
01:23:21arkanoidI'm quite sure I'm looking at a bug here, problem is thay my effort in reducing to small case fails
01:25:28FromDiscord<Yepoleb> do you think it should pass or fail?
01:27:12*ltriant joined #nim
01:27:51FromDiscord<Yepoleb> are you copying the same file between two computers or is it different
01:28:06FromDiscord<Yepoleb> @Arkanoid
01:28:52arkanoidYepoleb, it should fail! The whole project is 1:1 between the two machines (git sync)
01:29:06arkanoidI'm writing a small play.nim-lang
01:29:49FromDiscord<Yepoleb> In reply to @arkanoid "<@144300201857777664>, it should fail!": but do you recompile?
01:31:04arkanoidYepoleb, yes
01:31:16arkanoidheres how I'm generating the issue https://play.nim-lang.org/#ix=4hxY
01:31:31arkanoidI'm trying to replicate it in a minimal, external case, but yet no cake
01:32:21arkanoidI'm running "nimble -f test" on both machines
01:32:42FromDiscord<Yepoleb> if you just do the almostEqual it fails both times?
01:34:55arkanoidYepoleb, this fails on both machines https://play.nim-lang.org/#ix=4hy0 (quite obvious)
01:35:15arkanoidbut same thing inside that "test generator" function generates that weird case
01:36:52FromDiscord<Yepoleb> maybe the comparison never happens
01:36:58FromDiscord<Yepoleb> and the test exits eariler
01:37:25FromDiscord<Yepoleb> if you send over the two files i can disassemble them
01:42:12arkanoidthe check happens, because the test run ends on both machine. Just one prints ALL PASS, the other prints 1 ERROR
01:44:01FromDiscord<Yepoleb> "ALL PASS" doesn't tell you how many checks were run
01:47:57arkanoidI'm creating an alternative version of almostEqual dumping all the internal checks, I want to find the one that glitches away
01:50:32FromDiscord<Yepoleb> The fact that the math behaves identically in isolation is a strong indication that the bug is actually in your testing and not the math
01:54:12arkanoidI do agree, but my only way to debug starting from the nearest branch
01:57:14arkanoidI've copypasted the function almostEqual from math.nim and renamed fooEqual. now I have "dump almostEqual(A,B, 2^9); dump fooEqual(A,B,2^9)" printing "true, false"
01:57:41arkanoidsomething really weird is going on
02:00:47arkanoidhttps://play.nim-lang.org/#ix=4hy5
02:01:10arkanoidsorry, forgot to rename some vars in dump
02:01:38arkanoidthis is correct https://play.nim-lang.org/#ix=4hy6
02:02:10arkanoiddamn, I've inverted true/false
02:02:29arkanoidfinally right: https://play.nim-lang.org/#ix=4hy7
02:09:11arkanoidthere must be something special if the function is called from math.almostEqual, or from somewherelse.almostEqual
02:09:27arkanoidas copypaste 1:1 fixes the problem
02:10:54FromDiscord<Yepoleb> you're not calling it with `math.almostEqual`
02:13:57arkanoidyou're also right, and using math.almostEqual explicitly also solves the problem ... but I don't have another almostEqual declared in my namespace and "go to reference" takes me to math.nim in vscode
02:14:34arkanoidso ... what am I calling when I do almostEqual(a,b) vs math.almostEqual(a,b)?
02:15:36FromDiscord<Yepoleb> 🤔
02:17:35arkanoidYepoleb, apparently I have another almostEqual definition imported into my namespace that takes precedence over math.almostEqual, but I don't know which one as vscode take me to math.almostEqual, but repr clearly shows two different function addresses
02:18:57arkanoidfound it! https://github.com/SciNim/Unchained/blob/6956150343fa9f738224fe8af4375266d3d2f3dc/src/unchained/utils.nim#L41
02:19:43arkanoidbut now the question is: why one machine runs math.almostEqual, but the other runs unchained.utils.almostEqual, when code just calls almostEqual(a,b)?
02:24:36FromDiscord<Yepoleb> the new almostEqual was added just 15 days ago
02:24:42FromDiscord<Yepoleb> you have an older package somewhere
02:24:52arkanoidI've been fighting a polluted namespace from an update of an external lib for hours ... this due to vscode not pointing me to the right code used for that call
02:28:20FromDiscord<Elegantbeef> Something something lockfiles one day
02:28:49arkanoidboth machines have installed the same version of that lib. The dilemma why one machine prefers math. and the other the other machine prefers unchained. remains
02:31:35FromDiscord<Yepoleb> i think the library version gets chosen because it is not generic
02:32:10arkanoidboth machine have same libs installed, can't be that
02:35:01arkanoidwhat's the current solution for this kind of problem?
02:35:27arkanoidI need to assure machine A and machine B compiles the same code with same sources
02:35:55FromDiscord<Yepoleb> just specify the module explicitly
02:36:27FromDiscord<Yepoleb> does you compiler maybe have different versions?
03:05:51*crem quit (Read error: Connection reset by peer)
03:08:38*droidrage joined #nim
03:32:15arkanoidno, 1.6.10 both
03:40:59*nyeaa492842 quit (Ping timeout: 268 seconds)
03:46:10FromDiscord<salt rock lamp> maybe i missed it, but is there no `sum()` function for `array`s? i only see one in `std/math` for `openArray`
03:51:22FromDiscord<Tuatarian> if I have a `pointer` to a a bunch of procs (of differing types) stored in a `Table` how would I deref properly at runtime?
03:55:21FromDiscord<Elegantbeef> `cast[procType](myProc)(args)`
03:55:26FromDiscord<Elegantbeef> Arrays are openarrays
03:56:08FromDiscord<salt rock lamp> oh i see. thank you
04:07:43*droidrage quit (Remote host closed the connection)
04:07:43*ixmpp quit (Remote host closed the connection)
04:10:59*arkurious quit (Quit: Leaving)
04:19:33*ixmpp joined #nim
04:29:30FromDiscord<Tuatarian> Right beef but the question is how would I generate that programmatically at runtime
04:29:49FromDiscord<Tuatarian> Given any procname, proctype (known, but not at comp time)
04:30:04FromDiscord<Elegantbeef> You cannot
04:30:16FromDiscord<Elegantbeef> You need to know at compiletime what proc you're going to call
04:30:19FromDiscord<Elegantbeef> Since you need to invoke it
04:48:14FromDiscord<ChocolettePalette> You can do this in C at runtime doe...
04:51:16FromDiscord<Elegantbeef> Uhh
05:00:32FromDiscord<ChocolettePalette> So here we come to a conclusion that Nim is less expressive than C, don't we?
05:00:44FromDiscord<Elegantbeef> Not really
05:00:50FromDiscord<Elegantbeef> How do you do it in C?
05:02:13FromDiscord<ChocolettePalette> With void\ pointers for both functions and their argument, e.g. `void func(void data)` or smth
05:03:06FromDiscord<ChocolettePalette> Well it can be done in Nim too, but it won't be a Nim way to do this
05:04:54FromDiscord<ChocolettePalette> Just like Rust can do many stuff but requires using unsafe which makes the solution weird considering Rust philosophy
05:05:52FromDiscord<Elegantbeef> You can make the proc a `proc(data: ref)` and it's a bit cleaner
05:06:45FromDiscord<Elegantbeef> But yea it's still bleh
05:06:56FromDiscord<Elegantbeef> You're doing something inherently not statically typed
05:07:17FromDiscord<ChocolettePalette> Will it be a GC-safe data which can be casted to what one needs?
05:08:32FromDiscord<Elegantbeef> sorta
05:08:42FromDiscord<Elegantbeef> But with orc you need `pointer` anyway atleast on the calling side
05:21:40*ltriant quit (Ping timeout: 256 seconds)
05:25:09*ltriant joined #nim
05:41:14*ltriant quit (Ping timeout: 260 seconds)
06:33:37FromDiscord<tbrekalo> anyone good good neovim setup with nim?
06:34:00FromDiscord<tbrekalo> working with default nimlsp and pooling syntax from somewhere?
07:11:28ZevvPlug 'alaviss/nim.nvim'
07:11:44Zevvif (&ft=='nim' )
07:11:47Zevv let g:nim_noremap = 1
07:11:47Zevv nmap <C-]> <Plug>NimGoToDefBuf
07:11:47Zevv nmap <M-]> <Plug>NimOutline
07:11:48Zevvendif
07:12:04Zevvit's a good neovim setup, but does no check your other boxes :)
07:25:17FromDiscord<tbrekalo> Oh; might need to do it on my own then
07:44:21*junaid_ joined #nim
07:54:17*pro joined #nim
08:57:06*jmdaemon quit (Ping timeout: 252 seconds)
08:59:33*jmdaemon joined #nim
09:12:36FromDiscord<Phil> unit testing question into the round
09:12:43FromDiscord<Phil> I'd like to test my procs individually
09:13:01FromDiscord<Phil> So basically the typical one testfile for each module file
09:13:20FromDiscord<Phil> How do I actually import that module file into the test?
09:14:38FromDiscord<Phil> Because imports like `import ../../src/snorlogue/filePathType` don't really work
09:25:54*pro quit (Ping timeout: 256 seconds)
09:35:21FromDiscord<Rika> ?
09:35:28FromDiscord<Rika> I don’t understand the question
09:40:33NimEventerNew thread by fxn: Sequtils.nim(786, 15) Error: expected: ':', but got: 'result', see https://forum.nim-lang.org/t/9685
09:40:37FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hzD
09:40:44FromDiscord<.tochka> wonder is it possible to instruct require nimble package only when certain module is imported. probably not as nimble is executed before compiler?
09:40:49*derpydoo joined #nim
09:41:20FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4hzD" => "https://play.nim-lang.org/#ix=4hzE"
09:42:05FromDiscord<.tochka> In reply to @Isofruit "How do I actually": usually you have config.nims with `switch("path", "$projectDir/../src")`
09:43:17FromDiscord<.tochka> if you're doing nimble way of course
09:43:19FromDiscord<Phil> I do, does that change the available import paths?
09:43:46FromDiscord<.tochka> ye, `import module` should work instead of `import ../src/module`
09:44:30FromDiscord<Phil> It did! Got to keep that one in mind
09:45:35FromDiscord<Phil> The nice thing about nim procs is that an entire type of tests ("How does it handle null") just evaporates due to excessive usage of non-ref types everywhere
09:50:32FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hzF
09:51:39FromDiscord<.tochka> probably better to separate cases to different test files, and do it without define
09:52:08FromDiscord<.tochka> could just have some file you include with shared test implementation for both
09:53:11FromDiscord<Phil> "testRepository" basically.↵Fair, I was mostly asking though if there's a clean way to check that defining `-d:sqlite` leads to importing and exporting the `sqliteRepository` module etc.
09:53:26FromDiscord<.tochka> ahh
09:53:34FromDiscord<Phil> Which means that the test would need to do the compilation and be able to define flags
09:54:39FromDiscord<.tochka> probably gotta check for availability of some specific symbols
09:55:06FromDiscord<.tochka> and for export testing would need to import that and test again or something
09:55:20FromDiscord<.tochka> not sure by what doe
09:56:17FromDiscord<Phil> I think either way I might just have to run the same test-suite twice, once with each compiler-flag
10:02:45FromDiscord<Phil> I may need to rewire my brain on how to do testing.↵In Java you typically mock all the internal components used from elsewhere away so that only the code in that specific file remains. I can't really do that in nim, I can only take a function as it is available and test its entire functionality
10:10:37NimEventerNew thread by ingo: Ftpclient download problem., see https://forum.nim-lang.org/t/9686
10:29:46*pro joined #nim
10:55:36*Simon[m]12345 joined #nim
11:01:40*junaid_ quit (Remote host closed the connection)
11:11:47*ltriant joined #nim
11:16:40*ltriant quit (Ping timeout: 252 seconds)
11:24:42*AMIGrAve joined #nim
11:25:11AMIGrAveHi there, I remember reading somewhere that there was a meta module which includes usual stuff such as strformat, parseutils, ... but I can't remember it's name, can't find it on google, and I've browsed a bit the files in the stdlib but nothing triggered any "gotcha!", has this module been removed ?
11:26:03FromDiscord<ringabout> it is called prelude
11:26:20AMIGrAveringabout: Thank you so much !
11:26:43FromDiscord<ringabout> Np
11:27:55NimEventerNew question by A.K _ThePortal: Nim: expression &amp;#39;a&amp;#39; is of type &amp;#39;int&amp;#39; and has to be used (or discarded), see https://stackoverflow.com/questions/74666275/nim-expression-39a39-is-of-type-39int39-and-has-to-be-used-or-disc
11:29:48AMIGrAveand indeed 'prelude' didn't rang a bell. Is it worth for me to do a PR in order to specify in the heading doc comment of each included module that it is included by prelude, or such a PR would not be accepted ?
11:32:44*ltriant joined #nim
11:38:54*ltriant quit (Ping timeout: 268 seconds)
11:40:08*AMIGrAve quit (Ping timeout: 268 seconds)
11:41:54*jmdaemon quit (Ping timeout: 256 seconds)
11:58:53FromDiscord<ambient> Why do these two different iterators return the same value? If I comment out the other echo line, it works fine. (Advent of Code spoilers) https://github.com/amb/aoc2022/blob/master/3/s.nim
12:03:29*ltriant joined #nim
12:08:30*ltriant quit (Ping timeout: 268 seconds)
12:13:47*AMIGrAve joined #nim
12:15:01NimEventerNew thread by pposca: Forum subscription feature, see https://forum.nim-lang.org/t/9687
12:20:27*PMunch joined #nim
12:25:21FromDiscord<メッリーレイムー 🎄> do you guys prefix enum members or just use {.pure.}\
12:25:22FromDiscord<メッリーレイムー 🎄> (edit) "{.pure.}\" => "{.pure.}?"
12:25:42FromDiscord<Generic> overloadable enums
12:25:46FromDiscord<Generic> so neither
12:25:50FromDiscord<メッリーレイムー 🎄> In reply to @Generic "overloadable enums": wdym
12:26:27FromDiscord<Rika> Pure does not enforce qualification anymore as far as I know
12:26:35FromDiscord<ezquerra> In reply to @AMIGrAve "Hi there, I remember": @AMIGrabe, using orelude has a few drawbacks, such as the fact that you must include instead of importing it like most other packages. Instead you could use the “batteries” module that I created (and which you can install using nimble). Batteries is similar to prelude but you can import it and it also imports a few additional modules that prelude doesn’t include
12:26:45FromDiscord<ezquerra> (edit) "orelude" => "prelude"
12:27:13FromDiscord<Generic> In reply to @メッリーレイムー 🎄 "wdym": https://nim-lang.org/docs/manual.html#types-overloadable-enum-field-names
12:29:06FromDiscord<Yardanico> In reply to @ezquerra "@AMIGrabe, using prelude has": include fact is no longer true
12:29:12FromDiscord<Yardanico> nowadays you can import prelude instead of including it
12:29:24FromDiscord<Yardanico> but yes, it's better to just use batteries or write your own file yourself with modules you think you frequently need
12:30:11FromDiscord<メッリーレイムー 🎄> im using a mix of `pure` enums for the AST LiteralKind enum and non pure enums because otherwise `not` would conflict w/ the languages `not` keyword
12:30:21FromDiscord<メッリーレイムー 🎄> so i prefix token not w/ `tk`
12:30:41FromDiscord<メッリーレイムー 🎄> this is what i do for my ast tho
12:30:48FromDiscord<メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hAm
12:31:15FromDiscord<Yardanico> any reason you're using a mix of object variants and inheritance instead of just using one of them?
12:31:21FromDiscord<メッリーレイムー 🎄> wdym?
12:31:30FromDiscord<Yardanico> just curious
12:31:40FromDiscord<Yardanico> you're using both inheritance (ref object of ..) and object variants (case kind: of )
12:31:50FromDiscord<Yardanico> why not e.g. make IntLiteral and StringLiteral as sub types of Literal?
12:32:35FromDiscord<メッリーレイムー 🎄> im only using OOP for the ast nodes because it makes slightly more sense to me than having everything be an object variant under one node
12:33:16FromDiscord<メッリーレイムー 🎄> @Yardanico how would u structure this?
12:33:30FromDiscord<Yardanico> i don't have a strict opinion, I was just curious, that's all :P
12:35:01*AMIGrAve quit (Ping timeout: 268 seconds)
12:35:26FromDiscord<ezquerra> In reply to @Yardanico "include fact is no": I don’t think that’s the case. I made a PR to fix that some time ago but I don’t think it was accepted. Checking the current std/prelude code does not show any call to export which is what would be needed to support import…
12:36:15FromDiscord<Yardanico> In reply to @ezquerra "I don’t think that’s": ah yeah you're right, I got confused by runnableExamples automatically inserting the import statement of the current module
12:36:57FromDiscord<メッリーレイムー 🎄> i mean would u use object variants instead?
12:39:25*AMIGrAve joined #nim
12:47:25*AMIGrAve quit (Ping timeout: 260 seconds)
12:53:14*AMIGrAve joined #nim
12:57:50*AMIGrAve quit (Ping timeout: 256 seconds)
13:17:06FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hAD
13:18:17FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hAE
13:18:50FromDiscord<ringabout> const closure function doesn't always work.
13:20:26FromDiscord<ringabout> `let` works.
13:21:14FromDiscord<ringabout> `let generatedProc {.compileTime.} : DummyProc = generateProc(string)↵` works too.
13:26:18FromDiscord<Rika> If you don’t need a closure, annotate your types and return value with nimcall
13:26:33*AMIGrAve joined #nim
13:31:10*AMIGrAve quit (Ping timeout: 260 seconds)
13:33:08*derpydoo quit (Ping timeout: 248 seconds)
13:36:26FromDiscord<ringabout> A known issue https://github.com/nim-lang/Nim/issues/20545
13:37:31FromDiscord<ringabout> Or https://github.com/nim-lang/Nim/issues/19005
13:43:01*ltriant joined #nim
13:43:08ZevvPMunch: https://note89.github.io/the-advent-of-code-ai-edition/#day-1--challenge-1
13:47:47*ltriant quit (Ping timeout: 268 seconds)
13:50:25*AMIGrAve joined #nim
13:55:04*AMIGrAve quit (Ping timeout: 256 seconds)
13:56:37FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hAY
13:57:15FromDiscord<Phil> (edit) "https://play.nim-lang.org/#ix=4hAY" => "https://play.nim-lang.org/#ix=4hAZ"
13:57:33FromDiscord<ringabout> irrc the tests of Prologue check it too.
13:58:00FromDiscord<Phil> Ahhh, so stealing from prologue tests, I'll be back after diving in there
13:58:38FromDiscord<ringabout> In reply to @Isofruit "Ahhh, so stealing from": Here you are => https://github.com/planety/prologue/blob/533c393f19f73b8e9ded18873d6721985ed2f9ae/tests/server/tserver_application.nim#L34
14:00:15FromDiscord<ringabout> that file is not well written though.
14:00:23*krux02 joined #nim
14:03:01*pro left #nim (#nim)
14:06:42FromDiscord<Phil> Okay, so have a file that defines the server to boot.↵Define the CLI command to compile it with `execCmd` to a binary and run it with `startProcess`, which will boot the server (why not spawn btw?).↵Now the big question for me is, when does `startProcess` return and your code continue running?↵When the new process has been created and the binary has started to execute (which is not yet when the server is up, it'll take the server sta
14:07:01FromDiscord<Phil> Basically how can you be sure when your client-code starts running that the prologue server isn't still in the "booting up" phase?
14:12:18FromDiscord<ringabout> https://github.com/planety/prologue/blob/533c393f19f73b8e9ded18873d6721985ed2f9ae/tests/server/tserver_application.nim#L41 It uses `asynchttpclient` to check whether the server is ready or not and repeat until the address can be pinged.
14:16:42FromDiscord<ringabout> > (why not spawn btw?).↵Yeah, that is a better idea. Nim is new to me when I wrote the code. Perhaps I didn't even
14:16:51FromDiscord<ringabout> (edit) "is" => "was"
14:17:10FromDiscord<ringabout> (edit) removed "Perhaps I didn't even"
14:17:42FromDiscord<ringabout> (edit) "> (why not spawn btw?).↵Yeah, that is a better idea. ... Nimmuch" added "I didn't know" | "was new to me" => "much"
14:27:33FromDiscord<Phil> Ahhh that's what the async client is for
14:28:23FromDiscord<Phil> Does it need to be an async client though? Seems like a normal client could do the same job
14:30:06FromDiscord<ringabout> Yeah, `HttpClient` should suffice.
14:32:54FromDiscord<Phil> gnaa, spawn enforces gcsafety
14:48:39*qwr quit (Ping timeout: 260 seconds)
14:55:44FromDiscord<deech> sent a code paste, see https://play.nim-lang.org/#ix=4hBb
15:08:06*ltriant joined #nim
15:12:54*ltriant quit (Ping timeout: 260 seconds)
15:39:43*ltriant joined #nim
15:44:24*ltriant quit (Ping timeout: 260 seconds)
16:11:17*ltriant joined #nim
16:17:01*ltriant quit (Ping timeout: 268 seconds)
16:26:52FromDiscord<Phil> In reply to @ringabout "> (why not spawn": I set up my tests based on your code.↵Did a bit of renaming and refactoring to suit my needs. ↵https://github.com/PhilippMDoerner/Snorlogue/tree/main/tests/utils↵In case you would want to use any of it
16:27:38FromDiscord<!!sharpcdf!!> does anyone know why `l.match(re"=(\s)?\w+")` keep returning false? `l = "arg = hello"`
16:27:48FromDiscord<!!sharpcdf!!> it works in two regex testers ive used but not in nim
16:27:52FromDiscord<Phil> It might actually be a nice idea to make a little package out of that for "testing prologue" or sth
16:28:00FromDiscord<Phil> Noted for later
16:28:31FromDiscord<ringabout> In reply to @Isofruit "I set up my": Nice, it is the time for a CI workflow 🎉
16:29:03FromDiscord<Phil> One after the other, I actually need to figure out how I'd want to perform postgres tests
16:29:40FromDiscord<Phil> Likely a container will need to be started as part of the tests, meaning the test-suite would need to include docker commands for downloading and running one
16:36:02FromDiscord<ringabout> https://github.com/PhilippMDoerner/Snorlogue#installation says that you can use `nimble install -y snorlogue`. But Snorlogue hasn't been added to nimble packages.
16:38:34FromDiscord<Phil> That's why the first line of the Readme exists 😄
16:38:47FromDiscord<Phil> Maybe I should put it in h1 tags
16:42:48FromDiscord<ringabout> lol, I see
16:44:07*ltriant joined #nim
16:48:52*ltriant quit (Ping timeout: 248 seconds)
17:07:31FromDiscord<メッリーレイムー 🎄> what's the best way of representing Haskell/Rust enums/ADTs in Nim? If I use object variant then I still have to use a case of to check where as in Haskell Expr is it's own type
17:08:10FromDiscord<メッリーレイムー 🎄> using inheritance instead seems not the best idea so i'd like to use object variants but not sure how to
17:09:16FromDiscord<メッリーレイムー 🎄> (edit) "what's the best way of representing Haskell/Rust enums/ADTs in Nim? If I use object variant then I still have to use a case of ... to" added "everywhere"
17:09:33FromDiscord<メッリーレイムー 🎄> (edit) "using inheritance instead ... seems" added "would achieve what i'm looking for but"
17:13:53FromDiscord<メッリーレイムー 🎄> or am i misunderstanding
17:14:41FromDiscord<Phil> Finally getting to somewhere where the test code feels somewhat okay https://media.discordapp.net/attachments/371759389889003532/1048648481511833730/image.png
17:17:26FromDiscord<メッリーレイムー 🎄> basically I want a Sum type
17:17:38FromDiscord<deech> In reply to @メッリーレイムー 🎄 "what's the best way": Yes you can get some surface level emulation of ADTs using macros and various pattern matching libraries but you don't get exhaustiveness checking. IMO it's best to just them as a Pascal style variant.
17:17:52FromDiscord<メッリーレイムー 🎄> In reply to @deech "Yes you can get": could you give an example?
17:18:13FromDiscord<メッリーレイムー 🎄> of the pascal style variant
17:19:59FromDiscord<deech> In reply to @メッリーレイムー 🎄 "of the pascal style": That's what Nim's object variant is modeled after so Nim itself is the best example.
17:20:06FromDiscord<メッリーレイムー 🎄> oh ok
17:20:16*AMIGrAve joined #nim
17:21:21PMunchGetting ready for streaming day three :)
17:21:24FromDiscord<deech> In reply to @メッリーレイムー 🎄 "oh ok": But I do agree that it's a shame Nim doesn't have native ADTs with pattern matching. It would a huge improvement.
17:21:56FromDiscord<deech> (edit) "improvement." => "improvement but it seems like the author of Nim doesn't like either."
17:23:02*PMunch quit (Quit: leaving)
17:23:29FromDiscord<メッリーレイムー 🎄> i may just use inheritance then so I can pass around Expr instead of having to use a million case of variants
17:23:35FromDiscord<メッリーレイムー 🎄> not an ideal solution at all
17:24:03FromDiscord<メッリーレイムー 🎄> nim with ADTs and pattern matching would be a dream
17:24:15FromDiscord<メッリーレイムー 🎄> it could even complement the existing variant system
17:25:24*PMunch joined #nim
17:25:39FromDiscord<deech> In reply to @メッリーレイムー 🎄 "it could even complement": You could write up an RFC but right now I suspect it won't go very far unfortunately.
17:30:09FromDiscord<メッリーレイムー 🎄> kinda surpised it doesnt have pattern matching when even java and python has it
17:30:41FromDiscord<メッリーレイムー 🎄> @PMunch where are you streaming
17:30:50FromDiscord<spoon> sl is a seq of seq of ints, why does this give me the error "expression expected but found ')'"?↵`echo sl.map(proc(x: seq[int]): int = for i in x:(result += i))`
17:31:09FromDiscord<メッリーレイムー 🎄> (edit) "kinda surpised it doesnt have pattern matching when even java and python has it ... " added "now"
17:31:54FromDiscord<spoon> or thats what my lsp is telling me, executing says it requires indentation, for loop should work with parentheses, no?
17:32:16FromDiscord<メッリーレイムー 🎄> i think for is a statement but i could be wrong
17:34:13FromDiscord<spoon> well i've done code golfing in nim and parens around for loop statements have worked before...
17:34:35PMunchOn Twitch: https://www.twitch.tv/pmunche and on YouTube: https://www.youtube.com/watch?v=jQ6gFQ5a1DI メッリーレイムー 🎄
17:45:42FromDiscord<メッリーレイムー 🎄> @PMunch i just dropped a sub btw on YT
17:45:52FromDiscord<メッリーレイムー 🎄> do u stream often?
17:50:35arkanoidquestion: is nims (VM) == compile time execution? https://nim-lang.org/docs/nims.html I mean, all I can do in nims I can do at compile time in nim program?
17:54:15FromDiscord<Yardanico> yes
17:54:30FromDiscord<spoon> found out there was a much much simpler way of doing what i was doing, trying to learn rust was my downfall
17:54:50FromDiscord<メッリーレイムー 🎄> is nims the scripting language variant
17:54:52FromDiscord<spoon> never do rust not even once
17:55:01FromDiscord<メッリーレイムー 🎄> agreed rust is bad
17:55:05FromDiscord<spoon> yes, it runs in a vm and you can embed it
17:55:21FromDiscord<メッリーレイムー 🎄> its community is annoying too
17:55:23FromDiscord<Yardanico> In reply to @メッリーレイムー 🎄 "is nims the scripting": nim in the vm is called nimscript
17:55:29FromDiscord<Screentapper> Is there a way to autocomplete `import` statements in vscode - eg to list system libraries or even libraries from nimble?
17:56:15FromDiscord<Yardanico> yes, the nimsaem extension does that already for nimble packages
17:56:18FromDiscord<メッリーレイムー 🎄> @spoon i sent u a dm fellow 2hu enjoyer
17:56:20FromDiscord<Yardanico> but it doesn't do it for the stdlib
17:56:37FromDiscord<Yardanico> https://marketplace.visualstudio.com/items?itemName=nimsaem.nimvscode
17:56:43FromDiscord<Yardanico> you should use this extension if you're using nim
17:56:46FromDiscord<Yardanico> (edit) "you should use this extension if you're using nim ... " added "in vscode"
17:57:11FromDiscord<メッリーレイムー 🎄> theres another one
17:57:16FromDiscord<メッリーレイムー 🎄> by konstantin something
17:57:21FromDiscord<Yardanico> i know, that was the main one
17:57:24FromDiscord<Yardanico> and it's unmaintained now
17:57:27FromDiscord<Yardanico> that's why you should use this one
17:57:41FromDiscord<Yardanico> this extension is a port of the original nim extension from js to nim (since nim has a js backend) and has other improvements
17:58:00FromDiscord<Yardanico> err, right, the original was in typescript, not much different though
17:58:00FromDiscord<Screentapper> In reply to @Yardanico "yes, the nimsaem extension": Maybe I need to set it up or something
17:58:11FromDiscord<Yardanico> no, it should just work if you have nim correctly set up
17:58:52FromDiscord<メッリーレイムー 🎄> ah
17:58:56FromDiscord<メッリーレイムー 🎄> ill switch then
17:59:29FromDiscord<メッリーレイムー 🎄> whats the difference between them?
17:59:31FromDiscord<Screentapper> In reply to @Yardanico "err, right, the original": I'm on Linux, `nim` and `nimble` are in my path...
17:59:37FromDiscord<Yardanico> what about `nimsuggest` ?
17:59:45FromDiscord<Yardanico> and are you sure it doesn't work?
17:59:54FromDiscord<Yardanico> as I said, in nimsaem's extension it only works for nimble pkgs that you have installed
18:02:04FromDiscord<メッリーレイムー 🎄> does it autocomplete stdlib?
18:02:11FromDiscord<Yardanico> no as i said
18:02:25FromDiscord<Yardanico> it shouldn't be that hard to add that though I guess
18:06:14*derpydoo joined #nim
18:16:56FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4hCd
18:17:19FromDiscord<jmgomez> besides doing another overload oc
18:17:51FromDiscord<Screentapper> https://media.discordapp.net/attachments/371759389889003532/1048664379031302195/nim-autocomplete1.mp4
18:19:44FromDiscord<Screentapper> In reply to @Yardanico "as I said, in": Ahhh, that might be the issue 😅
18:23:30FromDiscord<Gumbercules> In reply to @jmgomez "how can one make": make `options` an `Option[FModifyContextOptions]` and supply a default value of `none(FModifyContextOptions)` for the parameter
18:23:51FromDiscord<Gumbercules> then inside `addMappingContext` you can do `isSome(options)` or `isNone(options`
18:23:58FromDiscord<Gumbercules> that or use a pointer
18:24:09FromDiscord<Gumbercules> (edit) "pointer" => "pointer/ref"
18:24:41FromDiscord<jmgomez> In reply to @Gumbercules "make `options` an `Option[FModifyContextOptions]`": I prefer to avoid changing the API, since it's an automatic binding
18:24:49FromDiscord<Gumbercules> other hackery might involve adding a field to `FModifyContextOptions` and initializing it to -1 or some bs, that or you could just check to see if you're dealing with an uninitialized object
18:24:51FromDiscord<Gumbercules> well then you're a bit out of luck
18:25:04FromDiscord<Gumbercules> because you can't have `nil` non ref var parameters
18:25:21FromDiscord<Gumbercules> you'd have the same problem in C
18:25:52FromDiscord<Gumbercules> best bet is probably just to see if options = FModifyContextOptions()
18:25:53FromDiscord<jmgomez> Okay, that's what I suspected but wanted to be sure. Will do an overload and praise to dont have lots of these on the same signature
18:25:56FromDiscord<Gumbercules> (edit) "=" => "=="
18:26:16FromDiscord<jmgomez> thanks for looking into it!
18:26:20*wallabra quit (Ping timeout: 260 seconds)
18:26:22FromDiscord<Gumbercules> yeah this is where I usually just say fuck it and use `ptr`
18:26:36FromDiscord<Gumbercules> sure thing! have been to this rodeo once or twice 😉
18:27:23FromDiscord<jmgomez> thing is in cpp probably they expect it to dont be nil
18:27:53FromDiscord<Gumbercules> what is the C++ function signature>
18:27:55FromDiscord<Gumbercules> (edit) "signature>" => "signature?"
18:28:35FromDiscord<jmgomez> let me check
18:28:38FromDiscord<Gumbercules> https://docs.unrealengine.com/5.0/en-US/API/Plugins/EnhancedInput/IEnhancedInputSubsystemInterface/AddMappingContext/ ?
18:28:51FromDiscord<Gumbercules> https://docs.unrealengine.com/5.0/en-US/API/Plugins/EnhancedInput/IEnhancedInputSubsystemInterface/AddMappingContext/2/
18:28:55FromDiscord<Gumbercules> looks like it
18:29:12FromDiscord<Gumbercules> yeah they're passing a reference there
18:29:15FromDiscord<jmgomez> yeah
18:30:02*wallabra joined #nim
18:30:28FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4hCg
18:30:53FromDiscord<Gumbercules> right which returns a const ref
18:31:02FromDiscord<Gumbercules> so on the Nim side I would just use a `ptr`
18:31:33FromDiscord<Gumbercules> You can't use a `ref` because the Nim runtime doesn't own that allocation
18:31:48FromDiscord<Gumbercules> well it works both ways
18:32:01FromDiscord<Gumbercules> if UE5 is calling into Nim, Nim won't own the allocation and will try to GC the ref and you'll run into issues
18:32:10FromDiscord<jmgomez> yes I know Im passing pointers around anyways, I just want the api to be safe
18:32:14FromDiscord<Gumbercules> if you're calling into UE5 and passing a Nim owned ref, Nim might try to GC it while UE5 is accessing it
18:32:21FromDiscord<jmgomez> Im doing ptr for the interop and copy semantics
18:32:22FromDiscord<Gumbercules> well what you're doing is unsafe anyway so
18:32:28FromDiscord<jmgomez> dont use ref types at all
18:32:57FromDiscord<Gumbercules> yeah I'd avoid them and just use `ptr` if you can't live with `ptr` then a `var` type is your best bet but you live with the fact that the raw pointer is hidden from you
18:35:45FromDiscord<jmgomez> I mean, there are two kind of semantics on Unreal. UObject which is pretty much all ptr and they are GCd by UE. On those in the nim side of things it's pointers all the way down. The other kind of semantics are FStructs which are mostly copied but sometimes they are passed as reference. So in that case I just use var. Thing is now with optional values.. maybe I do as you suggest and I will just change the api for those var FStucts
18:36:18*wallabra_ joined #nim
18:36:27FromDiscord<Gumbercules> yeah Unreal won't care if you use `ptr` or `var`
18:36:29FromDiscord<jmgomez> The way the interop is done is via their reflection system rather than binding cpp directly, Im sending over mostly "fake types" that matchs the memory layout
18:36:33FromDiscord<Gumbercules> `var` is a pointer under the hood anyway
18:36:38FromDiscord<Gumbercules> sure
18:36:42FromDiscord<Gumbercules> yeah this is the way to interop in C++ anyway
18:37:01FromDiscord<jmgomez> In reply to @Gumbercules "`var` is a pointer": yeah I know but wanted to respect the semantics as much as I can
18:37:09FromDiscord<jmgomez> var ref are kinda close
18:37:12FromDiscord<Gumbercules> well using `ptr` is coming closer to matching C++ semantics
18:37:15FromDiscord<jmgomez> (cpp ref I meant)
18:37:25FromDiscord<Gumbercules> C++ has nothing like Nim's `var`
18:37:41FromDiscord<jmgomez> hmm I think & (ref) is quite close
18:37:51FromDiscord<Gumbercules> that's more like Nim's `ref`
18:38:11FromDiscord<Gumbercules> but obviously a `ref` isn't going to work outside of Nim's runtime without calling `gc_ref` etc....
18:38:17FromDiscord<jmgomez> when you say ref dont you refer to gc types?
18:38:20FromDiscord<Gumbercules> and that's a whole nother world of pain
18:38:24*wallabra quit (Ping timeout: 256 seconds)
18:38:31*wallabra_ is now known as wallabra
18:38:35FromDiscord<Gumbercules> yes, but I mean you can always pass a Nim GC'd object to C/C++
18:38:42FromDiscord<Gumbercules> it's just, don't expect the C/C++ side of things to understand what it is
18:38:54FromDiscord<Gumbercules> or for Nim's runtime to know that you've passed it to C/C++ code
18:38:57FromDiscord<Gumbercules> this is on the programmer
18:39:38FromDiscord<jmgomez> ohh yeah, I know.. done that but as ptr. I meant before the closest reasonable thing to & semantics is var that what I did that mapping but yeah got what you are saying
18:39:44FromDiscord<Gumbercules> I gotcha
18:40:23FromDiscord<Generic> In reply to @Gumbercules "that's more like Nim's": that's not true
18:40:26FromDiscord<Gumbercules> yeah if it's a struct being passed by reference, then `var` / `pte` works
18:40:33FromDiscord<Gumbercules> (edit) "`pte`" => "`ptr`"
18:40:34FromDiscord<Generic> Nim's ref is like std::shared_ptr
18:40:43FromDiscord<Gumbercules> yes I was confused by the Unreal types, excuse me
18:41:44FromDiscord<Gumbercules> and no it's not really
18:41:56FromDiscord<Gumbercules> at least not under the old memory model
18:42:08FromDiscord<Gumbercules> thus the existence of the smart_ptrs module
18:42:18FromDiscord<Generic> well it isn't atomic
18:42:36FromDiscord<Generic> but otherwise it is pretty similar
18:42:51FromDiscord<Gumbercules> again not under the default gc, but whatever
18:42:58FromDiscord<メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hCj
18:47:08FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4hCl
18:47:20PMunchメッリーレイムー 🎄, not sure if you watched the stream where I replied to your question. But I try to stream my AoC solutions every day, otherwise I only do occasional streams, haven't done any for quite a while
18:48:18FromDiscord<jmgomez> (edit) "https://play.nim-lang.org/#ix=4hCl" => "https://play.nim-lang.org/#ix=4hCm"
18:48:35FromDiscord<メッリーレイムー 🎄> In reply to @PMunch "メッリーレイムー 🎄, not sure if": i was watching then got distracted'
19:18:16arkanoidhow to print an object variant? `$` is not defined, only repr works out of the box, which is not ideal
19:19:57FromDiscord<Generic> define your own
19:20:21FromDiscord<メッリーレイムー 🎄> whats a good name for a object holding both the type information for an AST node, as well as any specifiers like if it is constant or not
19:35:57arkanoidk
19:41:44FromDiscord<Phil> Do we have a convenience function to remove unnecessary whitespace from HTML?
19:42:23FromDiscord<Phil> Mostly asking because I'm testing HTTP responses from my prologue server and I'd like to cut down the sheer fuckton of whitespace noise I added elsewhere to make the templates there read nicely
19:42:53FromDiscord<Phil> Because I'm printing said HTML to console/error logs if an assertion fails
19:55:20FromDiscord<c4ulmu> Hey, how do I copy seq ? I can't find it
19:58:41Amun-Ravar b = a?
19:59:18Amun-Rathere's also system/shallowCopy
19:59:26Amun-Raand deepCopy, too
19:59:36FromDiscord<Phil> sent a code paste, see https://play.nim-lang.org/#ix=4hCE
19:59:38FromDiscord<Phil> Typed together in inim
20:00:02*sagax quit (Read error: Connection reset by peer)
20:00:28Amun-Raassigning to var copies seq, whether it's a deep or shallow copy I don't know (I bet it's shallow one)
20:00:39FromDiscord<Horizon [She/Her]> What would be the best way to do webdev with Nim? I want to test my app fast but Nim isn't exactly super fast when compiling aha
20:00:51FromDiscord<Phil> In what sense?
20:00:55FromDiscord<Phil> What's the featurescope you want?
20:00:58FromDiscord<Phil> What's your userscope
20:01:54FromDiscord<Horizon [She/Her]> Wdym by that? I just want quick compilation to test my app (I'm using a local web server to serve my files so)
20:02:01FromDiscord<c4ulmu> Cool. But why nim uses this approach. I mean usually list or big vector doesn't copied but uses pass by reference. It can be very expensive perfomance wise
20:02:23FromDiscord<c4ulmu> and how do I pass it to function without copying?
20:02:34FromDiscord<Horizon [She/Her]> `var seq[type]`
20:02:42FromDiscord<Horizon [She/Her]> `type` being the actual type
20:02:48FromDiscord<Horizon [She/Her]> Note this needs the list to be mutable
20:02:52Amun-Rac4ulmu: because it's a "var", if you do let b = a it won't make a copy
20:02:55FromDiscord<Horizon [She/Her]> And also means the list can be edited
20:03:08Simon[m]12345Nim can run interpreted, fast to test in webdev context.
20:03:18FromDiscord<Horizon [She/Her]> In reply to @Event Horizon "And also means the": (In the function)
20:03:27FromDiscord<Horizon [She/Her]> In reply to @Simon "Nim can run interpreted,": In the web? How?
20:04:01FromDiscord<Phil> I mean, you just need a dummy-webserver to spin up with ideally a route that can react to stuff I assume?
20:04:23FromDiscord<Phil> I'm trying to wrap my head around what you mean by "application", so far I'm guessing you got a native application that pings to a server somewhere?
20:04:29FromDiscord<Phil> Or is this about karax?
20:04:32FromDiscord<c4ulmu> Thank you. I guess I get the idea
20:04:33FromDiscord<Phil> Or something else entirely
20:06:00FromDiscord<Horizon [She/Her]> No i mean, I just want to use clientside Nim (so JS backend) for my app, I'm just doing a lot of DOM-related things, and i want to be able to test my Nim code very quickly, but compilation of big projects tend to slow down quite a lot so i want to know if there's a quicker way to compile Nim to JS
20:06:13FromDiscord<Horizon [She/Her]> I'm not having issues with the code at all
20:06:37*ltriant joined #nim
20:07:00FromDiscord<Phil> Ohhhhhh okay... I'm out when it comes to "quicker compile speeds". I mean, devel compiles pretty quickly for me these days (1.7.3), you on that yet?
20:07:23FromDiscord<Horizon [She/Her]> Ah fair, I'll use Nim devel then
20:07:29FromDiscord<Horizon [She/Her]> Thanks anyway aha
20:07:45FromDiscord<Phil> Try it out first, I actually did not take any data, but to me it felt like compile speeds bumped up
20:08:04FromDiscord<Horizon [She/Her]> Yeah fair
20:08:23FromDiscord<Horizon [She/Her]> Is there a way to run a command after a file hasn't been edited for 5 seconds? :p
20:11:20FromDiscord<Horizon [She/Her]> Ah found a VSC extension for that
20:11:21*ltriant quit (Ping timeout: 268 seconds)
20:12:00FromDiscord<demotomohiro> @c4ulmu `a = b` copys seq does not means they are passed by copy when you call procedures. Nim optimize how parameters are passed based on sizeof parameter type.↵Also `a = b` can also optimized to move:↵https://nim-lang.org/docs/destructors.html
20:16:10FromDiscord<Horizon [She/Her]> VSC's Nim extension is really hating using the `dom` module rn, so many errors even after i added `--define:js` in the config file :p
20:17:49FromDiscord<Horizon [She/Her]> any tips to supress most of those errors? :p
20:19:13FromDiscord<Require Support> sent a code paste, see https://play.nim-lang.org/#ix=4hCK
20:20:26*junaid_ joined #nim
20:21:07FromDiscord<huantian> it rhymed it with it
20:23:08NimEventerNew thread by choltreppe: Parser generator, see https://forum.nim-lang.org/t/9690
20:23:17*arkurious joined #nim
20:46:14FromDiscord<Jessa> could i preview the actual nim code if i have just the ast tree? / nimNode tree
20:54:02FromDiscord<skaracic> sent a long message, see http://ix.io/4hCP
20:54:42FromDiscord<メッリーレイムー 🎄> theres `repr` but its kinda messy or you could override `$`
20:57:31FromDiscord<huantian> `echo fmt"{x = }"`
20:58:10FromDiscord<huantian> !eval import std/strformat; let x = 1; echo fmt"{x = }"
20:58:14NimBotCompile failed: x = 1
20:58:47FromDiscord<skaracic> Thst doesnt work with a y variable 🙂
20:59:03FromDiscord<huantian> !eval import std/strformat; let y = 1; echo fmt"{y = }"
20:59:07NimBotCompile failed: y = 1
20:59:25FromDiscord<huantian> wonder why it says Compile failed, but still prints the correct thing lmao
21:00:58FromDiscord<skaracic> Are you trolling me or do you not understand what I'm asking for?
21:01:42FromDiscord<huantian> uh I guess the latter cus I thought that was what you're asking for
21:02:16FromDiscord<huantian> if you want to debug the value of a variable by printing, use `strformat` or treeform's `print`
21:02:32FromDiscord<huantian> (edit) "if you want to debug the value of a variable by printing, use `strformat` ... or" added "`{variable = }`"
21:03:28FromDiscord<skaracic> sent a long message, see http://ix.io/4hCS
21:03:34FromDiscord<skaracic> I guess I want a macro 😄
21:03:40FromDiscord<huantian> right you want treeform's `print`
21:03:48FromDiscord<skaracic> I'll look into that, thanks 🙂
21:03:58FromDiscord<huantian> strformat is generic over the variable name though
21:04:05FromDiscord<huantian> you can give it any variable name and it'll do what you want
21:04:22FromDiscord<skaracic> I'm too lazy to strformst all the time 😉
21:04:31FromDiscord<demotomohiro> !eval import sugar; dump 1 + 2 + 3
21:04:36NimBot1 + 2 + 3 = 6
21:05:22FromDiscord<demotomohiro> !eval import sugar; var a = 1; dump a + 1
21:05:28NimBota + 1 = 2
21:05:51FromDiscord<huantian> but it doesn't have colors like `print`!
21:06:40FromDiscord<skaracic> Close, but no cigar @demotomohiro ↵!eval import sugar; var x = 1; dump x
21:06:55FromDiscord<skaracic> Print seems like the thing!
21:06:58FromDiscord<メッリーレイムー 🎄> In reply to @huantian "right you want treeform's": holy shit this is amazing I thought I would have to write an AST pretty printer just to debug
21:07:07FromDiscord<skaracic> (edit) removed "↵!eval import sugar; var x = 1; dump x"
21:07:11FromDiscord<skaracic> !eval import sugar; var x = 1; dump x
21:07:16NimBotx = 1
21:07:20FromDiscord<huantian> yeah it even works for `ptr`s and such
21:08:13FromDiscord<メッリーレイムー 🎄> @huantian i get this tho
21:08:15FromDiscord<メッリーレイムー 🎄> `/home/rem/Documents/Coding/tsuki/src/tsuki.nim(7, 8) Error: cannot open file: print↵`
21:08:23FromDiscord<skaracic> In reply to @NimBot "x = 1": Heeey, thst doesnt work on my machine?? I get `Error: undeclared identifier: 'PNimType'`
21:08:32FromDiscord<メッリーレイムー 🎄> sent a code paste, see https://play.nim-lang.org/#ix=4hCU
21:08:44FromDiscord<huantian> did you `nimble install print` and/or add `print` to your `.nimble` file?
21:09:11FromDiscord<メッリーレイムー 🎄> it didnt add it automatically
21:09:42FromDiscord<huantian> yeah `nimble install` only installs the package globally, it doesn't add it to your project
21:10:32FromDiscord<メッリーレイムー 🎄> ah ok
21:11:27FromDiscord<demotomohiro> !eval import print; var a = 3; print a
21:11:31NimBotCompile failed: /usercode/in.nim(1, 8) Error: cannot open file: print
21:11:46FromDiscord<huantian> don't think `print` is included on playground
21:13:32FromDiscord<skaracic> The dark blue output of the variables is hard to read against my terminal background 😛↵Maybe I'll create a PR to change the default to something brighter ↵↵Anyway, thanks again everyone
21:14:30FromDiscord<Jessa> Can i reconstruct Nim code that i can read from AST / NimNode tree?↵Basically the inverse of `dumpAstGen`
21:15:17*ltriant joined #nim
21:15:17FromDiscord<メッリーレイムー 🎄> !eval echo "nim is pog"
21:15:22NimBotnim is pog
21:15:29FromDiscord<メッリーレイムー 🎄> good bot
21:18:30FromDiscord<Phil> Writing yourself tooling for testing is pretty tedious work I must say
21:20:25FromDiscord<Horizon [She/Her]> So in my program, I'd be able to generate code for multiple programming languages, but I need to figure out a way to have 'arguments', which just let you input data (think about it like how scratch lets you put variables into a block), what would be the most ideal way?
21:21:07FromDiscord<Horizon [She/Her]> Since it'd need to work for primitive types at least
21:24:14FromDiscord<demotomohiro> @Jessa Probably this can do it: https://nim-lang.org/docs/macros.html#astGenRepr%2CNimNode
21:24:34FromDiscord<Jessa> Oo
21:24:49FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hD0
21:25:34FromDiscord<Jessa> In reply to @demotomohiro "<@268111216277323779> Probably this can": ah, nvm↵that just prints the ast
21:26:18FromDiscord<voidwalker> or at least have a default return type that I don't have to specify ?
21:27:54FromDiscord<demotomohiro> @voidwalker I dont it is possible because there are different types in same size like int and float.
21:28:42FromDiscord<voidwalker> Yes but I am only interested in the int types for return value
21:29:47FromDiscord<demotomohiro> Also a length of string is determined at runtime but type must be determined at compile type.
21:30:15FromDiscord<voidwalker> I think a template can be written for this though, to compute the length of the string range, and pass parameter based on that ?
21:31:06FromDiscord<メッリーレイムー 🎄> In reply to @Event Horizon "So in my program,": what program u writing
21:33:45FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4hD5
21:35:08FromDiscord<Horizon [She/Her]> In reply to @メッリーレイムー 🎄 "what program u writing": It's a website i mean, using Nim
21:35:19FromDiscord<Horizon [She/Her]> It's a scratch-like code builder
21:35:25FromDiscord<Horizon [She/Her]> For languages like Python
21:38:29FromDiscord<Gumbercules> In reply to @Event Horizon "So in my program,": I'm not really sure what you're trying to do - this description is pretty vague but I'd just store them in a buffer with enough reflection information to cast the data in the buffer into whatever type(s) I need
21:39:19FromDiscord<Gumbercules> for a function I'd probably just create a type to represent the args, then store the arg data in a buffer along with the type name so I'd know how to cast the data in the buffer back into the appropriate type
21:39:26FromDiscord<Gumbercules> but again, hard to discern what you're really trying to do with that description
21:40:43FromDiscord<Jessa> In reply to @Jessa "Can i reconstruct Nim": while this would still massively help me, i finally managed to debug it properly
21:40:51FromDiscord<Jessa> so what i wanted, now works
21:41:21FromDiscord<Gumbercules> In reply to @Jessa "while this would still": this already exists?
21:41:36FromDiscord<Jessa> what exists?
21:42:10FromDiscord<Jessa> the ast structure to readable nim code?
21:43:21FromDiscord<Gumbercules> mmm, sorry I think I misunderstood
21:43:53FromDiscord<demotomohiro> If you just want to print AST in a macro, you can do `echo someast.treeRepr`.
21:44:09FromDiscord<Gumbercules> thought you meant something like - https://nim-lang.org/docs/macros.html#toStrLit%2CNimNode
21:44:14FromDiscord<Jessa> No, not the ast.↵↵re-constructed nim code from ast tree
21:44:15FromDiscord<Gumbercules> or maybe you do....
21:44:41FromDiscord<Gumbercules> or `treeRepr`
21:44:50FromDiscord<Jessa> In reply to @Gumbercules "thought you meant something": omg that is it
21:44:51FromDiscord<Gumbercules> but yeah, you just cleared that up for us 🙂
21:45:07FromDiscord<Gumbercules> oh, well then yay!
21:45:47FromDiscord<Elegantbeef> `.repr`?
21:48:44FromDiscord<voidwalker> In reply to @voidwalker "is there any hopes": @ElegantBeef will you take a look at this please ? Is a template that rewrites the proc to be called like msg2byteGeneric[uint16], by computing the range length (eg, p..p+3 = 4 -> uint32), the right way to go about this, if I want it "truly" generic ?
21:49:20FromDiscord<Elegantbeef> Demo gave you the answer
21:50:25FromDiscord<voidwalker> Not really, he told me how stuff works, I am asking if there's any way I can go around the limitation, by using a template, or macro, for this specific case where length of parameter and thus type of return can be determined at compile time
21:50:48FromDiscord<voidwalker> Also my parameter is not static (const or literal)
21:51:23FromDiscord<Elegantbeef> Nim is statically typed you cannot branch the type system dynamically
21:51:59FromDiscord<Elegantbeef> To branch the type system it has to be flow control that is compiled
21:52:00FromDiscord<Phil> Do we have a simple, elegant way to map Exceptions to HTTP-Statuscodes?
21:52:05FromDiscord<Phil> (edit) "Do we have a simple, elegant way to map Exceptions to HTTP-Statuscodes? ... " added "(In Prologue)"
21:52:06FromDiscord<voidwalker> no, but you can reroute a proc call with a template, based on info you can determine at compile time, no ?
21:52:41FromDiscord<Elegantbeef> You want to depending on the contents of `s` change the return type of a procedure
21:53:02FromDiscord<voidwalker> depending on the length of s
21:53:10FromDiscord<Elegantbeef> That's the content
21:53:15FromDiscord<Elegantbeef> That's dynamic typing
21:53:25FromDiscord<Elegantbeef> The type of a procedure call would be untyped until runtime
21:53:35FromDiscord<voidwalker> which is always a range, I do not call it with a whole string variable, but a range, like 1..3, or p+1..p+3
21:53:50FromDiscord<voidwalker> I think that can be computed at compile time
21:54:00FromDiscord<Elegantbeef> If you want a single path use a object variant
21:54:05FromDiscord<Elegantbeef> Otherwise you cannot do what you want
21:54:23FromDiscord<Elegantbeef> It's just against static typing to have runtime information change the type a procedure returns
21:54:25FromDiscord<voidwalker> why my idea wouldn't work ?
21:54:31FromDiscord<c4ulmu> I've read that nim uses merge sort. Tried to write quick sort and got faster sort times. cool
21:54:34FromDiscord<Elegantbeef> Let's simplify
21:55:04FromDiscord<voidwalker> I am talking about compile time, not runtime. I know runtime it's impossible with static typing
21:55:16FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4hDf
21:55:30FromDiscord<Elegantbeef> You may have worded it poorly but that is what i understand you're trying to do
21:56:06FromDiscord<Elegantbeef> The above obviously does not work
21:56:11FromDiscord<voidwalker> I want to use the fact that I can compute the length of the parameter at compile time, as it's simple ranges in the form of x..x+4
21:56:33FromDiscord<voidwalker> And the length of the parameter can be used to call myGenericProc[uint16], [uint32], etc based on that
21:57:00FromDiscord<voidwalker> so I have a bit cleaner code, that is the whole reason
21:57:08FromDiscord<voidwalker> pretend to be python : )
21:59:45FromDiscord<voidwalker> I never wrote a template or macro. I just want to know if my idea is sound before studying further, for the purpose of implementing this
22:00:34FromDiscord<Elegantbeef> I still dont understand what you're after
22:01:13FromDiscord<Elegantbeef> You just want to remove the case statement and call a proc directly?
22:01:17FromDiscord<albassort> is it bad code to mix c direct c bindings with a c wrapped library?
22:01:26FromDiscord<albassort> (edit) removed "c"
22:01:57FromDiscord<albassort> im doing x11 stuff, and theres something I wanna do that I don't know how I would implement in C efficiently, so im using the x11 bindings
22:02:03FromDiscord<albassort> but i also have native x11 code already written
22:02:10FromDiscord<albassort> is this bad
22:02:15FromDiscord<voidwalker> welp. basically a template/macro that I can use to replace calls of the form `msg2byteGeneric[uint16](x[p+4..p+5])` with just `msg2byteGeneric(x[p+4..p+5])` - it would compute length of the range and call the already generic proc with the appropiate type prefix
22:02:52FromDiscord<voidwalker> (p+5)-(p+4) +1
22:02:59FromDiscord<Elegantbeef> You technically could make `msg2byte` a macro which then introspects the syntax
22:03:15FromDiscord<Elegantbeef> But then that means you Have to slice
22:03:30FromDiscord<voidwalker> yes, they are all slice calls
22:03:55FromDiscord<Elegantbeef> god that's awful
22:04:35FromDiscord<Elegantbeef> `toOpenArray` doesnt allocate
22:05:00FromDiscord<voidwalker> I am also researching into alternatives, as this is only a tiny annoyance with the code structure I have now
22:05:50FromDiscord<voidwalker> (de)serializing streams of network data, that follow a specific protocol/sequence (including big endian conversion)
22:06:46FromDiscord<voidwalker> https://github.com/sealmove/nimitai - at first glande this looks like something I'd want to use
22:06:51FromDiscord<voidwalker> (edit) "glande" => "glance"
22:07:29FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hDg
22:07:40FromDiscord<Elegantbeef> https://github.com/sealmove/binarylang
22:09:58FromDiscord<albassort> I can use async timeouts with non async code, right?
22:10:29FromDiscord<albassort> do... i have to do a thread timeout?
22:11:33FromDiscord<albassort> oh this is gonna be nasty
22:11:37FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4hDi
22:13:36FromDiscord<albassort> i basically want to keep an updated x11 event
22:13:45FromDiscord<albassort> which, would poll every like 100 ms
22:14:00FromDiscord<albassort> but it blocks, so i want to stop it if it doesn't find it after x
22:14:03FromDiscord<albassort> its c so it cant be async
22:14:16FromDiscord<Elegantbeef> A selector with 100ms timeout 😄
22:14:20FromDiscord<albassort> so, my new idea is to make a thread for it and have it update a pointer on the shared heap
22:14:40FromDiscord<albassort> In reply to @Elegantbeef "A selector with 100ms": ok you're right thats a bit extreme but i would play with it
22:15:08FromDiscord<voidwalker> sent a code paste, see https://play.nim-lang.org/#ix=4hDl
22:15:21FromDiscord<albassort> In reply to @Elegantbeef "A selector with 100ms": i take it, that since you're joking, you don't see a easy way to do this
22:15:33FromDiscord<Elegantbeef> I mean i'm only slightly joking
22:15:43FromDiscord<Elegantbeef> I hardly ever need to do two things at once
22:15:49FromDiscord<Elegantbeef> So i'm the worst person here
22:16:14FromDiscord<albassort> beef, doesn't how slow a parallelizable task can operate ever stress you out?
22:16:22FromDiscord<albassort> dont you ever go
22:16:27FromDiscord<Elegantbeef> I mainly make games
22:16:29FromDiscord<albassort> "I want to do this 400% faster"
22:16:36FromDiscord<albassort> beef that can be threaded asf
22:16:39FromDiscord<Elegantbeef> No amount of threading can make my games faster
22:16:46FromDiscord<albassort> tell that to ss14
22:16:57FromDiscord<Elegantbeef> My main blocker is the opengl api
22:17:05FromDiscord<albassort> ez write it in vulkan
22:17:12FromDiscord<Elegantbeef> It's a single threaded api, and even if it wasnt it's not worth my time
22:17:58FromDiscord<Elegantbeef> Throwing more threads also doesnt make a programmer faster
22:18:11FromDiscord<Elegantbeef> Designing it smarter does
22:19:17FromDiscord<Arouzing> I mean optimize single threaded first then add threads if possible right?
22:19:38FromDiscord<Elegantbeef> Correct
22:19:46FromDiscord<Elegantbeef> Unless the task requires threads of course 😄
22:20:04FromDiscord<albassort> In reply to @Elegantbeef "Throwing more threads also": not always but most of the time
22:20:07FromDiscord<Elegantbeef> Atleast that's my view i'm sure others differ
22:20:27FromDiscord<Elegantbeef> "I'm going to spool up multiple threads to make `find` faster"
22:21:51FromDiscord<albassort> In reply to @Elegantbeef ""I'm going to spool": I've done that
22:21:53FromDiscord<albassort> distrbute go brr
22:22:00FromDiscord<albassort> 200% increase
22:22:09FromDiscord<albassort> (each thread is 50% as efficient due to startup times)
22:23:12*ltriant quit (Ping timeout: 256 seconds)
22:24:18FromDiscord<Elegantbeef> You left out the best part that now you have to ensure you dont mutate the data
22:29:14FromDiscord<albassort> In reply to @Elegantbeef "You left out the": I left out that timehole, yes
22:29:26FromDiscord<albassort> it is sometimes such a pain the ass to write that code
22:29:32FromDiscord<albassort> i still need to write my templates and macros for that
22:29:33FromDiscord<albassort> lazyyy
22:49:41*junaid_ quit (Remote host closed the connection)
22:58:40FromDiscord<Yepoleb> In reply to @voidwalker "welp. basically a template/macro": i have a better idea, you give the proc the type and it calculates the slice instead
22:59:13FromDiscord<Yepoleb> which is what the streams module already does
23:11:44FromDiscord<voidwalker> not sure what you mean @Yepoleb ,but I am on a better track. There seem to be two DSL libraries for defining binary parsing structurs. binarylang and binaryparser.. trying to decide which one is better now
23:11:49AMIGrAveezquerra & Yardanico: sorry, just reading your messages 11 hours ago :) thanks for your responses !
23:17:17*krux02 quit (Remote host closed the connection)
23:19:44NimEventerNew thread by curioussav: Don't understand why ref is marked cyclic, see https://forum.nim-lang.org/t/9691
23:36:33FromDiscord<伊弉冉の恵み> windows defender said it found a thread named "wacapew.c! ml" on nimgrab.exe (just re-installed nim after formatting my system) - is it something I should worry about or it's just a false positive?
23:36:38FromDiscord<伊弉冉の恵み> (edit) "thread" => "threat"
23:36:50FromDiscord<伊弉冉の恵み> (edit) "it's" => "is it"
23:36:52*AMIGrAve quit (Quit: leaving)
23:37:11FromDiscord<huantian> false positive
23:37:26FromDiscord<Phil> That's it, mapping errors to HTTP Error codes is too painful and error prone to test for, getting HTTP500 when you send bad data is now intended behaviour
23:38:00FromDiscord<demotomohiro> In reply to @伊弉冉の恵み "windows defender said it": https://internet-of-tomohiro.netlify.app/nim/faq.en.html#nim-compiler-is-nimslashnimble-virus-or-malwareqmark
23:42:25*nimcurious joined #nim
23:45:38FromDiscord<albassort> OH NO MORE JAPANESE
23:45:50nimcuriousAnybody know why https://forum.nim-lang.org/t/9688 was moderated? According to the json it was posted by: https://forum.nim-lang.org/profile/N4v - looks like a legit post. Thanks..
23:45:52FromDiscord<Phil> It is fine
23:45:58FromDiscord<Phil> THe japanese characters can't eat you
23:46:04FromDiscord<albassort> they're eating my time
23:46:17FromDiscord<albassort> currently im pretty sure japanese is top 5 languages here
23:46:38FromDiscord<albassort> sent a long message, see http://ix.io/4hDv
23:46:49FromDiscord<Elegantbeef> Posts by new users i think are forced to be moderated to reduce spam
23:47:08nimcuriousAh okay
23:47:36FromDiscord<伊弉冉の恵み> In reply to @demotomohiro "https://internet-of-tomohiro.netlify.app/nim/faq.en": alright thanks
23:49:15*nimcurious quit (Quit: leaving)