00:02:28 | FromDiscord | <Elegantbeef> Range values implicitly convert to base types, so if you do want it to stay as a range type you can implement the operations |
00:12:21 | FromDiscord | <wick3dr0se> I can't figure out how to set an img to wallpaper atleast in Linux with nim. Been trying to look for some library or at least make a system call. The only results I found for that were repositories that are out of date or not used it seems |
00:19:00 | FromDiscord | <auxym> In reply to @wick3dr0se "I can't figure out": pretty sure this is dependent on whatever DE you are using, KDE Plasma, GNOME, etc, not just "linux" |
00:20:06 | arkanoid | Elegantbeef, ok, thanks |
00:20:24 | arkanoid | why slicing an array returns a sequence? I don't want allocations! |
00:21:12 | FromDiscord | <wick3dr0se> i3 |
00:21:18 | arkanoid | let foo = [1,2,3,4,5] # foo is array[5,int]. let bar = foo[0..3] # bar is seq[int] |
00:21:43 | FromDiscord | <wick3dr0se> (edit) "i3 ... " added "Arch Linux. I use xwallpaper and thought about just making a call" |
00:24:26 | FromDiscord | <Elegantbeef> You have to use `toOpenArray` if you dont want to have heap allocations |
00:24:48 | FromDiscord | <Elegantbeef> !eval var foo = [1, 2, 3, 4, 5]; echo foo.toOpenArray(0, 3) |
00:24:54 | NimBot | [1, 2, 3, 4] |
00:27:21 | arkanoid | Elegantbeef, do I need experimental views? |
00:30:23 | arkanoid | I'm getting error in my context. invalid type: 'openArray[AreaDensity]' for let |
00:30:37 | * | disso_peach quit (Remote host closed the connection) |
00:30:39 | FromDiscord | <Elegantbeef> you cannot store `openArray` in a varaible |
00:30:43 | FromDiscord | <Elegantbeef> It has to go directly into a function |
00:31:00 | * | disso_peach joined #nim |
00:32:05 | arkanoid | Elegantbeef, mmm would produce smelly code in my case. Let me try with views |
00:33:36 | FromDiscord | <Elegantbeef> Unless you use views of course |
00:34:04 | arkanoid | whoa! Error: internal error: getTypeDescAux(tyFromExpr) |
00:34:58 | FromDiscord | <Elegantbeef> Yea misuisng openarray is bound to cause issues |
00:35:40 | arkanoid | I'm probably not misusing it, because code compiles with default gc, and rasises internal error with arc |
00:35:50 | arkanoid | (and code is quite trivial at this point) |
00:36:21 | FromDiscord | <Elegantbeef> Well i consider views misusing it š |
00:37:14 | arkanoid | oh! ok, if you say so |
00:37:46 | arkanoid | quite sad, this would be a perfect spot to use views, but I have to avoid them instead |
00:37:48 | FromDiscord | <Elegantbeef> If you're just trying to pass slices using a template is likely less error ridden |
00:38:24 | FromDiscord | <Elegantbeef> `template mySlice: auto = myColl.toOpenArray(a, b)` |
00:39:52 | FromDiscord | <huantian> In reply to @wick3dr0se "i3 Arch Linux. I": Yeah it might just be more worth it to go the lazy way and not use a c binding |
00:41:33 | arkanoid | Elegantbeef, I'll consider it down the road, thanks again |
00:41:45 | arkanoid | so far, I'll just copypaste arrays |
00:42:42 | FromDiscord | <Elegantbeef> Ugh |
00:46:21 | arkanoid | still better than allocating |
00:46:40 | arkanoid | I'll replace copypaste with toOpenArray when possible down the road |
00:46:58 | arkanoid | speaking of openArray, why I don't get .length of it? |
00:47:04 | FromDiscord | <Elegantbeef> Eh stack allocating is still allocating |
00:47:07 | arkanoid | https://nim-lang.org/docs/system.html#openArray says it has a length attribute |
00:47:08 | FromDiscord | <Elegantbeef> What do you mean? |
00:47:10 | FromDiscord | <Elegantbeef> `.len` works |
00:47:39 | FromDiscord | <Elegantbeef> openarrays internals hidden away just like `seq` |
00:49:33 | FromDiscord | <wick3dr0se> I found my answer from the osproc library, `execCmd` |
00:51:46 | arkanoid | I'm writing a function that multiplies two openarray element-wise, but I don't want allocations. I know the size of the input arrays at compile time so I could hardcore the loop counter, but I'd like to generalize. Is there a solution for this? I'm getting that a.len cannot be evaluated at compile time within the body of the fun |
00:52:38 | arkanoid | this is the signature func `*`[T, J](a: openArray[T], b: openArray[J]): auto = |
01:01:08 | arkanoid | solved with func `*`[N, T, J](a: array[N, T], b: array[N, J]): auto = |
01:08:13 | FromDiscord | <Elegantbeef> Openarray are runtime sliced values so the len is not known statically |
01:08:39 | FromDiscord | <Elegantbeef> Arrays are required for this |
01:08:40 | FromDiscord | <Elegantbeef> Just to clarify |
01:09:22 | arkanoid | yes I think I've found a sweet spot for this. Quite fun trying to write without heap, I'm viewing common problems into new perspective |
01:10:08 | arkanoid | damn, I'm trying to bend spoons here. func `*`[N, T, J](a: array[N, T], b: array[N, J]): array[N, T*J] = |
01:13:01 | FromDiscord | <Elegantbeef> I had an entire array module i made for fun eons ago, it's a fight with the type system |
01:13:22 | FromDiscord | <Elegantbeef> `T J` is... supposed to be what? |
01:14:33 | FromDiscord | <Rika> How does one multiply types |
01:14:44 | FromDiscord | <Rika> Unless youāve defined it of course in which case what would it be |
01:15:43 | arkanoid | Elegantbeef, I'm using this https://github.com/Udiknedormin/NimUnits and T and J are two types like "Mass" and "Acceleration" and the result would be typedesc[Force] |
01:16:13 | arkanoid | for example, this line compiles and run "let asd: Length / Time = 5.Velocity" |
01:16:42 | arkanoid | normally it would be used like "let asd: Velocity = 5.m / 2.s |
01:16:45 | FromDiscord | <Elegantbeef> I see, sorta |
01:16:53 | FromDiscord | <auxym> In reply to @Rika "How does one multiply": product types? Like in function languages. which end up working like https://github.com/alaviss/union sort of |
01:16:56 | FromDiscord | <Elegantbeef> Yea i dont get the point on typedescs |
01:17:04 | FromDiscord | <auxym> (edit) "function" => "functional" |
01:18:20 | arkanoid | but I'm failing to write a function that takes two arrays of same size, one array[5, Length], and one array[5, Time], and output an array[5, Velocity] |
01:18:55 | arkanoid | I'm failing to use the operations on types when I try to generalize |
01:19:03 | FromDiscord | <Elegantbeef> you might have to use `auto` |
01:19:12 | FromDiscord | <Rika> In reply to @auxym "product types? Like in": Does that use |
01:19:18 | FromDiscord | <Rika> I know of product types at least |
01:19:54 | FromDiscord | <Elegantbeef> https://play.nim-lang.org/#ix=4dsh something like this ark |
01:20:58 | arkanoid | wait a sec my browser refuses to show the page for some reason |
01:21:11 | FromDiscord | <auxym> In reply to @Rika "Does that use *": Yeah IIRC ML-family uses `` to create product types |
01:21:25 | arkanoid | seems down to me |
01:21:30 | FromDiscord | <auxym> which has nothing to do actually with @Arkanoids units thing |
01:21:36 | FromDiscord | <Elegantbeef> Refresh perhaps ark |
01:21:56 | FromDiscord | <Elegantbeef> Seems i took the playground down |
01:21:57 | FromDiscord | <Elegantbeef> http://ix.io/4dsh |
01:21:58 | FromDiscord | <Elegantbeef> There |
01:22:08 | FromDiscord | <wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4dsi |
01:22:21 | FromDiscord | <Elegantbeef> `strutils.join` |
01:23:04 | FromDiscord | <wick3dr0se> ty |
01:24:07 | arkanoid | thanks for the backup link. I'm getting "expression 'default(array[N, typeof(Si[1, 0, 1, 0, 0])])' has no type (or is ambiguous)" |
01:27:26 | FromDiscord | <wick3dr0se> Hell yea `join()` worked great |
01:27:36 | arkanoid | wait, I thing I'm fighting a nim bug here. I'm getting again internal compiler error toggling arc |
01:27:38 | FromDiscord | <wick3dr0se> Skips the whole for loop part too |
01:28:44 | arkanoid | this line "dump array[5, Mass / Area].default" compiles with default gc, raises "Error: internal error: getTypeDescAux(tyFromExpr)" if I enable arc |
01:35:34 | arkanoid | this Units packages is capable of crashing the compiler in creative ways ... |
01:44:56 | arkanoid | I'm creating a minimal example to submit the issue. Do you know what is "Error: system module needs: nimGCvisit" ? |
01:53:03 | arkanoid | here's the minimal example that causes the issue https://github.com/nim-lang/Nim/issues/20588 |
02:01:00 | arkanoid | Elegantbeef, btw, after ruling out the issue generated by arc, the solution you suggested doesn't compile. It complains "expression 'default(array[N, typeof(Si[1, 0, 1, 0, 0])])' has no type (or is ambiguous)" |
02:03:45 | arkanoid | but I've found a weird trick to make it work |
02:04:07 | arkanoid | var asd: T*J; result = default(array[N, asd.typedesc]) |
02:06:41 | arkanoid | this is shorter but still I don't understand why it works "result = default(array[N, default(T * J).typedesc])" |
02:11:50 | * | arkurious quit (Quit: Leaving) |
03:00:01 | * | wallabra_ joined #nim |
03:01:43 | * | wallabra quit (Ping timeout: 250 seconds) |
03:01:47 | * | wallabra_ is now known as wallabra |
03:25:23 | * | derpydoo quit (Quit: derpydoo) |
03:46:59 | * | wallabra_ joined #nim |
03:47:15 | * | wallabra quit (Ping timeout: 248 seconds) |
03:48:45 | * | wallabra_ is now known as wallabra |
04:39:46 | * | ehmry quit (Ping timeout: 260 seconds) |
04:40:05 | * | genpaku quit (Remote host closed the connection) |
04:40:46 | * | genpaku joined #nim |
04:43:24 | * | ehmry joined #nim |
05:04:16 | * | henrytill joined #nim |
05:43:02 | madprops | hey nimbros |
05:43:09 | madprops | so what's the state of web servers? |
05:53:51 | FromDiscord | <Phil> Could you specify? |
05:54:16 | madprops | what's nim's node |
05:54:24 | madprops | nodejs* |
05:57:31 | FromDiscord | <Phil> you mean webframework? |
05:57:48 | FromDiscord | <Phil> or do you mean nim's compilation to JS? |
05:58:10 | FromDiscord | <Phil> Or do you mean nim's frontend libraries such as karax? |
06:07:39 | FromDiscord | <Rika> Node is a backend system using JavaScript so |
06:07:41 | madprops | simple webserver to listen to requests and return something |
06:07:51 | FromDiscord | <Rika> Web server frameworks |
06:08:04 | FromDiscord | <Rika> Ehem, Phil, go on |
06:11:04 | madprops | though some framework on top might help |
06:11:09 | madprops | like what express is to nodejs |
06:11:28 | madprops | i used to use python's django a lot. but it ran on apache |
06:17:15 | FromDiscord | <Bung> https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents read this |
06:18:26 | FromDiscord | <Bung> https://github.com/ringabout/awesome-nim#frameworks |
06:27:44 | * | kenran joined #nim |
06:30:52 | * | kenran` joined #nim |
06:32:43 | * | kenran quit (Ping timeout: 246 seconds) |
06:35:28 | * | PMunch joined #nim |
06:59:25 | * | rockcavera quit (Remote host closed the connection) |
07:07:27 | * | LuxuryMode quit (Quit: Connection closed for inactivity) |
07:38:52 | FromDiscord | <Phil> sent a long message, see http://ix.io/4dtq |
07:40:47 | FromDiscord | <Phil> Server Side Rendering: NimjaāµORM: Norm or ormin. Can't say much about ormin, norm works well for me (and it's soon getting connection pooling! Moigagoo just needs to make a new release as the PR for pooling is already merged!)āµAuthentication and Encryption you need to throw together yourself.āµHowever at least I can refer you to how I did it: https://stackoverflow.com/questions/70716906/how-do-i-re-build-djangos-password-hashing-in-nim/ |
07:41:30 | FromDiscord | <Phil> Prologue also has docs on how to deploy it with nginx, both of them in separate docker containers with a docker-compose setup |
07:42:12 | FromDiscord | <Phil> Though those shouldn't be too hard to adjust to use them with jester |
08:21:19 | FromDiscord | <Phil> Also, the #webdev channel exists precisely for webdev questions ^^ |
09:27:01 | * | xet7 quit (Read error: Connection reset by peer) |
10:31:31 | * | jmdaemon quit (Ping timeout: 248 seconds) |
11:08:48 | arkanoid | is it possible to define a range type from an interval generated by custom type? |
11:08:59 | arkanoid | range[1.myfloat .. 5.myfloat] |
11:10:34 | * | arkurious joined #nim |
11:12:14 | arkanoid | well, I guess I'll avoid them https://status-im.github.io/nim-style-guide/language.range.html |
11:52:40 | PMunch | Is there a way to set the working directory to the binary directory so that e.g. `fileExists` will be relative to program location? |
11:53:21 | FromDiscord | <Esther> Iād have thought thatād work, surely? |
11:53:30 | FromDiscord | <Esther> It does in Ada ._. |
12:04:27 | PMunch | @Esther, that what works? |
12:33:56 | * | derpydoo joined #nim |
13:11:57 | arkanoid | I have this trivial function that does work, but the typedesc/default hack I've found by mere luck does smell bad. Do you know how can I improve it? https://play.nim-lang.org/#ix=4duB |
13:16:00 | PMunch | By the way, I managed to solve my problem with setCurrentDirectory(getAppDirectory()) |
13:18:29 | PMunch | arkanoid, I think that looks okay |
13:18:35 | PMunch | You don't need that assert though |
13:19:01 | PMunch | Since you use N for bath the length of a and b there is no way they can be different because N == N always |
13:19:13 | arkanoid | PMunch: you're right! |
13:21:55 | arkanoid | is there a way to get from a type the "parent type" like given "float" -> "Somefloat" |
13:22:34 | arkanoid | I'm using a lib that generate types but I want to find how it works internally to get a "parent type" to use as generic argument limiter |
13:35:40 | PMunch | SomeFloat isn't a parent type of float |
13:35:51 | PMunch | It's a group that happens to include float |
13:36:16 | PMunch | So there isn't a 1:1 mapping from a type to a parent |
14:05:21 | * | PMunch quit (Quit: Leaving) |
14:35:30 | * | hochata joined #nim |
14:58:47 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvk |
15:00:05 | * | rockcavera joined #nim |
15:00:05 | * | rockcavera quit (Changing host) |
15:00:05 | * | rockcavera joined #nim |
15:05:24 | FromDiscord | <Rika> caddr does not sound like a stdlib function |
15:09:39 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvx |
15:12:21 | FromDiscord | <ChocolettePalette> Why isn't it a template? |
15:13:51 | FromDiscord | <sOkam!> š¤·āāļø |
15:14:36 | FromDiscord | <sOkam!> how would I write something similar for chroma?āµHow do you turn an object with 4 floats, into an array? |
15:16:10 | FromDiscord | <Dumb Dragon> unimportant question, but how would I go about getting the time at compile time? |
15:16:22 | FromDiscord | <Dumb Dragon> I can't use `std/times` because that uses importc |
15:16:39 | FromDiscord | <ChocolettePalette> Make an empty array, then write 4 lines of code adding stuff to your array from an object |
15:17:55 | FromDiscord | <kraptor> Hi nimmers! How would you protect an object from being instantianted using the standard constructor by users of your library? I would like to provide initX/newX but not allow the use of the standard X(). Is there a way? Any hint? |
15:19:59 | FromDiscord | <Rika> In reply to @Dumb Dragon "unimportant question, but how": https://nim-lang.org/docs/system.html#CompileTime probably works, i dont remember |
15:20:03 | FromDiscord | <Rika> been a while since i used nim |
15:20:10 | FromDiscord | <Rika> In reply to @kraptor "Hi nimmers! How would": no |
15:20:13 | FromDiscord | <Dumb Dragon> Yeah I was about to say I just figured it out lol, I'm dumb |
15:20:33 | FromDiscord | <Dumb Dragon> thanks |
15:21:20 | FromDiscord | <Rika> iirc there is no way even if you dont provide the type itself because then you have `typeof(newX(<dummy init values>))()` that uses the "standard constructor" |
15:23:39 | * | kenran` quit (Remote host closed the connection) |
15:23:41 | FromDiscord | <kraptor> uhm... and is there a way to hijack the default constrcutor? |
15:23:48 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvB |
15:24:50 | FromDiscord | <kraptor> that wont work @sOkam!, as temp is on the stack it doesn't have an address (and if you get one, it will break things once passed to underlying opengl) |
15:25:55 | FromDiscord | <kraptor> my suggestion would be to make Color a union of array+struct (or even just an array type with accessors) and then send OpenGL the address of the first element |
15:26:01 | FromDiscord | <kraptor> (edit) "element" => "item" |
15:26:06 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvF |
15:26:29 | FromDiscord | <sOkam!> In reply to @kraptor "my suggestion would be": The type is given by chroma, I don't own it |
15:26:54 | FromDiscord | <sOkam!> I'm just trying to bridge chroma to opengl |
15:27:31 | FromDiscord | <Rika> In reply to @kraptor "uhm... and is there": nope xd |
15:28:30 | FromDiscord | <kraptor> ouch! Thanks Rika, maybe in the future š I'll try to educate users of my library for now... š |
15:28:39 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4dvI |
15:28:42 | FromDiscord | <Rika> prolly will die immediately like the stack version |
15:29:16 | FromDiscord | <Rika> In reply to @kraptor "ouch! Thanks Rika, maybe": pretty much the whole ecosystem is built on trust that the user doesnt use them directly (or they put sanity checks everywhere) |
15:29:38 | FromDiscord | <demotomohiro> You need to learn how stack memory works.āµ@sOkam! http://zevv.nl/nim-memory/ |
15:30:37 | FromDiscord | <Rika> https://github.com/treeform/chroma/blob/master/src/chroma/colortypes.nim#L2āµthe colo[u]r type has the proper layout already, so it should be fine directly using addr |
15:31:06 | FromDiscord | <kraptor> I see Color is a "packed" (not explicitly, but 4 float32 members) struct, you could just cast it to an array[4, float32] and call it a day passing the first element addr |
15:31:14 | FromDiscord | <Rika> you dont even need the cast |
15:31:25 | FromDiscord | <Rika> wait, no you do |
15:31:33 | FromDiscord | <kraptor> was thinking the same, just the address of the color.r member will do |
15:31:39 | FromDiscord | <Rika> ptr is typed xd i forgot about typing |
15:31:45 | FromDiscord | <Rika> what C does to a mf |
15:32:00 | FromDiscord | <sOkam!> kk ty |
15:32:03 | FromDiscord | <Rika> well actually |
15:32:24 | FromDiscord | <Rika> `cast[ptr GLfloat](colour.addr)` perhaps |
15:32:28 | FromDiscord | <Rika> not sure what a GLfloat is but |
15:32:32 | FromDiscord | <Rika> yeah |
15:32:54 | FromDiscord | <kraptor> in any case, a cast will do: cast[ptr GLfloat](colour.r.addr) |
15:33:01 | FromDiscord | <Rika> In reply to @sOkam! "I'm trying to relearn": so here you put what i wrote instead of colour.caddr i believe |
15:34:01 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvO |
15:34:51 | FromDiscord | <Rika> i dont remember the behaviour of using addr on function parameters, i think it takes the stack address of the function's input parameters so prolly use a template |
15:35:01 | FromDiscord | <sOkam!> kk |
15:35:06 | FromDiscord | <Rika> In reply to @sOkam! "Oh, I just found": or make it var |
15:35:14 | FromDiscord | <Rika> like the reply |
15:35:34 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvQ |
15:42:18 | FromDiscord | <Rika> return type |
15:44:36 | FromDiscord | <sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvV |
15:44:37 | FromDiscord | <Andycol> Hey Guys |
15:45:12 | FromDiscord | <Andycol> sent a code paste, see https://play.nim-lang.org/#ix=4dvW |
15:45:55 | FromDiscord | <Andycol> (edit) "https://play.nim-lang.org/#ix=4dvW" => "https://play.nim-lang.org/#ix=4dvY" |
15:47:26 | FromDiscord | <Rika> what am i looking at |
15:47:34 | FromDiscord | <Andycol> that is bash code |
15:47:43 | FromDiscord | <Andycol> so echos the below output into the file custom.xml |
15:47:51 | FromDiscord | <Rika> https://nim-lang.org/docs/io.html#writeFile,string,string |
15:48:28 | FromDiscord | <Rika> sent a code paste, see https://play.nim-lang.org/#ix=4dw0 |
15:48:46 | FromDiscord | <Andycol> awesome let me try thanks!! |
15:50:33 | FromDiscord | <sOkam!> bash looking pretty as always š |
16:10:44 | * | wallabra_ joined #nim |
16:12:46 | * | wallabra quit (Ping timeout: 260 seconds) |
16:12:47 | * | wallabra_ is now known as wallabra |
16:21:06 | FromDiscord | <tsoj> On my machine, the following program prints out `23 hours`. Does anyone know what could be going on? On https://play.nim-lang.org/#ix=4dwf it prints out `1 day` |
16:21:18 | FromDiscord | <tsoj> sent a code paste, see https://play.nim-lang.org/#ix=4dwh |
16:24:08 | FromDiscord | <Rika> i assume its timezones |
16:24:15 | FromDiscord | <Rika> your timezone probably has DST |
16:24:33 | FromDiscord | <Rika> perhaps you just hit the day DST is changed |
16:25:03 | FromDiscord | <Rika> seems not |
16:25:05 | FromDiscord | <Rika> not sure then |
16:25:29 | FromDiscord | <Rika> oh wait no |
16:25:36 | FromDiscord | <Rika> DST does change march 26 in some countries |
16:25:58 | FromDiscord | <tsoj> oh i comletely forgot about that |
16:26:00 | FromDiscord | <Rika> lol |
16:26:04 | FromDiscord | <Rika> welcome to time hell |
16:26:31 | FromDiscord | <tsoj> yeah it's my first encounter |
16:26:55 | FromDiscord | <treeform> I made a timezone/calendar lib that I feel make more sense: https://github.com/treeform/chrono |
16:27:08 | FromDiscord | <treeform> By default its all in UTC so you will not have that issue. |
16:27:47 | FromDiscord | <treeform> DST can be very unpredictable |
16:28:09 | FromDiscord | <treeform> Its hast stopped in many countries and some US states in the last 20 years. |
16:28:34 | FromDiscord | <Rika> treeform literally prints libraries |
16:28:40 | FromDiscord | <Rika> snaps them into existence |
16:28:45 | FromDiscord | <treeform> Some countries change times 4 times a year (mainly for religious events like Ramadan). |
16:28:55 | FromDiscord | <Rika> by the time its tomorrow he'd have released 15 new super useful libraries |
16:29:36 | FromDiscord | <treeform> Some states like Indiana, have like 9-13 timezones depending on how you count |
16:30:10 | FromDiscord | <Rika> oh man the fucking fractional timezones |
16:30:12 | FromDiscord | <treeform> Some countries (mostly around India) are 30 or 15 minutes off UTC. |
16:32:53 | FromDiscord | <treeform> Historical time zones are also really crazy ... West cost of US was -7:52:58 off from East cost in the 1800s. |
16:52:58 | FromDiscord | <Takemichi Hanagaki> In reply to @Patitotective "to evaluate code at": I had an idea.āµI'll do a repl to C language using TinyCC as backend.āµI know that TCC already can turn C into a script language, using `#env/bin/tcc --run`, if I'm not wrong.āµMy plan isn't the nim repl, but just a repl, to learn more about terminal. |
16:53:10 | FromDiscord | <Takemichi Hanagaki> (edit) "backend.āµI" => "backend. āµI" | "backend. āµIknow that TCC already can turn C into a script language, using `#env/bin/tcc --run`, if I'm not wrong.āµMy plan isn't the nim repl, but just a repl, to learn more about terminal. ... " added "š" |
16:53:42 | FromDiscord | <baalajimaestro> Yep india is +5.30, Bangladesh is +5.45āµ(@treeform) |
17:01:46 | arkanoid | is there any advantage in having large "let/var" blocks, instead of multiple statements? |
17:02:20 | FromDiscord | <Rika> advantage in what sense |
17:02:55 | FromDiscord | <auxym> In Canada we have https://en.wikipedia.org/wiki/Newfoundland_Time_Zone (UTC -3.5) |
17:03:00 | FromDiscord | <rakgew> less source code to ready, maybe. |
17:03:21 | arkanoid | performance, compiler efficiency, and so on |
17:03:46 | FromDiscord | <auxym> no, it's just syntax (aka programmer convenience) |
17:10:15 | arkanoid | k |
17:11:57 | FromDiscord | <vindaar> arkanoid\: I'm not sure what you're trying to achieve exactly, but possibly `unchained` can be of use? https://github.com/SciNim/unchained At the very least I'll be able to answer the kind of questions you're wondering about nim-units š
|
17:12:41 | arkanoid | vindaar, are you saying I've been using the wrong units library all the time? |
17:14:26 | arkanoid | I've been fighting https://github.com/Udiknedormin/NimUnits for a whole day, lol |
17:14:31 | arkanoid | well, it works nice! |
17:15:18 | FromDiscord | <vindaar> I'm not sure. I'd say there is no "right or wrong". Both have their own pros and cons, I guess. I don't know it very well, but it tries to do slightly different things, afaik. It treats quantities as the things for the generic arguments essentially and `unchained` uses explicit units |
17:17:06 | arkanoid | vindaar, you mean that unchained won't let me "func calcspeed(a: Length, b: Time): Velocity = a / b" ? |
17:17:40 | arkanoid | will it become "func calcspeed(a: meters, b: seconds): meters/seconds = a / b |
17:18:10 | FromDiscord | <vindaar> No. You'd be explicitly writing `proc calcSpeed(a: KiloMeter, b: Hour): KiloMeterā¢Hourā»Ā¹ = a / b` for example (there are short hands for the units of course. |
17:18:37 | FromDiscord | <vindaar> and if the unicode is too crazy for you, you can also write e.g. `kmh^-1` etc |
17:18:44 | FromDiscord | <vindaar> oh, wait |
17:19:03 | arkanoid | si you're saying exactly what I am saying |
17:19:04 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dwH |
17:19:10 | FromDiscord | <vindaar> yup |
17:19:14 | * | ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.) |
17:19:20 | FromDiscord | <vindaar> (except not quite ;) ) |
17:20:02 | arkanoid | not sure if it's a better way to go, actually. If I write a function taking SI units, and I drop it Imperial units of same quantity, what happens? |
17:20:16 | * | ehmry joined #nim |
17:21:10 | FromDiscord | <vindaar> two options\:āµ1. you take the imperial units as arguments. When you start doing math with a mix of imperial + SI it'll apply the correct conversion to SI for the imperial units (as SI is the base unit system by default)āµ2. you call the `to` function, like `5.lbs.to(kg)` in the argument |
17:21:53 | arkanoid | vindaar, so under the hood unchained knows that feet and meters are units of the same quantity, right? |
17:21:54 | FromDiscord | <vindaar> (I've thought about turning the existing quantities into `concepts`, so that what you can do in `nim-units` is also possible in `unchained`, but it's not a priority for me |
17:22:01 | FromDiscord | <vindaar> yup |
17:23:02 | FromDiscord | <vindaar> https://github.com/SciNim/Unchained/tree/master/examples for a more complex example (note the `^` operator is now built in. But it's a bit dangerous due to Nim precedence rules..) |
17:23:35 | FromDiscord | <vindaar> https://github.com/SciNim/Unchained/blob/master/src/unchained/si_units.nim defines the SI unit system |
17:23:40 | arkanoid | nim-units doesn't have "to" function. You can only say "use SI" and deply a converter for feet-to-meters, then when you do "5.ft" it is immediately converted to meters |
17:24:04 | arkanoid | so uder the hood there's only one system, but you can start from wherever you want |
17:24:19 | arkanoid | what is not trivial to do is converting meters to feet |
17:24:22 | arkanoid | for example |
17:25:01 | FromDiscord | <vindaar> I see |
17:26:03 | arkanoid | writing functions expressing quantities as input types feels nice, but then within the body when you have constants you still end up giving up this elegant way of thinking |
17:26:56 | FromDiscord | <vindaar> I feel like being explicit is once again better than not. That way your code expresses the intent and the compiler is simply there to make sure you're not doing anything wrong + doing the trivial (but easy to mess up) calculations of unit conversions for you |
17:28:06 | arkanoid | in either case you are not going to use wrong quantities. You describe your function as processing quantities, then you feed in amount in units expressing such quantities. Is perfectly logical and still sounds at compile time |
17:28:50 | arkanoid | can unchained do implicit conversion of units? |
17:28:58 | FromDiscord | <vindaar> yes |
17:29:09 | arkanoid | for example feeding 5.ft to "proc foo(a: meters)" |
17:29:24 | FromDiscord | <vindaar> the approach nim-units takes seems more limiting though. Because if I want to have my function return a wavelength in `nm`, I simply write that |
17:29:54 | FromDiscord | <vindaar> not in that case. Only when doing math. But that's due to the Nim compiler (the different units really are different existing types)āµ(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
17:29:58 | FromDiscord | <vindaar> you could define a converter though |
17:30:32 | arkanoid | well, this means nim-units is superior |
17:31:01 | FromDiscord | <vindaar> as I say, it is dependent on what you actually want. If that convenience is important to you, sure it is |
17:31:52 | arkanoid | let me thing about it for a while. I'll surely want to try a hard switch |
17:31:58 | arkanoid | I have another quesiton though |
17:32:08 | arkanoid | what about array manipulations? |
17:32:23 | arkanoid | array * array mul, div |
17:32:31 | arkanoid | or array * const mul, div |
17:32:40 | arkanoid | broadcasting, I mean |
17:33:15 | arkanoid | does unchained supports this out of the box? I'm writing my own functions for nim-units and is not quite trivial |
17:35:37 | FromDiscord | <vindaar> No, it doesn't. The units defined by `unchained` are simply regular Nim units. So all normal restrictions apply. I don't usually do a lot of array \ scalar stuff. And by "array \ array" you mean element wise multiplication?Some of them can be implemented in a couple of lines of code. Others will get more messy. |
17:37:26 | FromDiscord | <vindaar> do you have an explicit example? Then I might have a better idea |
17:38:32 | FromDiscord | <vindaar> and by array you strictly mean `array` (i.e. also `array` return type and not a `seq`?) |
17:41:23 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dwM |
17:43:55 | FromDiscord | <vindaar> (`/` is identical and the element wise multiplication and division assuming same length arrays { anything else doesn't make sense to me anyway? } is also essentially the same) |
17:44:17 | FromDiscord | <vindaar> I can throw them into a PR if that seems useful to you I guess |
17:44:17 | arkanoid | vindaar: here a brief example https://play.nim-lang.org/#ix=4dwO |
17:45:29 | arkanoid | I've not found a better solution (so far) than "let t = default(T) * default(J)" |
17:45:55 | arkanoid | well, SomeUnit is something I struggle not having in num-units |
17:46:19 | arkanoid | as you can see, I have not type limiter in my generic arguments, and this is bad |
17:46:41 | arkanoid | this is because I don't have (or I have not found yet) the equivalent in nim-units |
17:47:32 | FromDiscord | <vindaar> yeah, pretty much what I wrote there. what are you working on though? dynamic fuel model? |
17:48:14 | arkanoid | vindaar, wildfire simulation stuff. Converting my python stuff actually |
17:48:32 | FromDiscord | <vindaar> sorry, I'm no help there either. Could be that there is no equivalent |
17:48:33 | FromDiscord | <vindaar> interesting! |
17:50:50 | arkanoid | I'm trying to develop the core login without heap allocations. I expect it to be super-fast! |
17:51:01 | arkanoid | *core logic |
17:53:36 | arkanoid | surely python is still far superior in this stuff |
17:54:09 | arkanoid | in my original python implementation, I'n not only getting correcy units, but also uncertainty and error propagation model out of the box |
17:55:52 | FromDiscord | <vindaar> https://github.com/SciNim/measuremancer |
17:56:13 | arkanoid | :O |
17:56:15 | arkanoid | :O O |
17:56:18 | arkanoid | WHAT? |
17:56:50 | arkanoid | I've been missing nim news for too long, I suppose |
17:57:26 | FromDiscord | <vindaar> (it doesn't handle correlated quantities though. Aside from the trivial cases of same symbol addition / subtraction etc.; only simple linear "gaussian" error propagation) |
17:57:39 | FromDiscord | <vindaar> I just suck at advertising š« šāµ(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
17:57:56 | arkanoid | Measurement math with different unchained units is currently only supported using multiplication, *. For the others the implementation is still pending. |
17:58:20 | arkanoid | damn, I would jump on this immediately if it would support more operations |
17:59:26 | arkanoid | damn, I would jump on this immediately if it would support the operations I need |
18:00:10 | FromDiscord | <vindaar> I just have to implement them. Shouldn't be a big deal. Not even sure if that message is still correct |
18:01:25 | arkanoid | I can share the python compatibility layer I've created for my real-world use case to use two different uncertainties libraries by toggling a switch |
18:02:19 | arkanoid | https://gist.github.com/arkanoid87/b81c5cae6f0bb5682e83e51edbae2c2c |
18:03:09 | * | kenran joined #nim |
18:06:44 | FromDiscord | <vindaar> ok, the division is broken. but `+`, `-` and `` work in measuremancer with same and different units, respectively |
18:07:21 | arkanoid | btw, this is a game changer. I'll switch immediately from nim-units to unchained, as my final target would actually have my whole login in nim + unchained + measuremancer! |
18:07:34 | arkanoid | vindaar, be aware you've just changed my day |
18:08:07 | arkanoid | what about trigonometric functions? |
18:10:35 | FromDiscord | <vindaar> ok, got `/` working |
18:11:01 | FromDiscord | <vindaar> currently only `sin`, `cos` (well and `exp`) are implemented. But others can be added easilyāµ(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
18:12:24 | FromDiscord | <vindaar> just note that `measuemancer` is still really rough around the edges. I implemented it partially for fun and partially because I needed it. But I didn't even get around to writing proper tests or adding a CI yet. So you might stumble over bugs |
18:13:27 | arkanoid | sure! well, thanks, I'll try to find out if my able to add the operations I need |
18:18:00 | FromDiscord | <vindaar> I'll create a PR for my division fix quickly |
18:18:30 | arkanoid | vindaar, at first I though the name "unchained" comes from the uttertly ugly "chain" unit measure in imperial system, which is so horrible that you want to be "unchained" as soon as you meet one |
18:23:40 | FromDiscord | <vindaar> just merged the PR and tagged a new release. I'll add some tests one of these days to make sure at least the basics work correctly outside of my personal project testing, haha |
18:23:41 | arkanoid | vindaar, my first line found a non-pre-existing IS unit of measure |
18:23:59 | arkanoid | https://en.wikipedia.org/wiki/Area_density |
18:25:19 | FromDiscord | <vindaar> ah |
18:25:23 | FromDiscord | <vindaar> not imperial, haha |
18:25:29 | FromDiscord | <vindaar> imperial system is pretty lacking. Feel free to open issues about them or just a PR that adds them. Should be pretty straight forward now (in that file I linked earlier)āµ(<@709044657232936960_arkanoid=5b=49=52=43=5d>) |
18:25:31 | FromDiscord | <vindaar> I read that IS as "imperial system" |
18:26:23 | * | derpydoo quit (Quit: derpydoo) |
18:26:57 | FromDiscord | <vindaar> it needs a new quantity after this https://github.com/SciNim/Unchained/blob/master/src/unchained/si_units.nim#L38 and then a corresponding unit somewhere here https://github.com/SciNim/Unchained/blob/master/src/unchained/si_units.nim#L110 |
18:27:06 | arkanoid | my fault. In my native language is SI like, but my head wraps the words when speaking english. I mean Systeme international, |
18:27:48 | FromDiscord | <vindaar> š |
18:28:43 | FromDiscord | <vindaar> I'll be away for the night in a few minutes. Feel free to try to locally add a quantity + unit and see if it works. Otherwise I'll do it likely tomorrow |
18:29:21 | arkanoid | np, thanks for the help and the feedback! |
18:30:32 | FromDiscord | <vindaar> you're welcome! |
18:30:59 | arkanoid | vindaar, these are the units I'm using in nim-units https://play.nim-lang.org/ |
18:31:13 | arkanoid | I had to add 3 (the ones with wikipedia link) |
18:31:19 | arkanoid | sorry wrong link |
18:31:31 | arkanoid | https://play.nim-lang.org/#ix=4dwZ |
18:34:50 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dx0 |
18:35:35 | FromDiscord | <vindaar> (might still be useful to have `AreaDensity` as a quantity for certain use cases of course) |
18:37:54 | FromDiscord | <vindaar> (I'm saying that mainly because `AreaDensity` doesn't seem to have a common unit of its own. It's just expressed in terms of a compound SI unit, either `g/cmĀ²` or `kg/mĀ²` etc) |
19:16:55 | arkanoid | I vindaar, I've started to converto my code from nim-units to unchained, but on the way I'm finding some major hiccups: https://play.nim-lang.org/#ix=4dxf |
19:17:10 | arkanoid | the very same test in nim-units works |
19:46:40 | FromDiscord | <4zv4l> I made some programs which have a main procāµI use a main zig program that adds a menu and run one or the other main function depending on the choiceāµand it seems that I cannot compile for Windows using that technic |
19:46:53 | FromDiscord | <4zv4l> this is the simple array |
19:46:56 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4dxs |
19:46:59 | FromDiscord | <4zv4l> with Linux it compiles fine |
19:47:02 | FromDiscord | <4zv4l> but for Windows I get this |
19:47:19 | FromDiscord | <4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4dxv |
19:48:26 | FromDiscord | <4zv4l> (edit) "zig" => "nim" |
19:48:59 | arkanoid | could you please help me decrypt this error message? To my eyes, there no error https://play.nim-lang.org/#ix=4dxw |
20:03:30 | FromDiscord | <Recruit_main707> does it work without the range? |
20:03:44 | FromDiscord | <Recruit_main707> like, just `array[2, ...]` |
20:10:08 | * | kenran quit (Remote host closed the connection) |
20:14:09 | FromDiscord | <Bung> gcsafe ? |
20:25:15 | FromDiscord | <vindaar> sent a long message, see http://ix.io/4dxH |
20:25:17 | FromDiscord | <vindaar> will be afk again |
20:29:05 | * | derpydoo joined #nim |
20:32:05 | FromDiscord | <Elegantbeef> One of your procs is not gcsafeāµ(@4zv4l) |
20:32:30 | FromDiscord | <Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=e5t |
20:32:44 | FromDiscord | <4zv4l> what does `MainProc` do ? |
20:37:39 | FromDiscord | <Elegantbeef> Type converts it |
20:38:01 | FromDiscord | <Elegantbeef> Right now the first procedure is the type for the collection, so if you have `gcSafe` proc first it assumes the entire collection is `gcSafe` |
20:38:15 | FromDiscord | <Elegantbeef> So hitting a non safe procedure causes a type mismatch |
20:50:02 | FromDiscord | <ShalokShalom> In reply to @arkanoid "<@150345911057252352>, at first I": According to the README, if you read at the bottom, is this actually the caseāµāµAt least a little bit |
20:58:52 | FromDiscord | <morgan> is there an easy way to find the largest set value smaller than some number? and then the index of that value |
20:59:59 | FromDiscord | <Elegantbeef> What? |
21:00:42 | FromDiscord | <morgan> if i have a set of values {1, 3, 4, 10}, and a value 5, it would be 4 (value) and 2 (index) |
21:01:12 | FromDiscord | <Elegantbeef> iterate the set is the only way |
21:01:16 | FromDiscord | <morgan> ok |
21:01:48 | FromDiscord | <morgan> i'll probably leave this off for now, its for a feature i might add later on in something this'll be used for, so i don't really need it |
21:02:04 | FromDiscord | <morgan> or i could use a btree |
21:02:28 | FromDiscord | <morgan> if there's an easy way to create a btree without needing to add each index with a proc call |
21:02:48 | FromDiscord | <Varriount> Is there a way to compile Nim to WASM, to help boost Javascript performance? |
21:03:08 | FromDiscord | <Elegantbeef> You can use emscripten or NLVM to generate wasm |
21:03:22 | FromDiscord | <Elegantbeef> Remember that wasm cannot modify DOMs though so it's more like a system library for speed |
21:03:44 | FromDiscord | <Varriount> Sure. |
21:04:43 | FromDiscord | <Elegantbeef> https://github.com/treeform/nim_emscripten_tutorial is reference for using emscripten |
21:04:45 | FromDiscord | <Generic> In reply to @MorganAlyssa "is there an easy": there is another way which is pretty fast |
21:05:38 | FromDiscord | <Generic> https://gist.github.com/RSDuck/6a00efb32fcecebf88966b735b1c85bf |
21:06:13 | FromDiscord | <Generic> basically this, but for maximum (would need to work in reverse and use countLeadingZeroBits) |
21:08:51 | FromDiscord | <Generic> combined with masking off (i.e. `yourSet.excl({highestValue..high(yourSetType)})`) the upper set values you don't want to find |
21:09:07 | FromDiscord | <Generic> for maximum performace both steps could be performed into one |
21:09:46 | FromDiscord | <Generic> so the search for the maximum value would start in the first word of the set below the maximum value |
21:10:09 | FromDiscord | <Generic> where you'd then mask off the upper values |
21:10:27 | FromDiscord | <Generic> and then do the rest of the search without even needing a mask |
21:10:52 | FromDiscord | <Generic> ah now I'm reading you wrote easier, not faster |
21:35:07 | arkanoid | vindaar, as you said adding defUnit(m???s) on top of the module made it works. Knowing in advance all the moving types for this kind of work seems not so easy to do |
21:37:10 | arkanoid | not sure how I managed to generate two types that are equivalent but distinct, but the idea of this possibility kinda scares me |
21:53:55 | * | wallabra quit (Ping timeout: 246 seconds) |
21:54:34 | * | wallabra joined #nim |
21:57:48 | FromDiscord | <vindaar> it's because I abuse the fact that types can be defined locally. in certain use cases it can lead to these errors. it's a bit annoying, but you can rest assured that the worst that might happen are additional CT errors in cases such as this. any code that deals with units within the library does not care for specific type symbols |
21:58:47 | FromDiscord | <vindaar> I could add a switch to fully disable local types. but that would imply that for every intermediate type a `defUnit` call would be necessary |
21:59:26 | * | jmdaemon joined #nim |
22:00:09 | * | genpaku quit (Read error: Connection reset by peer) |
22:00:50 | * | genpaku joined #nim |
22:01:37 | FromDiscord | <morgan> In reply to @Generic "there is another way": thanks i'll try this out |
22:03:04 | arkanoid | vindaar, I'm porting more and more code to unchained, so far so good, but surely is more verbose than nim-units |
22:04:00 | arkanoid | but mostly because of explicit conversion of equal quanties (eg for imperial to is) |
22:05:02 | arkanoid | let me try writing an implicit converter, should not be too difficult |
22:07:01 | FromDiscord | <exelotl> say I'm wrapping a C library where most functions return true to indicate success, false to indicate error |
22:07:26 | FromDiscord | <exelotl> the functions that also need to return something useful do so via out parameters |
22:08:40 | FromDiscord | <exelotl> I'd like to stay close to the C API but make some convenience methods that return tuples (bool _and_ actual result) |
22:09:29 | FromDiscord | <exelotl> sent a code paste, see https://play.nim-lang.org/#ix=1lGt |
22:11:58 | FromDiscord | <exelotl> I'm thinking the latter because the useful thing should go first tbh |
22:12:40 | FromDiscord | <morgan> hm if you're returning just one then either would work but if you return ok first you could have any number of returns in the tuple after that |
22:12:52 | FromDiscord | <morgan> without needing to keep track which one is `ok` |
22:12:56 | FromDiscord | <morgan> (edit) "ok" => "`ok`" |
22:13:57 | FromDiscord | <exelotl> hm true, though I think "ok comes last" is also not too bad to remember |
22:14:07 | * | rez quit (Quit: much snoozes...) |
22:14:34 | FromDiscord | <morgan> or ok is 0, and then the 1 indexed output is that number in the brackets |
22:14:53 | FromDiscord | <vindaar> sent a code paste, see https://play.nim-lang.org/#ix=1nHS |
22:15:21 | FromDiscord | <exelotl> alternatively I could use `Result` from the stdlib but idk what the current feeling on that is |
22:15:26 | FromDiscord | <vindaar> (excuse the confusing inverted type names) |
22:15:43 | FromDiscord | <exelotl> wait I mean `Option` |
22:16:04 | FromDiscord | <exelotl> `Result` is status's one right? |
22:22:49 | FromDiscord | <Elegantbeef> Yes |
22:59:23 | FromDiscord | <morgan> is there a way to convert an int to an enum field with the same value? |
22:59:33 | FromDiscord | <Elegantbeef> `MyEnum(myInt)` |
22:59:39 | FromDiscord | <morgan> ah thanks |
23:02:06 | FromDiscord | <morgan> ah it also seems to work with the same syntax as distinct stuff can use |
23:02:27 | FromDiscord | <morgan> (at least i think so, i have an error elsewhere and im not calling that proc currently) |
23:04:12 | arkanoid | vindaar, is there a way to declare a derived unit without editing si_units.nim ? |
23:04:43 | FromDiscord | <Elegantbeef> Yea it's just type conversionsāµ(@morgan) |
23:20:26 | FromDiscord | <ratapenado> Hello, I was wondering if there was something to build desktop apps with web interface like electron for JavaScript or tauri for rust ? Thanks ! |
23:25:03 | FromDiscord | <Elegantbeef> There is https://github.com/juancarlospaco/webgui |
23:33:12 | * | krux02 joined #nim |
23:35:09 | FromDiscord | <ratapenado> In reply to @Elegantbeef "There is https://github.com/juancarlospaco/webgui": Thank you ! |