cherly icon indicating copy to clipboard operation
cherly copied to clipboard

Leaky API

Open vlm opened this issue 16 years ago • 0 comments

One would assume that an API which supports "lists of items" can support list of 0 elements, or a list of an empty item. This is not the case with Cherly.

The problem is: we can't store empty data in Cherly. Here's the proof:

14> f(C), {ok, C} = cherly:start(128). {ok,{cherly,#Port<0.523>}}

15> cherly:put(C, "key", [<<"value">>]). true 16> cherly:get(C, "a").
not_found 17> cherly:get(C, "key"). {ok,[<<"value">>]}

18> cherly:put(C, "key", [<<>>]).
true 19> cherly:get(C, "key").
** exception error: no function clause matching cherly:unpack([0],[],[]) in function cherly:unpack/2 20>

Here's another proof:

21> f(C), {ok, C} = cherly:start(128). {ok,{cherly,#Port<0.525>}}

22> cherly:put(C, "key", []). % Storing empty list true 23> % Storing empty list 23> cherly:get(C, "key"). ** exception error: no match of right hand side value [] in function cherly:unpack/2 24>

Here's another case:

15> f(C), {ok, C} = cherly:start(128).
{ok,{cherly,#Port<0.529>}}

16> cherly:put(C, "key", [<<>>,B]).
true 17> cherly:get(C, "key").
{ok,[<<>>,<<"abc">>]}

18> cherly:put(C, "key", [B,<<>>]).
true 19> cherly:get(C, "key").
** exception error: no function clause matching cherly:unpack([0],[],[<<"abc">>]) in function cherly:unpack/2 20>

vlm avatar Nov 26 '09 11:11 vlm