> More precisely, instead of building > list and passing it to constructor build desired object > directly.
Building the desired object through list might be faster than build directly -- for example, enqueue! checks if its argument is empty every time, that slows thing down. > OTOH in other cases signifcant savings are > obtained by sharing substructures. But sharing works > well only if we avoid destructive operations. But like you said in the other thread, Spad is pretty imperative, thus destructive operations are unavoidable, thus Spad (and Lisp) provides both destructive operations and non destructive operation. That gives more reason to have a destructive version of constructor. > Concerning idea of destructive constructor: memory is > freed by garbage collector, so all we can do to free > memory is to avoid keeping references to unneeded things. > This means that destructive constructor can give any > gain only in very special cases. For some data structure, I think a destructive constructor takes O(1) instead of O(n): for example Stack (because of the direct assign). For other data structure, a destructive constructor can save half time and half peak memory -- copy is O(n), we can save that step. -- 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.
