Live data from Hacker News

Common Lisp's block / return-from and unwind-protect

axisofeval.blogspot.com

51–60 of 63 posts

Re: Common Lisp's block / return-from and unwind-protect

#51

Earlier quoted context omitted.

Yes, building anything non-trivial in CL will show the discerning programmer that there is nothing new under the sun.

Could you clarify what you mean by 'there is nothing new under the sun' when referring to programming with Common Lisp? Are you indicating that Lisp has already introduced many of the concepts and features that are now found in modern programming languages, implying that contemporary languages have largely assimilated Lisp's ideas and paradigms? Your comment left me with a strange sentiment. I'm somewhat disheartenin…

> might be redundant

I'm also the kind of weirdo who thinks that the old and new testaments are baseline requirements for a human to be "literate" (along with Ovid and Aristophanes).

Despite these works having been recycled a large number of times, the originals still bear close scrutiny.

You'll never know what modern $proglang authors screwed up until you go back and read the fundamentals. For a concrete example, consider the Python module system, and the pirouettes you have to do to use it programmatically. Until you look at (just for example) how this works in CL and RS5/6S, you'll not have the context to readily apprehend the hack job in question (although if you have a modicum of taste you may wrinkle your nose regardless).

It'll also give you a good feel for what the true inventions have been since the early nineties.

Re: Common Lisp's block / return-from and unwind-protect

#52
post #12

Earlier quoted context omitted.

One of the only languages where I saw this non-local returns is Kotlin. You can return from a function from within a lambda (and I believe this works on any number of levels), for example: fun go(list: List ): Boolean { list.forEach { if (it.isEmpty()) return@go true } return false }

Longjmp in standard C, swapcontext in POSIX C. I think GCC allows gotos to the containing function from a local function (but I never used GCC local functions). Smalltalk, and I believe ruby, allow non local return from blocks.

swapcontext was in POSIX.1-2001; it was removed in 2008.

In relation to all this, in POSIX, there are often good reasons to use sigsetjmp and siglongjmp rather than setjmp and longjmp, because these also save and restore the signal mask. If you jump out of a context that locally disabled certain signals, you likely want them restored, like you would if that code returned normally. (It doesn't necessarily have to be a jump out of a signal handler!)

Re: Common Lisp's block / return-from and unwind-protect

#53

Earlier quoted context omitted.

Could you clarify what you mean by 'there is nothing new under the sun' when referring to programming with Common Lisp? Are you indicating that Lisp has already introduced many of the concepts and features that are now found in modern programming languages, implying that contemporary languages have largely assimilated Lisp's ideas and paradigms? Your comment left me with a strange sentiment. I'm somewhat disheartenin…

> might be redundant I'm also the kind of weirdo who thinks that the old and new testaments are baseline requirements for a human to be "literate" (along with Ovid and Aristophanes). Despite these works having been recycled a large number of times, the originals still bear close scrutiny. You'll never know what modern $proglang authors screwed up until you go back and read the fundamentals. For a concrete example, co…

Could you summarize what is great about the CL module system ? How does it compare to other languages like Rust/Go ?

Re: Common Lisp's block / return-from and unwind-protect

#54
post #53

Earlier quoted context omitted.

> might be redundant I'm also the kind of weirdo who thinks that the old and new testaments are baseline requirements for a human to be "literate" (along with Ovid and Aristophanes). Despite these works having been recycled a large number of times, the originals still bear close scrutiny. You'll never know what modern $proglang authors screwed up until you go back and read the fundamentals. For a concrete example, co…

Could you summarize what is great about the CL module system ? How does it compare to other languages like Rust/Go ?

Runtime access to read and redefine namespaces and their contents at whim.

Similarly powerful to having the compiler available at runtime, another thing trickling very slowly into mainstream languages.

"But why would you want this?! That sounds dangerous!"

It's quite dangerous, but so is a 700cc dirt bike.

"Can you give me any practical reason you'd want this?"

Aside from the freedom to redefine other folks' code (see: the derogatory term "monkeypatching"), you can leverage runtime namespace access and manipulation to, when loading a "fasl" into a running Lisp image, identify all classes that you care about and then upgrade them to new definitions without restarting the Lisp process.

Most mainstream languages completely punt on "deployment" (PHP [accidentally] aside, where you can joyfully edit production all day, a paradigm too many folks sneer at in the name of cargo cult professionalism), forcing the system operator to restart the process with new binaries (or pycs, whatever, I'm sure you can generalize the point).

A CL system supports that model, of course, but one can also precompile binaries to be loaded into the running system, redefining system behavior without downtime. Binaries, we should note, that don't include the entire Lisp runtime.

It's not that this provides some sort of day-to-day omg ergonomic bonus over the popular Algol families, but that I feel respected as a software author in a Lisp context in a way that I really don't in many other contexts ("nobody needs generics", to pick on some old low-hanging fruit), and the language providing interfaces to itself in itself is a delightfully low-friction cognitive model.

To return to the dirt bike analogy, I could prattle all day about this, but unless you're the kind of person inclined to spend five hours a week learning to enjoy riding dirtbikes, I don't know that I can spill enough ink to convey the fun of managing a few hundred cc's around the track at speed. Countersteering, inertia management, traction, all of these things are going to go over your head if your idea of a fun time with motive power is a Rivian.

Re: Common Lisp's block / return-from and unwind-protect

#55
post #53

Earlier quoted context omitted.

Could you summarize what is great about the CL module system ? How does it compare to other languages like Rust/Go ?

Runtime access to read and redefine namespaces and their contents at whim. Similarly powerful to having the compiler available at runtime, another thing trickling very slowly into mainstream languages. "But why would you want this?! That sounds dangerous!" It's quite dangerous, but so is a 700cc dirt bike. "Can you give me any practical reason you'd want this?" Aside from the freedom to redefine other folks' code (se…

I've always said half-joking, that CL users write more text praising it than actual code in CL. This thread is a fine example, but still fun to read.

But back to your examples - I feel that a lot of ideas CL is built on just aged poorly, I guess? No way I want to see some magical binary where some guru adjusted a parameter in the image or the ugly head of monkeypatching or macros all over the place in production code. CL serves the myth of lonely hacker where the rest of the world has accepted the fact that writing software is mostly a social activity and that code is as much for other people as for the machine.

Re: Common Lisp's block / return-from and unwind-protect

#56

Earlier quoted context omitted.

Runtime access to read and redefine namespaces and their contents at whim. Similarly powerful to having the compiler available at runtime, another thing trickling very slowly into mainstream languages. "But why would you want this?! That sounds dangerous!" It's quite dangerous, but so is a 700cc dirt bike. "Can you give me any practical reason you'd want this?" Aside from the freedom to redefine other folks' code (se…

I've always said half-joking, that CL users write more text praising it than actual code in CL. This thread is a fine example, but still fun to read. But back to your examples - I feel that a lot of ideas CL is built on just aged poorly, I guess? No way I want to see some magical binary where some guru adjusted a parameter in the image or the ugly head of monkeypatching or macros all over the place in production code…

> I feel that a lot of ideas CL is built on just aged poorly, I guess?

byte-code enhancement in Java?

You'll find dynamic features in a bunch of other languages, too. R, Ruby, Python, JavaScript, ...

Re: Common Lisp's block / return-from and unwind-protect

#57

Earlier quoted context omitted.

Hello my friend, I am very pleased to make your acquaintance and I am very excited about your journey. I am also very impressed that for someone who is newly learning the field, you already are so well-spoken and knowledgeable about the language and the tools. Thank you so much for your response. I also appreciate that you are only a little older than my parents, and if you are learning so well and so quickly then th…

Thank you! Do come in, the water is fine. If you keep Python for it's applicability today and pick up Common Lisp for it's practicality tomorrow, I don't see how you could go wrong. Emacs is the weakest link in the Common Lisp experience but, yes, you have to defeat that boss to move up. I love/hate Emacs and mostly struggle to do anything. GNU Emacs is a ball of mud with decades of technical debt in dire need of a g…

If you end up starting a blog, please share it on HN so I can find it :)

Re: Common Lisp's block / return-from and unwind-protect

#58

Earlier quoted context omitted.

Runtime access to read and redefine namespaces and their contents at whim. Similarly powerful to having the compiler available at runtime, another thing trickling very slowly into mainstream languages. "But why would you want this?! That sounds dangerous!" It's quite dangerous, but so is a 700cc dirt bike. "Can you give me any practical reason you'd want this?" Aside from the freedom to redefine other folks' code (se…

I've always said half-joking, that CL users write more text praising it than actual code in CL. This thread is a fine example, but still fun to read. But back to your examples - I feel that a lot of ideas CL is built on just aged poorly, I guess? No way I want to see some magical binary where some guru adjusted a parameter in the image or the ugly head of monkeypatching or macros all over the place in production code…

eyyy you should see the paens I've written to lovers past ;)

Note that I'm not strongly advocating anyone ship CL in hot loops in prod, merely that there are wonders in there worth examining, as perhaps the surviving mainstream descendant implementations missed a nuance or three.

It's really not a great fit for middle-of-the-road software teams with quotidien concerns.

It does have plenty of great food for thought for the thinking programmer.

Re: Common Lisp's block / return-from and unwind-protect

#59

Gah, another Lisp post to tempt me to add yet another mini project to my plate...I always am curious about trying more Lisp because I keep seeing commentary about how powerful it is to actually build applications once you get moving on building things. Anyone here have any recent practical experience in this direction who would confirm this in Lisp vs in other programming languages? Does effort in Lisp really compoun…

I've written a few small CL web applications( with about 100 users active a day), along with a few terminal applications (with only ~10 users). Other languages I know is C , Erlang, Elixir and a bit of python. This will end up sounding a bit evangelical but so be it. I feel that the lisp code was easier to write and reason about, the being able to hot reload code from the repl significantly decreased the time to comp…

When do you work in emacs vs lem?

Re: Common Lisp's block / return-from and unwind-protect

#60
post #59

Earlier quoted context omitted.

I've written a few small CL web applications( with about 100 users active a day), along with a few terminal applications (with only ~10 users). Other languages I know is C , Erlang, Elixir and a bit of python. This will end up sounding a bit evangelical but so be it. I feel that the lisp code was easier to write and reason about, the being able to hot reload code from the repl significantly decreased the time to comp…

When do you work in emacs vs lem?

So, I've looked at lem. Lem seems to be a really great start and push in the right direction.

I work in LEM for my personal projects, that dont have other LSP integration needs and hooks into my org-mode/org-babel workflow. These should not be show stoppers, but will eventually be a non issue.

There are however some features that I'm missing in LEM before I can fully switch over.

1. The documentation for Lem is lacking. 2. I have lazy hands and hit shift on some keys when I shouldn't (shift and backspace for example). I'd need some way to ignore that. 3. An built in undo, (c-x u equivalent). 4. A documented library interface (this is kinda #1 again)

I will eventually get around to making my own plugins to solve most of these. Its a matter of time vs tradeoff.

Post reply on HN