-
Notifications
You must be signed in to change notification settings - Fork 28
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
Implement Let
block
#36
Comments
Is there a need for a = 1
a * 2 ? |
Beside that it is not valid elm? It allows you to define recursive structures too. |
Exactly. So far we're trying to be syntactically idiomatic to Elm. When we succeed to copy the whole language we might discuss some changes. But it's definitely not a time for that yet :) Plus having |
Could you elaborate on this @OvermindDL1? |
Assignment is not an expression in Elm. |
Some valid elm, you can create inline mutually recursive functions and calls and such. import Html exposing (text)
main =
let
r = c 1
a b = 21 * b
c d = a (d+1)
in text (toString r) I still prefer the OCaml method though, much more clear and redefinable... |
You could still achieve that without the main =
r = c 1
a b = 21 * b
c d = a (d+1)
text (toString r) |
The purpose is to allow rebinding as well (this is not valid elm because elm is a bit stupid in how it does a lot of things): import Html exposing (text)
main =
let
r = c 1
a b = 21 * b
c d = a (d+1) in
let r = r + 1 in
text (toString r) In addition to controlling scoping and more things. Plus, it does not matter, it is still not valid elm to leave the |
@net Exactly. But the |
@OvermindDL1 Is rebinding in an expression really that important? Many would argue that rebinding only causes confusion. Pick better variable names instead. Scoping is entirely possible with the non- |
@wende Right, so allowing assignments before an expression does not violate the one-expression-per-function rule. |
Unless you are getting into whitespace sensitivity (ew) then it becomes ambiguous: a = 4
b = 4 + a
b + 6 Unless the language is whitespace sensitive (big ew) it is parsed like: (a = 4) (b = (4 + (a b) + 6) The But still, it is a moot point, elm does not allow it. ;-) |
@OvermindDL1 ...
Something ->
fun
a
b
c
SomethingElse b c ->
... You can't really know where |
I know, it endlessly bugs me. ^.^; Honestly I'd say you should write a new backend for OCaml that compiles to Elixir instead. ^.^ |
Add:
Let
Example:
->
The text was updated successfully, but these errors were encountered: