avatar
Shriram Krishnamurthi @shriram.bsky.social

I've got my own opinions about these kinds of topics as pedagogical devices, so maybe best not to get me started on this topic. (-:

sep 3, 2025, 4:27 pm • 3 0

Replies

avatar
James Brundage | MVP @mrpowershell.com

Happy to hear them, especially since I basically built this variation of Turtle to teach, inspire, and peel back layers of the universe. ( Also, in case this isn't clear, if you work on a language you end up a language nerd ) Please share your opinions, I'm eager to hear them.

sep 3, 2025, 4:34 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

parentheticallyspeaking.org/articles/how...

sep 3, 2025, 4:36 pm • 1 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Btw, if you want a real recursive head trip, do you know of any other language that allows anonymous recursion? It's one of the more fun little lambdas to bust out in #PowerShell. I still haven't seen that feature anywhere else, but my knowledge is finite. 😉. You seen it anywhere ?

sep 3, 2025, 4:45 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

I'm not sure what "anonymous recursion" means really, but the Y-combinator might be what you're looking for, and it's encodable in numerous languages directly or with a little bit of effort (depending on eager vs lazy evaluation, the specific type structure of the language, etc.).

sep 3, 2025, 4:47 pm • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Hmm. I suppose one way to think of it would be in terms of a "automatic" y-combinator. & $myinvocation.MyCommand.ScriptBlock # brief anonymous recursion example. Let's me build a recursive lambda without ever saving it to a variable. ( $myInvocation is an automatic variable )

sep 3, 2025, 4:56 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

Is this the sort of thing you mean? Note that there is no recursive name reference. I've also purposely created an outer function so we can confirm the two instances (non-rec-lucas and non-rec-fib) are not confused with each other, i.e., they really are from this *invocation*.

(define (lucas-or-fib n0 n1) (lam (n) (cond [(= n 0) n0] [(= n 1) n1] [(> n 1) (+ ($myinvocation (- n 1)) ($myinvocation (- n 2)))]))) (define non-rec-fib (lucas-or-fib 0 1)) (check-equal? (non-rec-fib 5) 5) (check-equal? (non-rec-fib 10) 55) (define non-rec-lucas (lucas-or-fib 2 1)) (check-equal? (non-rec-lucas 5) 11) (check-equal? (non-rec-lucas 10) 123)
sep 3, 2025, 8:41 pm • 1 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Looks like it. What language is that? (looks vaguely functional, but I don't think it's scheme)

sep 3, 2025, 10:17 pm • 0 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

It's @racket-lang.org. I just wrote the macro to do that.

#lang racket (provide lam) (define-syntax (lam stx) (syntax-case stx () [(lam args body ...) (with-syntax ([$myinvocation (datum->syntax (syntax lam) '$myinvocation)]) #'(letrec ([$myinvocation (lambda args body ...)]) $myinvocation))]))
sep 3, 2025, 11:31 pm • 1 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

But if that's what it is, then it's certainly not a Y-combinator! It's just an anaphoric name binding. (Which is very easy to implement if you have a reasonably powerful macro system with the right primitives.)

sep 3, 2025, 11:33 pm • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Cool! I've run across Racket but haven't used it much, or deeply integrated it for automagic interpretation just yet. Will add it to the "to-do" list. PowerShell is deeply influenced by functional languages. I would not at all be surprised if this is where $myInvocation came from. Will ask.

sep 3, 2025, 11:46 pm • 1 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

Btw, I put the code and some more examples up in this repo. Please let me know if I should credit you differently. Thanks. github.com/shriram/anon...

sep 4, 2025, 12:12 am • 1 0 • view
avatar
Shriram Krishnamurthi @shriram.bsky.social

MIT Scheme (and probably other Lisps before it) had a variant of `lambda` where you could slip in a name before the argument list, and it automatically created a recursive binding. That is a very handy feature, and seems nicer than this slightly clunkier fixed name…

sep 4, 2025, 12:12 am • 0 0 • view
avatar
James Brundage | MVP @mrpowershell.com

Good article. Recursion is a tricky topic to teach and explain. FWIW, the Turtle I linked to doesn't use it ( yet ), as the object pipeline helps avoid it. If I were looking for a practical example to teach, I would probably try for serialization ( for example, converting objects to css ).

sep 3, 2025, 4:42 pm • 0 0 • view