Hacker News new | past | comments | ask | show | jobs | submit login
The Miracle of Smalltalk's become: (gbracha.blogspot.com)
28 points by blasdel on July 31, 2009 | hide | past | favorite | 5 comments



A more civiled, less procedural version of CL's change-class + update-instance-for-redifined-class.


I was wondering what the lisp version (if any) of become: would be. Thanks for saying it.


A good compromise would be if you could specify an object as being "replacable" and then it would have the extra layer of indirection (the table) to make it fast. That way you don't pay a penalty when you're not using that feature and/or don't have to walk the heap. It would also be better for security in that you'd have to explicitly state which objects were allowed to be replaced. You have to think about needing that feature in advance though.


I believe Squeak just adds the extra indirection when #become: is used, by turning the old objects into "forwarders". On the next full GC, the forwarders get cleaned up and the extra indirection removed.


I always wondered what this was able to do and how it worked technically. It's one of those things I put in a SEP-field and never thought about again.

It reminds me about an Objective-C feature I also never fully understood. I believe it was "-poseAs:".




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: