[erlang-questions] queue:split/2 unsafe!

Fred Hebert mononcqc@REDACTED
Wed Apr 10 03:29:03 CEST 2013


On 04/10, Richard A. O'Keefe wrote:
> 
> Does anyone else find it confusing that it's "listS.erl" (plural)
> but "queue.erl" (singular)?  Is there only one queue?  
> 

That kind of inconsistency is repeated in many places. "gb_trees",
"dict", "array", "sets", "digraph", and so on. There just isn't much
consistency when it comes to pluralization of data structures.

If anything "queue" would benefit from being plural given it implements
three different APIs over the same functional queue structure!

> However, looking through queue.erl has convinced me, the next
> time I need queues, to write my own module.
>

Generally speaking, I haven't had issues with the module regarding its
amortized O(1) time (ignoring repeated cases that would need
laziness/memoization according to Okasaki).

The most annoying thing about it is possibly the reversed-spelling API
(Okasaki API) which contains 'snoc' for 'cons', 'deah' for 'head', but
has 'last' spelled correctly (because it was available), and contains
'lial' for 'tail', but still has the mispelling for 'lait' as a bad
reversal of 'tail'. I'm guessing deprecation would make sense there.

But yeah, all in all, it seems to respect the queues described by
Okasaki rather well.

What's your main problem with it?

Regards,
Fred.



More information about the erlang-questions mailing list