queue->list, list->queue Shiro Kawai 03 Dec 2014 06:38 UTC
I think most X->Y procedures in Scheme returns a freshly
allocated Y, and I'm afraid that queue->list and list->queue's
semantics of sharing the storage can lead confusion.
Can they be named so that it indicates sharing semantics?
I haven't come up good names, but just an idea:
queue-list instead of queue->list
Indicates that it's an accessor to the internal storage
('list' slot of 'queue' record),
instead of type conversion function.
make-queue-with-list instead of list->queue
It's a constructor with special initial value.
If we have queue->list and list->queue, I'd like them to copy the
storage, even if those can be trivial to implement:
(define (queue->list q) (queue-list (queue-copy q)))
(define (list->queue l) (apply queue l))
On a side note, don't we want dequeue-all! operation? SLIB and
Gauche has it; for the name consistency, we can name it like
queue-remove-all! or something.