Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve the order when encoding structs? #39

Open
etnt opened this issue Sep 10, 2013 · 0 comments
Open

preserve the order when encoding structs? #39

etnt opened this issue Sep 10, 2013 · 0 comments

Comments

@etnt
Copy link

etnt commented Sep 10, 2013

Hi,

I noticed that ufp_utils:encode_list/3 will reverse the order of the encoded structs.
Why? I think that is confusing and error prone. At least in OF 1.0 it was important that an output-action was last in an action-list else the actions wasn't performed correctly. Isn't that true also for 1.2 and above ?

Anyway, an alternative implementation could be (completely untested):

encode_list(Encoder, Structs) ->
    lists:foldr(fun(Struct, Binaries) ->
                     StructBin = erlang:apply(Encoder, [Struct]),
                     <<StructBin/bytes, Binaries/bytes>>
                  end, <<>>, Structs).

Cheers, Tobbe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant