3 ms·
This is the case in Java as well--you can redefine standard in or standard out out in any location and it will have an effect everywhere that uses the same clas
by hyperpape 9y ago
This is the case in Java as well--you can redefine standard in or standard out out in any location and it will have an effect everywhere that uses the same classloader.
- richard_todd 9y agoI did not mean to imply that it was a perl6-specific hazard, and in fact I lost interest because I can already do these kinds of hacks in languages that are decades old. The downsides are exactly the same, and the advice (“don’t do that in real code”) is exactly the same. In 2017, “look how dynamic things are” is not a differentiator... that part of language design space is pretty mature by now.
- raldi 9y agoPython, too. Let's say you import some code that does this, somewhere deep inside: try: x = 1 / int(s) except ZeroDivisionError, ValueError: print "uh oh" Oops, you just accidentally overwrote what the term ValueError means, in a way that won't get you a warning or anything. But somewhere else, far away, when you try to refer to ValueError, you're going to get really weird bugs and have no idea where they're coming from, since the stack trace will be nowhere near the code with the bug.
- cesarb 9y agoThat particular gotcha has been fixed in Python 3: >>> try: ... x = 1 / int(s) ... except ZeroDivisionError, ValueError: File "<stdin>", line 3 except ZeroDivisionError, ValueError: ^ SyntaxError: invalid syntax It now requires the "as" keyword. Also, AFAIK setting ValueError to something else affects only the current module; only modifying __builtins__.ValueError would affect other modules.