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

Make environment arguments reference-only #34

Open
Feliix42 opened this issue Apr 12, 2019 · 1 comment
Open

Make environment arguments reference-only #34

Feliix42 opened this issue Apr 12, 2019 · 1 comment

Comments

@Feliix42
Copy link
Member

Currently, environment values are captured as owned references and cloned, if necessary. This raises a number of issues however, ranging from required workarounds (see #29) to bugs due to the fact that ohuac does not know about these changes (see smap::smap_with_envarc_in_loop test case).

When discussing this with Justus, we agreed that enforcing the use of borrowed environment arguments would be a fine thing to do as it would make the constraints to environment arcs transparent.

Enforcing this could become quite hard however, due to the fact that we cannot typecheck a variable name handed to the macro.

It might suffices to just remove any existing workarounds and add a note to the documentation, saying that any environment values have to be borrowed?

@Feliix42
Copy link
Member Author

This also raises the question, whether this should be valid:

fn main(ctrl: &bool, inp: &String) -> String {
    if (ctrl) {
        modify_string_positive(inp)
    } else {
        modify_string_negative(inp)
    }
}

Technically, ctrl is supplied as input to an operator (namely if), which should not happen according to the current implementation. If this should indeed be invalid, I would prefer if ohuac would check invariants like these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant