<< 19-10-2024 >>

00:02:39*thomasross_ joined #nim
00:02:39*thomasross quit (Killed (molybdenum.libera.chat (Nickname regained by services)))
00:02:39*thomasross_ is now known as thomasross
00:24:24FromDiscord<spaceshaman> Wait... all procedures are pointers?
00:24:43FromDiscord<spaceshaman> why though?
00:25:29FromDiscord<Elegantbeef> They're not
00:25:36FromDiscord<Elegantbeef> They're first class
00:25:51FromDiscord<Elegantbeef> > A procedural type
00:25:56FromDiscord<Elegantbeef> Is the important part
00:32:45FromDiscord<spaceshaman> What I mean is, when you use the identifier of a proc, you are getting a value that is internally an address. You dont do `my_func.addr()`
00:33:09FromDiscord<Elegantbeef> Right cause Nim has first class procedures
00:33:27FromDiscord<Elegantbeef> Calling named procedures does not create a procedure type
00:33:39FromDiscord<Elegantbeef> This works just like C
00:33:42FromDiscord<spaceshaman> you can have first class functions and procedures without that
00:34:02FromDiscord<Elegantbeef> They're not first class if you have to call `.addr` on them to get the pointer proc
00:34:26FromDiscord<spaceshaman> thats like saying that nim doenst have first class integers
00:34:44FromDiscord<spaceshaman> which is obviously wrong
00:34:48FromDiscord<Elegantbeef> Well no cause then `ptr proc()` is the type when you pass them around
00:35:02FromDiscord<spaceshaman> of course
00:35:06FromDiscord<Elegantbeef> Which means you can only have a proc inside of a pointer type
00:35:14FromDiscord<Elegantbeef> So they're clearly not first class
00:35:32FromDiscord<Elegantbeef> If you cannot just pass procedures as values I find it hard to believe they're first class
00:37:28FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=YNPxhaFH
00:37:38FromDiscord<Elegantbeef> Just for clarity
00:38:20FromDiscord<Elegantbeef> It serves little benefit to have a non usable `proc()` type that you have to prefix with `ptr` imo
00:38:56FromDiscord<spaceshaman> if you are passing procedures as values, that means you are passing around the actual function body.
00:39:07FromDiscord<Elegantbeef> No
00:39:11FromDiscord<Elegantbeef> That's not what I meant
00:39:24FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=MWENyFdr
00:39:35FromDiscord<Elegantbeef> If you need to do `i: ptr proc()` and `myFunc.addr` that is certainly not first class
00:40:09FromDiscord<Elegantbeef> There is `static proc()` which allows you to pass procedures into a procedure then expand them statically instead of with a pointer proc
00:41:00FromDiscord<Elegantbeef> Then there's also the issue that `ptr T` is generally to be avoided, but in the case of procedures it'd be enabling them. Then we also have closures which add even more headaches
00:41:21FromDiscord<Elegantbeef> This is at least if I understand you right
00:41:42FromDiscord<spaceshaman> is there no way to get a `ref T` from an lvalue?
00:41:53FromDiscord<Elegantbeef> A ref is ref counted
00:41:58FromDiscord<Elegantbeef> So of course not
00:42:05FromDiscord<Elegantbeef> You have to heap allocate then move the data
00:42:22FromDiscord<spaceshaman> so thats what it meant by that
00:42:34FromDiscord<Elegantbeef> `ref proc()` certainly is not the semantics you want for a pointer proc obviously
00:42:39FromDiscord<spaceshaman> ptr doent work with the GC?
00:42:49FromDiscord<Elegantbeef> ptr is an unsafe pointer
00:42:53FromDiscord<Elegantbeef> No different to a C pointer
00:43:01FromDiscord<spaceshaman> manual got it
00:43:13FromDiscord<spaceshaman> is there a gc pointer type?
00:43:33FromDiscord<Elegantbeef> `ref`
00:43:38FromDiscord<Elegantbeef> That's all there is
00:43:57FromDiscord<Elegantbeef> It's a ref counted heap allocated data block
00:44:13FromDiscord<Elegantbeef> There is no other method in Nim presently to have a memory safe pointer
00:44:16FromDiscord<spaceshaman> are the docs referring to reference counting when they mention a garbage collector?
00:44:22FromDiscord<Elegantbeef> well aside from `var` and `lent`
00:44:37FromDiscord<Elegantbeef> With Nim 2.0 and Arc/Orc yes
00:45:10FromDiscord<spaceshaman> ah, Im used to GC referring to a scanning GC
00:45:11FromDiscord<Elegantbeef> refc is a proper garbage collector but the default is now orc which is scope ref counting + cycle collector
00:45:52FromDiscord<Elegantbeef> The cycle collector is a mark and sweep collector that is only supposed to be invoked on cyclical types
00:46:57FromDiscord<spaceshaman> I have a pretty elementary understanding of GC types and terms
00:47:40FromDiscord<Elegantbeef> Good thing too my dear watson
00:48:05FromDiscord<spaceshaman> I definitely disagree on when functions are first class
00:48:35FromDiscord<Elegantbeef> > In computer science, a programming language is said to have first-class functions if it treats functions as first-class citizens. This means the language supports passing functions as arguments to other functions, returning them as the values from other functions, and assigning them to variables or storing them in data structures
00:49:12FromDiscord<spaceshaman> I would say the reason C doesnt have first class functions is that it lacks the ability to create them as values. And when I say first class functions, I mean first class function pointers
00:49:16FromDiscord<Elegantbeef> > In languages with first-class functions, the names of functions do not have any special status; they are treated like ordinary variables with a function type.
00:49:33FromDiscord<Elegantbeef> Well that's not what anyone agrees with
00:50:05FromDiscord<Elegantbeef> Passing a function by value means passing a pointer
00:50:20FromDiscord<Elegantbeef> Since a function is a labelled unit of code
00:50:32FromDiscord<spaceshaman> thats not by value
00:50:42FromDiscord<spaceshaman> a variable is a labeled unit of memory
00:50:43FromDiscord<Elegantbeef> That is by value
00:50:47FromDiscord<Elegantbeef> Cause a function's value is it's label
00:51:03FromDiscord<spaceshaman> a variable's value is not its label
00:51:12FromDiscord<spaceshaman> thats its address
00:51:26FromDiscord<Elegantbeef> Functions are pointer types though
00:51:56FromDiscord<spaceshaman> you can have function types that are not pointer types
00:52:40FromDiscord<Elegantbeef> In what way?
00:56:13FromDiscord<majortrips1763> You know .. realistically ... functions are just an agreed upon calling symantic on how we setup the registers and the stack before moving the instruction pointer around...
00:57:31FromDiscord<spaceshaman> sent a long message, see https://pasty.ee/ndhDuvdG
00:57:50FromDiscord<majortrips1763> like .. are we going to say that there is an idea of a load&store function vs an immediate in-so-far as the calling symantics?
00:58:39FromDiscord<majortrips1763> In reply to @spaceshaman "they are composed of": This isn't strictly true, at the ASM level you can jump to an absolute address .. the label is just a matter of convencience.. you can even setup a whole stack of offsets for different jmp's.
00:59:00FromDiscord<spaceshaman> its not strictly true, but its a good generalization
00:59:12FromDiscord<Elegantbeef> A function is the label though
00:59:13FromDiscord<majortrips1763> Any sort of function table, interrupt table, jump table, etc .. there doesn't need to be a label at all.
00:59:30FromDiscord<Elegantbeef> What the function does requires invoking it, so it's tangential to what a function is
00:59:55FromDiscord<majortrips1763> @ElegantBeef no, you don't need the label .. it can be fully optimized out. At the end of the day it is just an address somewhwere that you can point the IP at.
01:00:21FromDiscord<spaceshaman> In reply to @majortrips1763 "Any sort of function": but thats true of variables too, so... I think you havent read enough of the converation
01:00:26FromDiscord<majortrips1763> but, you can pass intructions as arguments and execute them
01:00:27FromDiscord<spaceshaman> (edit) "converation" => "conversation"
01:00:43FromDiscord<majortrips1763> see: executable stack
01:00:56FromDiscord<Elegantbeef> The address is the label
01:00:57FromDiscord<spaceshaman> major you're missing the point of the convo
01:01:01FromDiscord<Elegantbeef> I'm not using the ASM term label
01:01:31FromDiscord<majortrips1763> I think when we get down into ASM we are off in the woods .. the labels are sort of arbitrary as they are aliases for an address somewhere (be it an offset or not)
01:01:43FromDiscord<Elegantbeef> I'm saying a function is some location in the binary, and calling that a label, and passing "by value" makes no sense given a function is nothing more than a place in memory with no useful data
01:01:47FromDiscord<Elegantbeef> Other than tobe invoked it's pointless
01:02:55FromDiscord<spaceshaman> In reply to @majortrips1763 "I think when we": right, but there are conventions that I am referring to.
01:03:26FromDiscord<majortrips1763> In reply to @Elegantbeef "I'm saying a function": Yah, I generaly agree on the whole of it is generally impractical as hell to imagine passing function bodies as a param to a function .. BUT .. it can be done .. but at the same time .. pretty much nothing larger than a register can "truly" be passed to a function either...
01:04:20FromDiscord<majortrips1763> Like .. you really can't pass a string as an argument to a function .. when we get down to immidiates or indirects .. almost nothing is going to be trully passed "as a param" .. it will almost always be an address to some piece of memory somewhere.
01:04:38FromDiscord<spaceshaman> In reply to @Elegantbeef "Other than tobe invoked": and thats an ok thing to have. It means that you cant mistake the type of `foo` and `foo` where atm it could be a direct call or fetching the pointer
01:06:37FromDiscord<Elegantbeef> There is no mistaking though
01:06:42FromDiscord<Elegantbeef> `myFunc is proc()`
01:07:14FromDiscord<majortrips1763> In reply to @spaceshaman "and thats an ok": Again, we are back to the calling ABI where we agree that we have data types of limited sizes that can be passed directly as arguments (immediate), and everything else is either copied onto the stack, or is an address pointing off into the heap.↵↵Again . I think once we are down in ASM land the distinction become super weird because a function is going to suddenly change its behavio
01:12:47FromDiscord<majortrips1763> But .. it is also worth pointing out that it is totally possible to pass a "copy" of a function to another function at the C/ASM level. I dunno how practical it would be... maybe as part of some tooling for writing code that self-mutates binaries in memory?
01:13:04FromDiscord<Elegantbeef> We have macros for that 😄
01:13:11FromDiscord<majortrips1763> Like, you really could pass copies of functions just like copies of strings..
01:13:17FromDiscord<Elegantbeef> Or `static proc()` is the closest to passing by value, where it can inline calls
01:13:23FromDiscord<majortrips1763> I thought macros only worked on the AST..
01:13:41FromDiscord<Elegantbeef> Right but you can pass a symbol to a proc then do things to it
01:13:54FromDiscord<Elegantbeef> Of course all methods are compile time limited
01:14:34FromDiscord<majortrips1763> I was more off in hypothetical land, trying to imagine doing things like having a common routine in which I could pass some code to "inject" into memory and have the routine sort of PIE load the code into a random address and pass me back a pointer to it. Stuff like that.
01:15:50FromDiscord<Elegantbeef> Yea practically runtime macros, which sounds horrendous
01:15:51FromDiscord<majortrips1763> Like .. I really can't imagine a practical use for it .. but it could certainly be done. Realistically .. stack injections are kinda like passing a function and moving the instruction pointer to a bad address .. though .. most stuff should have a non-executable stack anymore to avoid that mess.
01:16:16FromDiscord<Elegantbeef> Excuse me whilst my program requires me to catch sigill
01:18:13FromDiscord<majortrips1763> I think that sort of stuff would likely be only interesting to people trying to do dynamically obfuscated binaries.. which anymore is likely only people trying to write malware... I feel like the stranglehold on "licensed binaries" and obfuscation compilers is part of the days of old..
01:19:03FromDiscord<Elegantbeef> I think the worst part on the userfront is it makes a type that is pointless 😄
01:19:52FromDiscord<majortrips1763> Hmm .. I wonder if it would be possible to get Nim to transpile to popcorn/tal instead of C/ASM
01:20:30FromDiscord<Elegantbeef> Araq does like pointing out that the VM is only a few thousand lines of code
01:20:42FromDiscord<majortrips1763> https://www.cs.cornell.edu/talc/
01:21:09FromDiscord<majortrips1763> Was an old project .. but it implemented a full Typed Assembly language and a C-like dialect (popcorn) that targetted it.
01:23:12FromDiscord<majortrips1763> Stuff like this was always interesting.
01:32:17FromDiscord<litlighilit> What about Hot Code Reloading(https://nim-lang.org/docs/hcr.html)?
01:32:23FromDiscord<Elegantbeef> It don't work
01:32:53FromDiscord<litlighilit> all right. I used to think it helps😅
01:33:45FromDiscord<Elegantbeef> https://github.com/beef331/potato/ is my attempt at some HCR goodness, not that it's overly stable(and is linux only) 😄
01:34:24FromDiscord<Elegantbeef> https://streamable.com/2mxktc It does partially work!
02:17:09*thomasross is now known as Guest5758
02:17:09*thomasross_ joined #nim
02:17:09*Guest5758 quit (Killed (tantalum.libera.chat (Nickname regained by services)))
02:17:09*thomasross_ is now known as thomasross
02:17:12*thomasross quit (Remote host closed the connection)
04:04:48*SchweinDeBurg quit (Ping timeout: 246 seconds)
07:05:50Amun-Ranice
08:40:05FromDiscord<whisperecean> I am trying to use disruptek's atoz package but I am getting a weird error: Error: invalid number: '25ae1f9e9aa35755ec5de0b1926a9031842726200eaf5db68815970cd60e7324'. Looks like something to do with the lfs (the generated APIs are big files).
10:10:08*strogon14_ quit (Quit: Auf Wiese geh'n!)
10:11:09*strogon14 joined #nim
10:43:48FromDiscord<firasuke> In reply to @firasuke "Is this still true?": ? 🙂
10:52:21FromDiscord<nnsee> In reply to @firasuke "? 🙂": seems fairly easy to test
11:15:53FromDiscord<jns> sent a code paste, see https://play.nim-lang.org/#pasty=iPlvslQJ
11:16:03FromDiscord<jns> (edit) "https://play.nim-lang.org/#pasty=epOUdlde" => "https://play.nim-lang.org/#pasty=MvyEGBCI"
11:16:18FromDiscord<jns> (edit) "https://play.nim-lang.org/#pasty=kmYfssiK" => "https://play.nim-lang.org/#pasty=rvTQrUuC"
11:25:08FromDiscord<odexine> only certain keywords can be used as operators
11:29:27FromDiscord<jns> sent a code paste, see https://play.nim-lang.org/#pasty=NCufMpfb
11:37:47*SchweinDeBurg joined #nim
11:42:14*SchweinDeBurg quit (Ping timeout: 260 seconds)
11:47:50*SchweinDeBurg joined #nim
12:03:18FromDiscord<odexine> templates require return types as well
12:06:33*ryuukk quit (Remote host closed the connection)
12:38:39*ryuukk joined #nim
12:50:05FromDiscord<firasuke> In reply to @nnsee "seems fairly easy to": ok gotcha xD
13:10:17*strogon14 quit (Quit: Auf Wiese geh'n!)
13:11:04*strogon14 joined #nim
13:42:46*beholders_eye joined #nim
13:44:02*ntat joined #nim
13:44:56FromDiscord<double_spiral> How can i change which c compiler nim uses?
13:45:34FromDiscord<double_spiral> Like as a path to the binary since im using a custom one
13:46:58*ryuukk quit (Remote host closed the connection)
13:51:23FromDiscord<nnsee> In reply to @double_spiral "Like as a path": see https://nim-lang.org/docs/nimc.html#compiler-selection and the section below that (the one about cross compilation)
13:51:29FromDiscord<nnsee> shows how you can set custom paths
13:58:29FromDiscord<double_spiral> thanks
14:07:03FromDiscord<double_spiral> Oh theres already a thing for it↵https://nim-lang.org/docs/nimc.html#crossminuscompilation-for-nintendo-switch
14:07:08FromDiscord<double_spiral> Surprised im not the first oen
14:07:11FromDiscord<double_spiral> (edit) "oen" => "one"
14:36:48FromDiscord<double_spiral> yessssss https://media.discordapp.net/attachments/371759389889003532/1297206823652425848/image.png?ex=6715157f&is=6713c3ff&hm=d2ca8aee2c16c926b3880a871628209dd30cd9bf1c587cf2d21ad6f38d6463fd&
14:41:52FromDiscord<narimiran> For those who don't check the #nimconf channel:↵NimConf will be held next Saturday!↵↵See the schedule here: https://conf.nim-lang.org
14:47:50FromDiscord<whisperecean> Can I use Nim js backend to write a github action?
14:49:04*ryuukk joined #nim
15:02:56*ryuukk quit (Remote host closed the connection)
15:04:44*ryuukk joined #nim
15:05:02*ryuukk_ joined #nim
15:06:44*ryuukk quit (Remote host closed the connection)
15:23:18FromDiscord<knakas> sent a code paste, see https://play.nim-lang.org/#pasty=hXlhtInl
15:31:36FromDiscord<knakas> Nevermind figured it out. (It's because it's wrapping a C function, I need to update the init.Chr4c to have an extra layer.)
15:37:06*SchweinDeBurg quit (Ping timeout: 246 seconds)
15:39:05*SchweinDeBurg joined #nim
15:49:49FromDiscord<knakas> sent a code paste, see https://play.nim-lang.org/#pasty=xRGtIiHW
16:10:54FromDiscord<rakgew> thank you for the notify - looking forward to nimconf!↵is that `#nimconf` room bridged to matrix by? I cannot seem to find the handle in the matrix room search.↵(@narimiran)
16:44:09*coldfeet joined #nim
17:31:33*beholders_eye quit (Ping timeout: 248 seconds)
18:17:31FromDiscord<double_spiral> How can i echo a number's binary value?
18:18:12Amun-Rastd/strutils
18:19:08Amun-Rato_bin
18:26:26*xet7 joined #nim
18:45:15*xet7 quit (Remote host closed the connection)
18:46:20*xet7 joined #nim
18:51:12*xet7 quit (Remote host closed the connection)
18:54:03*xet7 joined #nim
19:17:16*xet7 quit (Quit: Leaving)
19:21:35*xet7 joined #nim
19:46:19*coldfeet quit (Remote host closed the connection)
19:54:10*bgupta joined #nim
20:04:04bguptaWhen defining an importc proc with optional params, and call it while leaving the optional params unset but they are all at the end it works fine and sends along the defaults for any that are missing. However, if I set one of the later optional params, and leave some unset/default, I get missing param errors. I can add an extra wrapper function to address, but this seems a little wrong. Am I missing something? (Docs didn't help.)
20:14:11FromDiscord<spaceshaman> are types values?
20:14:33FromDiscord<spaceshaman> basically, is there a `Type` type?
20:14:52FromDiscord<Elegantbeef> there is `typedesc` but it cannot be instantiated
20:17:59FromDiscord<spaceshaman> sent a code paste, see https://play.nim-lang.org/#pasty=bzvZlcEo
20:19:38FromDiscord<Elegantbeef> bgupta the importc should match the ABI of the importing procedure
20:19:38FromDiscord<Elegantbeef> As such optional parameters make little sense
20:19:54FromDiscord<Elegantbeef> Alternatively make an issue and hope it's fixed 😄
20:23:42FromDiscord<spaceshaman> In reply to @spaceshaman "I was wondering if": wait does this matter if I use template or proc here?
20:25:46FromDiscord<spaceshaman> like does by using proc here does this:↵`do_stuff(int)(55)`↵ basically become this?:↵`(static do_stuff(int))(55)`
20:27:20FromDiscord<Elegantbeef> Oh bridge dropped a message, but yes you can do that
20:28:38FromDiscord<Elegantbeef> That is afterall what generics are fore
20:28:38FromDiscord<Elegantbeef> sent a code paste, see https://play.nim-lang.org/#pasty=WxWYlvkl
20:28:39FromDiscord<Elegantbeef> fore\
20:28:39FromDiscord<Elegantbeef> for\\\\\\\
20:31:27FromDiscord<SmaamX> Any lib like fuzzywuzzy(python) for nim?
20:56:46FromDiscord<Elegantbeef> https://nim-lang.org/docs/editdistance.html#editDistance%2Cstring%2Cstring
21:14:23bguptaTo be clear I mean by optional, we would define the default to pass into the C function, so as far as C goes it's getting all it's params, but nim which does understand optional/default values, can just send the default for any params that aren't in the call to the nim function.
21:15:13bguptasorry that last should say "that aren't in the call to the C function."
21:15:19FromDiscord<Elegantbeef> Yea it's likely a bug that it doesn't work
21:16:07bguptaAh ok.
21:16:31*ntat quit (Quit: Leaving)
22:12:14*GnuYawk joined #nim
23:23:25FromDiscord<monkey085395> Hi, can any forum mod help me sign up? Im getting `Couldn't send email`