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

I dispute the basic narrative here. If you have tail calls, you have GOTO. If you have closures, you have pointers. The story (so far) is not one of features disappearing, but of features being subsumed by other more general, abstract features.


Everything ultimately manifests as a restriction on the set of assembler instruction series you are permitted to execute. A GOTO that is restricted from leaping outside of its local scope is a limitation. A language with no GOTO is even more limited. A language that only permits tail calls is yet more limited. You don't have GOTO unless you have a full, unrestricted JMP, and if all your language has are tail calls, you do not have a full unrestricted JMP. If you have "pointers" but can't perform arithmetic on them, you don't really have "pointers".

All of these things are restrictions, as well as features. The idea that "features == more power" is not accurate... features and power have a complicated relationship, the moreso since there's more than one useful definition of power, but they are almost no matter what neither strictly in opposition, nor strictly working together. But pretty much every useful high level feature is some restriction on what code sequences you can cause to run with the language, together with something built on top of that restriction that would be either harder or less safe without the restriction.


If you have closures, you have pointers.

And if you have closures you generally have a garbage collector of some sort or another. But anyways, I don't think closures are more "general" than pointers. Closures form a proper subset of memory access vectors (to use a fairly simple definition of "pointer"), so there are things pointers can do that closures can't. But for that matter pointers themselves are an abstraction for memory addresses that the Real Programmers of Yore used before compilers came in and made us all wimps...


As long as they are not directly available to the programmer.


No you don't. A GOTO allows you to GOTO a location that isn't valid code—for example, the middle of a multibyte instruction. A tail call does not. That's what the article meant by "disallowing invalid code": a GOTO is strictly equivalent to a tail call, except for all the extra invalid things a GOTO also allows you to do.


Not really. Machine language jumps can do that sort of nasty stuff but usually gotos are restricted to more well-behaved labels.

That said, gotos are still much less structured than tail calls. You can make some much more spaghetti-like control flow patterns and you are also encouraged to use shared mutable variables instead of passing parameters by value.




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

Search: