<< 17-04-2021 >>

00:00:11*natrys quit (Ping timeout: 240 seconds)
00:00:37*natrys joined #nim
00:45:23*njoseph quit (Quit: http://quassel-irc.org - Chat comfortably. Anywhere.)
00:45:44*njoseph joined #nim
00:47:07*natrys quit (Quit: natrys)
01:04:41*audiophile quit (Ping timeout: 240 seconds)
01:22:25*clyybber quit (Quit: WeeChat 3.1)
01:34:26FromDiscord<j-james> What's the reason behind `abs cannot be passed to a procvar`?
01:34:57FromDiscord<ElegantBeef> `abs` is a `magic` which means it relies on compiler logic to run afaik
01:35:03FromDiscord<Yardanico> In reply to @ElegantBeef "`abs` is a `magic`": abs's are not magic
01:35:07FromDiscord<ElegantBeef> Oh
01:35:13FromDiscord<Yardanico> I mean
01:35:23FromDiscord<Yardanico> @j-james @ElegantBeef is right, abs for ints is magic, yes
01:35:25FromDiscord<Yardanico> for floats it's not
01:59:40*WilhelmVonWeiner quit (Read error: Connection reset by peer)
01:59:55FromDiscord<j-james> Oh that's really interesting
02:00:12FromDiscord<j-james> Is the `magic` just for performance?
02:02:26FromDiscord<Yardanico> In reply to @j-james "Is the `magic` just": mostly for implementation reasons, but sometimes can be for performance too
02:30:06FromGitter<xflywind> abs should be implemented as procs.
02:30:49FromGitter<xflywind> https://github.com/timotheecour/Nim/pull/485
02:33:36FromGitter<xflywind> so make a issue, then this PR may move on
03:02:51*voltist joined #nim
03:03:18voltistAnybody got a favorite game engine for Nim?
03:04:10FromDiscord<ElegantBeef> I tend to use Nico for game projects, but Godot also has bindings
03:06:03*spiderstew joined #nim
03:06:14FromDiscord<ElegantBeef> Have been thinking of trying raylib 😄
03:08:19voltistOo nico looks cool
03:08:26*spiderstew_ quit (Ping timeout: 240 seconds)
03:17:52*tefter quit (Ping timeout: 240 seconds)
03:20:07*tefter joined #nim
04:20:48FromDiscord<congusbongus> oh awesome, I can't believe nico isn't on the curated packages page
04:24:02FromDiscord<ElegantBeef> Time to go add it 😛
04:36:21FromDiscord<congusbongus> boom done↵https://github.com/nim-lang/Nim/wiki/Curated-Packages#games↵curated by randos on the internet
05:01:46FromDiscord<ElegantBeef> The future is now!
05:07:10*Monev joined #nim
05:14:10*vicfred joined #nim
05:19:33*Monev quit (Ping timeout: 260 seconds)
05:21:11*Monev joined #nim
06:08:55*rockcavera quit (Remote host closed the connection)
06:09:01*vicfred quit (Quit: Leaving)
06:19:57*krux02 joined #nim
06:25:16*nmz joined #nim
06:26:37*letto quit (Quit: Konversation terminated!)
06:27:12*Monev quit (Ping timeout: 240 seconds)
06:28:39*letto joined #nim
06:47:04*krux02 quit (Remote host closed the connection)
07:36:24FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WmD
07:38:08FromDiscord<mlokis> (edit) "https://play.nim-lang.org/#ix=2WmD" => "https://play.nim-lang.org/#ix=2WmE"
07:43:53*sacredfrog quit (Quit: ZNC 1.8.2 - https://znc.in)
07:44:09*sacredfrog joined #nim
08:18:29FromDiscord<ElegantBeef> @mlokis shouldnt this `var w = result.workers[0].addr` be `var w = result.workers[i].addr`?
08:18:50FromDiscord<mlokis> oh no am so stupid
08:18:54FromDiscord<ElegantBeef> also btw you can do `0..<threadCount` 😄
08:25:13*tefter quit (Quit: WeeChat 3.1)
08:46:46FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WmR
08:47:58FromDiscord<ElegantBeef> Nim attempts to ensure you do not do unsafe threading, you can override the analysis with `{.cast(gcSafe).}:` and the offending code in that block or globally with `--threadAnalysis:off`
08:50:04*NimBot joined #nim
08:50:09FromDiscord<mlokis> so there would be a problem in case thread stored closure for later and data would meanwhile get dropped on origina thread?
08:50:51FromDiscord<mlokis> (edit) "data" => "data(captured by closure)"
08:51:40FromDiscord<ElegantBeef> I belive that's the concern yes, but i'm uncertain about closures
08:51:44FromDiscord<ElegantBeef> (edit) "belive" => "believe"
08:56:05FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WmS
08:59:59FromDiscord<ElegantBeef> sent a code paste, see https://play.nim-lang.org/#ix=2WmT
09:00:13FromDiscord<mlokis> that does not work i tried
09:00:52FromDiscord<mlokis> it gives invalid indentation
09:01:44FromDiscord<ElegantBeef> Well fix the indentation i guess
09:01:50FromDiscord<ElegantBeef> It should work
09:04:47FromDiscord<mlokis> oh god finnally
09:04:54FromDiscord<mlokis> (edit) "finnally" => "finally"
09:11:38*Vladar joined #nim
09:11:56*filcuc joined #nim
09:25:47ForumUpdaterBotNew thread by HJarausch: How to create a pull request?, see https://forum.nim-lang.org/t/7808
09:36:44filcuci'm reading https://nim-lang.org/docs/destructors.html but i don't understand the wasMoved(a) in the sink proc. Shouldn't be wasMoved(b) since we're stealing data from b to a
09:36:47filcuc?
09:37:03filcucthus we don't want the b destructor to happen
10:05:49*lritter joined #nim
10:16:51filcucis there a weak ref type?
10:19:33FromDiscord<haxscramper> `ptr` for untraced references or `{.cursor.}` annotation for field
10:20:10FromDiscord<haxscramper> `ptr` for regular pointers that can work as untraced references
10:28:26*filcuc quit (Ping timeout: 260 seconds)
10:30:14FromDiscord<shirleyquirk> i want to create a test for std/net with a server and client, any ideas how to get testament to run two files in the right order like that?
10:37:18FromDiscord<no name fits> I'm not sure if there's a "best way" to do the following:↵I have a data type which contains three members, the sum of which must always be zero, so when you make a new instance of that data type, and you enter invalid values, something should happen
10:37:46*krux02 joined #nim
10:39:55FromDiscord<shirleyquirk> maybe declare it {.requiresInit.}, and/or don't export the type, only the initProc so user can't make it without your constructor
10:40:36FromDiscord<no name fits> Right
10:43:55FromDiscord<shirleyquirk> not having the type exported means user can't put it in a seq tho. hmm. well, private members, public setters for sure
10:44:39FromDiscord<no name fits> I wouldn't need to have private members if I made it immutable
10:44:59FromDiscord<no name fits> I believe
10:45:02FromDiscord<no name fits> I may be wrong
10:48:34FromDiscord<haxscramper> If you need to keep some form of invariant for field values the best bet is to provide getters/setters and don't expose them. In this particular case `{.requiresinit.}` is not necessary as value sare always zero-initialized
10:48:48FromDiscord<haxscramper> So 0+0+0 = 0
10:48:56FromDiscord<haxscramper> big brain time
10:49:06FromDiscord<shirleyquirk> still waking up
10:49:26FromDiscord<shirleyquirk> can you do that math again slower?
10:49:51FromDiscord<haxscramper> `0 + 0 + 0 = 0`
10:50:04FromDiscord<shirleyquirk> XD
10:50:27FromDiscord<haxscramper> But in general adding `{.requiresinit.}` might be a good idea at prototyping stage, though it has some inconvenient interactions with `mapIt` and similar templates
10:52:08FromDiscord<shirleyquirk> this is a weird type, setting any member would be invalid, you'd have to set at least two at a time, yes, it should be immutable
11:12:00FromGitter<gogolxdong> https://github.com/Chia-Network/chia-blockchain
11:13:46FromGitter<gogolxdong> How to express something goes very popular very soon.
11:16:00*Vladar quit (Quit: Leaving)
12:21:03FromDiscord<exelotl> sent a code paste, see https://paste.rs/cma
12:21:52FromDiscord<haxscramper> You mean it uses `dest` as a base for an array of multiple `Tile` elements?
12:22:08FromDiscord<haxscramper> Like C `start T, int len`
12:22:08FromDiscord<exelotl> Yep, `dest: ptr Tile` would capture the intent a lot better, but it makes the common usage a bit uglier x)
12:23:26FromDiscord<haxscramper> I suppose this is not really what one would expect from `var`, but if you think it is justified ... Maybe views would make it possible to solve this using something more idiomatic?
12:24:00FromDiscord<haxscramper> I personally would use `ptr` to make it clear what is going on, because `var` is associated with single mutable element, almost always
12:25:31FromDiscord<exelotl> Yeah, that's fair, guess I'll stick with ptr
12:27:59m33[m]Hi guys, in the process of learning about encryption and nim-lang, here is my first library pushed to nimble directory 🙂 https://github.com/nim-lang/packages/pull/1871
12:29:18m33[m]This nim thing is growing on me
12:30:54FromDiscord<Rika> nice
12:36:00FromDiscord<Nisha's alt> In reply to @m33 "This nim thing is": Mood af
12:36:18FromDiscord<Nisha's alt> So, i wanna make an OS using the linux kernel, how would i do that? :P
12:36:34FromDiscord<Nisha's alt> Like, any guides i can use and adapt to Nim?
12:37:41FromDiscord<Rika> glhf
12:37:51FromDiscord<Nisha's alt> Lmao
12:38:03FromDiscord<Nisha's alt> It's not practical, nor will it be intended for a practical use
12:38:10FromDiscord<Nisha's alt> But it'll be a learning experience and stuff
12:39:14FromDiscord<dom96> Start here: http://www.linuxfromscratch.org/
12:39:21FromDiscord<Nisha's alt> Thanks!
12:44:53ForumUpdaterBotNew Nimble package! libsaedea - Library implementing a variation of the Simple And Efficient Data Encryption Algorithm (INTERNATIONAL JOURNAL OF SCIENTIFIC & TECHNOLOGY RESEARCH VOLUME 8, ISSUE 12, DECEMBER 2019 ISSN 2277-8616), see https://git.qoto.org/m33/libsaedea
12:44:53ForumUpdaterBotNew Nimble package! nptr - Nim lang smart pointers, see https://github.com/henryas/nptr
12:45:11*spiderstew quit (Ping timeout: 260 seconds)
12:45:19m33[m]wow, that was quick ^^
12:48:31*Vladar joined #nim
12:48:43FromDiscord<demotomohiro> @m33
12:48:47FromDiscord<demotomohiro> Is the link to research paper pdf on your project README.md correct?↵It links to papar that says VOLUME 2, ISSUE 12, DECEMBER 2013.
12:49:24m33[m]<FromDiscord "<demotomohiro> Is the link to re"> my bad, copy paste error, thanks I will update the link right now
12:51:08m33[m]<FromDiscord "<demotomohiro> Is the link to re"> updated
12:56:34FromDiscord<demotomohiro> @m33 I can read the paper. Thank you!
13:02:26FromDiscord<shirleyquirk> In reply to @exelotl "Yep, `dest: ptr Tile`": `ptr UncheckedArray[Tile]` is a `tile` under the hood, so same as `ptr` and `var` but more ergonomic, e.g. `toOpenArray` exists
13:03:58*natrys joined #nim
13:10:11*spiderstew joined #nim
13:17:29FromDiscord<exelotl> @shirleyquirk i have VRAM mapped as an array of tiles, so usage is like this:↵`copyFrame(addr objTileMem[tileId], gfxDog, anim.frame)`
13:19:00FromDiscord<exelotl> so I worry that making it a ptr UncheckedArray or openArray would just be making things harder
13:19:13*spiderstew quit (Ping timeout: 258 seconds)
13:19:55FromDiscord<exelotl> (edit) "so I worry that making it a ptr UncheckedArray or ... openArray" added "var"
13:20:35*spiderstew joined #nim
13:20:51FromDiscord<exelotl> unless I built the offset into the signature, like↵`objTileMem.copyFrame(tileId, gfxDog, anim.frame)`
13:22:44FromDiscord<shirleyquirk> i'm not seeing multiple tiles copied, does `copyFrame` sometimes decide to move more than one based on anim.frame?
13:23:26FromDiscord<clyybber> I think `var UncheckedArray` would be the nicest
13:23:33FromDiscord<exelotl> it depends on which `gfxFoo` enum is passed in
13:23:49FromDiscord<exelotl> a tile is 8x8 but most graphics are several tiles in size
13:24:16FromDiscord<clyybber> so tileId really means tileId..Inf ?
13:24:47FromDiscord<exelotl> yeah I guess so
13:25:13*Vladar quit (Quit: Leaving)
13:25:25FromDiscord<clyybber> Hmm, I think openarray would be the most idiomatic right now
13:25:38FromDiscord<clyybber> but you could make your own toUncheckedArraySlice thingy
13:26:57FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=2Wo2
13:28:10FromDiscord<clyybber> I guess then it makes sense to expose that exact interface? Maybe with a sugar for `tileId+gfxDog.tilesPerFrame`
13:28:15FromDiscord<exelotl> (edit) "https://play.nim-lang.org/#ix=2Wo2" => "https://play.nim-lang.org/#ix=2Wo3"
13:28:24ForumUpdaterBotNew thread by Alexeypetrushin: Facelift for `db_postgres`, experimenting :), see https://forum.nim-lang.org/t/7809
13:28:51FromDiscord<clyybber> although we don't have postfix operators, so it's hard to express the upper bound exactly
13:28:54FromDiscord<Nisha's alt> Is it a good idea to use Nimscript to make tasks for building my Nim code? :p
13:28:56FromDiscord<clyybber> (edit) "operators, so it's hard to express the upper bound exactly" => "operators"
13:30:01FromDiscord<clyybber> @exelotl Is there a use case for doing `objTileMem[tileId..<(tileId+gfxDog.tilesPerFrame)-X] = gfxDog.getTiles(anim.frame)` in practice?
13:30:45FromDiscord<dk> Is there any good reason to use nimscript for build tasks instead of nim?
13:30:45FromDiscord<clyybber> if so then I would maybe adopt a syntax similar to `..^`, like `...` maybe?
13:31:00FromDiscord<clyybber> nimscript is nim, just run in the VM
13:31:04FromDiscord<clyybber> In reply to @Charlotte|💻⭐ "Is it a good": yep
13:31:15FromDiscord<dk> In reply to @Clyybber "nimscript is nim, just": It's more limited
13:31:26FromDiscord<clyybber> sure, but you don't have to build it in the first place
13:32:13FromDiscord<Nisha's alt> In reply to @Clyybber "yep": Noice
13:32:24ForumUpdaterBotNew thread by Shirleyquirk: Server/client test, using testament, see https://forum.nim-lang.org/t/7810
13:32:32FromDiscord<clyybber> @exelotl maybe `objTileMem[tileId...gfxDog.tilesPerFrame] = gfxDog.getTiles(anim.frame)` ?↵Or just `objTileMem[tileId...0] = gfxDog.getTiles(anim.frame)` ?
13:33:02FromDiscord<exelotl> In reply to @Clyybber "<@!90614688374624256> Is there a": is `...` a thing? 🤔
13:33:10FromDiscord<clyybber> nope, would have to make it a thing :D
13:34:54FromDiscord<exelotl> I'm leaning back towards this one haha `objTileMem.copyFrame(tileId, gfxDog, anim.frame)`
13:35:17*filcuc joined #nim
13:35:36FromDiscord<clyybber> yeah haha, probably the easiest to grok, but I would make it `ptr` instead of `var`
13:36:01FromDiscord<clyybber> since conceptually `var` means you are only going to modifiy that one location, and not ones adjacent to it
13:36:20FromDiscord<clyybber> so you wouldn't be able to turn it into a func for example with strictfuncs
13:36:31FromDiscord<clyybber> and it's also clearer IMO if you explicitly do that addr
13:58:01*filcuc quit (Ping timeout: 260 seconds)
14:06:28ForumUpdaterBotNew thread by Alexeypetrushin: Add named parameters and automatic type conversion to `pg_postgres` library?, see https://forum.nim-lang.org/t/7811
14:14:23*filcuc joined #nim
14:24:44filcucis there a weak ref?
14:28:18FromDiscord<flywind> don't think so, but these is a `WeakPtr` https://github.com/henryas/nptr/blob/d59034b16232815cf78aadd9a23e0aa1ea98f2f0/src/nptr.nim#L40
14:29:04FromDiscord<flywind> see also https://github.com/nim-lang/Nim/pull/17333/files
14:30:30filcucweird that there's no weak ptr concept
14:31:29*rockcavera joined #nim
14:45:18*nmz left #nim ("Ploop")
14:47:57FromDiscord<Goel> Can someone explain me what does if i change the bufSize? From -1 to 0 or to 1↵`proc open(filename: string; mode: FileMode = fmRead; bufSize: int = -1): File`
14:52:28*vicfred joined #nim
14:55:38*filcuc quit (Ping timeout: 240 seconds)
15:01:44*filcuc joined #nim
15:03:05*filcuc quit (Client Quit)
15:04:36*filcuc joined #nim
15:08:09FromDiscord<Marcin(MrogaM)> sent a code paste, see https://play.nim-lang.org/#ix=2WoT
15:16:28FromDiscord<Goel> https://nim-lang.org/docs/manual.html#lexical-analysis-raw-string-literals
15:18:00*filcuc quit (Quit: Konversation terminated!)
15:18:11*filcuc joined #nim
16:04:22FromDiscord<jtiai> When reading file with `readBytes` is there way to say "whole file"?
16:16:48ForumUpdaterBotNew thread by Sixte: How to use macros for an intermediate compiler step?, see https://forum.nim-lang.org/t/7812
16:18:12filcucis there a way to pass by const ref an object in a proc?
16:22:00FromDiscord<haxscramper> https://nim-lang.org/docs/manual_experimental.html#strict-funcs
16:24:24filcuchonestly i'm working with lamda, callbacks and move semantics...and i really not getting into Nim..and i'm a C++ dev ... probably it's me
16:25:26FromDiscord<haxscramper> There is not type-level immutability in nim, so you can't have "const ref" in the same way you use `const T` in C++
16:26:01FromDiscord<haxscramper> There are several smart pointer libraries if you would prefer that over built-in `ref` type
16:26:08FromDiscord<treeform> In reply to @jtiai "When reading file with": Why not just `readFile` instead?
16:26:24FromDiscord<haxscramper> But `strictFuncs` is the closes you would get to "const ref" using built-in features
16:26:30FromDiscord<haxscramper> What is your use case?
16:26:56FromDiscord<haxscramper> Just don't want to modify data passed to procedure via `ref`? Then strict funcs is exactly what you should look for
16:27:00filcuci dont need immutability but being sure to pass a ref
16:27:16filcucwithout having a "ref object"
16:27:21FromDiscord<Yardanico> why do you need a ref exactly?
16:27:24FromDiscord<Yardanico> for mutating?
16:27:42filcucno
16:27:44FromDiscord<haxscramper> In reply to @filcuc "without having a "ref": You have to have `ref T` somewhere, either in `var value: ref T`
16:27:46filcucconst ref
16:27:50FromDiscord<haxscramper> Or in object definition
16:28:12FromDiscord<haxscramper> In reply to @filcuc "const ref": You need `ref` for `const ref`?
16:28:35FromDiscord<haxscramper> just to be clear - you are talking about `c++`-style `const`, not nim's `const` keyword
16:28:43FromDiscord<haxscramper> That is completely different thing
16:28:56filcucno i want an "object" without ref and simply pass a const ref to a func . I could use a "var" parameter but that doesn't work with object declared immutable "let"
16:29:15FromDiscord<haxscramper> Just define an object and pass it to a function
16:29:29FromDiscord<haxscramper> Nim automatically optimizes argument passing
16:29:31FromDiscord<Yardanico> @filcuc objects larger than 24 bytes are passed by reference automatically
16:29:32filcucbut that doesn't guarantee that the compiler could put a copy in between
16:29:56FromDiscord<haxscramper> If you are trying to have `const T& arg` then in nim it is just `arg: T`
16:30:17filcucagain..that doesn't ensure that the compiler could not put a copy in between
16:30:39FromDiscord<haxscramper> you need a copy or not? If you absolutely must evade copying pass `ptr` or `var` argument
16:30:40FromDiscord<Solitude> if you declare the type with {.byref.} it does
16:30:40filcuci could work around by casting and passing pointers
16:30:47FromDiscord<Yardanico> you can make =copy for your type an error
16:30:53FromDiscord<Yardanico> then the compiler will error out when it tries to copy it
16:31:53filcucthat could work but that's just the tip of the iceberg
16:32:14filcuci was reading about sink https://nim-lang.org/docs/destructors.html#lifetimeminustracking-hooks-eqsink-hook for me the wasMoved(dest) doesn't make sense
16:32:22filcuci would expected wasMoved(source)
16:32:24FromDiscord<haxscramper> In reply to @filcuc "that could work but": then describe your use case better, because it sounds like an XY problem
16:33:35filcuchaxscramper i'm just ranting and maybe i should not even write ...
16:33:37FromDiscord<haxscramper> If you need to have a type that is always passed by reference to a function the best option would be to use https://nim-lang.org/docs/manual.html#foreign-function-interface-byref-pragma as solitude just said
16:34:16FromDiscord<haxscramper> In reply to @filcuc "haxscramper i'm just ranting": Nim's function-argument-copy sematics can be a bit confusing so
16:34:21FromDiscord<haxscramper> (edit) "sematics" => "semantics"
16:35:06FromDiscord<haxscramper> Especially for people coming from C++ (that has support for ref/pointer/by-value/rvalue multiplied by const)
16:36:32filcucprobably...maybe not and that's just me...but boy...i'm trying to implement threading support in NimQml and i'm facing issues all over...move semantics, closure and local heap...
16:37:02FromDiscord<Yardanico> use arc/orc, they have a shared heap
16:37:25FromDiscord<Yardanico> (you still need to have synchronization, locks, etc, but the heap is shared)
16:38:06filcucYardanico: yes i could but as a library author it's simply wrong forcing a gc to the end ensure
16:38:14FromDiscord<Yardanico> it's not wrong
16:39:24filcucYardanico: i find it wrong...i wish the language have at least some kind of guaranteees for the library authors about how all the GC works...
16:39:56FromDiscord<Rika> guarantees like what
16:40:05filcucshared heap vs local heap
16:40:12filcucfor example
16:40:17FromDiscord<Yardanico> arc and orc guarantee you that they're using shared heap
16:40:19FromDiscord<Yardanico> also boehm
16:40:45FromDiscord<Rika> p sure everything else uses thread local
16:41:00filcucbut no the default gc at least in 1.2 (if i'm not wrong)
16:41:08FromDiscord<Yardanico> yes, arc/orc aren't the default even on 1.4
16:41:12FromDiscord<Goel> sent a code paste, see https://play.nim-lang.org/#ix=2Wpm
16:41:25FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=2Wpn
16:41:43FromDiscord<Yardanico> ah you mean "a".."z", no
16:41:58FromDiscord<Goel> of a..z To check if is one between `a` and `z`
16:42:22FromDiscord<Rika> use characters
16:42:23FromDiscord<Rika> ?
16:42:25filcucimho the language it's schizophrenic
16:42:30FromDiscord<Solitude> strings are not ordinals, you cant range them
16:42:48FromDiscord<Yardanico> @filcuc yeah, whatever :)
16:42:58FromDiscord<Solitude> yes, change = schizophrenia
16:43:13FromDiscord<Rika> how are we to take you seriously if you cannot even express your issues properly
16:44:06FromDiscord<haxscramper> sent a code paste, see https://paste.rs/jsv
16:44:17FromDiscord<Yardanico> In reply to @haxscramper "`case myString[0]`, or `for": one of the cases here is a double space
16:44:21FromDiscord<Yardanico> that's why single char approach won't work
16:44:54FromDiscord<haxscramper> Then test for that can't be mapped to characters and then iterate by-char
16:44:58FromDiscord<Yardanico> yeah
16:45:16FromDiscord<haxscramper> Though it can be optimized if you iterate using indices and do
16:45:42FromDiscord<haxscramper> sent a code paste, see https://paste.rs/BOQ
16:46:08FromDiscord<haxscramper> Where for `" " in str` you would be iterating string twice.
16:47:28FromDiscord<Yardanico> yeah, true
16:48:41filcucRika i'm a library author of NimQml i wrote some Nim code..i'm not unexperienced in programming...but yep i should stop ranting..
16:48:46FromDiscord<Goel> I found another way, i'll change the code using another char proc so that might work, i just need to check the first three chars of a line of text, so thats easier using chars instead of strings. I only though of using strings because i need to cover the " " double space or triple space, but i'll just check first char -> 2ndh ->3th
16:49:27FromDiscord<Rika> you may not be inexperienced in programming but that does not mean you are experienced in communicating
16:50:29filcucRika no and i never said to be...
16:51:26*filcuc quit (Quit: Konversation terminated!)
16:51:40*filcuc joined #nim
16:57:38FromDiscord<jtiai> In reply to @treeform "Why not just `readFile`": does `readFile` return bytes?
17:00:28FromDiscord<treeform> In reply to @jtiai "does `readFile` return bytes?": it returns a string which is basically bytes, just a cast a way: `cast[seq[byte]](readFile(...))`
17:00:57FromDiscord<jtiai> And it works with binary files just fine?
17:00:57*filcuc quit (Ping timeout: 260 seconds)
17:01:01FromDiscord<treeform> yes
17:01:06FromDiscord<treeform> I use this everywhere
17:01:17FromDiscord<Yardanico> In reply to @jtiai "And it works with": nim strings aren't C strings, they can have null just fine
17:01:17FromDiscord<Solitude> In reply to @jtiai "And it works with": nim strings are byte arrays
17:01:34FromDiscord<Yardanico> since they're pascal strings technically (length is internally located before the string data)
17:01:47FromDiscord<jtiai> And then I manually need to copy returned bytes to my seq?
17:01:50FromDiscord<treeform> In reply to @jtiai "And it works with": If you are going to read binary files I have a library for that: https://github.com/treeform/flatty
17:02:17FromDiscord<treeform> In reply to @jtiai "And then I manually": seq[byte] is a string no need to copy in theory
17:02:19*Amun_Ra quit (Ping timeout: 260 seconds)
17:02:29FromDiscord<jtiai> I do have seq already allocated.
17:02:55FromDiscord<jtiai> Since destination might be bigger than source.
17:03:10FromDiscord<jtiai> And I need to position it correctly as well.
17:03:28*Amun_Ra joined #nim
17:03:39FromDiscord<treeform> I don't know what you are doing with the algorithm, I don't know if you need to copy or not.
17:03:47FromDiscord<jtiai> I emulate memory.
17:03:57FromDiscord<jtiai> which I load binaries (rom images)
17:03:58FromDiscord<Solitude> you can get file size with getFIleSize and read that amount of bytes
17:04:16FromDiscord<treeform> In reply to @jtiai "which I load binaries": Then copy is probably necessary
17:04:19FromDiscord<jtiai> and memory is allocated before hand (since it's fixed). size of rom and position might differ.
17:05:20FromDiscord<Yardanico> then do as solitude said
17:06:09FromDiscord<jtiai> That's what I am doing but just was wondering is there magical `len=-1` that would have read whole file.
17:07:45FromDiscord<Yardanico> In reply to @jtiai "That's what I am": not really
17:07:50FromDiscord<Yardanico> readFile checks the size beforehand as well
17:19:20FromDiscord<shirleyquirk> is there a way for a testament test to change code based on which backend its using?
17:20:39FromDiscord<Yardanico> there's a way to do that in nim itself
17:20:42FromDiscord<shirleyquirk> defined(js/cpp/c)
17:20:46FromDiscord<Yardanico> yes
17:20:51FromDiscord<shirleyquirk> thank you
17:38:35*filcuc joined #nim
18:09:52*filcuc quit (Ping timeout: 240 seconds)
18:23:42*kevinlage[m] joined #nim
18:27:32*SebastianM joined #nim
18:28:17*SebastianM quit (Client Quit)
18:37:44*kevinlage[m] left #nim ("User left")
18:40:52FromDiscord<clyybber> filcuc: If you want to ensure that it's being passed as by reference you can use {.byref.} as solitude said
18:41:14FromDiscord<clyybber> filcuc: If you want to ensure it is moved, you can declare the parameter as sink YourType
18:41:36FromDiscord<clyybber> and declare the `=copy` proc of your type to be {.error.}
18:42:48FromDiscord<haxscramper> If I declare argument as `sink`, will assigning it to `result` copy?
18:43:05FromDiscord<clyybber> filcuc: The wasMoved(dest) in the examples doesn't really do anyhthing useful, it's just there to illustrate a pattern
18:43:57FromDiscord<clyybber> filcuc: But there is no wasMoved(source) because the source get's zeroed out at callsite conceptually
18:44:35FromDiscord<clyybber> In reply to @haxscramper "If I declare argument": if it can be moved then nope
18:46:20FromDiscord<haxscramper> By "can be moved" you mean? I'm trying to have something similar to C++ property configurator chain where you have `createObject().takesMutableRefAndReturs().again().again()`
18:46:54FromDiscord<haxscramper> So I'm not exactly sure if this would create copies on each call or not? Using `sink` parameter everywhere
18:47:17FromDiscord<clyybber> sent a code paste, see https://play.nim-lang.org/#ix=2Wqh
18:47:30FromDiscord<clyybber> it won't create copies on each call
18:48:21FromDiscord<haxscramper> ... since result of a function is never used except in subsequent calls and so all values can be moved safely?
18:48:58FromDiscord<clyybber> yep, essentially
18:49:24FromDiscord<clyybber> but it really depends on the proc bodies; if you were to uncomment the `echo s` here, then a copy would be created
18:49:40FromDiscord<clyybber> but that copy would not be created by `a` itself, not your code calling `a`
18:53:18FromDiscord<jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wqk
18:53:47FromDiscord<Yardanico> yes but one of them is deprecated
18:54:04FromDiscord<Yardanico> to not specify the type "bar: Baz" each time, and just "bar", you can use https://nim-lang.org/docs/manual.html#statements-and-expressions-using-statement
18:54:46FromDiscord<Yardanico> to not specify "bar." each time you can use https://nim-lang.org/0.20.0/manual_experimental.html#automatic-self-insertions but it's deprecated (it's not in the manual for the last release because of that)
18:55:00FromDiscord<Yardanico> consider using https://github.com/zevv/with instead
18:55:35FromDiscord<haxscramper> https://play.nim-lang.org/#ix=2Wqm did I get `=copy` wrong here, or there are no copies in any of the implementations?
18:56:06*lritter quit (Ping timeout: 240 seconds)
18:57:22FromDiscord<clyybber> In reply to @haxscramper "https://play.nim-lang.org/#ix=2Wqm did I get": you implemented `=sink` :D
18:57:50FromDiscord<haxscramper> ...
18:58:24FromDiscord<haxscramper> After fixing that everything works correctly, thanks for the explanation
18:58:30FromDiscord<clyybber> np :)
18:58:54*teasea quit (Quit: teasea)
19:00:50*teasea joined #nim
19:05:20*kevinlage joined #nim
19:20:51*krux02_ joined #nim
19:23:54FromDiscord<mlokis> writing macros is so messy and unreadable, is there some practice to apply?
19:24:21FromDiscord<mlokis> or is it just me who writes it like that
19:24:35FromDiscord<haxscramper> https://nim-lang.org/blog/2021/03/10/fusion-and-pattern-matching.html
19:24:44FromDiscord<Yardanico> In reply to @mlokis "writing macros is so": It's not really messy nor unreadable
19:24:57FromDiscord<Yardanico> just don't use strings and prefer to use quote do over manual AST construction
19:24:58*vicfred quit (Quit: Leaving)
19:25:05FromDiscord<haxscramper> In reply to @Yardanico "It's not really messy": Loud sounds of `[0][0].kind == nnkList`
19:25:20FromDiscord<Yardanico> In reply to @Yardanico "just don't use strings": also you can use https://github.com/PMunch/macroutils
19:25:30FromDiscord<Yardanico> In reply to @haxscramper "Loud sounds of `[0][0].kind": macroutils fixes exactly that
19:25:43FromDiscord<haxscramper> Yes, pattern matching fixes that too
19:25:55FromDiscord<mlokis> well i end up with `something[0][3][2]` everywhare
19:26:00FromDiscord<mlokis> (edit) "everywhare" => "everywhere"
19:26:39FromDiscord<mlokis> making the error handling will be tough
19:26:54FromDiscord<haxscramper> Use pattern matching for AST deconstruction, there was a good semi-introduction video to it, maybe I will find it
19:27:48FromDiscord<mlokis> well my approach is to use quote to create a somewhat template and then append to it
19:27:55FromDiscord<haxscramper> https://www.reddit.com/r/nim/comments/mk5hv9/learning_nim_creating_a_query_macro/
19:28:19FromDiscord<haxscramper> Good example on how to use pattern matching to extract necessary elements from the AST
19:28:40FromDiscord<haxscramper> And for code generation it usually a mix of `newTree()` and `quote do:`
19:29:12FromDiscord<mlokis> pattern matching can actually make it cleaner
19:29:43FromDiscord<haxscramper> That was one of the main reasons to make it
19:30:22FromDiscord<haxscramper> I would even say that this was a main priority to make it play nice with macros
19:31:33kevinlageHi, im pretty new to nim and Im working on a Selenium/Webdriver implementation. Right now I have some troubles parsing this Json response (https://ghostbin.co/paste/guu3) I just need to get this value "element-6066-11e4-a52e-4f735466cecf" but its different for every response. Any tips / ideas?
19:32:08FromDiscord<haxscramper> In reply to @haxscramper "https://nim-lang.org/blog/2021/03/10/fusion-and-pat": This article goes into details of how you can approach more complex macro implementation (one that requires IR)
19:33:35FromDiscord<Yardanico> In reply to @kevinlage "Hi, im pretty new": you can iterate over key, value pairs of "value"
19:33:38FromDiscord<haxscramper> Also it depends on your particular use case - there are different ways of constructing DSL ranging from thin facade over proc calls that do all the job
19:33:42FromDiscord<Yardanico> also, have you seen https://github.com/halonium/halonium ?
19:33:45FromDiscord<Yardanico> it has really similar goals
19:33:58FromDiscord<Yardanico> it's selenium translated to nim, and seems to be maintained
19:34:14FromDiscord<haxscramper> In reply to @haxscramper "Also it depends on": to something like embedded compiler
19:34:23FromDiscord<Yardanico> In reply to @Yardanico "you can iterate over": with https://nim-lang.org/docs/json.html#pairs.i%2CJsonNode
19:34:34FromDiscord<Yardanico> for key, value in myjsobj["value"]:
19:34:35kevinlagethanks, will look into it
19:35:34*clyybber joined #nim
19:49:06*kevinlage quit (Quit: Leaving)
19:54:44FromDiscord<jtiai> In reply to @Yardanico "consider using https://github.com/zevv/with instead": `with` reminds me nodejs... and "is odd" there...
19:54:57FromDiscord<Yardanico> why does it remind you of js?
19:55:02FromDiscord<Yardanico> oh I see
19:55:05FromDiscord<jtiai> 😄
19:55:16FromDiscord<Yardanico> but in nim it's just a macro
19:56:12FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WqD
19:56:28FromDiscord<mlokis> (edit) "https://play.nim-lang.org/#ix=2WqD" => "https://play.nim-lang.org/#ix=2WqE"
19:56:32FromDiscord<jtiai> In reply to @Yardanico "but in nim it's": Yep. And quite beautiful makro that is.
19:56:42FromDiscord<Yardanico> makro
19:56:45FromDiscord<jtiai> (edit) "makro" => "macro"
19:56:52FromDiscord<Yardanico> :P
19:56:55FromDiscord<jtiai> Yep 😄 thanks for Finnish language.
19:57:22FromDiscord<mlokis> makro is how you would pronounce macro in my language
19:57:45FromDiscord<Yardanico> you mean write maybe?
19:58:02FromDiscord<Yardanico> also, deleting messages is useless, since they're instantly bridged to IRC and we have a log there :P
19:58:13FromDiscord<Yardanico> just saying for future
19:58:36FromDiscord<jtiai> sidenote: saying "log" usually screams "gdpr" in my head.
19:58:44FromDiscord<Yardanico> this is a public chat :)
19:58:44FromDiscord<haxscramper> I think large portion of people are on discord so it makes sense to delete messages
19:58:53FromDiscord<Yardanico> https://irclogs.nim-lang.org/
19:59:31FromDiscord<mlokis> well i realized how amazing that sentence i formed sounds and deleted it
19:59:49FromDiscord<haxscramper> In reply to @mlokis "am making macro for": This certainly looks like something that would benefit from IR if it gets more complex
20:00:21FromDiscord<haxscramper> And converting IR into nim code would also be easier since you don't have to mix unparsing and codegen in one step
20:04:09FromDiscord<mlokis> sent a code paste, see https://play.nim-lang.org/#ix=2WqJ
20:04:40FromDiscord<mlokis> oh should i pass addr am dumm
20:05:35FromDiscord<mlokis> why do i have var in template in first place...
20:11:08*yeet joined #nim
20:12:40*yeet quit (Client Quit)
20:13:13*sz0 joined #nim
20:13:34FromDiscord<matf> 👋 any way to get type info in vscode of a value? Something I've missed installing? I'm having to do the ugly hack of typing it incorrectly for it to raise a compiler error which I can hover over to see the actual type. It works, but it would be nicer to go "let blah = ...." hey what is blah anyways
20:14:21FromDiscord<Yardanico> In reply to @matf "👋 any way to": you get the type of a value when it's used, sadly nimsuggest/vscode doesn't show type info in the declaration itself
20:14:34FromDiscord<Yardanico> maybe with the IC and new nimfind it'll work
20:15:18FromGitter<BracketMaster> I'm a bit new to nim and am trying to run the ui example here: https://github.com/nim-lang/ui/blob/master/examples/histogram.nim
20:15:31FromGitter<BracketMaster> first I did `nimble install ui
20:15:50FromGitter<BracketMaster> then `nim c histogram.nim`
20:16:42*filcuc joined #nim
20:16:49FromDiscord<Yardanico> Hi, ui is not really maintained anymore, but this example works just fine for me
20:16:53FromDiscord<Yardanico> what's the error you're getting?
20:17:26giaco__how to split a long lines of code? I've a "proc foo(): bool = cond or cond or cond or cond ... I just want to layout it on multiple lines but I'm not finding the correct way
20:17:40FromDiscord<Yardanico> just split it after "or"
20:18:34FromGitter<BracketMaster> "_uiWindowSetMargined", referenced from: ⏎ ⏎ ``` _main__lwbtpZ59ceYyX3kxu9cVWNBQ in @mhistogram.nim.c.o``` ⏎ ⏎ ld: symbol(s) not found for architecture arm64 [https://gitter.im/nim-lang/Nim?at=607b429a97cf5067466b657c]
20:18:44FromGitter<BracketMaster> could be the fact I'm on Apple Silicon?
20:18:45giaco__thanks, not sure why it was giving error before, probably nimsuggest hiccup
20:19:29FromDiscord<Yardanico> @giaco you can even do something like this - https://play.nim-lang.org/#ix=2WqN
20:22:34FromDiscord<matf> @Yardanico thanks. I'll keep using this hack then.
20:24:53FromDiscord<Yardanico> In reply to @BracketMaster "could be the fact": yeah, it could be, if the libui sources in the repo are not updated for M1
20:42:24FromGitter<BracketMaster> But doing `nimble install ui; nim c histogram.c` is the right way to build things?
20:45:54FromDiscord<Yardanico> yes, because ui ships libui source code
20:46:03FromDiscord<Yardanico> but as I said, it's not really maintained, so it's better to look for other GUI options
21:13:28ForumUpdaterBotNew thread by Dullbananas: IndexedDB, see https://forum.nim-lang.org/t/7813
21:19:26*filcuc quit (Ping timeout: 246 seconds)
21:42:11FromDiscord<jtiai> sent a code paste, see https://play.nim-lang.org/#ix=2Wrg
21:42:18FromDiscord<Yardanico> f: proc(x, y: int)
21:42:47FromDiscord<ElegantBeef> generally you make a typedef to not have to type the procedure signature every damn time
21:42:58FromDiscord<Yardanico> but what if you only need the proc signature once?
21:43:19FromDiscord<ElegantBeef> Did i stutter 😛
21:44:16FromDiscord<Yardanico> In reply to @ElegantBeef "Did i stutter 😛": you didn't talk about cases when you only need to specify it once :)
21:44:54FromDiscord<jtiai> What is typedef? Google was quiet on that one.
21:45:03FromDiscord<Yardanico> In reply to @jtiai "What is typedef? Google": a type definition
21:45:05FromDiscord<ElegantBeef> `type YourProc = proc(x,y: int)`
21:45:10FromDiscord<Yardanico> but again, this is optional
21:45:15FromDiscord<Yardanico> In reply to @ElegantBeef "`type YourProc = proc(x,y:": where's the damn space after the comma
21:45:26FromDiscord<ElegantBeef> What are you my mom, leave me alon!
21:45:28FromDiscord<ElegantBeef> (edit) "alon!" => "alone!"
21:46:55FromDiscord<jtiai> So why I would need to type singature every time if I have it in one object type?
21:47:03FromDiscord<jtiai> (edit) "singature" => "signature"
21:47:11FromDiscord<ElegantBeef> You wouldnt
21:47:20FromDiscord<ElegantBeef> The implication was you needed it more than once
21:47:30FromDiscord<ElegantBeef> (edit) "The implication was ... you" added "if"
21:49:26FromDiscord<jtiai> And thanks for the person who hinted about `with` package. Pretty neat.
22:16:16*krux02 quit (Ping timeout: 258 seconds)
22:21:04*sz0 quit (Quit: Connection closed for inactivity)
23:47:58*krux02_ quit (Remote host closed the connection)
23:48:11*natrys quit (Ping timeout: 240 seconds)
23:48:38*natrys joined #nim
23:53:37*clyybber quit (Quit: WeeChat 3.1)