develooper Front page | perl.perl6.language | Postings from October 2005

Re: Exceptuations

Thread Previous | Thread Next
From:
Dave Whipp
Date:
October 5, 2005 13:40
Subject:
Re: Exceptuations
Message ID:
20051005204004.30882.qmail@lists.develooper.com
Luke Palmer wrote:
> Of course, exactly how this "public interface" is declared is quite undefined.

Reading this thread, I find myself wondering how a resumable exception 
differs from a dynamically scropted function. Imagine this code:

sub FileNotWriteable( Str $filename ) {
   die "can't write file: $filename";
}

sub write_file (Str $filename)  {
   FileNotWriteable($filename) unless -w $filename;
   ...
}


sub my_program {

   temp sub FileNotWriteable( Str $filename ) {
     return if chmod "+w", $filename;
     OUTER::FileNotWriteable( $filename );
   }

   ...
   write_file("foo.txt");
   ...
}


Ignoring syntactic sugar, what semantics does exception handling have 
that a dynamically scoped function does not?

In the case of non-resumable exceptions, we see things like deferred 
handling -- the exception is passed as a property of an undef value. I 
assume such an exception cannot be resumed, so it does appear to me that 
there are fundamental differences between resumable things, and 
non-resumable, deferrable, exceptions. What is the benefit of unifying 
them under a common syntax (CATCH blocks)?

Larry suggested that the exception mechanism might be a way of unifying 
errors and warnings; but perhaps the opposite is true. Perhaps what we 
see is a needed to generalize the distinction between warnigns and errors.


Dave.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About