[erlang-questions] Proposed addition to gb_trees

Pierpaolo Bernardi olopierpa@REDACTED
Mon Nov 30 03:47:49 CET 2015

On Mon, Nov 30, 2015 at 3:34 AM, Richard A. O'Keefe <ok@REDACTED> wrote:
> On 28/11/2015, at 6:55 am, Pierpaolo Bernardi <olopierpa@REDACTED> wrote:
>> On Fri, Nov 27, 2015 at 6:14 AM, Richard A. O'Keefe <ok@REDACTED> wrote:
>> It should take an optional initializer parameter, like for example the
>> corresponding function in Racket.
>> http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._hash-update%29%29
> That's a somewhat broken interface.  If you want the
> default result to be a function, you have to wrap an
> extra function around it, which is nasty.

Agreed.  Although this case is not common, I think.

> The documentation of hash-update is ambiguous; it is
> not clear whether the failure-result argument is used
> as the failure-result of the implicit hash-ref or as
> the result of hash-update itself.

Yes, it's not clear from the doc. It's used as the result of the
implicit hash-ref.

For example: (hash-update table key add1 0)  will increment the value
associated to key. If key was not present, it will take the value 1
(not 0).

More information about the erlang-questions mailing list