3 ms·
>Programming languages advance by introducing new constraints. Among other things. >throw is a little bit too goto-y for my taste Conceptually, throw is not
by romaniv 6y ago
>Programming languages advance by introducing new constraints.
Among other things.
>throw is a little bit too goto-y for my taste
Conceptually, throw is not at all like GOTO. It's not a control structure, but a communication tool. Throw interrupts execution of logic in a subsystem that encounters abnormal conditions and communicates those conditions to the containing system. The second part is the most important one.
>However, for all of NPM’s problems, at least it is a package management system at all! It’s easy to pick on NPM [...], but even at its worst it’s a huge improvement over manually managing dependencies
This really depends. In many ways NPM made introduction of new dependencies easier, while making handling dependencies over long periods of time a much more hairy problem. I don't like that most devs today assume that versioned packages is the only way you can do things. Many also don't understand that "dependencies" is not a real thing, it's an aggregate label that is applied to a set of problems that happen to be solved by package managers. Problems like discovery, deprecation and compatibility checking.
- carapace 6y ago> throw is not at all like GOTO They are the same thing. To see it clearly, replace each exception with a label, each "try" by a no-op, each "catch" by a label statement, and each "throw" by a GOTO statement. try: foo() catch BarException baz() def foo(): ... throw BarException ... Is like: CALL foo GOTO end LABEL bar CALL baz LABEL end LABEL foo ... GOTO bar ... RET Either you have relatively simple exceptions and the equivalent GOTOs would also be simple enough to be not "considered harmful"; -or- you have complicated exceptions, which is really an ad hoc state machine, and you might be better off making that explicit rather than hiding it in a tangle of try/catch/throw control-flow logic, eh?