On 01/27/2016 04:32 PM, Felipe Gasper wrote:
On 27 Jan 2016 10:15 AM, Moritz Lenz wrote:

On 01/27/2016 03:15 PM, Felipe Gasper wrote:
So, what *is* the scoping of $!?

Scoped to a routine, iirc (sub, method, regex)

Interesting. JavaScript programmers that I’ve known bemoan that their
language uses function scoping rather than block scoping.

That also seems incongruent with the built-in block scoping for try/CATCH.

Has Perl 6 embraced function scoping as a major paradigm, then?

I wouldn't say "major paradigma", but it's not the only construct that uses routine scoping. return() and fail() come to mind, which are also routine-scoped.

But, what is the point of $! at all?

Convenience. It makes it easy to write commonly-used constructs much faster.

My mostly unscientific approach to gather usage of try vs. CATCH in the ecosystem: moritz@hack:~/p6/perl6-all-modules$ git grep --word CATCH | wc -l
461
moritz@hack:~/p6/perl6-all-modules$ git grep --word try | wc -l
864

CATCH is also rather clunky by comparison (requires an explicit block, whereas 'try' can be used as a statement prefix; requires a "when" or "default" blocks).

$! is also not mentioned here: http://perl6intro.com/#_exception_handling

Feel free to fix that by submitting a pull request :-)

Cheers,
Moritz

Reply via email to