Fwd: [erlang-questions] Re: data sharing is outside the semantics of Erlang, but it sure is useful

Witold Baryluk baryluk@REDACTED
Thu Sep 17 04:46:09 CEST 2009


Dnia 2009-09-15, wto o godzinie 22:38 +0200, Tony Rogvall pisze:
> > Here is nice term encoder/decoder (below) that will solve the size  
> > problem.
> > The algorithm is not efficient (in Erlang) but if/when implemented  
> > in C it could be used as a bif.
> > Still it will produce decent results on (all) shared data.
> >
> >

Wow, really nice work. Quickly and simple.

te module is really interesting. but still needs some optimazations in
encode function like finding variables which are used only once and
merging / propagating them into original structure.

te:encode([ala,ewa,ala,ewa,{ala,bzium,"xasdddd","asdddd"},{foo,bar}])
is
{ala,ewa,97,115,100,[],
     [5|6],
     [5|7],
     [5|8],
     [5|9],
     [4|10],
     [3|11],
     120,
     [13|12],
     bzium,
     {1,15,14,12},
     bar,foo,
     {18,17},
     [19|6],
     [16|20],
     [2|21],
     [1|22],
     [2|23],
     [1|24],
     25}

it should be something more like:
{ala,ewa,{l,"asdddd"},[],
     120,
     [5|3],
     bzium.
     {1,6,7,3},
     {l,{bar,foo}},
     [2,1,2,1,8,9]}


where {l, X} means literal value of X.


or maybe even:
{ala,ewa,{l,"asdddd"},[],
     120,
     [2,1,2,1,{1,{l,bzium},[5|3],3},{l,{foo,bar}}]}

or even

{ala,ewa,{l,"asdddd"},[],
  [2,1,2,1,{1,{l,bzium},[{l,120}|3],3},{l,{foo,bar}}]}


depending what is "smaller"

I think that "optimization" of the output of the encode/1 function
can be done as separate pass after encode/1.


-- 
Witold Baryluk
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: To jest cz??? wiadomo?ci podpisana cyfrowo
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090917/fb180476/attachment.bin>


More information about the erlang-questions mailing list