<br><br><div class="gmail_quote">On Mon, Jan 21, 2013 at 9:24 PM, Steve Davis <span dir="ltr"><<a href="mailto:steven.charles.davis@gmail.com" target="_blank">steven.charles.davis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Even better solution is to send "lists of integers" as tuples:<br>
2> term_to_binary({1,2,3,4}).<br>
<<131,104,4,97,1,97,2,97,3,97,4>><br>
<br>
:-)<br></blockquote><div><br></div><div>While we're on the subject - shouldn't we rename lists.</div><div><br></div><div>stacks is a much better name - Erlang has no lists only stacks.</div><div><br></div><div>think of explaining reverse</div>
<div><br></div><div>reverse(L) -> reverse(L, []).</div><div><br></div><div>reverse([H|T], L) -> reverse(T, [H|L]);</div><div>reverse([], L) -> L.</div><div><br></div><div>easy to explain using the "two stacks of plates" model.</div>
<div><br></div><div>Lists is a stupid name :-)</div><div><br></div><div>/Joe</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888">/s<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
On Jan 21, 2013, at 2:15 PM, Steve Davis <<a href="mailto:steven.charles.davis@gmail.com">steven.charles.davis@gmail.com</a>> wrote:<br>
<br>
> Hi Dmitry,<br>
><br>
> Unfortunately, Bert-js suffers from the same ambiguity client side.<br>
><br>
> I have in fact found a reasonable hack which only costs an extra byte and is to prepend NIL_EXT to the list:<br>
> 1> term_to_binary([[],1,2,3,4]).<br>
> <<131,108,0,0,0,5,106,97,1,97,2,97,3,97,4,106>><br>
><br>
> Best,<br>
> Steve<br>
><br>
> On Jan 21, 2013, at 2:13 PM, Dmitry Kolesnikov <<a href="mailto:dmkolesnikov@gmail.com">dmkolesnikov@gmail.com</a>> wrote:<br>
><br>
>> Hi Steve,<br>
>><br>
>> There is a well document External Term Format protocol. I am not here to judge that protocol but it is implementable on other languages as well (<a href="https://github.com/rustyio/BERT-JS" target="_blank">https://github.com/rustyio/BERT-JS</a>). Yes, it make sense in scopes of that protocol specification.<br>
>><br>
>> Long time ago, I've been trying to use it for WebApp development and … switched to JSON. :-)<br>
>> But I strongly believe that External Term Format make sense for other use-case...<br>
>><br>
>><br>
>> Best Regards,<br>
>> Dmitry<br>
>><br>
>><br>
>> On Jan 21, 2013, at 10:00 PM, Steve Davis <<a href="mailto:steven.charles.davis@gmail.com">steven.charles.davis@gmail.com</a>> wrote:<br>
>><br>
>>> Hi Dmitry,<br>
>>><br>
>>> It "makes sense" only if the "binary_to_term" decode is done in erlang.<br>
>>><br>
>>> br,<br>
>>> /s<br>
>>><br>
>>> On Jan 21, 2013, at 1:53 PM, Dmitry Kolesnikov <<a href="mailto:dmkolesnikov@gmail.com">dmkolesnikov@gmail.com</a>> wrote:<br>
>>><br>
>>>> Hello,<br>
>>>><br>
>>>> This make sense to me!<br>
>>>><br>
>>>> term_to_binary/1 returns a binary data object which is the result of encoding Term according to the Erlang external term format. See <a href="http://erlang.org/doc/apps/erts/erl_ext_dist.html" target="_blank">http://erlang.org/doc/apps/erts/erl_ext_dist.html</a><br>
>>>><br>
>>>> Use list_to_binary or unicode:character_to_binary depends on your use-case.<br>
>>>><br>
>>>> - Dmitry<br>
>>>><br>
>>>> On Jan 21, 2013, at 9:38 PM, Steve Davis <<a href="mailto:steven.charles.davis@gmail.com">steven.charles.davis@gmail.com</a>> wrote:<br>
>>>><br>
>>>>> The following appears to encode lists of integers as strings (?!?):<br>
>>>>><br>
>>>>> Eshell V5.9.3 (abort with ^G)<br>
>>>>> 1> term_to_binary([1,2,3,4]).<br>
>>>>> <<131,107,0,4,1,2,3,4>><br>
>>>>><br>
>>>>> Is there a reason for this that I'm missing?<br>
>>>>><br>
>>>>> regs,<br>
>>>>> /s<br>
>>>>><br>
>>>>> _______________________________________________<br>
>>>>> erlang-questions mailing list<br>
>>>>> <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
>>>>> <a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
>>>><br>
>>><br>
>><br>
><br>
<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</div></div></blockquote></div><br>