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

HOCs as desugared base for "controlflow" constructs ("Closure" Problem) #739

Open
emil14 opened this issue Oct 28, 2024 · 3 comments
Open
Labels

Comments

@emil14
Copy link
Collaborator

emil14 commented Oct 28, 2024

Related to #724

There're (probably) no problems with things like ternary/binary/cond/if-else/etc - components that we wanna support at syntax level, that are NOT implemented as HOCs.

On the other hands there are things like For(Each), etc. They have dependencies. Let's imagine this kind of syntax for #687

def Foo(foo stream<int>, bar any) (sig any) {
    :foo -> for {
        // accessing :bar from here
        data -> ...
        idx -> ...
        last -> ...
    } -> :sig
}

For(Each) is a component that takes dependency and DI in Nevalang is not inline (see #720 for details). This mean that we don't have closures. In other words we can't access :bar from inside for loop here. Same goes for switch, match, etc. All syntax features that implemented as HOCs under the hood.

@emil14 emil14 added the Major label Oct 28, 2024
@emil14
Copy link
Collaborator Author

emil14 commented Oct 28, 2024

Restrict Closures

Simplest solution is to check that all port-addresses that we use are (in this case) data, idx and last.

Problem

The power of for-loop construct in C-like languages comes with being able to access outside scope and early termination with break, both of these features are not implemented in this. This is more problem of #687 issue but not having closures might be confusing

@emil14 emil14 changed the title HOCs as desugared base for "controlflow" constructs HOCs as desugared base for "controlflow" constructs ("Closure" Problem) Oct 29, 2024
@emil14
Copy link
Collaborator Author

emil14 commented Oct 29, 2024

Could ForEach (or it's alternative?) be implemented not as a HOC?

@emil14
Copy link
Collaborator Author

emil14 commented Nov 3, 2024

might be related to #627

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

No branches or pull requests

1 participant