-
Notifications
You must be signed in to change notification settings - Fork 149
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
setdefault
, or some superior functionality as part of transform()
#95
Comments
Seems cool, I can definitely see the use case. At first I was thinking that the type information should be possible to use for auto building default structures. It seems to me that it would impose a lot of restrictions since the type information would have to be unambiguous (a type is specified, only one type is specified, the type is not abstract, etc.). Furthermore I guess it may not always be the case that you want to do the exact same thing for every transformation involving a particular type. This means that the behaviour should probably not be tied to the type/class at all but instead be supplied as input to the transform operation. I guess this was what you were thinking as well since you mentioned What about making it possible to pass a function
|
That seems like it would require enough typing that it wouldn't save any time. In practice with
|
(Or some other, better, argument name.) |
The only problem with that as I see it is that there are a lot of cases where such simplification would not be usable at all. For example when applying a transform to a data structure without type information (nested pvectors, pmaps and psets for example). It's of course possible to combine the two suggestions and have a parameter (would calling it |
Maybe instead of an option to
|
Consider the following code:
Constructing the pyrsistent objects is quite annoying, which is why I'm doing it with mutable objects, due to lack of
setdefault
or "create a default object in transform()". Ideally I'd do:but since
newapp
doesn't exist it blows up...The text was updated successfully, but these errors were encountered: