<< 12-09-2022 >>

00:14:06*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
00:44:47*arkanoid joined #nim
00:46:03arkanoidI have a vanilla javascript function that I want to make fast (need to call it billions of times). Is there a js -> nim thing?
00:48:19FromDiscord<auxym> sent a code paste, see https://play.nim-lang.org/#ix=4afZ
00:48:55FromDiscord<Elegantbeef> it imports a variable that is a `uint8` in C
00:49:13FromDiscord<auxym> result in this codegen? `extern NU8 desc_cdc_itf;` I'm getting a segfault and according to SO, it's because the codegen should be `extern NU8 desc_cdc_itf[]`;
00:49:25FromDiscord<auxym> In reply to @Elegantbeef "it imports a variable": sorry, hit enter too soon 😛
00:49:29FromDiscord<Elegantbeef> Those are the same thing
00:49:43FromDiscord<auxym> not according to https://stackoverflow.com/questions/21642741/usage-of-extern-variable-in-c
00:50:06FromDiscord<auxym> and dereferencing in nim like `tusbCdcDesc[0]` segfaults
00:50:42FromDiscord<Elegantbeef> The difference is they're using static sized arrays
00:50:48FromDiscord<Elegantbeef> `NU a` is the same as `NU a[]`
00:51:03FromDiscord<Elegantbeef> Eitherway you can use codegendecl
00:51:09FromDiscord<auxym> sooo... how do I not segfault?
00:51:36FromDiscord<auxym> codegendecl the only way? If so I'd argue that's a nim codegen bug...
00:51:49FromDiscord<Elegantbeef> `let tusbCdcDesc {.importc: "desc_cdc_itf", nodecl.}: ptr UncheckedArray[uint8]` ?
00:53:05FromDiscord<auxym> nah I need an extern declaration, the var is from another c file included in the build
00:56:43FromDiscord<Elegantbeef> I dont think it is a Nim codegen bug↵(@auxym)
00:56:59FromDiscord<Elegantbeef> It's more of a C design bug
00:57:22FromDiscord<Elegantbeef> If `int a[]` and `int a` are not compatible in some cases C fucked up 😄
00:57:46FromDiscord<auxym> is it just because it's a static array? It would work without the codegendecl if it was a ↵"regular" array declaration, and nim has no way of knowing if it's a static array?
00:58:20FromDiscord<Elegantbeef> bunt `int a[]` isnt a static array
00:58:22FromDiscord<Elegantbeef> but\
00:59:11FromDiscord<auxym> blah. people say "C is a beautiful language because it's so simple" but then there's a 1000 gotchas...
01:01:11FromDiscord<Elegantbeef> Ah nvm `int a[]` is invalid C
01:01:25FromDiscord<auxym> In reply to @Elegantbeef "bunt `int a[]` isnt": my C file has something like `uint8 const desc_cdc_itf[] = {...stuff...}`. In which case would the `NU8` declaration be valid then?
01:01:38FromDiscord<Elegantbeef> that's an inferred length static array
01:01:58FromDiscord<auxym> yeah. so `NU8` would work only for a non-static array?
01:02:12FromDiscord<Elegantbeef> Yes i was wrong about C's `[]` semantics 😄
01:02:28FromDiscord<Elegantbeef> So you just need to do `array[sizeof(desc_cdc_itf), uint8]`
01:03:14FromDiscord<Elegantbeef> Yes you need to figure out the size in C 😄
01:03:34FromDiscord<auxym> ah lemme try that. `let tusbCdcDesc {.importc: "desc_cdc_itf", codegenDecl:"extern uint8_t $2[]".}: ptr UncheckedArray[uint8]` seemed to be working though
01:03:54FromDiscord<Elegantbeef> It'll work but it's ugh
01:03:59FromDiscord<auxym> yeah
01:04:47FromDiscord<auxym> its just unit tests though, to get access to data generated in C stuff, and making sure I'm generating the same stuff in Nim.
01:05:09FromDiscord<auxym> anyways, much C fun. ty for the help understanding this stuff (sort of).
01:05:24FromDiscord<Elegantbeef> Hey i've been doing dumb shit with a wasm runtime, C is making me scared of code
01:06:15FromDiscord<Elegantbeef> This runtime is quite barebones and as such does some funky Cism
01:06:49FromDiscord<Elegantbeef> Like it has a function that takes in a stack pointer and then to get result/arguments from the vm you increment the pointer and grab the data at that pointer
01:07:18FromDiscord<Elegantbeef> So you end up with something like `cast[ptr returnType(p)](stackPointer) = p(cast[ptr typeof(param[0])](stackPointer + sizeof(uint64) 0)[], ..)`
01:07:33FromDiscord<auxym> 🥲
01:07:44FromDiscord<Elegantbeef> Luckily we have macros so i can generate this all
01:07:49FromDiscord<Elegantbeef> macros really make life so much better
01:08:21FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ag4
01:09:48FromDiscord<auxym> yep. took me a while to wrap my head around macros but yeah they do save your butt sometimes
01:11:26FromDiscord<auxym> generics too. this is just magic: https://github.com/treeform/flatty/blob/master/src/flatty.nim#L158 Like you can just calls fields in an implicit magic and it'll just codegen the correct proc for any object type?
01:11:48FromDiscord<Elegantbeef> any object type
01:12:30FromDiscord<auxym> yeah, magic. Was about to write a somewhat macro to do the same thing, until I can across that and had my mind blown.
01:12:44FromDiscord<Elegantbeef> It doesnt work for every object
01:12:49FromDiscord<Elegantbeef> It fails on tagged unions
01:13:12FromDiscord<Elegantbeef> I personally use `typeIt` from https://github.com/disruptek/assume
01:13:26FromDiscord<Elegantbeef> I did write my own ugly variant for nimscripter, but it has some very peculiar requirements
01:13:42FromDiscord<auxym> meh, it works on normal objects, which is just what I need 😄
01:13:49FromDiscord<Elegantbeef> Also works on tuples
01:14:00FromDiscord<Elegantbeef> But yea not on references(without dereference or tagged unions)
01:16:01*jmdaemon joined #nim
01:26:59FromDiscord<! Nilts> In reply to @Patitotective "read https://github.com/PMunch/futhark": I can’t seem to install it.
01:28:04FromDiscord<SaAnd> do you have clang installed?
01:32:16FromDiscord<! Nilts> In reply to @SaAnd "do you have clang": no
01:32:52FromDiscord<SaAnd> you need that
01:33:45FromDiscord<! Nilts> Ok
01:44:03FromDiscord<! Nilts> Now, i am utterly confused. I want to import libtidy. Thats all. Wtf is sysPath and do i need it. I Am. Confused
01:47:20FromDiscord<Elegantbeef> Cause the library is exposed as a C-api you need that in something Nim understands
01:47:30FromDiscord<Elegantbeef> You either need to use c2nim, futhark, or manually import the C code into Nim
01:47:50FromDiscord<Elegantbeef> Futhark uses libclang to parse the C api and converts that into Nim
02:08:20*wallabra_ joined #nim
02:09:41*wallabra quit (Ping timeout: 265 seconds)
02:10:30*wallabra_ is now known as wallabra
02:25:07*arkurious quit (Quit: Leaving)
02:53:33FromDiscord<ravinder387> image.writeFile("C:\Users/ravin/Pictures/pixie/square.png")
02:54:04FromDiscord<ravinder387> don't save png i tried \, \\, // slashes
02:54:30FromDiscord<ravinder387> sent a long message, see http://ix.io/4agk
02:54:53FromDiscord<Yardanico> that's not how you write Windows paths
02:55:01FromDiscord<Yardanico> either use raw strings (with `r`) or `\\`
02:56:30FromDiscord<ravinder387> sent a long message, see http://ix.io/4agl
02:56:40FromDiscord<ravinder387> I see empty in my pixie folder
02:57:35FromDiscord<Yardanico> In reply to @ravinder387 "`import pixie let": also, please use Discord code blocks in the future, it's much easier to read and the bridges can parse it properly
02:58:02FromDiscord<Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4agm
02:58:22FromDiscord<Yardanico> does your code show any errors?
02:58:40FromDiscord<ravinder387> no
02:59:10FromDiscord<Yardanico> I just tried and the code works fine for me, are you sure you're not looking in the wrong folder?
02:59:16FromDiscord<Yardanico> of course I changed username to my own
03:00:11FromDiscord<Yardanico> try pasting `C:\Users\ravin\Pictures\pixie` into the explorer address input, and pressing enter
03:02:08FromDiscord<ravinder387> https://media.discordapp.net/attachments/371759389889003532/1018718125891539044/2022-09-12_083104.mp4
03:03:07FromDiscord<Yardanico> and can you show how you're executing the code?
03:04:41FromDiscord<ravinder387> https://media.discordapp.net/attachments/371759389889003532/1018718766030405743/2022-09-12_083346.mp4
03:05:11FromDiscord<Yardanico> you're not actually running the binary
03:05:20FromDiscord<Yardanico> `nim c file.nim` just _compiles_ the code, it doesn't execute
03:05:26FromDiscord<Yardanico> if you want to compile and execute use `nim c -r file.nim`
03:05:35FromDiscord<Yardanico> or first compile, and then execute the .exe manually yourself
03:06:39FromDiscord<ravinder387> i execute .\app.exe
03:07:07FromDiscord<ravinder387> thanks very much https://media.discordapp.net/attachments/371759389889003532/1018719377312460811/2022-09-12.png
03:07:13FromDiscord<Yardanico> np
03:43:05FromDiscord<SaAnd> has anyone used drchaos here?
03:43:37arkanoidthe output of linux echo "foo" | sha1sum and nim's std/sha1 for same input are not equal
03:44:20FromDiscord<SaAnd> im getting a linker error for LLVMFuzzerMutate
03:44:38FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4ags
03:44:40FromDiscord<SaAnd> even for an the example
03:45:05FromDiscord<Elegantbeef> You need to do `exportC`
03:46:29FromDiscord<Elegantbeef> Do you have all it's deps?!
03:46:35FromDiscord<Elegantbeef> Shit no need for interrobang
03:46:41FromDiscord<SaAnd> thats what im not sure of
03:46:44FromDiscord<SaAnd> i have clang
03:47:05FromDiscord<Elegantbeef> @geekrelief\: that `myFunc` in the `mylib.nim` should have `exportC` on it
03:47:20FromDiscord<geekrelief> ah thanks beef!
03:47:37FromDiscord<Elegantbeef> You need `libfuzzer `saand
03:48:57FromDiscord<SaAnd> when i look at https://llvm.org/docs/LibFuzzer.html it says that for clang \> 6.0 it should be installed
03:49:13FromDiscord<SaAnd> at fuzzer usage
03:49:14FromDiscord<Elegantbeef> Might need dev packages?
03:50:49FromDiscord<Elegantbeef> Pinging planetis might get an answer for you saand
03:50:51FromDiscord<Elegantbeef> So we'll see
03:51:03FromDiscord<Elegantbeef> They're in some EU time so may get a response soon
04:13:43FromDiscord<ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agy
04:14:00FromDiscord<ravinder387> how to wrap this js class in nim any idea?
04:14:41FromDiscord<ravinder387> like we do calling c in nim
04:28:56*wallabra quit (Ping timeout: 268 seconds)
04:31:23FromDiscord<ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agE
04:31:48FromDiscord<ravinder387> when i compile this then open browser console it says age() is not defined
04:39:01FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4agF
04:39:48FromDiscord<Elegantbeef> you dont need `header` on the proc afaik since it's statically linked
04:39:59FromDiscord<Elegantbeef> That might be wrong though 😄
04:40:01FromDiscord<geekrelief> if I don't add header nim complains
04:40:26FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4agG
04:41:20FromDiscord<geekrelief> I'm wondering if with just the declarations we can make nimforue compile faster
04:46:29FromDiscord<Elegantbeef> Yea that makes sense after i said it
05:35:55*jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in)
05:55:30FromDiscord<ravinder387> In reply to @Elegantbeef "Yea that makes sense": how to use jsffi
05:55:58FromDiscord<Elegantbeef> The same as C ffi
05:56:18FromDiscord<Elegantbeef> Provide a example of what doesnt work and i'll help, i'm not going to write it for you. Half of learning is effort
05:56:26FromDiscord<ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agO
05:56:43FromDiscord<ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agy
05:57:02FromDiscord<Elegantbeef> You're importing a procedure call
05:57:10FromDiscord<Elegantbeef> `{.importJs: "age".}`
05:57:31FromDiscord<ravinder387> sent a long message, see http://ix.io/4agR
05:58:44FromDiscord<ravinder387> Error: `importjs` for routines requires a pattern
05:58:52FromDiscord<Elegantbeef> `importC` then
05:59:03FromDiscord<Elegantbeef> or you know copy the code you're copying proc jq(selector\: JsObject)\: JsObject {.importjs\: "$$(#)".}
05:59:06FromDiscord<Elegantbeef> Whoops
05:59:06FromDiscord<Elegantbeef> `proc jq(selector: JsObject): JsObject {.importjs: "$$(#)".}`
05:59:29FromDiscord<Elegantbeef> https://github.com/nim-lang/Nim/blob/version-1-6/lib/std/jsfetch.nim is an example of a wrappepd api
06:14:01*mahlon quit (Ping timeout: 250 seconds)
06:20:21*wallabra joined #nim
06:21:40*mahlon joined #nim
08:19:01*buster_blue[m] quit (Quit: Bridge terminating on SIGTERM)
08:19:08*reversem3[m] quit (Quit: Bridge terminating on SIGTERM)
08:25:42*buster_blue[m] joined #nim
08:34:40*derpydoo quit (Quit: derpydoo)
08:35:37*rockcavera quit (Remote host closed the connection)
08:40:00*neceve quit (Quit: ZNC - https://znc.in)
08:40:46*neceve joined #nim
08:51:47*m5zs7k quit (Ping timeout: 248 seconds)
08:54:20*m5zs7k joined #nim
09:00:01*reversem3[m] joined #nim
09:43:02*supakeen left #nim (WeeChat 3.4)
10:21:27*wallabra quit (Ping timeout: 250 seconds)
11:29:48FromDiscord<dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4ahC
11:31:28FromDiscord<dlesnoff> There is a lot of getType functions in std/macros, but since these are defined with the `magic` pragma, I don't understand what they do.
13:05:05*arkurious joined #nim
13:10:34*derpydoo joined #nim
13:48:51*monkeybusiness joined #nim
13:49:43*qwr quit (Ping timeout: 252 seconds)
14:00:51FromDiscord<Require Support> is there documentation for chronos? or documented examples on using httpclient? I saw the examples but need something with a bit more commentary 🤔
14:02:15FromDiscord<Patitotective> In reply to @Require Support "is there documentation for": i don't think there is actual documentation, but https://discord.com/channels/371759389889003530/979844494205812806/994776608961478686
14:04:48*rez joined #nim
14:05:26FromDiscord<Require Support> In reply to @Patitotective "i don't think there": perfect, thanks so much
14:05:49*rockcavera joined #nim
14:05:49*rockcavera quit (Changing host)
14:05:49*rockcavera joined #nim
14:37:36*rez quit (Ping timeout: 268 seconds)
14:43:39*qwr joined #nim
15:36:44FromDiscord<rolha> Hi everyone, when using `osproc/startProcess(...)` I can print the output in "realtime" using the output stream. But when using `option={poEvalCommand}` I cannot. Is this expected, or am I doing something wrong.
15:42:08FromDiscord<leorize> yes it is expected
15:43:03FromDiscord<rolha> leorize\: thanks. Is there a way to execute a shell command and still being able to have an output stream?
15:43:15FromDiscord<leorize> oh wait no lol
15:43:36FromDiscord<leorize> you should still be able to read from the streams
15:46:50FromDiscord<rolha> Cool, I'll try that. thanks.
15:48:01FromDiscord<leorize> I'd not recommend readLine due to the way this sort of reading works tbf
15:48:24FromDiscord<leorize> also poParentStreams can be useful if you just want to forward the data without looking into it
15:48:37FromDiscord<Patitotective> this might be useful https://github.com/Patitotective/ImNimble/blob/main/src/processes.nim#L29
15:49:24FromDiscord<leorize> since the process stream is unbuffered, reading a line basically means you're reading character by character until a newline is found
15:51:08FromDiscord<planetis> SaAnd\: you need to pass the correct flags to the compiler. look at the nim.cfg in the tests directory. I should add it to the docs
15:52:33FromDiscord<rolha> leorize, @!Patitotective thanks for the tips. I'll try to first find if there's a problem (the commands do run, I've checked) and if I can read the stream some other way.
16:49:30FromDiscord<soda> Is there a quick way to prune strings to remove things like carriage or newline symbols?
16:50:53FromDiscord<soda> also, how to run a system command?
16:51:20FromDiscord<soda> sent a code paste, see https://play.nim-lang.org/#ix=4ajg
16:58:39FromDiscord<ezquerra> In reply to @soda "the equivalent of C++'s": https://nim-lang.org/docs/osproc.html#execCmd%2Cstring
16:58:57FromDiscord<soda> Thanks
16:59:14FromDiscord<ezquerra> You can also have a look at https://github.com/Vindaar/shell
17:00:27FromDiscord<Zoom> sent a code paste, see https://paste.rs/XLe
17:00:29FromDiscord<ezquerra> In reply to @soda "Is there a quick": https://nim-lang.org/docs/strbasics.html#strip%2Cstring%2Cset%5Bchar%5D
17:00:36FromDiscord<ezquerra> Although that will also strip other white space
17:00:46FromDiscord<ezquerra> Not just newlines
17:01:09FromDiscord<Zoom> I have a suspicion `invokeExternalProcess` gets reordered before the lock release, judging from how the processes executed from this proc behave.
17:02:55FromDiscord<soda> In reply to @ezquerra "https://nim-lang.org/docs/strbasics.html#strip%2Cst": Seems to be the right thing. The delimiter is customizable
17:14:36FromDiscord<rakgew> when I build my app, it compiles fine with↵`nim c --cincludes=libs/libgit2/include --clibdir=libs/libgit2/lib --passL=libs/libgit2/lib/libgit2.so gitapp/gitapp.nim`↵but when I try to run it, it still asks for libgit2.so, not using the one specified in `--passL`.↵is thera a way(some compile option), so that it does not need an extra copy/symlink next to it?
17:19:48*jmdaemon joined #nim
17:20:10*rockcavera quit (Remote host closed the connection)
17:20:16FromDiscord<rolha> Ok, so I found the problem and it was quite silly. The above code worked in some cases but not others, but it was a shell issue. If I used tilde in the commands it would not work.↵So replacing `foo ~/bar` with `foo $HOME/bar` works everytime.
17:30:40*sforman joined #nim
17:44:54NimEventerNew question by Andr&#233;s Hein: Problema con Java libreria NimRODLookAndFeel y base de datos, see https://stackoverflow.com/questions/73693260/problema-con-java-libreria-nimrodlookandfeel-y-base-de-datos
17:52:54FromDiscord<Rika> Lol
18:04:02*rockcavera joined #nim
18:04:02*rockcavera quit (Changing host)
18:04:02*rockcavera joined #nim
18:14:18FromDiscord<that_dude> Who thought nimrod is another thing as well
18:31:17*kenran joined #nim
18:45:46FromDiscord<Require Support> anyone familiar with chronos know the quickest add my own headers to a request?
18:56:14FromDiscord<Bung> https://github.com/status-im/nim-chronos/blob/master/tests/testhttpclient.nim here's the test file
18:57:44FromDiscord<Bung> before you request you should initialize a client, so you can request multiple times
19:02:01FromDiscord<Require Support> yes, im going off the test file but from what I'm understanding is that I cant specify headers when creating a client? or maybe im missing something
19:06:57FromDiscord<aruZeta> In reply to @NimEventer "New question by Andr&#233;s": man at least use google translate 💀
19:09:17FromDiscord<Bung> In reply to @Require Support "yes, im going off": the lib can't assuming you always use same headers for each request
19:28:31FromDiscord<Require Support> In reply to @Bung "the lib can't assuming": so how can I go about specifying my own `User-Agent` ? Create session then create `HttpCientRequestRef` object and specify session with my user-agent header?
19:29:55*FromDiscord quit (Remote host closed the connection)
19:30:08*FromDiscord joined #nim
19:32:26FromDiscord<Bung> nothing special , u have variable store your common headers for each request concatenate with your extrovert headers like u do in other languages or libs
19:32:54FromDiscord<Bung> (edit) "concatenate" => "concate" | "extrovert" => "extro"
19:37:43FromDiscord<geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4ajT
19:38:05FromDiscord<geekrelief> if I comment out the `"C"` from NIM_EXTERNC, I still get the error.
19:38:37FromDiscord<geekrelief> seems like the compiler check for backend:cpp is failing somehow.
19:58:29NimEventerNew thread by archnim: Turning a tuple to json, see https://forum.nim-lang.org/t/9461
19:59:21*wallabra joined #nim
20:00:46FromDiscord<EyeCon> Do we have a timezone implementation? I found https://github.com/GULPF/timezones which seems to be reasonably well implemented but doesn't seem to work with the newest timezone files.
20:15:43FromDiscord<Elegantbeef> I dont think so, you have the CABI which means you need to give each overload it's own name↵(@geekrelief)
20:47:50FromDiscord<geekrelief> In reply to @Elegantbeef "I dont think so,": looks like I'll need to modify the compiler then
21:30:24FromDiscord<choltreppe> sent a code paste, see https://play.nim-lang.org/#ix=4akl
21:40:45FromDiscord<Bung> your test dispatch is totally wrong
21:42:54FromDiscord<choltreppe> ok. how would it be correct?
21:44:04*kenran quit (Quit: WeeChat info:version)
21:47:32FromDiscord<Bung> nvm I miss read that long line
21:50:00FromDiscord<Bung> u can echo time inside test
21:50:30FromDiscord<Bung> see what's happening , with start time and end time
21:51:00FromDiscord<Bung> the code is not practical though
21:51:18FromDiscord<dain> sent a code paste, see https://play.nim-lang.org/#ix=4akq
21:52:38FromDiscord<choltreppe> yea its just a simplified version of the problem, not my real code
21:56:05FromDiscord<Bung> maybe use async sleep simulate the busy logic?
21:57:06FromDiscord<Bung> In reply to @dain "back again on this": search issue there's similar one
22:00:30FromDiscord<dain> not sure which you mean
22:00:59FromDiscord<dain> oh and there's also this https://nim-lang.org/blog/2021/10/19/version-160-released.html `iterable[T]` thing introduced which works for 3 but not 1 and 2 ..
22:01:07FromDiscord<dain> why is this so confusing x_x
22:03:42FromDiscord<choltreppe> ok ist works with sleepAsync. but why doesnt ist work with the loop. it takes way longer then 1ms, i messured
22:05:01*sagax quit (Read error: Connection reset by peer)
22:07:53FromDiscord<Elegantbeef> `iterable` only works for templates↵(@dain)
22:08:00FromDiscord<Elegantbeef> Whoops misread 😄
22:09:35FromDiscord<Bung> In reply to @choltreppe "ok ist works with": am curious now, I'd try myself , leaving my bed
22:11:21FromDiscord<Elegantbeef> The issue Dain is that iterators are just not chosen for procedure calls so you have to use templates
22:11:34FromDiscord<Elegantbeef> You can use `iterable[T]` but then you need to do `.items` on collections
22:13:58FromDiscord<Bung> https://github.com/nim-lang/RFCs/issues/397
22:14:27FromDiscord<Elegantbeef> Eh iterable is a meh addition anyway
22:15:34FromDiscord<dain> ughghg why is this so hard
22:15:50FromDiscord<Elegantbeef> Cause Nim inline iterators are glorified templates
22:16:08FromDiscord<dain> why isnt seq an iterable
22:16:15FromDiscord<Elegantbeef> Cause it's not a iterator
22:16:18FromDiscord<Elegantbeef> you need to call `.items`
22:16:22FromDiscord<Elegantbeef> iterable only takes iterators
22:16:23FromDiscord<dain> so why call it iterable
22:16:26FromDiscord<dain> instead of just iterator
22:16:27*jmdaemon quit (Ping timeout: 250 seconds)
22:16:40FromDiscord<Elegantbeef> Cause it's a generic typeclass over all iterators that yield T
22:16:53FromDiscord<Elegantbeef> Like i said iterable is very ill designed and a cludge hack
22:16:57FromDiscord<dain> but the word iterable means "that which can be be iterated over"
22:17:06FromDiscord<dain> a seq can be iterated over therefore it's an iterable
22:17:18FromDiscord<Elegantbeef> Dont look at me i didnt implement iterable
22:17:25FromDiscord<Elegantbeef> I like the idea but it's a god awful implementation
22:20:00FromDiscord<huantian> Consider python: list is an iterable because you can call iter() on it to get an iterator
22:20:08FromDiscord<dain> okay once and for all i want to find this out: how do you write a proc/template that takes an iterable (the common sense english definition of iterable meaning something i can loop over) and does something useful with it
22:20:21FromDiscord<Elegantbeef> You use a concept
22:20:28FromDiscord<Elegantbeef> But it will never be able to accept a `iterator`
22:20:40FromDiscord<dain> yeah that's my problem the concept doesnt work
22:20:52FromDiscord<huantian> But in python list is not an iterator, that’s the general convention of iterable vs iterator
22:20:54FromDiscord<Elegantbeef> A proc cannot take a non closure iterator
22:20:59FromDiscord<Elegantbeef> You have to use a template
22:21:29FromDiscord<dain> a template of untyped -> untyped?
22:22:18FromDiscord<Elegantbeef> You have to use untyped if you want to take iterators cause Nim does not consider iterators in dispatch
22:22:54FromDiscord<dain> i want something that can take: a seq, a slice, a closure iterator, an inline iterator, and any other iterable-oid thing i haven't thought of. and just treat them all the same
22:23:06FromDiscord<dain> with minimum fuss
22:23:08FromDiscord<Elegantbeef> You have to use untyped there then
22:23:24FromDiscord<dain> okay. so `template(foo: untyped): untyped` is the right way(tm) ?
22:23:26FromDiscord<Elegantbeef> I can only say nim doesnt have a explicit way to handle this so many types
22:23:34FromDiscord<Elegantbeef> so many times\
22:24:20FromDiscord<Elegantbeef> Yes it's the "right way"
22:24:24FromDiscord<dain> okay
22:25:04FromDiscord<dain> thanku
22:29:29FromDiscord<Bung> In reply to @choltreppe "ok ist works with": u block the cpu, there's nothing to do with async
22:31:00FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4akx
22:34:21FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4aky
22:35:01FromDiscord<choltreppe> sent a code paste, see https://play.nim-lang.org/#ix=4akz
22:35:27FromDiscord<choltreppe> just not that nice to implement in my real code
22:35:40FromDiscord<choltreppe> think ill use threads
22:36:20FromDiscord<dain> In reply to @Bung "https://github.com/nim-lang/RFCs/issues/397": > This proposal would allow a value a with items(a) defined on it to match against iterable[T], in the same way that for implicitly adds items:↵yeah that would be a nice addition. that's how i thought it worked already until i tried
22:37:13FromDiscord<Bung> sent a code paste, see https://play.nim-lang.org/#ix=4akA
22:37:25FromDiscord<Elegantbeef> you mean io bound?
22:38:02FromDiscord<Bung> yeah, that's async for , right ?
22:38:12FromDiscord<Elegantbeef> Yes
22:39:01FromDiscord<Bung> but choltreppe examples does not simulate the real way
22:42:18FromDiscord<! Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4akD
22:45:03FromDiscord<Bung> nothing can help, any code ?
22:45:59FromDiscord<! Nilts> In reply to @Bung "nothing can help, any": line 52 ` node.text = getUrl(url)`. node is a XmlNode
22:49:37FromDiscord<Bung> dont know how you construct the node , node.k is not in range like the error reported
22:50:50FromDiscord<! Nilts> In reply to @Bung "dont know how you": What? the node is a normal XmlNode. It was constructed by parsehtml
22:51:49FromDiscord<Bung> https://github.com/nim-lang/Nim/blob/c9a92117f9b78e3227dfe2cdcc7cf5b113185832/lib/pure/xmltree.nim#L40-L67
22:52:07FromDiscord<! Nilts> In reply to @Bung "https://github.com/nim-lang/Nim/blob/c9a92117f9b78e": what about it
22:52:25FromDiscord<Bung> you see `case k: XmlNodeKind`
22:53:52FromDiscord<Bung> you'll need echo node.kind see what's the node kind
22:59:18FromDiscord<! Nilts> In reply to @Bung "you'll need echo node.kind": `xnElement` is node.kind
22:59:54FromDiscord<Bung> so that's why u get this error, it requires ` {xnText, xnComment, xnCData, xnEntity}`
23:00:32FromDiscord<! Nilts> In reply to @Bung "so that's why u": ? ok
23:11:52FromDiscord<dain> are there any benchmarks comparing inline iterators to closure iterators? how much performance overhead do the closure ones have
23:12:23FromDiscord<Elegantbeef> I've toyed with them they're like 2 times slower
23:12:25FromDiscord<Elegantbeef> Which kinda makes sense given what they do
23:12:59FromDiscord<Elegantbeef> https://github.com/beef331/slicerator/blob/master/benchmarks/closures.nim my benchmark for reference
23:13:08FromDiscord<dain> ty!
23:18:00*jmdaemon joined #nim