RE: catching warnings
In light of Apo4, I thought I'd re-ask this question. Is the following still the approved idiom, or will we have a nice little /[A-Z]+/ thingie: sub foo { temp $SIG{__WARN__} = sub { warn $(timestamp) $@\n } warn hello } Dave. -- Dave Whipp, Senior Verification Engineer, Fast-Chip inc., 950 Kifer Rd, Sunnyvale, CA. 94086 tel: 408 523 8071; http://www.fast-chip.com Opinions my own; statements of fact may be in error.
catching warnings
Perl6 is going to introduce a non-resumable throw/catch mechanism to replace die/$@. (I assume that die will be synonymous with throw, for compatibility.) But what about warnings? I frequently find myself wanting to catch warnings (e.g. to add extra context around a library's use of undefined value warning; or to die when a library issues a warning). Its possible to hack this but, as far as I am aware, there is no clean mechanism for resumable exceptions. Could perl6 add such a capability? I don't know what the correct syntax would be, but the pseudo code might look like: sub foo { try { $a = undef + 1 # replace this with something more interesting! } catch:warn { print $(datestamp): $@\n; resume unless $::warn_count++ 10; die warning-limit exceeded; } } It doesn't have to be in the core language, but it would be nice if it was easy to add as a module. Dave.
RE: catching warnings
Or possibly a universal catch, with the $@.warning and $@.die or something, so that you can check it. Ilya -Original Message- From: David Whipp [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 08, 2002 7:25 PM To: Perl6-Language (E-mail) Subject: catching warnings Perl6 is going to introduce a non-resumable throw/catch mechanism to replace die/$@. (I assume that die will be synonymous with throw, for compatibility.) But what about warnings? I frequently find myself wanting to catch warnings (e.g. to add extra context around a library's use of undefined value warning; or to die when a library issues a warning). Its possible to hack this but, as far as I am aware, there is no clean mechanism for resumable exceptions. Could perl6 add such a capability? I don't know what the correct syntax would be, but the pseudo code might look like: sub foo { try { $a = undef + 1 # replace this with something more interesting! } catch:warn { print $(datestamp): $@\n; resume unless $::warn_count++ 10; die warning-limit exceeded; } } It doesn't have to be in the core language, but it would be nice if it was easy to add as a module. Dave.