Skip to content

Conversation

OlivierNicole
Copy link
Contributor

This reverts commit 3ceafdf: caml_compare can raise Invalid_argument.

Fixes #2089.

This reverts commit 3ceafdf:
`caml_compare` can raise `Invalid_argument`.
@hhugo
Copy link
Member

hhugo commented Aug 27, 2025

Maybe add a comment next to //Provides to explain why it's not "mutable"

Some comparison functions may raise on functional values.
@OlivierNicole
Copy link
Contributor Author

Done. I’m still wondering why the annotation is “mutable”.

@hhugo
Copy link
Member

hhugo commented Aug 27, 2025

Done. I’m still wondering why the annotation is “mutable”.

It means that the call cannot be reordered with a "mutator" call.

@OlivierNicole
Copy link
Contributor Author

Isn’t it the opposite? mutable seems to mean that there are no side effects.

@vouillon
Copy link
Member

We have three purity annotations:

  • mutator (the default): the primitive may have side-effects
  • mutable: the primitive does not have side-effects, but cannot be reordered with effectful operations (for instance, when one of the parameter is a mutable datastructure)
  • pure: the primitive will always return the same value (given the same parameters).

@hhugo hhugo merged commit 5231118 into ocsigen:master Aug 28, 2025
24 of 27 checks passed
@OlivierNicole
Copy link
Contributor Author

I understand now, thanks!

@OlivierNicole OlivierNicole deleted the fix-compare branch August 28, 2025 11:48
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.

[BUG] Change of behaviour in function comparison
3 participants