-
Notifications
You must be signed in to change notification settings - Fork 47
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
Sequences of bindings for let ... in
#87
Comments
I'd say no on that personally. That is a Haskell'y format that implies that they can be recursively defined, which I highly doubt is the case here? |
To clarify, do you mean that it would imply we can define recursive functions in the let binding or that functions in the sequence can refer to ones previously defined in the same sequence? |
As in the syntax given reminds of the Haskell syntax where you can define recursive functions, a trivial example: let
blee x =
| x <= 0 = 0
| otherwise = blah x
blah x = bleh (x - 1)
in blah 42 In Haskell such a form is naturally recursive, the equivalent form in OCaml, as an example, could be: let rec blee = function
| x when x<0 -> 0
| x = blah x in
and blah x = bleh (x - 1) in
blah 42 Also, if your function returns unit in OCaml, you can elide the let () = someFuncThatReturnsUnit 42 in someFuncThatReturnsUnit 42; TL;DR: It would imply to me that the functions within would be mutually recursive, also the |
Ah, I think I see. So in Alpaca atm all function bindings are actually
is perfectly fine (assuming top-level bindings for both here). Both have the return type "infinitely recursive" ( I should have been a bit more specific, I was referring to bindings within top-level functions/bindings, e.g.
vs
Better/worse? Totally open to different separators. |
I meant the same. ^.^ I definitely prefer the (In OCaml, the 'rec' is not default not because it would slow down compilation or anything, but because OCaml lets you 'name' a function then overwrite it later to be exposed, and this is entirely doable in the Erlang AST as well by just having the non-exposed variants have private unique names. OCaml uses this so that you can do things like |
Interesting...bindings within top-level bindings in Alpaca are rewritten/renamed with synthetic/unique names but then checked for collision with bindings created later, e.g.
will generate a duplicate definition error. The motivation behind the check is to explicitly remove the ability to shadow things, especially with respect to changing types and renaming is to avoid a few issues with names escaping With respect to the
I think this sort of thing does help address Erlang behaviours or something like them as well. @Tuncer and I talked a little bit about things like 1ML and a few other things a while back but to be perfectly honest I've got a lot more reading and understanding to do :) I may be getting into the weeds a bit here, probably a better discussion for a new issue or on irc. |
In regards to the points raised in this thread:
The latter reads more nicely than the former (pure opinion), from the perspective that I like code to come off as a narrative. Repeated
Borrowing from OCaml (which I know little about), and this explanation about |
In LFE, people seem to strongly dislike like the distinction between let x = 42
y = x + 1 (* Error: x is undefined) *)
in ... ... and let x = 42
y = x + 1
in ... (* y = 43 *) In those terms, Clojure defaults to the As far as that concern, I'd prefer sequential let. As far as the For the separator, I like "new line and leading indentation match" and maybe let x = 42
y = x + 1
in ... or let x = 42
y = x + 1 in
... and maybe let x = 42; y = x + 1 in ... Does Alpaca have a |
@OvermindDL1 @saem I missed the distinction between My basic opinion right now: I see value in default implementations of signatures/interfaces but would like to consider more specificity than @yurrriq with respect to sequential let I'm firmly in the same camp as you. I'm honestly not sure what the utility of As for separators I don't have any really strong feelings aside from not using significant whitespace. @ypaq I think was right to push for its removal in IRC and @lepoetemaudit just went through a fair bit of work removing the need for it (part of the reason we now have leading |
They do not need to be though. The external interface for a module is defined explicitly in the EVM so you could easily build up a list of internal functions with the final defined set being the ones that are actually exposed (rename prior). :-) |
Oh definitely possible yes :) My reluctance to go this direction is an assumption that most people coming from languages other than OCaml might naturally expect functions to be essentially
PS I really appreciate the input/feedback/ideas. |
In regards to the question about It's interesting covering a number of issues around git diffs, action to intent/return distance, etc... I do think that it's a nice to have, and people can make do in the mean time, so it wouldn't be unreasonable to sideline it for now. |
@saem that's a really great post, thanks for linking it! "Intent first" is an interesting way to put it and I think a good argument in favour of us adding |
👎 from me. I would prefer there to be only one way to create variables and this new syntax does not add anything not already possible with the existing syntax. |
Rather than:
I'd like to be able to do something like
The text was updated successfully, but these errors were encountered: