00:14:06 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
00:44:47 | * | arkanoid joined #nim |
00:46:03 | arkanoid | I 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:19 | FromDiscord | <auxym> sent a code paste, see https://play.nim-lang.org/#ix=4afZ |
00:48:55 | FromDiscord | <Elegantbeef> it imports a variable that is a `uint8` in C |
00:49:13 | FromDiscord | <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:25 | FromDiscord | <auxym> In reply to @Elegantbeef "it imports a variable": sorry, hit enter too soon 😛 |
00:49:29 | FromDiscord | <Elegantbeef> Those are the same thing |
00:49:43 | FromDiscord | <auxym> not according to https://stackoverflow.com/questions/21642741/usage-of-extern-variable-in-c |
00:50:06 | FromDiscord | <auxym> and dereferencing in nim like `tusbCdcDesc[0]` segfaults |
00:50:42 | FromDiscord | <Elegantbeef> The difference is they're using static sized arrays |
00:50:48 | FromDiscord | <Elegantbeef> `NU a` is the same as `NU a[]` |
00:51:03 | FromDiscord | <Elegantbeef> Eitherway you can use codegendecl |
00:51:09 | FromDiscord | <auxym> sooo... how do I not segfault? |
00:51:36 | FromDiscord | <auxym> codegendecl the only way? If so I'd argue that's a nim codegen bug... |
00:51:49 | FromDiscord | <Elegantbeef> `let tusbCdcDesc {.importc: "desc_cdc_itf", nodecl.}: ptr UncheckedArray[uint8]` ? |
00:53:05 | FromDiscord | <auxym> nah I need an extern declaration, the var is from another c file included in the build |
00:56:43 | FromDiscord | <Elegantbeef> I dont think it is a Nim codegen bug↵(@auxym) |
00:56:59 | FromDiscord | <Elegantbeef> It's more of a C design bug |
00:57:22 | FromDiscord | <Elegantbeef> If `int a[]` and `int a` are not compatible in some cases C fucked up 😄 |
00:57:46 | FromDiscord | <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:20 | FromDiscord | <Elegantbeef> bunt `int a[]` isnt a static array |
00:58:22 | FromDiscord | <Elegantbeef> but\ |
00:59:11 | FromDiscord | <auxym> blah. people say "C is a beautiful language because it's so simple" but then there's a 1000 gotchas... |
01:01:11 | FromDiscord | <Elegantbeef> Ah nvm `int a[]` is invalid C |
01:01:25 | FromDiscord | <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:38 | FromDiscord | <Elegantbeef> that's an inferred length static array |
01:01:58 | FromDiscord | <auxym> yeah. so `NU8` would work only for a non-static array? |
01:02:12 | FromDiscord | <Elegantbeef> Yes i was wrong about C's `[]` semantics 😄 |
01:02:28 | FromDiscord | <Elegantbeef> So you just need to do `array[sizeof(desc_cdc_itf), uint8]` |
01:03:14 | FromDiscord | <Elegantbeef> Yes you need to figure out the size in C 😄 |
01:03:34 | FromDiscord | <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:54 | FromDiscord | <Elegantbeef> It'll work but it's ugh |
01:03:59 | FromDiscord | <auxym> yeah |
01:04:47 | FromDiscord | <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:09 | FromDiscord | <auxym> anyways, much C fun. ty for the help understanding this stuff (sort of). |
01:05:24 | FromDiscord | <Elegantbeef> Hey i've been doing dumb shit with a wasm runtime, C is making me scared of code |
01:06:15 | FromDiscord | <Elegantbeef> This runtime is quite barebones and as such does some funky Cism |
01:06:49 | FromDiscord | <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:18 | FromDiscord | <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:33 | FromDiscord | <auxym> 🥲 |
01:07:44 | FromDiscord | <Elegantbeef> Luckily we have macros so i can generate this all |
01:07:49 | FromDiscord | <Elegantbeef> macros really make life so much better |
01:08:21 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4ag4 |
01:09:48 | FromDiscord | <auxym> yep. took me a while to wrap my head around macros but yeah they do save your butt sometimes |
01:11:26 | FromDiscord | <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:48 | FromDiscord | <Elegantbeef> any object type |
01:12:30 | FromDiscord | <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:44 | FromDiscord | <Elegantbeef> It doesnt work for every object |
01:12:49 | FromDiscord | <Elegantbeef> It fails on tagged unions |
01:13:12 | FromDiscord | <Elegantbeef> I personally use `typeIt` from https://github.com/disruptek/assume |
01:13:26 | FromDiscord | <Elegantbeef> I did write my own ugly variant for nimscripter, but it has some very peculiar requirements |
01:13:42 | FromDiscord | <auxym> meh, it works on normal objects, which is just what I need 😄 |
01:13:49 | FromDiscord | <Elegantbeef> Also works on tuples |
01:14:00 | FromDiscord | <Elegantbeef> But yea not on references(without dereference or tagged unions) |
01:16:01 | * | jmdaemon joined #nim |
01:26:59 | FromDiscord | <! Nilts> In reply to @Patitotective "read https://github.com/PMunch/futhark": I can’t seem to install it. |
01:28:04 | FromDiscord | <SaAnd> do you have clang installed? |
01:32:16 | FromDiscord | <! Nilts> In reply to @SaAnd "do you have clang": no |
01:32:52 | FromDiscord | <SaAnd> you need that |
01:33:45 | FromDiscord | <! Nilts> Ok |
01:44:03 | FromDiscord | <! 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:20 | FromDiscord | <Elegantbeef> Cause the library is exposed as a C-api you need that in something Nim understands |
01:47:30 | FromDiscord | <Elegantbeef> You either need to use c2nim, futhark, or manually import the C code into Nim |
01:47:50 | FromDiscord | <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:33 | FromDiscord | <ravinder387> image.writeFile("C:\Users/ravin/Pictures/pixie/square.png") |
02:54:04 | FromDiscord | <ravinder387> don't save png i tried \, \\, // slashes |
02:54:30 | FromDiscord | <ravinder387> sent a long message, see http://ix.io/4agk |
02:54:53 | FromDiscord | <Yardanico> that's not how you write Windows paths |
02:55:01 | FromDiscord | <Yardanico> either use raw strings (with `r`) or `\\` |
02:56:30 | FromDiscord | <ravinder387> sent a long message, see http://ix.io/4agl |
02:56:40 | FromDiscord | <ravinder387> I see empty in my pixie folder |
02:57:35 | FromDiscord | <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:02 | FromDiscord | <Yardanico> sent a code paste, see https://play.nim-lang.org/#ix=4agm |
02:58:22 | FromDiscord | <Yardanico> does your code show any errors? |
02:58:40 | FromDiscord | <ravinder387> no |
02:59:10 | FromDiscord | <Yardanico> I just tried and the code works fine for me, are you sure you're not looking in the wrong folder? |
02:59:16 | FromDiscord | <Yardanico> of course I changed username to my own |
03:00:11 | FromDiscord | <Yardanico> try pasting `C:\Users\ravin\Pictures\pixie` into the explorer address input, and pressing enter |
03:02:08 | FromDiscord | <ravinder387> https://media.discordapp.net/attachments/371759389889003532/1018718125891539044/2022-09-12_083104.mp4 |
03:03:07 | FromDiscord | <Yardanico> and can you show how you're executing the code? |
03:04:41 | FromDiscord | <ravinder387> https://media.discordapp.net/attachments/371759389889003532/1018718766030405743/2022-09-12_083346.mp4 |
03:05:11 | FromDiscord | <Yardanico> you're not actually running the binary |
03:05:20 | FromDiscord | <Yardanico> `nim c file.nim` just _compiles_ the code, it doesn't execute |
03:05:26 | FromDiscord | <Yardanico> if you want to compile and execute use `nim c -r file.nim` |
03:05:35 | FromDiscord | <Yardanico> or first compile, and then execute the .exe manually yourself |
03:06:39 | FromDiscord | <ravinder387> i execute .\app.exe |
03:07:07 | FromDiscord | <ravinder387> thanks very much https://media.discordapp.net/attachments/371759389889003532/1018719377312460811/2022-09-12.png |
03:07:13 | FromDiscord | <Yardanico> np |
03:43:05 | FromDiscord | <SaAnd> has anyone used drchaos here? |
03:43:37 | arkanoid | the output of linux echo "foo" | sha1sum and nim's std/sha1 for same input are not equal |
03:44:20 | FromDiscord | <SaAnd> im getting a linker error for LLVMFuzzerMutate |
03:44:38 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4ags |
03:44:40 | FromDiscord | <SaAnd> even for an the example |
03:45:05 | FromDiscord | <Elegantbeef> You need to do `exportC` |
03:46:29 | FromDiscord | <Elegantbeef> Do you have all it's deps?! |
03:46:35 | FromDiscord | <Elegantbeef> Shit no need for interrobang |
03:46:41 | FromDiscord | <SaAnd> thats what im not sure of |
03:46:44 | FromDiscord | <SaAnd> i have clang |
03:47:05 | FromDiscord | <Elegantbeef> @geekrelief\: that `myFunc` in the `mylib.nim` should have `exportC` on it |
03:47:20 | FromDiscord | <geekrelief> ah thanks beef! |
03:47:37 | FromDiscord | <Elegantbeef> You need `libfuzzer `saand |
03:48:57 | FromDiscord | <SaAnd> when i look at https://llvm.org/docs/LibFuzzer.html it says that for clang \> 6.0 it should be installed |
03:49:13 | FromDiscord | <SaAnd> at fuzzer usage |
03:49:14 | FromDiscord | <Elegantbeef> Might need dev packages? |
03:50:49 | FromDiscord | <Elegantbeef> Pinging planetis might get an answer for you saand |
03:50:51 | FromDiscord | <Elegantbeef> So we'll see |
03:51:03 | FromDiscord | <Elegantbeef> They're in some EU time so may get a response soon |
04:13:43 | FromDiscord | <ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agy |
04:14:00 | FromDiscord | <ravinder387> how to wrap this js class in nim any idea? |
04:14:41 | FromDiscord | <ravinder387> like we do calling c in nim |
04:28:56 | * | wallabra quit (Ping timeout: 268 seconds) |
04:31:23 | FromDiscord | <ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agE |
04:31:48 | FromDiscord | <ravinder387> when i compile this then open browser console it says age() is not defined |
04:39:01 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4agF |
04:39:48 | FromDiscord | <Elegantbeef> you dont need `header` on the proc afaik since it's statically linked |
04:39:59 | FromDiscord | <Elegantbeef> That might be wrong though 😄 |
04:40:01 | FromDiscord | <geekrelief> if I don't add header nim complains |
04:40:26 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4agG |
04:41:20 | FromDiscord | <geekrelief> I'm wondering if with just the declarations we can make nimforue compile faster |
04:46:29 | FromDiscord | <Elegantbeef> Yea that makes sense after i said it |
05:35:55 | * | jmdaemon quit (Quit: ZNC 1.8.2 - https://znc.in) |
05:55:30 | FromDiscord | <ravinder387> In reply to @Elegantbeef "Yea that makes sense": how to use jsffi |
05:55:58 | FromDiscord | <Elegantbeef> The same as C ffi |
05:56:18 | FromDiscord | <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:26 | FromDiscord | <ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agO |
05:56:43 | FromDiscord | <ravinder387> sent a code paste, see https://play.nim-lang.org/#ix=4agy |
05:57:02 | FromDiscord | <Elegantbeef> You're importing a procedure call |
05:57:10 | FromDiscord | <Elegantbeef> `{.importJs: "age".}` |
05:57:31 | FromDiscord | <ravinder387> sent a long message, see http://ix.io/4agR |
05:58:44 | FromDiscord | <ravinder387> Error: `importjs` for routines requires a pattern |
05:58:52 | FromDiscord | <Elegantbeef> `importC` then |
05:59:03 | FromDiscord | <Elegantbeef> or you know copy the code you're copying proc jq(selector\: JsObject)\: JsObject {.importjs\: "$$(#)".} |
05:59:06 | FromDiscord | <Elegantbeef> Whoops |
05:59:06 | FromDiscord | <Elegantbeef> `proc jq(selector: JsObject): JsObject {.importjs: "$$(#)".}` |
05:59:29 | FromDiscord | <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:48 | FromDiscord | <dlesnoff> sent a code paste, see https://play.nim-lang.org/#ix=4ahC |
11:31:28 | FromDiscord | <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:51 | FromDiscord | <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:15 | FromDiscord | <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:26 | FromDiscord | <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:44 | FromDiscord | <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:08 | FromDiscord | <leorize> yes it is expected |
15:43:03 | FromDiscord | <rolha> leorize\: thanks. Is there a way to execute a shell command and still being able to have an output stream? |
15:43:15 | FromDiscord | <leorize> oh wait no lol |
15:43:36 | FromDiscord | <leorize> you should still be able to read from the streams |
15:46:50 | FromDiscord | <rolha> Cool, I'll try that. thanks. |
15:48:01 | FromDiscord | <leorize> I'd not recommend readLine due to the way this sort of reading works tbf |
15:48:24 | FromDiscord | <leorize> also poParentStreams can be useful if you just want to forward the data without looking into it |
15:48:37 | FromDiscord | <Patitotective> this might be useful https://github.com/Patitotective/ImNimble/blob/main/src/processes.nim#L29 |
15:49:24 | FromDiscord | <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:08 | FromDiscord | <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:33 | FromDiscord | <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:30 | FromDiscord | <soda> Is there a quick way to prune strings to remove things like carriage or newline symbols? |
16:50:53 | FromDiscord | <soda> also, how to run a system command? |
16:51:20 | FromDiscord | <soda> sent a code paste, see https://play.nim-lang.org/#ix=4ajg |
16:58:39 | FromDiscord | <ezquerra> In reply to @soda "the equivalent of C++'s": https://nim-lang.org/docs/osproc.html#execCmd%2Cstring |
16:58:57 | FromDiscord | <soda> Thanks |
16:59:14 | FromDiscord | <ezquerra> You can also have a look at https://github.com/Vindaar/shell |
17:00:27 | FromDiscord | <Zoom> sent a code paste, see https://paste.rs/XLe |
17:00:29 | FromDiscord | <ezquerra> In reply to @soda "Is there a quick": https://nim-lang.org/docs/strbasics.html#strip%2Cstring%2Cset%5Bchar%5D |
17:00:36 | FromDiscord | <ezquerra> Although that will also strip other white space |
17:00:46 | FromDiscord | <ezquerra> Not just newlines |
17:01:09 | FromDiscord | <Zoom> I have a suspicion `invokeExternalProcess` gets reordered before the lock release, judging from how the processes executed from this proc behave. |
17:02:55 | FromDiscord | <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:36 | FromDiscord | <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:16 | FromDiscord | <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:54 | NimEventer | New question by André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:54 | FromDiscord | <Rika> Lol |
18:04:02 | * | rockcavera joined #nim |
18:04:02 | * | rockcavera quit (Changing host) |
18:04:02 | * | rockcavera joined #nim |
18:14:18 | FromDiscord | <that_dude> Who thought nimrod is another thing as well |
18:31:17 | * | kenran joined #nim |
18:45:46 | FromDiscord | <Require Support> anyone familiar with chronos know the quickest add my own headers to a request? |
18:56:14 | FromDiscord | <Bung> https://github.com/status-im/nim-chronos/blob/master/tests/testhttpclient.nim here's the test file |
18:57:44 | FromDiscord | <Bung> before you request you should initialize a client, so you can request multiple times |
19:02:01 | FromDiscord | <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:57 | FromDiscord | <aruZeta> In reply to @NimEventer "New question by Andrés": man at least use google translate 💀 |
19:09:17 | FromDiscord | <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:31 | FromDiscord | <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:26 | FromDiscord | <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:54 | FromDiscord | <Bung> (edit) "concatenate" => "concate" | "extrovert" => "extro" |
19:37:43 | FromDiscord | <geekrelief> sent a code paste, see https://play.nim-lang.org/#ix=4ajT |
19:38:05 | FromDiscord | <geekrelief> if I comment out the `"C"` from NIM_EXTERNC, I still get the error. |
19:38:37 | FromDiscord | <geekrelief> seems like the compiler check for backend:cpp is failing somehow. |
19:58:29 | NimEventer | New thread by archnim: Turning a tuple to json, see https://forum.nim-lang.org/t/9461 |
19:59:21 | * | wallabra joined #nim |
20:00:46 | FromDiscord | <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:43 | FromDiscord | <Elegantbeef> I dont think so, you have the CABI which means you need to give each overload it's own name↵(@geekrelief) |
20:47:50 | FromDiscord | <geekrelief> In reply to @Elegantbeef "I dont think so,": looks like I'll need to modify the compiler then |
21:30:24 | FromDiscord | <choltreppe> sent a code paste, see https://play.nim-lang.org/#ix=4akl |
21:40:45 | FromDiscord | <Bung> your test dispatch is totally wrong |
21:42:54 | FromDiscord | <choltreppe> ok. how would it be correct? |
21:44:04 | * | kenran quit (Quit: WeeChat info:version) |
21:47:32 | FromDiscord | <Bung> nvm I miss read that long line |
21:50:00 | FromDiscord | <Bung> u can echo time inside test |
21:50:30 | FromDiscord | <Bung> see what's happening , with start time and end time |
21:51:00 | FromDiscord | <Bung> the code is not practical though |
21:51:18 | FromDiscord | <dain> sent a code paste, see https://play.nim-lang.org/#ix=4akq |
21:52:38 | FromDiscord | <choltreppe> yea its just a simplified version of the problem, not my real code |
21:56:05 | FromDiscord | <Bung> maybe use async sleep simulate the busy logic? |
21:57:06 | FromDiscord | <Bung> In reply to @dain "back again on this": search issue there's similar one |
22:00:30 | FromDiscord | <dain> not sure which you mean |
22:00:59 | FromDiscord | <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:07 | FromDiscord | <dain> why is this so confusing x_x |
22:03:42 | FromDiscord | <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:53 | FromDiscord | <Elegantbeef> `iterable` only works for templates↵(@dain) |
22:08:00 | FromDiscord | <Elegantbeef> Whoops misread 😄 |
22:09:35 | FromDiscord | <Bung> In reply to @choltreppe "ok ist works with": am curious now, I'd try myself , leaving my bed |
22:11:21 | FromDiscord | <Elegantbeef> The issue Dain is that iterators are just not chosen for procedure calls so you have to use templates |
22:11:34 | FromDiscord | <Elegantbeef> You can use `iterable[T]` but then you need to do `.items` on collections |
22:13:58 | FromDiscord | <Bung> https://github.com/nim-lang/RFCs/issues/397 |
22:14:27 | FromDiscord | <Elegantbeef> Eh iterable is a meh addition anyway |
22:15:34 | FromDiscord | <dain> ughghg why is this so hard |
22:15:50 | FromDiscord | <Elegantbeef> Cause Nim inline iterators are glorified templates |
22:16:08 | FromDiscord | <dain> why isnt seq an iterable |
22:16:15 | FromDiscord | <Elegantbeef> Cause it's not a iterator |
22:16:18 | FromDiscord | <Elegantbeef> you need to call `.items` |
22:16:22 | FromDiscord | <Elegantbeef> iterable only takes iterators |
22:16:23 | FromDiscord | <dain> so why call it iterable |
22:16:26 | FromDiscord | <dain> instead of just iterator |
22:16:27 | * | jmdaemon quit (Ping timeout: 250 seconds) |
22:16:40 | FromDiscord | <Elegantbeef> Cause it's a generic typeclass over all iterators that yield T |
22:16:53 | FromDiscord | <Elegantbeef> Like i said iterable is very ill designed and a cludge hack |
22:16:57 | FromDiscord | <dain> but the word iterable means "that which can be be iterated over" |
22:17:06 | FromDiscord | <dain> a seq can be iterated over therefore it's an iterable |
22:17:18 | FromDiscord | <Elegantbeef> Dont look at me i didnt implement iterable |
22:17:25 | FromDiscord | <Elegantbeef> I like the idea but it's a god awful implementation |
22:20:00 | FromDiscord | <huantian> Consider python: list is an iterable because you can call iter() on it to get an iterator |
22:20:08 | FromDiscord | <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:21 | FromDiscord | <Elegantbeef> You use a concept |
22:20:28 | FromDiscord | <Elegantbeef> But it will never be able to accept a `iterator` |
22:20:40 | FromDiscord | <dain> yeah that's my problem the concept doesnt work |
22:20:52 | FromDiscord | <huantian> But in python list is not an iterator, that’s the general convention of iterable vs iterator |
22:20:54 | FromDiscord | <Elegantbeef> A proc cannot take a non closure iterator |
22:20:59 | FromDiscord | <Elegantbeef> You have to use a template |
22:21:29 | FromDiscord | <dain> a template of untyped -> untyped? |
22:22:18 | FromDiscord | <Elegantbeef> You have to use untyped if you want to take iterators cause Nim does not consider iterators in dispatch |
22:22:54 | FromDiscord | <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:06 | FromDiscord | <dain> with minimum fuss |
22:23:08 | FromDiscord | <Elegantbeef> You have to use untyped there then |
22:23:24 | FromDiscord | <dain> okay. so `template(foo: untyped): untyped` is the right way(tm) ? |
22:23:26 | FromDiscord | <Elegantbeef> I can only say nim doesnt have a explicit way to handle this so many types |
22:23:34 | FromDiscord | <Elegantbeef> so many times\ |
22:24:20 | FromDiscord | <Elegantbeef> Yes it's the "right way" |
22:24:24 | FromDiscord | <dain> okay |
22:25:04 | FromDiscord | <dain> thanku |
22:29:29 | FromDiscord | <Bung> In reply to @choltreppe "ok ist works with": u block the cpu, there's nothing to do with async |
22:31:00 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4akx |
22:34:21 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4aky |
22:35:01 | FromDiscord | <choltreppe> sent a code paste, see https://play.nim-lang.org/#ix=4akz |
22:35:27 | FromDiscord | <choltreppe> just not that nice to implement in my real code |
22:35:40 | FromDiscord | <choltreppe> think ill use threads |
22:36:20 | FromDiscord | <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:13 | FromDiscord | <Bung> sent a code paste, see https://play.nim-lang.org/#ix=4akA |
22:37:25 | FromDiscord | <Elegantbeef> you mean io bound? |
22:38:02 | FromDiscord | <Bung> yeah, that's async for , right ? |
22:38:12 | FromDiscord | <Elegantbeef> Yes |
22:39:01 | FromDiscord | <Bung> but choltreppe examples does not simulate the real way |
22:42:18 | FromDiscord | <! Nilts> sent a code paste, see https://play.nim-lang.org/#ix=4akD |
22:45:03 | FromDiscord | <Bung> nothing can help, any code ? |
22:45:59 | FromDiscord | <! Nilts> In reply to @Bung "nothing can help, any": line 52 ` node.text = getUrl(url)`. node is a XmlNode |
22:49:37 | FromDiscord | <Bung> dont know how you construct the node , node.k is not in range like the error reported |
22:50:50 | FromDiscord | <! Nilts> In reply to @Bung "dont know how you": What? the node is a normal XmlNode. It was constructed by parsehtml |
22:51:49 | FromDiscord | <Bung> https://github.com/nim-lang/Nim/blob/c9a92117f9b78e3227dfe2cdcc7cf5b113185832/lib/pure/xmltree.nim#L40-L67 |
22:52:07 | FromDiscord | <! Nilts> In reply to @Bung "https://github.com/nim-lang/Nim/blob/c9a92117f9b78e": what about it |
22:52:25 | FromDiscord | <Bung> you see `case k: XmlNodeKind` |
22:53:52 | FromDiscord | <Bung> you'll need echo node.kind see what's the node kind |
22:59:18 | FromDiscord | <! Nilts> In reply to @Bung "you'll need echo node.kind": `xnElement` is node.kind |
22:59:54 | FromDiscord | <Bung> so that's why u get this error, it requires ` {xnText, xnComment, xnCData, xnEntity}` |
23:00:32 | FromDiscord | <! Nilts> In reply to @Bung "so that's why u": ? ok |
23:11:52 | FromDiscord | <dain> are there any benchmarks comparing inline iterators to closure iterators? how much performance overhead do the closure ones have |
23:12:23 | FromDiscord | <Elegantbeef> I've toyed with them they're like 2 times slower |
23:12:25 | FromDiscord | <Elegantbeef> Which kinda makes sense given what they do |
23:12:59 | FromDiscord | <Elegantbeef> https://github.com/beef331/slicerator/blob/master/benchmarks/closures.nim my benchmark for reference |
23:13:08 | FromDiscord | <dain> ty! |
23:18:00 | * | jmdaemon joined #nim |