[m-rev.] Proposed changes to pqueue.m

Paul Bone paul at bone.id.au
Tue Nov 19 08:57:10 AEDT 2013


On Tue, Nov 19, 2013 at 01:21:50AM +1100, Julien Fischer wrote:
>
> Hi,
>
> On Mon, 18 Nov 2013, Paul Bone wrote:
>
>>>  @@ -47,6 +51,15 @@
>>>   :- pred pqueue.insert(K::in, V::in, pqueue(K, V)::in, pqueue(K, V)::out)
>>>       is det.
>>>
>>>  +    % Extract the smallest item from the priority queue without removing
>>> it.
>>>  +    % Fails if the priority queue is empty.
>>>  +    %
>>>  +:- pred pqueue.peek(pqueue(K, V)::in, V::out) is semidet.
>>>  +
>>>  +    % As above, but calls error/1 if the priority queue is empty.
>>>  +:- func pqueue.det_peek(pqueue(K, V)) = V.
>>>  +:- pred pqueue.det_peek(pqueue(K, V)::in, V::out) is det.
>>>  +
>>>       % Remove the smallest item from the priority queue.
>>>       % Fails if the priority queue is empty.
>>>       %
>>
>> How long are lines in your text editor?  We like to limit lines to 76
>> columns so taht a diff plus an e-mail reply doesn't cause wrapping.
>
> Do we?  According to the Mercury project's coding standard we limit them
> to 79 characters.  And indeed, that's what most of the code does.

Can we change it to 76?  I've been assuming 76 the whole time.

>>>  +%---------------------------------------------------------------------------%
>>>  +
>>>  +pqueue.det_peek(PQ) = V :-
>>>  +    pqueue.det_peek(PQ, V).
>>>  +
>>>  +pqueue.det_peek(PQ, V) :-
>>>  +    ( pqueue.peek(PQ, T) ->
>>>  +        V = T
>>>  +    ;
>>>  +        error("pqueue.det_peek/2: empty priority queue")
>>>  +    ).
>>>  +
>>
>> Since this module was written we've introduced 'implementation defined
>> literals'.  They include $module and $pred and can be used to print the
>> module and predicate name in errors.  Also see the unexpected predicate in
>> the require module.  So you can write:
>>
>>    unexpected($module, $pred, "empty priority queue")
>
> I prefer "unexpected($file, $pred, ..." since $pred already includes the
> module name.

Thanks, I didn't realize.


-- 
Paul Bone
http://www.bone.id.au



More information about the reviews mailing list