From 4b3d76788a98b9d66f79635aae3f85766c65408e Mon Sep 17 00:00:00 2001 From: "Paul M. Rodriguez" Date: Sun, 5 May 2024 21:10:46 -0500 Subject: [PATCH] Update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 061ec1b..5ad9a97 100644 --- a/README.md +++ b/README.md @@ -430,6 +430,8 @@ Even more usefully, we don’t have to worry about bugs caused by misspellings: ## Defer, scope guards, and RAII +A common complaint about writing code with C FFIs is that it forces you to write C in Lisp. It would be useful to have a paradigm available which, while not as safe as automatic memory management, makes manual memory management safer. + Some programming languages provide a way to register code to run later. Typically the programmer registers how to release a resource at the time the resource is allocated. Some languages provide this feature along lexical scopes using special syntax (Go’s and Zig’s `defer`, D’s `scope_guard`) and other languages (C++, Rust) provide it along lifetimes (what Lisp calls “extents”) but limit it to objects with special methods (C++ RAII, Rust `Drop`). Serapeum’s implementation looks like the Go/Zig/D style: @@ -443,7 +445,7 @@ Serapeum’s implementation looks like the Go/Zig/D style: )) ``` -Serapeum scope guards, however, are tied to *dynamic extent* (lifetime) rather than *lexical scope*, so they implement the full generality of RAII. The deferred call does not have to be in the lexical extent of `with-defer`: +Serapeum scope guards, however, are tied to *dynamic extent* (lifetime) rather than *lexical scope*, so they implement the full generality of RAII. The deferred call does not have to be in the lexical scope of `with-defer`: ``` lisp (defun open-managed-file (&rest args)