In case anyone missed this, I’ll be giving a talk on Elvish at GopherCon UK 2024 - at 13:30 on 15 August to be exact!
Since it’s GopherCon, this talk will focus more on Elvish as a Go project, so I’ll spend most of the time on the implementation side of things.
I’ll publish the slides later on and there should also be video recordings, but you can also find the slides for a similar talk I gave at the Recurse Center earlier this month.
“Lambda” is a synonym of anonymous functions and is an important construct you use in functional programming languages.
In case you’re not familiar with the concept at all, here’s my attempt at a quick explanation:
In older imperative languages like C, you have to declare functions on the top level and give them names. These are all the functions you can use in a program.
In functional languages however, you can construct functions wherever you want, without giving them names, and store them in variables and pass them as arguments. Pretty much like how you would construct lists, maps etc. on the fly.
To distinguish functions in functional languages from the much more restrictive functions in C, people call the former various names and “lambda” is one of them.
I have to learn more about this. Thank you for your explanation.
I guess lambdas are useful in the context of a shell because as a user I probably just want to execute some code and store the result and then continue to working with the result. Calling a function from many places is not really as relevant for shell scripts or in the terminal, right ?
The reason has more to do with language design - support for lambdas tend to produce a more powerful language.
If I were to point to a specific use case, I’d say how prompts are customized in Elvish - you can just assign edit:prompt to a function to customize the prompt. Compare this with bash, which has no support for lambdas, and the way you customize the prompt is by assigning a string to PS1 with a bunch of special sequences like %u for username.