Andrew Falanga wrote:
> Don Porter wrote:
>> In article <443e700e$1@usenet01.boi.hp.com>, Andrew Falanga wrote:
>>> I'm working on a new source command that will manage a list of loaded
>>> libraries for me. The code for the new source command is:
>> Let us count the opportunities for improvement...
>
> I never claimed to be the best :-)
>
>>> rename source _source
>>>
>>> proc source { pathToFile } {
>>> global libraryIndex
>>> if { ![file exists $pathToFile] } {
>>> Log "File: $pathToFile does not exist"
>>> exit
>>> }
>> Process exit is a pretty severe reaction to a missing file.
>> Sure that's what you want?
>
> In this case, I'm pretty sure that is what I want. I'm typically going
> to be sourcing in libraries and if I can't find them, the script won't
> run anyway.
>
except you are replacing a commonly used command that may be used
by other bits of code you don't control, so you should match the
behavior of the original command - which is to throw an error -
not exit. Perhaps you will use a library that has multiple
implementations and is coded to handle it by trying to source
a file, and if that fails alls back to another one, suddenly
it now exits instead. the proper place to add the exit is in
your application code that *calls* source - there is where the
determination if the error is fatal or not is appropriate.
Bruce
Received on Sun Apr 30 03:10:59 2006