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

Remove IvoryZero constraint from ifte and cond #116

Open
cblp opened this issue Nov 23, 2017 · 0 comments
Open

Remove IvoryZero constraint from ifte and cond #116

cblp opened this issue Nov 23, 2017 · 0 comments

Comments

@cblp
Copy link
Contributor

cblp commented Nov 23, 2017

I want to select a ref value by some condition.

getRef1, getRef2 :: Ivory eff (Ref s a)
ref3 = ifte c getRef1 getRef2

This is safe but Ivory use 0 initialized variable internally, and references can't be initialized with zero, so Ivory doesn't allow this.

So I have to use pointers instead of references and assert they are valid. Assertions, assertions everywhere!

Meanwhile, MISRA says:

Rule 9.1 (required):
All automatic variables shall have been assigned a value before being used.
The intent of this rule is that all variables shall have been written to before they are read. This does not necessarily require initialization at declaration.

So you don't need to zeroify local variable before an if statement. You don't need to initialize it at all.

Currently, Ivory internal representation requires local variables be initialized. So we need to relax this requirement, only internally, without exposure to the user.

I can do this, but I need an advice on how to do this. Extend Init type? XInit? local representation?

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

No branches or pull requests

1 participant