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 upNew syntax for lazy getters #1223
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
ljharb
Jun 11, 2018
Member
Please see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for how to best suggest new ideas.
|
Please see https://github.com/tc39/ecma262/blob/master/CONTRIBUTING.md for how to best suggest new ideas. |
ljharb
closed this
Jun 11, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
aaditmshah commentedJun 11, 2018
•
edited
Lazy getters are really useful in functional programming. They are used to prevent stackoverflows (via tail recursion modulo cons), and they can be used to create infinite data structures. However, they are very verbose. Consider the following lazy
takefunction:It would be nice to have syntactic sugar to create the lazy getter:
This syntax could also be used to succinctly tie the knot to create cyclic data structures:
This enables a limited form of
letrecwithout actually changing the semantics oflet,constorvar.