Skip to content

preserve the order when encoding structs? #39

@etnt

Description

@etnt

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions