>>> Anyway, "destructive" in FriCAS means that (some) argument may be
>>> modified, but there is not "will be modified"
>>
>>I think that only holds true for List.
>
> No. I don't currently have an example, but to my knowledge "destructive"
> just means that one cannot rely on the fact that the arguments are
> unchanged. It does not necessarily mean that the arguments really "are"
> changed.
I think, except for List,
x := funxxx!(x, restargs) can be replaced by funxxx!(x, restargs)
Waldek, is that true? (except for split!, I think)
> In fact, using destructive operations to speed up your
> code is terribly error prone.
Tell that to people using languages other than Haskell.
Lisp achieves a good balance between imperative/destructive
and functional/pure, destructive operations is the necessary evil.
A middle level experienced Lisp programmer will not write code
with bugs that caused by shared structure and destructive
operations. One simple rule: when writing non destructive
functions, do not modify its arguments, you can use destructive
operations on tmp values or copy of arguments, thus contain
the side effects inside the function.
> Use sparsely, destructive functions are fine, but one must really be
> very very careful in applying them.
Since Spad is not pure, the data structure is mutable, so we don't
have O(1) copy, and we must use destructive operations for speed.
But like I said, when writing Spad libraries, using and writing
destructive operations are not difficult and buggy.
--
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.