I spoke too soon earlier, it turns out that forth-style lambdas are possible by adding only 31 bytes to the self-hosted assembler. It might be worth it, it adds a lot of expressiveness by allowing to play with a lot of joy-like things.
I spoke too soon earlier, it turns out that forth-style lambdas are possible by adding only 31 bytes to the self-hosted assembler. It might be worth it, it adds a lot of expressiveness by allowing to play with a lot of joy-like things. 21 comments
@maxc Are you familiar with Joy? Thoses curlies denote lambdas, they're made a bit like a cons cell, there's a CDR-like address at the start, their pointer ends up on the stack so they can be unquoted, moved around, or called. @neauoire only as a kind of happiness and I guess as a family of nurses 😉 will look into it thanks I think ultimately for lambda/anonymous function stuff it's always all about convenience/laziness so as long as it's shorter and easier to write than making another function and copying the label for that elsewhere, there's a chance it's considered useful! @maxc Uxntal is already tacit PF, so not only you don't need to write parameter names in a function, you can now be even more lazy and skip naming it altogether. Here's a nice little primer to Joy. @neauoire for those following along I basically found https://hypercubed.github.io/joy/html/forth-joy.html and it was very readable. Haven't dug into devine's resources yet :) @maxc @neauoire the tutorial (https://hypercubed.github.io/joy/html/j01tut.html) also seems helpful! this is a very interesting rabbit hole :> @johnfredcee I mispoke, implemented how forth handles strings, but using that strategy more broadly to allow lambdas. @nil Yes, what I'm working on specifically is here: https://git.sr.ht/~rabbits/drifblim/tree/main/item/src/drifblim.tal @maxime_andre I went for a JMI -> STH2r, so I jump-stash over the lambda, and then move the pointer to the wst from the rst. It's nicer that way I found. @maxime_andre I'm not really sure which one is right, I've always called it Jumpstash for some reason ^^: @neauoire you're making me come back to Factor and Joy :) and try uxntal + varvara but that's for another day... maybe a port of Joy? @a13cui This morning I'm implementing some of Joy's combinators, I think you could write straight joy, directly in uxntal now. Instead of an absolute address(a-la cdr) to the end of the lambda scope, I'm piggy-backing on the JSI opcode which stores a relative address, so this gives me the length of the lambda scope, and as a side effect, "free" Pascal-style strings. I've totally lost track of where I was going with this lambda project, but I LOVE IT |
@neauoire can I get a breakdown of what's going on here?