News for hackers. Stuff that matters.
Re:Closures and Objects Are Equivalent (2013) by commandlinefan on Sunday November 20, 2022 @10:34PM (#33688416)
> an object is a struct with associated functions

And inheritance and polymorphism, which I don’t think you can reproduce with closures.

Re:Closures and Objects Are Equivalent (2013) by Jtsummers on Monday November 21, 2022 @12:08AM (#33689027)
Inheritance and polymorphism: https://okmij.org/ftp/Scheme/oop-in-fp.txt

The link at the bottom is dead, but here's the same file at his current site: https://okmij.org/ftp/Scheme/pure-oo-system.scm

You can reproduce these with closures, though you'll need more plumbing since it's not built into the language.

Re:Closures and Objects Are Equivalent (2013) by commandlinefan on Tuesday November 22, 2022 @10:14AM (#33706653)
> more plumbing since it's not built into the language

Well, sure - you can "reproduce" encapsulation, inheritance and polymorphism in plain-old C (heck, I've done it in Cobol), too. I'm not sure that's really the same, though.