<< 18-10-2022 >>

00:02:28FromDiscord<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:21FromDiscord<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:00FromDiscord<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:06arkanoidElegantbeef, ok, thanks
00:20:24arkanoidwhy slicing an array returns a sequence? I don't want allocations!
00:21:12FromDiscord<wick3dr0se> i3
00:21:18arkanoidlet foo = [1,2,3,4,5] # foo is array[5,int]. let bar = foo[0..3] # bar is seq[int]
00:21:43FromDiscord<wick3dr0se> (edit) "i3 ... " added "Arch Linux. I use xwallpaper and thought about just making a call"
00:24:26FromDiscord<Elegantbeef> You have to use `toOpenArray` if you dont want to have heap allocations
00:24:48FromDiscord<Elegantbeef> !eval var foo = [1, 2, 3, 4, 5]; echo foo.toOpenArray(0, 3)
00:24:54NimBot[1, 2, 3, 4]
00:27:21arkanoidElegantbeef, do I need experimental views?
00:30:23arkanoidI'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:39FromDiscord<Elegantbeef> you cannot store `openArray` in a varaible
00:30:43FromDiscord<Elegantbeef> It has to go directly into a function
00:31:00*disso_peach joined #nim
00:32:05arkanoidElegantbeef, mmm would produce smelly code in my case. Let me try with views
00:33:36FromDiscord<Elegantbeef> Unless you use views of course
00:34:04arkanoidwhoa! Error: internal error: getTypeDescAux(tyFromExpr)
00:34:58FromDiscord<Elegantbeef> Yea misuisng openarray is bound to cause issues
00:35:40arkanoidI'm probably not misusing it, because code compiles with default gc, and rasises internal error with arc
00:35:50arkanoid(and code is quite trivial at this point)
00:36:21FromDiscord<Elegantbeef> Well i consider views misusing it šŸ˜„
00:37:14arkanoidoh! ok, if you say so
00:37:46arkanoidquite sad, this would be a perfect spot to use views, but I have to avoid them instead
00:37:48FromDiscord<Elegantbeef> If you're just trying to pass slices using a template is likely less error ridden
00:38:24FromDiscord<Elegantbeef> `template mySlice: auto = myColl.toOpenArray(a, b)`
00:39:52FromDiscord<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:33arkanoidElegantbeef, I'll consider it down the road, thanks again
00:41:45arkanoidso far, I'll just copypaste arrays
00:42:42FromDiscord<Elegantbeef> Ugh
00:46:21arkanoidstill better than allocating
00:46:40arkanoidI'll replace copypaste with toOpenArray when possible down the road
00:46:58arkanoidspeaking of openArray, why I don't get .length of it?
00:47:04FromDiscord<Elegantbeef> Eh stack allocating is still allocating
00:47:07arkanoidhttps://nim-lang.org/docs/system.html#openArray says it has a length attribute
00:47:08FromDiscord<Elegantbeef> What do you mean?
00:47:10FromDiscord<Elegantbeef> `.len` works
00:47:39FromDiscord<Elegantbeef> openarrays internals hidden away just like `seq`
00:49:33FromDiscord<wick3dr0se> I found my answer from the osproc library, `execCmd`
00:51:46arkanoidI'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:38arkanoidthis is the signature func `*`[T, J](a: openArray[T], b: openArray[J]): auto =
01:01:08arkanoidsolved with func `*`[N, T, J](a: array[N, T], b: array[N, J]): auto =
01:08:13FromDiscord<Elegantbeef> Openarray are runtime sliced values so the len is not known statically
01:08:39FromDiscord<Elegantbeef> Arrays are required for this
01:08:40FromDiscord<Elegantbeef> Just to clarify
01:09:22arkanoidyes 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:08arkanoiddamn, 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:01FromDiscord<Elegantbeef> I had an entire array module i made for fun eons ago, it's a fight with the type system
01:13:22FromDiscord<Elegantbeef> `T J` is... supposed to be what?
01:14:33FromDiscord<Rika> How does one multiply types
01:14:44FromDiscord<Rika> Unless youā€™ve defined it of course in which case what would it be
01:15:43arkanoidElegantbeef, 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:13arkanoidfor example, this line compiles and run "let asd: Length / Time = 5.Velocity"
01:16:42arkanoidnormally it would be used like "let asd: Velocity = 5.m / 2.s
01:16:45FromDiscord<Elegantbeef> I see, sorta
01:16:53FromDiscord<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:56FromDiscord<Elegantbeef> Yea i dont get the point on typedescs
01:17:04FromDiscord<auxym> (edit) "function" => "functional"
01:18:20arkanoidbut 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:55arkanoidI'm failing to use the operations on types when I try to generalize
01:19:03FromDiscord<Elegantbeef> you might have to use `auto`
01:19:12FromDiscord<Rika> In reply to @auxym "product types? Like in": Does that use
01:19:18FromDiscord<Rika> I know of product types at least
01:19:54FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4dsh something like this ark
01:20:58arkanoidwait a sec my browser refuses to show the page for some reason
01:21:11FromDiscord<auxym> In reply to @Rika "Does that use *": Yeah IIRC ML-family uses `` to create product types
01:21:25arkanoidseems down to me
01:21:30FromDiscord<auxym> which has nothing to do actually with @Arkanoids units thing
01:21:36FromDiscord<Elegantbeef> Refresh perhaps ark
01:21:56FromDiscord<Elegantbeef> Seems i took the playground down
01:21:57FromDiscord<Elegantbeef> http://ix.io/4dsh
01:21:58FromDiscord<Elegantbeef> There
01:22:08FromDiscord<wick3dr0se> sent a code paste, see https://play.nim-lang.org/#ix=4dsi
01:22:21FromDiscord<Elegantbeef> `strutils.join`
01:23:04FromDiscord<wick3dr0se> ty
01:24:07arkanoidthanks 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:26FromDiscord<wick3dr0se> Hell yea `join()` worked great
01:27:36arkanoidwait, I thing I'm fighting a nim bug here. I'm getting again internal compiler error toggling arc
01:27:38FromDiscord<wick3dr0se> Skips the whole for loop part too
01:28:44arkanoidthis line "dump array[5, Mass / Area].default" compiles with default gc, raises "Error: internal error: getTypeDescAux(tyFromExpr)" if I enable arc
01:35:34arkanoidthis Units packages is capable of crashing the compiler in creative ways ...
01:44:56arkanoidI'm creating a minimal example to submit the issue. Do you know what is "Error: system module needs: nimGCvisit" ?
01:53:03arkanoidhere's the minimal example that causes the issue https://github.com/nim-lang/Nim/issues/20588
02:01:00arkanoidElegantbeef, 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:45arkanoidbut I've found a weird trick to make it work
02:04:07arkanoidvar asd: T*J; result = default(array[N, asd.typedesc])
02:06:41arkanoidthis 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:02madpropshey nimbros
05:43:09madpropsso what's the state of web servers?
05:53:51FromDiscord<Phil> Could you specify?
05:54:16madpropswhat's nim's node
05:54:24madpropsnodejs*
05:57:31FromDiscord<Phil> you mean webframework?
05:57:48FromDiscord<Phil> or do you mean nim's compilation to JS?
05:58:10FromDiscord<Phil> Or do you mean nim's frontend libraries such as karax?
06:07:39FromDiscord<Rika> Node is a backend system using JavaScript so
06:07:41madpropssimple webserver to listen to requests and return something
06:07:51FromDiscord<Rika> Web server frameworks
06:08:04FromDiscord<Rika> Ehem, Phil, go on
06:11:04madpropsthough some framework on top might help
06:11:09madpropslike what express is to nodejs
06:11:28madpropsi used to use python's django a lot. but it ran on apache
06:17:15FromDiscord<Bung> https://github.com/nim-lang/Nim/wiki/Nim-for-TypeScript-Programmers#table-of-contents read this
06:18:26FromDiscord<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:52FromDiscord<Phil> sent a long message, see http://ix.io/4dtq
07:40:47FromDiscord<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:30FromDiscord<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:12FromDiscord<Phil> Though those shouldn't be too hard to adjust to use them with jester
08:21:19FromDiscord<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:48arkanoidis it possible to define a range type from an interval generated by custom type?
11:08:59arkanoidrange[1.myfloat .. 5.myfloat]
11:10:34*arkurious joined #nim
11:12:14arkanoidwell, I guess I'll avoid them https://status-im.github.io/nim-style-guide/language.range.html
11:52:40PMunchIs 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:21FromDiscord<Esther> Iā€™d have thought thatā€™d work, surely?
11:53:30FromDiscord<Esther> It does in Ada ._.
12:04:27PMunch@Esther, that what works?
12:33:56*derpydoo joined #nim
13:11:57arkanoidI 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:00PMunchBy the way, I managed to solve my problem with setCurrentDirectory(getAppDirectory())
13:18:29PMuncharkanoid, I think that looks okay
13:18:35PMunchYou don't need that assert though
13:19:01PMunchSince 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:13arkanoidPMunch: you're right!
13:21:55arkanoidis there a way to get from a type the "parent type" like given "float" -> "Somefloat"
13:22:34arkanoidI'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:40PMunchSomeFloat isn't a parent type of float
13:35:51PMunchIt's a group that happens to include float
13:36:16PMunchSo 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:47FromDiscord<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:24FromDiscord<Rika> caddr does not sound like a stdlib function
15:09:39FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvx
15:12:21FromDiscord<ChocolettePalette> Why isn't it a template?
15:13:51FromDiscord<sOkam!> šŸ¤·ā€ā™‚ļø
15:14:36FromDiscord<sOkam!> how would I write something similar for chroma?ā†µHow do you turn an object with 4 floats, into an array?
15:16:10FromDiscord<Dumb Dragon> unimportant question, but how would I go about getting the time at compile time?
15:16:22FromDiscord<Dumb Dragon> I can't use `std/times` because that uses importc
15:16:39FromDiscord<ChocolettePalette> Make an empty array, then write 4 lines of code adding stuff to your array from an object
15:17:55FromDiscord<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:59FromDiscord<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:03FromDiscord<Rika> been a while since i used nim
15:20:10FromDiscord<Rika> In reply to @kraptor "Hi nimmers! How would": no
15:20:13FromDiscord<Dumb Dragon> Yeah I was about to say I just figured it out lol, I'm dumb
15:20:33FromDiscord<Dumb Dragon> thanks
15:21:20FromDiscord<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:41FromDiscord<kraptor> uhm... and is there a way to hijack the default constrcutor?
15:23:48FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvB
15:24:50FromDiscord<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:55FromDiscord<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:01FromDiscord<kraptor> (edit) "element" => "item"
15:26:06FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvF
15:26:29FromDiscord<sOkam!> In reply to @kraptor "my suggestion would be": The type is given by chroma, I don't own it
15:26:54FromDiscord<sOkam!> I'm just trying to bridge chroma to opengl
15:27:31FromDiscord<Rika> In reply to @kraptor "uhm... and is there": nope xd
15:28:30FromDiscord<kraptor> ouch! Thanks Rika, maybe in the future šŸ™‚ I'll try to educate users of my library for now... šŸ˜„
15:28:39FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4dvI
15:28:42FromDiscord<Rika> prolly will die immediately like the stack version
15:29:16FromDiscord<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:38FromDiscord<demotomohiro> You need to learn how stack memory works.ā†µ@sOkam! http://zevv.nl/nim-memory/
15:30:37FromDiscord<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:06FromDiscord<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:14FromDiscord<Rika> you dont even need the cast
15:31:25FromDiscord<Rika> wait, no you do
15:31:33FromDiscord<kraptor> was thinking the same, just the address of the color.r member will do
15:31:39FromDiscord<Rika> ptr is typed xd i forgot about typing
15:31:45FromDiscord<Rika> what C does to a mf
15:32:00FromDiscord<sOkam!> kk ty
15:32:03FromDiscord<Rika> well actually
15:32:24FromDiscord<Rika> `cast[ptr GLfloat](colour.addr)` perhaps
15:32:28FromDiscord<Rika> not sure what a GLfloat is but
15:32:32FromDiscord<Rika> yeah
15:32:54FromDiscord<kraptor> in any case, a cast will do: cast[ptr GLfloat](colour.r.addr)
15:33:01FromDiscord<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:01FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvO
15:34:51FromDiscord<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:01FromDiscord<sOkam!> kk
15:35:06FromDiscord<Rika> In reply to @sOkam! "Oh, I just found": or make it var
15:35:14FromDiscord<Rika> like the reply
15:35:34FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvQ
15:42:18FromDiscord<Rika> return type
15:44:36FromDiscord<sOkam!> sent a code paste, see https://play.nim-lang.org/#ix=4dvV
15:44:37FromDiscord<Andycol> Hey Guys
15:45:12FromDiscord<Andycol> sent a code paste, see https://play.nim-lang.org/#ix=4dvW
15:45:55FromDiscord<Andycol> (edit) "https://play.nim-lang.org/#ix=4dvW" => "https://play.nim-lang.org/#ix=4dvY"
15:47:26FromDiscord<Rika> what am i looking at
15:47:34FromDiscord<Andycol> that is bash code
15:47:43FromDiscord<Andycol> so echos the below output into the file custom.xml
15:47:51FromDiscord<Rika> https://nim-lang.org/docs/io.html#writeFile,string,string
15:48:28FromDiscord<Rika> sent a code paste, see https://play.nim-lang.org/#ix=4dw0
15:48:46FromDiscord<Andycol> awesome let me try thanks!!
15:50:33FromDiscord<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:06FromDiscord<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:18FromDiscord<tsoj> sent a code paste, see https://play.nim-lang.org/#ix=4dwh
16:24:08FromDiscord<Rika> i assume its timezones
16:24:15FromDiscord<Rika> your timezone probably has DST
16:24:33FromDiscord<Rika> perhaps you just hit the day DST is changed
16:25:03FromDiscord<Rika> seems not
16:25:05FromDiscord<Rika> not sure then
16:25:29FromDiscord<Rika> oh wait no
16:25:36FromDiscord<Rika> DST does change march 26 in some countries
16:25:58FromDiscord<tsoj> oh i comletely forgot about that
16:26:00FromDiscord<Rika> lol
16:26:04FromDiscord<Rika> welcome to time hell
16:26:31FromDiscord<tsoj> yeah it's my first encounter
16:26:55FromDiscord<treeform> I made a timezone/calendar lib that I feel make more sense: https://github.com/treeform/chrono
16:27:08FromDiscord<treeform> By default its all in UTC so you will not have that issue.
16:27:47FromDiscord<treeform> DST can be very unpredictable
16:28:09FromDiscord<treeform> Its hast stopped in many countries and some US states in the last 20 years.
16:28:34FromDiscord<Rika> treeform literally prints libraries
16:28:40FromDiscord<Rika> snaps them into existence
16:28:45FromDiscord<treeform> Some countries change times 4 times a year (mainly for religious events like Ramadan).
16:28:55FromDiscord<Rika> by the time its tomorrow he'd have released 15 new super useful libraries
16:29:36FromDiscord<treeform> Some states like Indiana, have like 9-13 timezones depending on how you count
16:30:10FromDiscord<Rika> oh man the fucking fractional timezones
16:30:12FromDiscord<treeform> Some countries (mostly around India) are 30 or 15 minutes off UTC.
16:32:53FromDiscord<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:58FromDiscord<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:10FromDiscord<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:42FromDiscord<baalajimaestro> Yep india is +5.30, Bangladesh is +5.45ā†µ(@treeform)
17:01:46arkanoidis there any advantage in having large "let/var" blocks, instead of multiple statements?
17:02:20FromDiscord<Rika> advantage in what sense
17:02:55FromDiscord<auxym> In Canada we have https://en.wikipedia.org/wiki/Newfoundland_Time_Zone (UTC -3.5)
17:03:00FromDiscord<rakgew> less source code to ready, maybe.
17:03:21arkanoidperformance, compiler efficiency, and so on
17:03:46FromDiscord<auxym> no, it's just syntax (aka programmer convenience)
17:10:15arkanoidk
17:11:57FromDiscord<vindaar> arkanoid\: I&#x27;m not sure what you&#x27;re trying to achieve exactly, but possibly `unchained` can be of use? https://github.com/SciNim/unchained At the very least I&#x27;ll be able to answer the kind of questions you&#x27;re wondering about nim-units šŸ˜…
17:12:41arkanoidvindaar, are you saying I've been using the wrong units library all the time?
17:14:26arkanoidI've been fighting https://github.com/Udiknedormin/NimUnits for a whole day, lol
17:14:31arkanoidwell, it works nice!
17:15:18FromDiscord<vindaar> I&#x27;m not sure. I&#x27;d say there is no "right or wrong". Both have their own pros and cons, I guess. I don&#x27;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:06arkanoidvindaar, you mean that unchained won't let me "func calcspeed(a: Length, b: Time): Velocity = a / b" ?
17:17:40arkanoidwill it become "func calcspeed(a: meters, b: seconds): meters/seconds = a / b
17:18:10FromDiscord<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:37FromDiscord<vindaar> and if the unicode is too crazy for you, you can also write e.g. `kmh^-1` etc
17:18:44FromDiscord<vindaar> oh, wait
17:19:03arkanoidsi you're saying exactly what I am saying
17:19:04FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dwH
17:19:10FromDiscord<vindaar> yup
17:19:14*ehmry quit (Quit: https://quassel-irc.org - Chat comfortably. Anywhere.)
17:19:20FromDiscord<vindaar> (except not quite ;) )
17:20:02arkanoidnot 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:10FromDiscord<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:53arkanoidvindaar, so under the hood unchained knows that feet and meters are units of the same quantity, right?
17:21:54FromDiscord<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:01FromDiscord<vindaar> yup
17:23:02FromDiscord<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:35FromDiscord<vindaar> https://github.com/SciNim/Unchained/blob/master/src/unchained/si_units.nim defines the SI unit system
17:23:40arkanoidnim-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:04arkanoidso uder the hood there's only one system, but you can start from wherever you want
17:24:19arkanoidwhat is not trivial to do is converting meters to feet
17:24:22arkanoidfor example
17:25:01FromDiscord<vindaar> I see
17:26:03arkanoidwriting 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:56FromDiscord<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:06arkanoidin 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:50arkanoidcan unchained do implicit conversion of units?
17:28:58FromDiscord<vindaar> yes
17:29:09arkanoidfor example feeding 5.ft to "proc foo(a: meters)"
17:29:24FromDiscord<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:54FromDiscord<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:58FromDiscord<vindaar> you could define a converter though
17:30:32arkanoidwell, this means nim-units is superior
17:31:01FromDiscord<vindaar> as I say, it is dependent on what you actually want. If that convenience is important to you, sure it is
17:31:52arkanoidlet me thing about it for a while. I'll surely want to try a hard switch
17:31:58arkanoidI have another quesiton though
17:32:08arkanoidwhat about array manipulations?
17:32:23arkanoidarray * array mul, div
17:32:31arkanoidor array * const mul, div
17:32:40arkanoidbroadcasting, I mean
17:33:15arkanoiddoes unchained supports this out of the box? I'm writing my own functions for nim-units and is not quite trivial
17:35:37FromDiscord<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:26FromDiscord<vindaar> do you have an explicit example? Then I might have a better idea
17:38:32FromDiscord<vindaar> and by array you strictly mean `array` (i.e. also `array` return type and not a `seq`?)
17:41:23FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dwM
17:43:55FromDiscord<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:17FromDiscord<vindaar> I can throw them into a PR if that seems useful to you I guess
17:44:17arkanoidvindaar: here a brief example https://play.nim-lang.org/#ix=4dwO
17:45:29arkanoidI've not found a better solution (so far) than "let t = default(T) * default(J)"
17:45:55arkanoidwell, SomeUnit is something I struggle not having in num-units
17:46:19arkanoidas you can see, I have not type limiter in my generic arguments, and this is bad
17:46:41arkanoidthis is because I don't have (or I have not found yet) the equivalent in nim-units
17:47:32FromDiscord<vindaar> yeah, pretty much what I wrote there. what are you working on though? dynamic fuel model?
17:48:14arkanoidvindaar, wildfire simulation stuff. Converting my python stuff actually
17:48:32FromDiscord<vindaar> sorry, I'm no help there either. Could be that there is no equivalent
17:48:33FromDiscord<vindaar> interesting!
17:50:50arkanoidI'm trying to develop the core login without heap allocations. I expect it to be super-fast!
17:51:01arkanoid*core logic
17:53:36arkanoidsurely python is still far superior in this stuff
17:54:09arkanoidin my original python implementation, I'n not only getting correcy units, but also uncertainty and error propagation model out of the box
17:55:52FromDiscord<vindaar> https://github.com/SciNim/measuremancer
17:56:13arkanoid:O
17:56:15arkanoid:O O
17:56:18arkanoidWHAT?
17:56:50arkanoidI've been missing nim news for too long, I suppose
17:57:26FromDiscord<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:39FromDiscord<vindaar> I just suck at advertising šŸ« šŸ˜›ā†µ(<@709044657232936960_arkanoid=5b=49=52=43=5d>)
17:57:56arkanoidMeasurement math with different unchained units is currently only supported using multiplication, *. For the others the implementation is still pending.
17:58:20arkanoiddamn, I would jump on this immediately if it would support more operations
17:59:26arkanoiddamn, I would jump on this immediately if it would support the operations I need
18:00:10FromDiscord<vindaar> I just have to implement them. Shouldn't be a big deal. Not even sure if that message is still correct
18:01:25arkanoidI 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:19arkanoidhttps://gist.github.com/arkanoid87/b81c5cae6f0bb5682e83e51edbae2c2c
18:03:09*kenran joined #nim
18:06:44FromDiscord<vindaar> ok, the division is broken. but `+`, `-` and `` work in measuremancer with same and different units, respectively
18:07:21arkanoidbtw, 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:34arkanoidvindaar, be aware you've just changed my day
18:08:07arkanoidwhat about trigonometric functions?
18:10:35FromDiscord<vindaar> ok, got `/` working
18:11:01FromDiscord<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:24FromDiscord<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:27arkanoidsure! well, thanks, I'll try to find out if my able to add the operations I need
18:18:00FromDiscord<vindaar> I'll create a PR for my division fix quickly
18:18:30arkanoidvindaar, 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:40FromDiscord<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:41arkanoidvindaar, my first line found a non-pre-existing IS unit of measure
18:23:59arkanoidhttps://en.wikipedia.org/wiki/Area_density
18:25:19FromDiscord<vindaar> ah
18:25:23FromDiscord<vindaar> not imperial, haha
18:25:29FromDiscord<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:31FromDiscord<vindaar> I read that IS as "imperial system"
18:26:23*derpydoo quit (Quit: derpydoo)
18:26:57FromDiscord<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:06arkanoidmy fault. In my native language is SI like, but my head wraps the words when speaking english. I mean Systeme international,
18:27:48FromDiscord<vindaar> šŸ‘Œ
18:28:43FromDiscord<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:21arkanoidnp, thanks for the help and the feedback!
18:30:32FromDiscord<vindaar> you're welcome!
18:30:59arkanoidvindaar, these are the units I'm using in nim-units https://play.nim-lang.org/
18:31:13arkanoidI had to add 3 (the ones with wikipedia link)
18:31:19arkanoidsorry wrong link
18:31:31arkanoidhttps://play.nim-lang.org/#ix=4dwZ
18:34:50FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=4dx0
18:35:35FromDiscord<vindaar> (might still be useful to have `AreaDensity` as a quantity for certain use cases of course)
18:37:54FromDiscord<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:55arkanoidI 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:10arkanoidthe very same test in nim-units works
19:46:40FromDiscord<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:53FromDiscord<4zv4l> this is the simple array
19:46:56FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4dxs
19:46:59FromDiscord<4zv4l> with Linux it compiles fine
19:47:02FromDiscord<4zv4l> but for Windows I get this
19:47:19FromDiscord<4zv4l> sent a code paste, see https://play.nim-lang.org/#ix=4dxv
19:48:26FromDiscord<4zv4l> (edit) "zig" => "nim"
19:48:59arkanoidcould you please help me decrypt this error message? To my eyes, there no error https://play.nim-lang.org/#ix=4dxw
20:03:30FromDiscord<Recruit_main707> does it work without the range?
20:03:44FromDiscord<Recruit_main707> like, just `array[2, ...]`
20:10:08*kenran quit (Remote host closed the connection)
20:14:09FromDiscord<Bung> gcsafe ?
20:25:15FromDiscord<vindaar> sent a long message, see http://ix.io/4dxH
20:25:17FromDiscord<vindaar> will be afk again
20:29:05*derpydoo joined #nim
20:32:05FromDiscord<Elegantbeef> One of your procs is not gcsafeā†µ(@4zv4l)
20:32:30FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=e5t
20:32:44FromDiscord<4zv4l> what does `MainProc` do ?
20:37:39FromDiscord<Elegantbeef> Type converts it
20:38:01FromDiscord<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:15FromDiscord<Elegantbeef> So hitting a non safe procedure causes a type mismatch
20:50:02FromDiscord<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:52FromDiscord<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:59FromDiscord<Elegantbeef> What?
21:00:42FromDiscord<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:12FromDiscord<Elegantbeef> iterate the set is the only way
21:01:16FromDiscord<morgan> ok
21:01:48FromDiscord<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:04FromDiscord<morgan> or i could use a btree
21:02:28FromDiscord<morgan> if there's an easy way to create a btree without needing to add each index with a proc call
21:02:48FromDiscord<Varriount> Is there a way to compile Nim to WASM, to help boost Javascript performance?
21:03:08FromDiscord<Elegantbeef> You can use emscripten or NLVM to generate wasm
21:03:22FromDiscord<Elegantbeef> Remember that wasm cannot modify DOMs though so it's more like a system library for speed
21:03:44FromDiscord<Varriount> Sure.
21:04:43FromDiscord<Elegantbeef> https://github.com/treeform/nim_emscripten_tutorial is reference for using emscripten
21:04:45FromDiscord<Generic> In reply to @MorganAlyssa "is there an easy": there is another way which is pretty fast
21:05:38FromDiscord<Generic> https://gist.github.com/RSDuck/6a00efb32fcecebf88966b735b1c85bf
21:06:13FromDiscord<Generic> basically this, but for maximum (would need to work in reverse and use countLeadingZeroBits)
21:08:51FromDiscord<Generic> combined with masking off (i.e. `yourSet.excl({highestValue..high(yourSetType)})`) the upper set values you don't want to find
21:09:07FromDiscord<Generic> for maximum performace both steps could be performed into one
21:09:46FromDiscord<Generic> so the search for the maximum value would start in the first word of the set below the maximum value
21:10:09FromDiscord<Generic> where you'd then mask off the upper values
21:10:27FromDiscord<Generic> and then do the rest of the search without even needing a mask
21:10:52FromDiscord<Generic> ah now I'm reading you wrote easier, not faster
21:35:07arkanoidvindaar, 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:10arkanoidnot 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:48FromDiscord<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:47FromDiscord<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:37FromDiscord<morgan> In reply to @Generic "there is another way": thanks i'll try this out
22:03:04arkanoidvindaar, I'm porting more and more code to unchained, so far so good, but surely is more verbose than nim-units
22:04:00arkanoidbut mostly because of explicit conversion of equal quanties (eg for imperial to is)
22:05:02arkanoidlet me try writing an implicit converter, should not be too difficult
22:07:01FromDiscord<exelotl> say I'm wrapping a C library where most functions return true to indicate success, false to indicate error
22:07:26FromDiscord<exelotl> the functions that also need to return something useful do so via out parameters
22:08:40FromDiscord<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:29FromDiscord<exelotl> sent a code paste, see https://play.nim-lang.org/#ix=1lGt
22:11:58FromDiscord<exelotl> I'm thinking the latter because the useful thing should go first tbh
22:12:40FromDiscord<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:52FromDiscord<morgan> without needing to keep track which one is `ok`
22:12:56FromDiscord<morgan> (edit) "ok" => "`ok`"
22:13:57FromDiscord<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:34FromDiscord<morgan> or ok is 0, and then the 1 indexed output is that number in the brackets
22:14:53FromDiscord<vindaar> sent a code paste, see https://play.nim-lang.org/#ix=1nHS
22:15:21FromDiscord<exelotl> alternatively I could use `Result` from the stdlib but idk what the current feeling on that is
22:15:26FromDiscord<vindaar> (excuse the confusing inverted type names)
22:15:43FromDiscord<exelotl> wait I mean `Option`
22:16:04FromDiscord<exelotl> `Result` is status's one right?
22:22:49FromDiscord<Elegantbeef> Yes
22:59:23FromDiscord<morgan> is there a way to convert an int to an enum field with the same value?
22:59:33FromDiscord<Elegantbeef> `MyEnum(myInt)`
22:59:39FromDiscord<morgan> ah thanks
23:02:06FromDiscord<morgan> ah it also seems to work with the same syntax as distinct stuff can use
23:02:27FromDiscord<morgan> (at least i think so, i have an error elsewhere and im not calling that proc currently)
23:04:12arkanoidvindaar, is there a way to declare a derived unit without editing si_units.nim ?
23:04:43FromDiscord<Elegantbeef> Yea it's just type conversionsā†µ(@morgan)
23:20:26FromDiscord<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:03FromDiscord<Elegantbeef> There is https://github.com/juancarlospaco/webgui
23:33:12*krux02 joined #nim
23:35:09FromDiscord<ratapenado> In reply to @Elegantbeef "There is https://github.com/juancarlospaco/webgui": Thank you !