David Beazley on Nostr: To elaborate, I've been thinking about how a class decorator expands into something ...
To elaborate, I've been thinking about how a class decorator expands into something like `cls = decorator(cls)`. A function call. So, why in the hell do most class decorators *mutate* the cls argument in-place as a side effect? (a very non-function kind of thing to do).
I've done this with class decorators in my books, but I'm hardly the only offender. Also class decorators in the standard library (e.g., dataclass) mutate the class. It now just feels off to me.
Published at
2024-04-22 01:13:05Event JSON
{
"id": "62f532d1a4431a2f88363d545cf2c25b941c0d9af09814a110a61e1d99297ae7",
"pubkey": "54be8b44da6d3e62d80831e30a85ef15645e1fb05fcadcf16709f5bb2a350112",
"created_at": 1713748385,
"kind": 1,
"tags": [
[
"e",
"b2cd99284f3bdc3f379db591b4e42ce4a5b9f1064538032191a42e14166b9dc6",
"wss://relay.mostr.pub",
"reply"
],
[
"proxy",
"https://mastodon.social/users/dabeaz/statuses/112312214194826968",
"activitypub"
]
],
"content": "To elaborate, I've been thinking about how a class decorator expands into something like `cls = decorator(cls)`. A function call. So, why in the hell do most class decorators *mutate* the cls argument in-place as a side effect? (a very non-function kind of thing to do).\n\nI've done this with class decorators in my books, but I'm hardly the only offender. Also class decorators in the standard library (e.g., dataclass) mutate the class. It now just feels off to me.",
"sig": "a7349a965a5a613ee2fa091ffa25315755d38b4ca8e293fd77390e29cea5d3b3adf9753b9e7e1f9a7828e7326b1909f8b2e2e8e2ebfd38386ba2c963e2772a6d"
}