On 06/28/2016 04:12 AM, oldk1331 wrote: > Similar problems exists for copy/deepCopy: > > (33) -> x:=[[1,2],[3,4]] > > (33) [[1,2],[3,4]] > Type: List(List(PositiveInteger)) > (34) -> y:=queue x > > (34) [[1,2],[3,4]] > Type: Queue(List(PositiveInteger)) > (35) -> x.1.1 := 5 > > (35) 5 > Type: PositiveInteger > (36) -> y > > (36) [[5,2],[3,4]] > Type: Queue(List(PositiveInteger)) > > > Should we use deepCopy and guarantee that construct doesn't > share any part of its argument?
Again, (36) is as expected, or rather: "I would not expect anything reasonable for y after applying a destructive operation to x." The rule I learned over time is: Whenever you apply "destructive" function to x, make sure that x does not share memory with other datastructures. Best is to do a copy of x beforehand." Were I certainly agree with you is that neither in FriCAS nor in the Aldor library it is always clearly specified whether or not a constructor copies its argument. In that sense the ++ docstrings are lousy. On the other hand it is also hard to do this, because then we might end up in an implementation of Stack that copies its constructor argument and another implementation that does not. Not specifying leaves more freedom for the domain implementor to choose an appropriate datastructure. But perhaps we can agree on a set of basic (simple) datastructures like Queue, Stack, Tree, etc. where proper specification of such details is advantageous. Ralf -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
