<< 18-07-2021 >>

00:02:35arkanoidyeah it is sad that I have to use my nim tools only on backend. Every time I try to build a windows tool I end up fighting with the AV and it looks like I am doing something nasty just to parse an xml
00:17:34FromDiscord<treeform> I primly develop on windows. I have 0 AV problems?
00:17:47FromDiscord<treeform> I think I disable all AV is its always bad for programming.
00:27:57FromDiscord<exithead> People actually program on windows? Wild.
00:28:57*xet7 quit (Remote host closed the connection)
00:29:41*xet7 joined #nim
00:32:50FromDiscord<treeform> if you work on games as a hobby, and most of gamers use windows. Its not that bad.
00:38:28FromDiscord<theangryepicbanana> In reply to @exithead "People actually program on": I prefer using .NET and JVM languages on windows ngl lol
00:41:21FromDiscord<j$> hey trying to use ffi, when importing structs do I have to declare all the fields?
00:45:54FromDiscord<stu002> Can I confirm that on macOS the homebrew install of nim does not install testament?
00:56:07fn<ForumUpdaterBot99> New thread by Stu002: Which macOS installation method for Nim?, see https://forum.nim-lang.org/t/8240
00:57:28FromDiscord<ElegantBeef> In reply to @j$ "hey trying to use": I dont know but i'm going to say you dont need to but for the most safe FFI it's probably the smartest
01:02:01*bkay joined #nim
01:04:30*beshr quit (Ping timeout: 255 seconds)
01:13:41arkanoidI have to serialize and deserialize GeoJSON format. I'm trying to data map it with object variant, but the "coordinates" key (see example here https://en.wikipedia.org/wiki/GeoJSON) contains seq[int] for Point type and seq[seq[int]] for LineString and Polygon type. Nim does not support object variant with attributes with different types for same name. What's an idiomatic solution for this?
01:15:21FromDiscord<treeform> In reply to @arkanoid "I have to serialize": you could name them different things
01:15:34FromDiscord<treeform> you could have Point have seq[seq[int]] as well.
01:15:53arkanoidbut that's now what the standard wants
01:16:06arkanoids/now/not
01:17:54arkanoidI think I will have to work with generics
01:22:13FromDiscord<treeform> you have have a problem that prop can be any type
01:23:29FromDiscord<treeform> and Polygon is a seq of seq of 2 int
01:24:28*vicfred_ joined #nim
01:25:01arkanoidyou're right, polygon is seq[seq[seq[float]]]
01:25:12arkanoidwell, any idea?
01:25:30arkanoidI'm only thinking about GeoJson[T]
01:26:10FromDiscord<treeform> I got some thing like this:
01:26:11FromDiscord<treeform> https://play.nim-lang.org/#ix=3tjw
01:26:21FromDiscord<treeform> its not a nim friendly format
01:26:37FromDiscord<treeform> its schema is loose
01:27:04FromDiscord<treeform> I kept everything that is super dynamic as JsonNode
01:28:20*vicfred quit (Ping timeout: 268 seconds)
01:42:43FromDiscord<j$> In reply to @ElegantBeef "I dont know but": yeah there are some places that so you should not have to, but it was giving me some error, so for my use case ill just wrap fields in functions and call it a day
01:42:56FromDiscord<j$> (edit) "so" => "say"
02:01:07FromDiscord<ajusa> This might be a weird question but does os.walkDir not work for file paths that have an "!" in their filename? I just tested it on my machine and that seems to be the case
02:06:07arkanoidis there a function to sanitize file names so that they can be used in paths?
02:11:44FromDiscord<ElegantBeef> You mean remove the extension?
02:11:53FromDiscord<ElegantBeef> or get the name + extension?
02:15:10FromDiscord<carmysilna> I think they mean sanitize a tainted string so it’s safe to open that file name
02:15:37FromDiscord<ElegantBeef> Tainted strings are opt in and basically 0 people use them 😄
02:20:26FromDiscord<ElegantBeef> `splitFile` and `extractFileName` in `std/os` should help
02:47:08arkanoidI mean remove weird characters from file name, like ()!.'
02:48:58FromDiscord<ElegantBeef> You should be able to do `import std/[os, strutils];fileName.replace(invalidFileNameChars)`
02:53:37FromDiscord<ajusa> Can I import a struct from Cwithout needing to redefine it?
02:55:01*vicfred_ quit (Quit: Leaving)
02:55:13*vicfred joined #nim
02:56:02fn<Prestige99> Don't think so
02:57:21FromDiscord<ajusa> Rip, I was trying to import tcp/ip/udp header definitions, that'll be a pain
02:57:44fn<Prestige99> c2nim might be useful
02:59:57FromDiscord<ajusa> Yeah, I'll try running it (although it'll be on some pretty messy 20 year old headers).
03:17:33fn<Prestige99> I found it pretty easy to convert headers using macros in vim, if you're using anything similar
03:26:15*arkurious quit (Quit: Leaving)
03:42:57FromDiscord<Revenant> hiya, i'm trying to use NimScript as a build tool, replacing makefiles, basically, but can't figure it out how to get it to work because the documentation is quite sparse...
03:43:12FromDiscord<Revenant> i have this in `build.nims`
03:43:14FromDiscord<Bung> @haxscramper okay, get it.
03:43:26FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=3tjS
03:43:59FromDiscord<Revenant> and this is how i'm trying to use it
03:44:15FromDiscord<Revenant> sent a code paste, see https://play.nim-lang.org/#ix=3tjT
03:44:37FromDiscord<Revenant> which doesn't actually execute the `build` task
03:47:05FromDiscord<Bung> task is defined by nimble
03:47:54FromDiscord<Revenant> no, it's defined by system
03:48:02FromDiscord<Revenant> it says it here https://nim-lang.github.io/Nim/nims.html
03:48:21FromDiscord<Revenant> "NimScript as a build tool" section
03:48:34FromDiscord<Revenant> but it doesn't show an example how to invoke the task in a nimscript file, that is my problem
03:51:28FromDiscord<Bung> hmm, havn't used it like this.
03:52:01FromDiscord<Revenant> okay, if i rename if to `config.nims`, then i can invoke `debug` with `nim debug`
03:52:45FromDiscord<Bung> so still works as a config file
03:53:27FromDiscord<Revenant> well... yeah... but the documentation is a bit misleading
03:53:39FromDiscord<Revenant> i thought you can just use tasks in any nimscript file
03:53:43FromDiscord<Bung> kinda , I agree
03:53:51FromDiscord<Revenant> but seems like just in the `config.nims` in the project root
03:54:25FromDiscord<Bung> more like config your build process
03:55:27FromDiscord<Revenant> yeah, it's all a bit confusing to be hones
03:55:28FromDiscord<Revenant> (edit) "hones" => "honest"
03:57:20FromDiscord<Bung> guess with nimble that parts does not need anymore.
04:06:02*supakeen quit (Quit: WeeChat 3.2)
04:06:38*supakeen joined #nim
04:12:20*bkay quit (Quit: Leaving)
04:12:34*beshr joined #nim
04:12:34*beshr quit (Changing host)
04:12:34*beshr joined #nim
04:27:03FromDiscord<hamidb80> https://github.com/hamidb80/mycouch/blob/main/src/mycouch/api.nim#L57↵↵> Error: undeclared field: 'code' for type httpclient.Response [type declared in C:\Users\HamidB80\.choosenim\toolchains\nim-#devel\lib\pure\httpclient.nim(227, 3)]
04:27:10FromDiscord<hamidb80> i'm going crazy
04:28:20FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/866174522456670208/unknown.png
04:28:35FromDiscord<hamidb80> the language server detect it
04:28:39FromDiscord<ElegantBeef> does `code(res).int` work?
04:29:06FromDiscord<hamidb80> In reply to @ElegantBeef "does `code(res).int` work?": nope
04:29:15FromDiscord<hamidb80> In reply to @hamidb80 "the language server detect": but the compiler not
04:32:02FromDiscord<Hi02Hi> In reply to @Revenant "well... yeah... but the": as far as i can tell, nimscript tasks act on files with `file.nims` or with directories with `config.nims`
04:33:30FromDiscord<Revenant> In reply to @Hi02Hi "as far as i": this doesn't make much sense...
04:35:58FromDiscord<Hi02Hi> In reply to @Revenant "this doesn't make much": which part doesnt make sense? if you mean `file.nims`, then i mean if the project is in `main.nim`, then the nimscript file would be `main.nims`
04:36:52FromDiscord<Revenant> well, my original goal was to use NimScript as a substitute for makefiles
04:37:31FromDiscord<Revenant> maybe there are not even any Nim files involved
04:37:43FromDiscord<hamidb80> In reply to @ElegantBeef "does `code(res).int` work?": removing the argument type fixes the problem
04:37:47FromDiscord<Revenant> maybe i just want to write a "makefile" in NimScript for a C++ project, or whatever
04:38:43FromDiscord<Rika> wdym?
04:38:47FromDiscord<Rika> i mean to hamid
04:38:52FromDiscord<Hi02Hi> so ig use `config.nims` and use a bunch of `import os ... exec("build command")`
04:39:07FromDiscord<ElegantBeef> I just tested it hamidb and it worked
04:39:14FromDiscord<Hi02Hi> or is `import os` not needed
04:39:24FromDiscord<Rika> exec needs os
04:39:26FromDiscord<Rika> i believe
04:39:26FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/866177317009227786/unknown.png
04:39:42FromDiscord<Rika> what was the type before
04:39:48FromDiscord<hamidb80> Response
04:39:53FromDiscord<Rika> strange
04:39:56FromDiscord<ElegantBeef> Oh you're not exporting the frigging type
04:40:00FromDiscord<Revenant> my problem with using `config.nims` is that while it works, if i do `exec "nim ..."` from there, then the script gets executed a SECOND time when i exec the nim compiler from the script
04:40:01FromDiscord<ElegantBeef> (edit) "type" => "module"
04:40:02FromDiscord<Revenant> which sucks
04:40:02FromDiscord<Rika> what?
04:40:13FromDiscord<Revenant> how can i reliably parse extra command line params then?
04:40:13FromDiscord<Rika> beef what are you spouting
04:40:18FromDiscord<hamidb80> In reply to @ElegantBeef "Oh you're not exporting": ?!
04:41:09FromDiscord<ElegantBeef> I dont know how that macro works that those procs are declared in
04:41:27FromDiscord<hamidb80> addTestCov?
04:41:30FromDiscord<ElegantBeef> But i just assumed it was due to not exporting `httpclient` since it was a template
04:41:30FromDiscord<ElegantBeef> Yes
04:41:44FromDiscord<hamidb80> it just adds `cov` pragma to the procs
04:42:05FromDiscord<ElegantBeef> Well oddly enough `export httpclient` resolves the issue 😄
04:43:08FromDiscord<hamidb80> it works fine when i compile api.nim individually
04:43:32FromDiscord<hamidb80> but `nimble test` somehow break it
04:43:57FromDiscord<hamidb80> (edit) "break" => "breaks"
04:44:50FromDiscord<hamidb80> and something more strange:
04:45:11FromDiscord<hamidb80> i didn't import macroutils in `tests/tapi.nim`
04:46:05FromDiscord<hamidb80> but it somehow injected
04:46:10FromDiscord<hamidb80> and the last line: https://github.com/hamidb80/mycouch/blob/main/tests/tapi.nim#L67
04:46:14FromDiscord<hamidb80> doesn't work
04:47:32FromDiscord<hamidb80> In reply to @ElegantBeef "Pmunch emits some converters": .
04:47:49FromDiscord<hamidb80> (edit) "but it somehow ... injected" added "goy"
04:47:55FromDiscord<hamidb80> (edit) "goy" => "got"
04:47:58FromDiscord<Rika> In reply to @ElegantBeef "Well oddly enough `export": ah, this was a file being imported?
04:48:04FromDiscord<ElegantBeef> Yea
04:48:10FromDiscord<Rika> yeah that means code needs to be exposed to the importing module as well
04:48:17FromDiscord<Rika> so you need to export httpclient
04:48:19FromDiscord<ElegantBeef> I'm trying to find the logic in this code
04:48:37FromDiscord<Rika> you need to find the logic in your head first 😛
04:48:47FromDiscord<ElegantBeef> I mean i fixed the error
04:49:02FromDiscord<Rika> i dont actually know where you're looking at
04:49:09FromDiscord<ElegantBeef> https://github.com/hamidb80/mycouch/blob/main/src/mycouch/api.nim
04:49:23FromDiscord<ElegantBeef> guess i should've grabbed line 56
04:49:52FromDiscord<ElegantBeef> This is the first time i've seen someone use `using`
04:50:12FromDiscord<Rika> i use using, not often but ive used it
04:51:36FromDiscord<hamidb80> it's because i'm too lazy to write argument types
04:51:52FromDiscord<ElegantBeef> I know why people use it 😄
04:52:36FromDiscord<ElegantBeef> Ok so seems like this is a templates issue(bug?)
04:53:00FromDiscord<Rika> why?
04:53:34FromDiscord<hamidb80> removing type fixes the issue
04:53:37FromDiscord<ElegantBeef> I really should open this up in a properly setup editor to expand on it
04:53:48FromDiscord<hamidb80> In reply to @hamidb80 "": .
04:53:56FromDiscord<Rika> In reply to @hamidb80 "removing type fixes the": oh yeah i forgot about that
04:55:56FromDiscord<hamidb80> i think every thing works fine magically
04:56:02FromDiscord<hamidb80> (edit) "i think every thing works fine magically ... " added "now"
04:56:34FromDiscord<hamidb80> (edit) "i think every thing works ... fine" added "magically " | removed "magically"
04:58:47FromDiscord<hamidb80> no
05:00:34FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/866182639126577163/2021-07-18_09-29-16.mkv
05:03:41FromDiscord<ElegantBeef> like i said replace it with `code(res)`
05:03:53FromDiscord<ElegantBeef> I mean it gets another compiler error unrelated
05:04:32FromDiscord<hamidb80> gives me same error
05:04:37FromDiscord<ElegantBeef> you didnt replace it in both spots
05:04:45FromDiscord<ElegantBeef> you use `res.code` twice
05:05:21FromDiscord<hamidb80> wow
05:05:35FromDiscord<hamidb80> fixes https://media.discordapp.net/attachments/371759389889003532/866183895871258624/unknown.png
05:05:38FromDiscord<hamidb80> the issue
05:05:47FromDiscord<ElegantBeef> Templates have some issues with the MCS when importing which can result in having to use C style calls
05:07:17FromDiscord<ElegantBeef> you can do `mixin code` in the first line to have it seem to work
05:07:23FromDiscord<ElegantBeef> But i dont know much about mixin/bind
05:07:53FromDiscord<ElegantBeef> Ah kinda makes sense what it does
05:09:52FromDiscord<hamidb80> works with mixin
05:10:04FromDiscord<hamidb80> https://media.discordapp.net/attachments/371759389889003532/866185022247272448/unknown.png
05:11:11FromDiscord<ElegantBeef> Almost like i tested it before hand 😄
05:16:16FromDiscord<hamidb80> do you know what are these errors? my code compiles but they exist https://media.discordapp.net/attachments/371759389889003532/866186588240085008/unknown.png
05:17:06FromDiscord<hamidb80> seems they dont give much information
05:17:26FromDiscord<ElegantBeef> It's something with your macros
05:31:33FromDiscord<hamidb80> it complains about `cov` ident https://media.discordapp.net/attachments/371759389889003532/866190433629765653/unknown.png
05:36:44FromDiscord<hamidb80> how can I tell to the compiler which `cov` i mean
05:37:05FromDiscord<hamidb80> `bindSym` seems not useful
06:24:43FromDiscord<Bung> there's something need improve, one that template/generic should be hint message, need to be configurable.
06:33:09FromDiscord<hamidb80> beef
06:33:15FromDiscord<hamidb80> i got confused
06:34:32FromDiscord<hamidb80> this code in separated file compiles successfully https://media.discordapp.net/attachments/371759389889003532/866206282201169940/unknown.png
06:43:01*max22- joined #nim
06:43:18*max22- quit (Remote host closed the connection)
06:43:41*max22- joined #nim
06:45:18FromDiscord<hamidb80> oh
06:45:25FromDiscord<hamidb80> static argument
06:45:46FromDiscord<hamidb80> i found a crazy bug
06:50:21FromDiscord<hamidb80> https://github.com/hamidb80/mycouch/blob/main/src/mycouch/api.nim#L759
06:50:50FromDiscord<hamidb80> if i remove static argument here everything gonna be ok
06:52:12FromDiscord<hamidb80> https://github.com/hamidb80/mycouch/blob/main/src/mycouch/api.nim#L763
07:37:01fn<ForumUpdaterBot99> New post on r/nim by WrongJudgment6: Nim on the Attack: Process Injection Using Nim and the Windows API, see https://reddit.com/r/nim/comments/omm010/nim_on_the_attack_process_injection_using_nim_and/
08:16:32FromDiscord<hamidb80> he compiled nim for windows in linux?
08:17:15FromDiscord<hamidb80> -d:mingw
08:17:43FromDiscord<ElegantBeef> yea you can cross compile windows binaries from linux depending on the dependancies you have
08:18:23FromDiscord<ElegantBeef> https://nim-lang.org/docs/nimc.html#crossminuscompilation
08:25:54FromDiscord<@bracketmaster-5a708063d73408ce4> I'm guessing no quick way to iterate over a string backwards?
08:26:36FromDiscord<hamidb80> ?
08:27:07FromDiscord<hamidb80> sent a code paste, see https://play.nim-lang.org/#ix=3tkC
08:28:59FromDiscord<@bracketmaster-5a708063d73408ce4> !eval var s = "hello"; for c in countdown(s.len - 1, 0)\: echo c
08:29:01NimBotCompile failed: /usercode/in.nim(1, 59) Error: expected: ':', but got: '[EOF]'
08:29:15FromDiscord<@bracketmaster-5a708063d73408ce4> !eval var s = "hello"; for c in countdown(s.len - 1, 0)\: echo c;
08:29:16NimBotCompile failed: /usercode/in.nim(1, 60) Error: expected: ':', but got: ';'
08:29:26FromDiscord<hamidb80> 😄
08:29:44FromDiscord<@bracketmaster-5a708063d73408ce4> which is not "olleh"
08:29:45FromDiscord<@bracketmaster-5a708063d73408ce4> sent a long message, see http://ix.io/3tkD
08:30:20FromDiscord<hamidb80> https://play.nim-lang.org/#ix=3tkE
08:30:24FromDiscord<hamidb80> s[c]
08:30:51FromDiscord<@bracketmaster-5a708063d73408ce4> yeah yeah, I know - but a little less elegant than string.reverse
08:30:55FromDiscord<@bracketmaster-5a708063d73408ce4> which doesn't exist
08:31:07FromDiscord<hamidb80> algorighm.reverse
08:31:36FromDiscord<hamidb80> https://play.nim-lang.org/#ix=3tkE
08:32:09FromDiscord<hamidb80> sorry
08:32:12FromDiscord<hamidb80> wait a minute
08:32:59FromDiscord<@bracketmaster-5a708063d73408ce4> wrong link?
08:33:58FromDiscord<hamidb80> https://play.nim-lang.org/#ix=3tkL
08:34:25FromDiscord<hamidb80> algorithm.reversed return seq[char] by default
08:35:20FromDiscord<hamidb80> you can convert it to string in many ways
08:35:21FromDiscord<hamidb80> https://stackoverflow.com/questions/32094567/converting-a-seqchar-to-string
08:35:30FromDiscord<@bracketmaster-5a708063d73408ce4> thanks
08:35:32FromDiscord<@bracketmaster-5a708063d73408ce4> that works
09:03:35FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=3tkT
09:03:42FromDiscord<ElegantBeef> Ideally you just make an iterator for 0 cost
09:05:15FromDiscord<ElegantBeef> always realizes the time of the message too late
09:50:48FromDiscord<Kermithos> Is there a way to get the ascii char from an int? for example I have the number 97 and want to convert it to 'a'
09:57:14fn<ForumUpdaterBot99> New thread by Rtrn: Base method when returning an iterator, see https://forum.nim-lang.org/t/8241
10:10:57FromDiscord<haxscramper> `char(97)`↵(@Kermithos)
10:11:37FromDiscord<Kermithos> In reply to @haxscramper "`char(97)` (<@739886115623927889>)": perfect, thanks
10:48:25*max22- quit (Ping timeout: 246 seconds)
11:23:29*lucerne quit (Quit: Bye)
11:25:03*greyrat_ joined #nim
11:25:24*lucerne joined #nim
11:26:34*greyrat quit (Ping timeout: 240 seconds)
12:06:01*supakeen quit (Quit: WeeChat 3.2)
12:06:36*supakeen joined #nim
12:27:10*arkurious joined #nim
12:34:44FromDiscord<haxscramper> @Bung @ElegantBeef https://github.com/haxscramper/hnimast/blob/master/tests/tNimscriptInterop.nim↵↵This is still more or less proof-of-concept, but it is able to handle variant objects, private fields, private fields in generic objects, nested variants with variant fields inside
12:35:22FromDiscord<haxscramper> Regular serialization approach `fromVm(target: T, source: PNode)`
12:36:06FromDiscord<haxscramper> `iterateFields()` from hnimast yields fields in exactly the same order as they are placed in the PNode representation in the VM, so I just copy data using index
12:36:38FromDiscord<haxscramper> This is how `VmVariant` looks in the Vm https://media.discordapp.net/attachments/371759389889003532/866297410330427412/unknown.png
12:37:04FromDiscord<haxscramper> sent a code paste, see https://play.nim-lang.org/#ix=3tlG
12:37:27FromDiscord<haxscramper> Round-trip preserves all data `(beforeKind: '\x00', privateField: 0.0, tableField: (test: "Non-default argument passed to private field", genr: ""), kind: vmkSecond, field2: "Set value in the VM side", afterKind: '\x00') `
12:39:03FromDiscord<haxscramper> You can also implement custom (de) serialization hooks and so on
12:40:01FromDiscord<haxscramper> I removed dependency on nimble, but devel breaks hmisc, most likely due to this enum "fix"
12:40:24FromDiscord<haxscramper> But in the example I can use std libraries just fine (tables), so
12:41:18*max22- joined #nim
12:43:38FromDiscord<haxscramper> So you can use this example as a reference if you already have object unparsing implemented, though hnimast is probably the best you can get for that sort of thing, unless you want to spend as much time as I did
12:44:18FromDiscord<haxscramper> In reply to @haxscramper "I removed dependency on": I had distinct enum typedef and on devel I can't convert it to the underlying enum
12:54:26FromDiscord<haxscramper> Is it normal I'm getting insane number of strange type mismatch errors when switching to devel?
12:54:38FromDiscord<haxscramper> ``type mismatch: got <uint8> but expected one of: proc echo(x: varargs[typed, `$`]) ``
12:55:05FromDiscord<haxscramper> Also had to fix like 5+ pefectly normal procs that suddely failed to compile
12:55:30FromDiscord<haxscramper> Most of them were `Type1 | Type2` and I had to separate them into two procedures
12:56:36*max22- quit (Ping timeout: 256 seconds)
13:00:30FromDiscord<haxscramper> `rror: ambiguous call; both pragmas.newNPragma(names: varargs[NimNode]) and pragmas.newNPragma(names: varargs[string]) match for: (string)`
13:00:41FromDiscord<haxscramper> And I had no implicit converters of course
13:05:05FromDiscord<haxscramper> Idk, maybe I just somehow managed to write all of the code incorrectly or something
13:08:17FromDiscord<haxscramper> In reply to @haxscramper "I had distinct enum": That one I at least figured out - now, for some reason you have to go through .int when converting distinct enum to the base type as well, which makes zero sense but anyway
13:09:15FromDiscord<haxscramper> But overall it seems like you are out of luck with hnimast on devel, @ElegantBeef , since I largely get completely random compilation errors for code that worked perfectly fine earlier
13:19:24FromDiscord<haxscramper> Also whatever fusion is installed by nimble & CI also fails with idk-why errors https://github.com/haxscramper/hmisc/runs/3097352353?check_suite_focus=true#step:5:24
13:26:48FromDiscord<haxscramper> Fusion is still tagged as 1.0, and package version in manifest has been the same for the last 15 months
13:40:42FromDiscord<generic linux user> really bit git banner
13:40:52FromDiscord<generic linux user> covers all of my scren😐
13:53:45*max22- joined #nim
14:10:13*huria4 joined #nim
14:12:30*huria4 quit (Quit: Leaving)
14:23:46FromDiscord<dom96> yeah, these embeds are annoying
14:23:49FromDiscord<dom96> deleted it
14:33:45FromDiscord<generic linux user> whyyy
14:33:53FromDiscord<generic linux user> just <> eh
14:47:24FromDiscord<jfmonty2> it appears that arrays indexed by enums are not bounds-checked? As in, if you cast an invalid value to the enum and use that to index the array, you can get a segfault.
14:47:48FromDiscord<jfmonty2> I'm guessing the official answer to this is "if you're casting types like that then you're taking your life into your own hands, the compiler can't help you"?
14:48:09FromDiscord<Rika> pretty much
14:48:51FromDiscord<Rika> i guess it would help if there was a runtime check for enum validity
14:49:07FromDiscord<deech> I'm using the `compile` pragma to build an object file, eg. `{.compile: "blah.cxx".}` but how do I pass the resulting `blah.cxx.o` to the linker? It ends up the the `~/.cache/nim/...` folder and simply doing `{.passL: "blah.cxx.o".}` doesn't find it.
14:49:19FromDiscord<jfmonty2> I mean there is, if you're using the regular conversions, but if you cast then all that goes out the window of course
14:49:30FromDiscord<Rika> well then there is the answer
14:49:39FromDiscord<jfmonty2> understandable but I will admit I was surprised since I was still intuitively expecting bounds checking to happen
14:50:06FromDiscord<Rika> https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-link-pragma @deech
14:50:13FromDiscord<Rika> would this help
14:52:26FromDiscord<carmysilna> In reply to @ElegantBeef "Tainted strings are opt": Oh, that’s funny. It was one of the features that drew me to Nim
14:55:28FromDiscord<Rika> its being rethought i believe
14:55:34FromDiscord<Rika> effects system is the modern equivalent
14:55:51FromDiscord<deech> @Rika Same issue. The object file is in the `cache` directly but `g++` can't find it.
14:56:05FromDiscord<carmysilna> The effects system is pretty cool as well.
14:56:37FromDiscord<deech> I'll ask in internals as well.
14:56:41FromDiscord<Rika> no clue then
14:56:50FromDiscord<haxscramper> If it was possible to enforce conversion via procedure and forbid .string this could make sense, otherwise tainted mode does not enforce it enough
14:57:33FromDiscord<Rika> yes but how would taintedstring -> string work?
14:57:47FromDiscord<Rika> are we restricting people regards which procs they can use now or something
14:58:21FromDiscord<Rika> are we adding a pragma `io` or an effect `parseeffect` or whatever that marks the proc for handling io
14:58:36FromDiscord<Rika> (i guess ioeffect already handles io)
14:58:50FromDiscord<Rika> i guess an effect isnt the way to go either
14:58:57FromDiscord<Rika> since that bubbles up
14:59:48FromDiscord<haxscramper> Isn't it what tainted mode was for?↵(@Rika)
15:00:07FromDiscord<haxscramper> To make everyone write converters and validate data
15:00:35FromDiscord<carmysilna> Well, there’s also “parse, don’t validate” to consider
15:00:36FromDiscord<Rika> i meant more "restricting" as in "people cannot make procs that handle stuff, it must go through stdlib stuff to convert" or so
15:00:43FromDiscord<Rika> (ofc stupid idea)
15:02:28FromDiscord<carmysilna> Maybe all io functions in the stdlib could also accept Twitter strings as input and it would be assumed that they would be properly sanitized
15:04:10FromDiscord<Rika> twitter strings?
15:04:53FromDiscord<carmysilna> Sorry, autocorrect. Tainted strings
15:05:43FromDiscord<Rika> that doesnt seem sensible; i dont understand exactly
15:06:51FromDiscord<carmysilna> So readFile accepts TaintedString as wells as string, and properly sanitizes the tainted string so that it is safe to open as a file name
15:07:59FromDiscord<Rika> hmm
15:08:13FromDiscord<Rika> that sounds complex
15:08:21FromDiscord<Rika> every proc that takes in a string needs to have a counterpart then
15:08:40FromDiscord<konsumlamm> In reply to @carmysilna "Oh, that’s funny. It": it's deprecsted in devel now
15:08:47FromDiscord<haxscramper> No, `readFile` path has very little to do with tained strings
15:08:47FromDiscord<konsumlamm> (edit) "deprecsted" => "depreca5ed"
15:08:54FromDiscord<konsumlamm> (edit) "depreca5ed" => "deprecated"
15:08:54FromDiscord<haxscramper> It has everything to do with `AbsFile = distinct string`
15:09:06FromDiscord<haxscramper> What it returns can be tainted string
15:09:26FromDiscord<haxscramper> Data from the outside world is 'tainted' and should be validated
15:11:12FromDiscord<haxscramper> That is also true, more or less. Handling absolutely everything via simple `string` - absolute/relative directory/file/link paths, environment variable names etc. is not the best idea↵(@Rika)
15:11:20FromDiscord<haxscramper> at least because of the overloading
15:11:42FromDiscord<haxscramper> Otherwise we end up with `removeFile`, `removeDir` as if we didn't have static typing
15:12:27FromDiscord<haxscramper> Well, remove procs might benefit from being explicit, so `exists()` or `.ext()` is a better
15:12:33FromDiscord<haxscramper> example
15:18:04FromDiscord<carmysilna> In reply to @konsumlamm "it's deprecated in devel": Oh, okay, good to know
15:27:51*Guest30 joined #nim
15:28:09*Guest30 quit (Client Quit)
15:51:54*stkrdknmibalz quit (Quit: WeeChat 3.0.1)
16:04:07*stkrdknmibalz joined #nim
17:03:50FromDiscord<tandy> im trying to import a file from a parent dir, \`import ../types\` but i'm having trouble getting it to work..
17:07:29FromDiscord<haxscramper> What is the error, or how does it fail?
17:07:29FromDiscord<tandy> oh nvm, the other file was importing the file i was trying to import from
17:29:58FromDiscord<tandy> is it possible to import like this \`import ../[types, utils]\`?
17:34:50FromDiscord<Ayy Lmao> sent a code paste, see https://play.nim-lang.org/#ix=3tmR
17:35:17FromDiscord<Ayy Lmao> I can't seem to capture `window` inside `windowProc` because it needs to be `stdcall`
17:37:44FromDiscord<Ayy Lmao> I basically just want to define my own draw procedure on a per window basis.
17:39:33FromDiscord<demotomohiro> Only closure proc can capture, other proc cannot.
17:39:58FromDiscord<haxscramper> IIRC you have to do `import ".."/[types, utill]`
17:40:19FromDiscord<Ayy Lmao> So am I basically forced to keep a table of all HWND : Window pairs and look up the Window in `windowProc` ?
17:40:52FromDiscord<haxscramper> If the code is does not have to be threadsave you can use `{.global.}` for captures
17:41:08FromDiscord<haxscramper> Copy captured variable to global, and make callback have `nimcall` or `stdcall`
17:41:13FromDiscord<haxscramper> But this is a hack
17:41:40FromDiscord<Ayy Lmao> In reply to @haxscramper "If the code is": Ideally I would like to stay away from something like that
17:42:04FromDiscord<haxscramper> Then you need to have lookup table somewhere else
17:42:37FromDiscord<Ayy Lmao> Alright, I figured that might be the case. It seems I was on the right track
17:42:47FromDiscord<haxscramper> Or you can store pair window + proc somehoa
17:43:55FromDiscord<Ayy Lmao> `windowProc` only gets a `HWND` passed in so that's all I have to go by to determine which window it is. I still need to look up the `Window` by its `HWND`
17:48:35FromDiscord<demotomohiro> Im usually use look up table like `Table[SomeId, ref Data]` when I use callback function in C library. Easy to detect use of id after freeing data.
17:49:40FromDiscord<demotomohiro> As long as id is never reused.
17:50:22FromDiscord<Ayy Lmao> In reply to @demotomohiro "Im usually use look": I will give it a try and see if I can get it working
17:55:53FromDiscord<demotomohiro> It seems this API can set pointer to user data on hWnd.↵https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptrw
17:58:11FromDiscord<Ayy Lmao> In reply to @demotomohiro "It seems this API": Unfortunately I am limited as to what I can use from the win api. I am making an extension for Reaper which ports a small subset of the win api over to OSX/Linux. So if I want cross platform compatibility I have to stay within those constraints.
17:59:10FromDiscord<Ayy Lmao> They do seem to have `SetWindowLong` supported though
18:16:50FromDiscord<Ayy Lmao> Using `Window` as a `ref object` and creating a lookup table seems to work.
19:16:22FromDiscord<Stuffe> It seems you can't make a const out of a ref object or an object with a ref in it. The only work around I can think of for having a self referential const object is using a seq in the type, any other ideas?
19:21:27FromDiscord<haxscramper> `ref` is const is not supported yet https://github.com/nim-lang/Nim/pull/15528
19:22:03FromDiscord<haxscramper> And I don't think there are any workarounds, at least if you need `ref`
19:31:20FromDiscord<ache of head> sent a code paste, see https://play.nim-lang.org/#ix=3tn7
19:31:51FromDiscord<ache of head> and in general use expressions like this?
19:32:54FromDiscord<ache of head> the reason i'm asking this and not doing if something: echo a else: echo b is because i want to conditionally include something in a longer stdout.write
19:33:24FromDiscord<konsumlamm> In reply to @c1m5j "is there a way": if you would have tried that, you would have seen that it indeed works
19:34:07FromDiscord<ache of head> i tried it and it doesn't work 🤔
19:34:28FromDiscord<ache of head> i wouldn't have asked if hadn't checked 😛
19:35:23FromDiscord<ache of head> i get a "expression is of type string and has to be used or discarded" error
19:39:48FromDiscord<konsumlamm> huh
19:39:59FromDiscord<konsumlamm> do `a` and `b` have the same typem
19:40:03FromDiscord<konsumlamm> (edit) "typem" => "type?"
19:40:54FromDiscord<ache of head> sent a code paste, see https://play.nim-lang.org/#ix=3tna
19:41:24FromDiscord<ache of head> hmm
19:41:28FromDiscord<ache of head> i added an else clause and it worked
19:41:30FromDiscord<ache of head> interesting
19:43:16FromDiscord<ynfle (ynfle)> If not ,there is no type
19:43:26FromDiscord<konsumlamm> In reply to @c1m5j "well, even something like": why would it? there is no value for the else case
19:44:10FromDiscord<ache of head> so an else clause is required?
19:44:36FromDiscord<ynfle (ynfle)> Yes
19:44:38FromDiscord<@bracketmaster-5a708063d73408ce4> Is there any way to make this work?↵↵var str = "hello"↵var xyz \: array[str.len, int]
19:44:41FromDiscord<ynfle (ynfle)> For an expression at least
19:44:54FromDiscord<ynfle (ynfle)> @BracketMaster What's the issue
19:45:12FromDiscord<@bracketmaster-5a708063d73408ce4> I need to statically create an array with the length of a certain string
19:45:23FromDiscord<ynfle (ynfle)> It needs to be const
19:45:34FromDiscord<Bung> @haxscramper interesting! how you pass around ref types and returns between them.
19:45:42FromDiscord<ynfle (ynfle)> Else, the compiler doesn't know the length
20:17:25FromDiscord<haxscramper> In reply to @Bung "<@!608382355454951435> interesting! how you": Will test this tomorrow
20:18:20FromDiscord<ynfle (ynfle)> Do default parameters get reevaluated at every call?
20:18:51*krux02 joined #nim
20:22:27FromDiscord<haxscramper> Yes, use expandMacros to see how they are substituted
20:23:48FromDiscord<ynfle (ynfle)> Expand macros? I didn't know it was a macro
20:24:08FromDiscord<haxscramper> It is not a macro
20:24:27FromDiscord<haxscramper> expand macros shows ast after all expansions and substitutions
20:24:32FromDiscord<haxscramper> Not only macros
20:24:57FromDiscord<ynfle (ynfle)> Oh
20:24:59FromDiscord<ynfle (ynfle)> Interesting
20:25:11FromDiscord<ynfle (ynfle)> `proc t(x = now()) = echo x`
20:25:30FromDiscord<ynfle (ynfle)> sent a code paste, see https://play.nim-lang.org/#ix=3tnj
20:25:32FromDiscord<ynfle (ynfle)> `t(now())`
20:30:35krux02actually expandMacros is a macro
20:30:37krux02I wrote it
20:36:03FromDiscord<hamidb80> hey krux
20:45:10FromDiscord<Schelz> hi, guys in not so experienced with nim but im with python, can someone please give me some websites where i can learn nim ?
20:46:57FromDiscord<carmysilna> In reply to @Schelz "hi, guys in not": https://github.com/nim-lang/Nim/wiki/Nim-for-Python-Programmers
20:47:11FromDiscord<Schelz> thx
20:48:17FromDiscord<Lefl> Hey, I'm using a library that implements a function `id(n: Node)` now the problem is I have an object that has a property `id: int`. How do I access the property? nim thinks I want to call the proc and raises an error
20:50:50nixfreak_nim[m]what am I doing wrong that .toCss isn't recognized ? https://play.nim-lang.org/#ix=3tnl
20:51:26nixfreak_nim[m]Error: undeclared field: 'toCss' for type system.string
20:59:08nixfreak_nim[m]Ok, nm I just reinstalled karax again and it seemed to work
21:03:17FromDiscord<ElegantBeef> @Lefl what library?
21:03:35FromDiscord<Lefl> Eh I meant module
21:03:45FromDiscord<Lefl> the `dom` one in the standard library
21:04:44*kayabaNerve joined #nim
21:05:35FromDiscord<Lefl> Oh maybe I'm stupid
21:07:18FromDiscord<ElegantBeef> There is no id field that i see for node
21:11:52FromDiscord<Lefl> Well I forgot to import the Object from my own module
21:33:46FromDiscord<@bracketmaster-5a708063d73408ce4> https://play.nim-lang.org/#ix=3tnB↵↵For some reason, mysice is of type seq[NimNode] instead of string?
21:33:49FromDiscord<@bracketmaster-5a708063d73408ce4> Macros are werid
21:37:52FromDiscord<ElegantBeef> It's not a `static` so it's taken as a Nimnode cause it can be an symbol or a literal
21:38:58FromDiscord<ElegantBeef> https://play.nim-lang.org/#ix=3tnC using static
22:24:21*beshr quit (Remote host closed the connection)
22:34:47FromDiscord<@bracketmaster-5a708063d73408ce4> thanks
22:49:49FromDiscord<demotomohiro> This news is related to Nim because Nim calls gcc in default and gcc calls `as` and `ld` in binutils.↵https://news.ycombinator.com/item?id=27875405
22:51:56FromDiscord<@bracketmaster-5a708063d73408ce4> Anything in particular about binutils I'm supposed to notice on that thread?
22:52:21FromDiscord<@bracketmaster-5a708063d73408ce4> It's a nice release note I guess
22:57:21fn<ForumUpdaterBot99> New thread by Fire: New Nim Discussion Site, see https://forum.nim-lang.org/t/8242
23:26:13*max22- quit (Remote host closed the connection)
23:31:29FromDiscord<ajusa> What's the recommended way to interface with a C style array? `cstring`, `UncheckedArray`, `openarray`?