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

Document that foreign functions should be pure #1495

Closed
yav opened this issue Feb 6, 2023 · 2 comments
Closed

Document that foreign functions should be pure #1495

yav opened this issue Feb 6, 2023 · 2 comments
Labels
docs LaTeX, markdown, literate haskell, or in-REPL documentation

Comments

@yav
Copy link
Member

yav commented Feb 6, 2023

We should add note to the FFI section to make it explicit that our intention is that foreign function are pure (i.e., do not have observable side effects).

@yav yav added the docs LaTeX, markdown, literate haskell, or in-REPL documentation label Feb 6, 2023
@ramsdell
Copy link

ramsdell commented Feb 7, 2023

Let me expand on this request.

The RefMan in the cryptol repository gives its readers no hint as to the fact that the order in which FFI calls are evaluated can influence the meaning of an expression. For example, suppose there is a C function called count that has some internal state, and it increments an integer with each call, ignores its input, and returns the integer. After loading this into cryptol

foreign count: [32] -> [32]
 
seq : [10][32]
seq = [ count i | i <- [0 .. 9 : [32]] ]

and typing seq ! 2; seq you get a different answer than had you started by typing seq.

Please expand the FFI section in the RefMan to help readers understand why this happens so they understand why one should not load functions with observable state.

@RyanGlScott
Copy link
Contributor

Done in #1558.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs LaTeX, markdown, literate haskell, or in-REPL documentation
Projects
None yet
Development

No branches or pull requests

3 participants