📦 is a user on mastodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
📦 @rocx

Idea for the day:

A function/macro to not return an instance of an object/struct, but a constructor to generate that object/struct in its current state. Probably demonstrated in Lisp by now.

· Web · 0 · 0

@rocx Unless the object/struct holds some kind of magical/stateful/singleton value (maybe socket, file handle, etc.), this f closes over the object and returns a constructor function that calls clone/dup on the obj. (Extra copy needed in closure if obj is mutable.)