Skip to content

Consider preserving order of sexpred maps #424

@lread

Description

@lread

Problem/Opportunity

We just merged #419 which perserves sexpr map element order for small maps (just like Clojure happens to do).

But maybe we could always (or optionally) preserve sexpr maps regardless of map size.

Option 0: Don't do anything

We are good with #419 behaviour.

Pros:

  • no new code, no new bugs!

Cons:

  • sexpr map order is preserved only for small maps

Option 1: Always preserve map order

Pros:

  • No additional knobs or dials to turn

Cons:

  • This is a perf impact for larger maps with no way to opt out

Option 2: Add an option flag

Add an option to preserve sexpr map element order.
Maybe :preserve-map-elem-order?

Pros:

  • There is a performance impact for larger maps, this would let the user choose.

Cons:

  • Granularity of choice is not tweakable at map level.

Option 3: Add an option fn

Add an option to specify a map fn
Maybe :sexpr-map-fn.

Pros:

  • User can tweak choice at map level

Cons:

  • More complicated to use than a flag.

Additional Notes

  • default behaviour would remain unchanged
  • option would be available at node sexpr level fns and zipper creation fns.
  • this does not cover preserving order of sets, we are just talking about maps here.

Next Steps

Mull over choices, flesh out details.
If we were to proceed, I think Option 3 might be interesting to explore.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions