Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move get, set, and has to be on Dict instead of on dictionary instances #564

Open
masak opened this issue Jul 26, 2021 · 0 comments
Open

Comments

@masak
Copy link
Owner

masak commented Jul 26, 2021

Very belatedly, I now think that get, set, and has should maybe all live on Object Dict instead, as static methods. The hand-wavy reason is that they are "infrastructure" (with regards to interacting with an object), and mixing them with "regular properties" in the object itself is asking for trouble down the line.

Interestingly, there's a recent ES proposal which seems to make the same point, belatedly proposing Object.hasOwn(obj, prop) as a safer obj.hasOwnProperty(prop); for reasons see which post.

I take this general sentiment ("put reflective/meta stuff outside of the object-level stuff") to be the driving force behind Bracha/Ungar's ideas about mirrors (ACM link) — without claiming to understand that work in detail. Indeed, from the abstract of that paper: "Stratification: meta-level facilities must be separated from base-level functionality".

Originally posted by @masak in #25 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant