Peter Bhat Harkins is a user on octodon.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.

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.

Peter Bhat Harkins @pushcx

@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.)