I was just playing around with eval, trying to figure out if you can define an operator overload at runtime (seems you can't, good) and noticed this in the spec... [1]
"Returns whatever $code returns, or fails." How does one get the compile error from an eval? What's the equivalent to $@? I don't see anything in the eval tests [2] that's checking for the error, just that it returned false. In addition, I'm surprised that eval doesn't throw an error when it fails. try { eval $code; CATCH { ... } } Using eval STRING in Perl 5 is pretty rare, and should hopefully be rarer in Perl 6 than Perl 5. While it can be used as a "does this compile" check, it's overwhelmingly used with the expectation that the code will compile and so it is an exception if it does not. More pragmatically, this resolves the problem of $@ by putting it into an exception rather than a side global. It also resolves this trap: if eval $code { say "code returned true"; } else { # this will also happen if $code fails to compile say "code returned false"; } While Perl 6 probably has some sort of magic "I failed" value you can check for separate from boolean false, folks aren't going to go through the extra convolutions. [1] http://perlcabal.org/syn/S29.html [2] https://github.com/perl6/roast/blob/master/S29-context/eval.t -- 31. Not allowed to let sock puppets take responsibility for any of my actions. -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army http://skippyslist.com/list/