Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upscope in let and a few bugs #667
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
process-bot
Jul 17, 2016
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!
Here is what to expect next, and if anyone wants to comment, keep these things in mind.
process-bot
commented
Jul 17, 2016
|
Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it! Here is what to expect next, and if anyone wants to comment, keep these things in mind. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Please check issue 873 in the elm-compiler repo. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jschoch
Jul 17, 2016
for the doBork function how is this recursive? isn't this a variable shadowing issue?
jschoch
commented
Jul 17, 2016
|
for the doBork function how is this recursive? isn't this a variable shadowing issue? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jul 17, 2016
Contributor
In this let-block:
let
a = { model | val = "bam"}
oldR = a.r
newR = { oldR | x = "XXX"}
model = { a | r = newR}the binding for a depends on model and the binding for model depends on a. In particular, the model you use in the binding for a is not the model from the "surrounding"
doBork model =
...Instead, it is the model from the binding inside the let-block, no matter that it appears a few lines below.
This is just a fact of how let-blocks work in Elm (and in Haskell, but not in OCaml, if you need comparisons to other languages).
|
In this let
a = { model | val = "bam"}
oldR = a.r
newR = { oldR | x = "XXX"}
model = { a | r = newR}the binding for doBork model =
...Instead, it is the This is just a fact of how |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jul 17, 2016
Contributor
If you need more explanation, please consult one of the community venues, for example the mailing list. Several options are listed at http://elm-lang.org/community.
This issue tracker here is really for bugs and things that need to change in core.
|
If you need more explanation, please consult one of the community venues, for example the mailing list. Several options are listed at http://elm-lang.org/community. This issue tracker here is really for bugs and things that need to change in |
jschoch commentedJul 17, 2016
i was trying to do a nested update and found an odd bug i recreated here. Start by clicking "not Borked". this seems to correctly change the value to 'model.r' to "XXX".
Then click "bork 2", which changes 'model.r' to
Finally Clicking Bork creates a
Uncaught TypeError: Cannot read property 'test' of undefinederror.The docs are not very clear on scoping of let. i've seen other places where the mutation is not as I would predict. As a newb in elm I have no idea how the scope works, I would expect I shouldn't be able to mutate stuff in place.
this was tested via the try elm function of your website.