-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add functions #32
Comments
Let's not do that for now. I'm still not quite sure as to whether unroll things on the language side of Zonk or on the compiler side. The former is simpler, the latter can be more efficient, because we unroll, compile and optimize at the same time, so a recursive function that computes some value would be optimized away to that value on the compiler side. We could interleave unrolling and evaluation on the language side as well, but then
One disadvantage of unrolling things on the compiler side is that this requires dealing with non-uniqueness of variable names. When we were unrolling loops on the language it was simple "unroll all the loops, then rename the entire program". But if we interleave unrolling and compilation, we'd have to worry about preserving global uniqueness of variables, which might be annoying and is certainly error-prone. Although we are going to face a similar problem even when implementing function-unrolling on the language side, because unrolling stuff like I think it makes sense to try both the options. I'm already going to implement loop-unrolling on the compiler side, so let's implement function-unrolling on the language side and see if it gives us any more info. |
Regarding the design. Quoting this comment:
We have two options for syntax. C-style: Haskell-style: f : Int -> Int -> Int
f x y = ...
p : Int -> Int -> Statement
p x y = ... where I much prefer the latter option as it also allows us to do things like (pseudosyntax) p : (Int -> Statement) -> Int -> Statement
p f i = do
f (i - 1)
f i
f (i + 1) use partial application, etc. |
We don't have indentation-sensitive syntax yet, so that would be
or something like that in the current syntax. |
Regarding syntax, should we follow Haskell syntax or Rust syntax? We already follow Rust syntax for C-family like comments. We probably need #44 for functions. I think we should start with lambdas and applications, as that will be the most straightforward to implement. For instance the built-in
|
I honestly have no idea what's better for us. My instinct would be just to have as Agda-like syntax as possible, but then our users are cryptographers and they'll be more comfortable with C/Rust-style syntax. Maybe we should ask people directly what they want.
Why? That issue is closed.
It's the other way around: |
|
Could you do that? (Note though that we still should feel free to make whatever decisions we think are sensible, so it's not that we ask something and then blindly implement what we are told to)
I think we should start with this. It's not
and While we're here, could you also ask people about syntax for functions? I wrote on that before and I think there are benefits to using Haskell-like syntax for them, but not sure what people think. Also make sure to ask Manuel as he might want to say "this all will be used within Plutus and we don't want any imperative syntax there". |
We need functions. Even non-recursive ones would be handy, but we probably want statically unrollable recursive functions.
Lambdas or proper function declarations? Having debugged Plutus Core code, I'm leaning towards the latter as we already have let-statements anyway.
The text was updated successfully, but these errors were encountered: