Modify ROTATE/SHUFFLE and add NROTATE/NSHUFFLE
Issue
The current manual for rotate
states:
Note: the original sequence may be destructively altered, and result sequence may share structure with it.
This is inconsistent with the naming scheme for destructive operations in Common Lisp, which are commonly prefixed with n
. This also means that Alexandria does not export a non-destructive sequence-rotating operation.
Proposal
Move the current fdefinition
of rotate
into nrotate
and export that new symbol. rotate
may then be implemented by means of calling nrotate
over copy-sequence
to always work on fresh data.
Cost to users
- User code may need to be modified to avoid double copying that results in effect of this change.
- Possible, but unlikely, package conflicts if another package used next to Alexandria exports a
nrotate
symbol. - Possible breakage of user code if
rotate
was used only for its side effects and not for its return-value.
Benefits to users
- Better separation of mutating from non-mutating operations by using the
n
prefix for mutating operations, just like withnconc
,nsubseq
, etc.. - Exporting a non-destructive functionality that performs the same operation as the new
nrotate
without mutating original data. - The change is backwards-compatible protocol-wise if the return value of
rotate
was used.
Edited by Michał Herda