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

Re: [MacPerl] is this a bug?



>I don't think "import" should be highlighted.  It's not a Perl builtin
>function, it's just a subroutine.  Your line is equivalent to:
>
>      'Mac::StandardFile'->import;


I think the fact that perl (that is the interpreter) knows about it is 
enough to justify highlighting it. However, there are other things perl 
knows about that aren't highlighted, and IMHO probably shouldn't be 
anyway, so I suppose it's a matter of choice. Please note that I wasn't 
sure if it was a bug or not. Hence no official bug report. Now I am sure 
it's NOT a bug, just a choice made.  Not my choice, but valid and 
reasonable.

Syntax coloring aside, this:

> You can just do
>    eval "use Mac::StandardFile";
> if you don't want to do the require/import combo.

Is a better way to do what I want, not because I don't WANT to do the 
require/import combo, but because this seems both cleaner and more 
'canonical'. I did some reading up. eval() redirects any error message to 
$@, so that if for some reason some Unix user gets into that conditional 
(which shouldn't happen BTW), eval returns undefined (essentially FALSE) 
for Mac::StandardFile, and the conditional gracefully exits.  It also 
fails gracefully if some benighted soul had removed Mac::StandardFile 
from their MacPerl (heaven forbid).  

>From the Camel:

"Note that since eval traps otherwise-fatal errors it is useful for 
determining whether a particular feature (such as dbmopen or symlink) is 
implemented."

Since that's pretty much what I'm trying to do here (suppres compile-time 
evaluation on systems that don't have support for the Mac-Only feature), 
obviously eval() is the right tool.  Obviously! ;-)



# Fungal Parataxonomy                   Mycology Information (Mycoinfo)
# Webmaster, Staff Writer      **The World's First Mycology E-Journal**   
# <mailto:webmaster@mycoinfo.com>            <http://www.mycoinfo.com/> 
#
# First they ignore you. Then they laugh at you. Then they fight you.
# Then you win.                                     --Mohandas Gandhi


===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org