Message316619
A possible use case would be a field that represents an auto-incrementing database ID. Since the field is auto-incrementing in the database, it would be desirable to keep this field frozen, and others mutable once an instance of a data class is created.
This is also a feature of data classes in other languages, for example Kotlin: https://kotlinlang.org/docs/reference/data-classes.html . The main difference here being that we don't have val and var, and thus mutability and immutability are harder to represent.
Hashing could be implemented such that frozen fields are allowed to be part of the hash, but unfrozen fields would remain only part of the hash when unsafe_hash is set. I believe equality follows from hashing, so the same rules should apply.
The conflict between setting the class to frozen, and a field to not frozen could be solved by raising an exception.
Upon investigation, attrs does not support this behavior. I can try this feature with attrs, but their implementation may differ enough to make it infeasible. |
|
Date |
User |
Action |
Args |
2018-05-15 04:20:40 | Daniel Lindeman | set | recipients:
+ Daniel Lindeman, eric.smith |
2018-05-15 04:20:40 | Daniel Lindeman | set | messageid: <1526358040.67.0.682650639539.issue33474@psf.upfronthosting.co.za> |
2018-05-15 04:20:40 | Daniel Lindeman | link | issue33474 messages |
2018-05-15 04:20:40 | Daniel Lindeman | create | |
|