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

Implement a well defined ordering among types #1702

Closed

Conversation

krader1961
Copy link
Contributor

This builds on the previous changes to implement a total ordering by replacing the dependency on the address at which various types are defined (which is effectively random) with an explicit ordering. For types without an explicit ordering it uses an ordering based on the order in which each unknown type is compared. This makes the ordering predictable based on the execution of Elvish code without regard to unpredictable factors such as the layout of data structures in the Elvish binary.

Note that the use of mechanisms like the peach command can introduce unpredictable ordering of unknown value types since this change handles unknown types at run time and thus, in theory, produce different results when Elvish code that invokes compare &total or order &total is run concurrently. Whereas the prior logic is not affected by the parallelism of Elvish code. Nonetheless, I maintain that the predictability of ordering heterogenous values introduced by this change is a net positive since the new behavior will be predictable and reproducible (as a practical matter) while the prior logic (based on the random layout of data structures in the Elvish binary) is neither.

Related #1495

This builds on the previous changes to implement a total ordering by
replacing the dependency on the address at which various types are defined
(which is effectively random) with an explicit ordering. For types without
an explicit ordering it uses an ordering based on the order in which each
unknown type is compared. This makes the ordering predictable based on the
execution of Elvish code without regard to unpredictable factors such as
the layout of data structures in the Elvish binary.

Note that the use of mechanisms like the `peach` command can introduce
unpredictable ordering of unknown value types since this change handles
unknown types at run time and thus, in theory, produce different results
when Elvish code that invokes `compare &total` or `order &total` is run
concurrently.  Whereas the prior logic is not affected by the parallelism of
Elvish code.  Nonetheless, I maintain that the predictability of ordering
heterogenous values introduced by this change is a net positive since the
new behavior will be predictable and reproducible (as a practical matter)
while the prior logic (based on the random layout of data structures in
the Elvish binary) is neither.

Related elves#1495
@krader1961 krader1961 closed this May 20, 2023
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

Successfully merging this pull request may close these issues.

None yet

1 participant