[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

queue->list, list->queue

This page is part of the web mail archives of SRFI 117 from before July 7th, 2015. The new archives for SRFI 117 contain all messages, not just those from before July 7th, 2015.



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.