-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
ARC: deepCopy in new runtime feature missing, do we have alternatives? #13997
Comments
I'm afraid there is no better way esp considering that |
From https://github.com/Yardanico/random-stuff/issues/1 - libraries like https://github.com/NimParsers/parsetoml, https://github.com/PMunch/nim-persistent-vector depend on deepCopy |
What to do if the object appears as non ptr/ref inside other object? let tmp = `=deepCopy`(addr(x))
`=sink`(result, tmp[])
`=destroy`(tmp) Looks bad do you have better ideas? Problem 2. |
adding @Clyybber to discussion |
Anyone? |
I think we should just wait for about 3 months and see if we have any similar ways to this. |
@cooldome One new idea that I had is to clearly separate the old RTTI from the new RTTI in the backend and if required ( |
@Araq can this be closed since |
Old runtime has deepCopy function that doesn't exist in new runtime, but I don't see alternatives to it.
The problem is I need to copy the
XmlParser
object fromxmlparser
to save its state. In order to save state ofXmlParser
I have useddeepCopy
in old runtime, because standard copy doesn't work asXmlParser
containsStream
which is ref only object.Things I tried as workaround and they don't work:
Try changing Stream to be non ref object.
Stream
ref hides the actual type of stream so it can't be not a ref object.Add custom copy assignment operator to
XmlParser
. Can't be done because, ref hides actual stream type and you don't know how to copy it if you don't know object type.I don't see alternatives to deepCopy function in presence of
ref RooObj
when you don't know what is behind the ref.IMO, we have to provide deepCopy function that will be copy the content of the
ref T
and possiblyptr T
. Fallback to standard copy operator when deepcopy specialization for type is not available.Any thoughts how it can be achieve in any other way?
The text was updated successfully, but these errors were encountered: