[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Mac::Dialogs questions



|END looks far too general to me (it's a global function).

It's actually just a block, and while it is global, you can have any
number of them and place them where you want. For example, in:

a.pm:
package a;
END {...}

b.pm:
package b;
END {...}

c.pl:
use a;
use b;
END {...}

all three END blocks are executed when the script quits (or is forced
to quit). Thus a package can have it's own END block without interferring
with any other package or user END blocks.

|DESTROY is only useable when you're programming in OO style.

True, although an object is a good way to encapsulate a resource that
needs to be created and destroyed cleanly. It's also an easy way to
have perl associate a function with an instance of an object. With
END you have to do that yourself and keep track of what objects are
extant yourself.

|What about the __DIE__ sig handler? I haven't tested it, but it OUGHT to
|work when command-period is pressed. 

Actually it ought not. $SIG{__DIE__} is only called when the script
executes a die, either explicitly, or implicitly because of some run-time
error in the script. Also, signals are fairly unreliable. The only thing
you can safely do in a signal is to set a flag. And even if $SIG{__DIE__}
did work and work reliably, it would either require the user to set it, or
require the user to be careful when using $SIG{__DIE__}. The quickest way
to get in trouble in programming is to leave something up to the user. :-)

Brian

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch