Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

+1 to this

I remember struggling to understand the x = 7 syntax for storing a value in x. My young self was like “so if x is equal to 7, how come we can write x is equal to 8 later? That doesn’t make sense”



A cool thing about this in Erlang (which I think is the same in Prolog) is that the = operator works almost exactly how you would have expected: it binds the value but then it asserts the binding’s equality. So once you’ve established x = 7, x = 8 is actually an error! Because you’re right, it doesn’t make sense that at one point x = 7 and later the same x = 8!


That's what I did in my own language[1], no shadowing allowed.

[1]: https://github.com/mimoo/noname




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: