This is the mail archive of the cygwin-talk mailing list for the cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FW: cygwin.bat improvements (was Re: Cygwin on XP disapearing terminal mystery)


On 01 February 2006 18:31, Igor Peshansky wrote:


> Contrary to all common sense, "if not errorlevel A" means "if
> %ERRORLEVEL% < A", not an equality test...  

  Actually, I don't think that's contrary to common sense.  I think it's contrary to *coding* sense and in perfect agreement with
*common* sense.

  In accord with common sense, "if not errorlevel A" means the opposite of "if errorlevel A".  Reasonable so far, no?

  But here's the bit where you have to think like a human rather than a programmer[*].  You're expecting "if errorlevel A" to be an
equality test.  I don't see why it should be.  After all, I don't see the word "equals" in there.

  What I see, trying to interpret that as if it was pseudo-english (which I guess it actually is anyway), is a statement that wants
to test the seriousness of an error, and a parameter A, which common sense tells me would be some kind of seriousness-of-error
variable, and common sense also tells me that the only reason for testing an error would be in order to try and do something about
it, like reporting it to the user or trying again or whatever.

  At that point, it makes perfect sense to me that, if A stands for some kind of value such as "no error", "warning", "minor error",
"major failure", where you're on a scale of ordinal values which implicitly has a sense of lesser and greater, any time you're
testing for an error, you'd equally want to know if the error was more serious than the level at which you get worried about it,
i.e. a greater-than-or-equal test.

  For instance, it's unlikely that you'd want to do something about a minor error, but consider a major failure would be just fine,
and if you bother to handle warnings, it's unlikely that you'd consider an actual error to be less significant.  Who'd think it was
sensible to design a scheme where you have to write code that effectively means ...

<command to test>
if errorlevel is a warning
  do whatever
endif
if errorlevel is a minor error
  do the same as above
endif
if errorlevel is a major error
  same block of code cut'n'pasted a third time
endif

... ?

  Nope, I say that there is an asymmetry in the nature of errors: that if you want to handle an error of seriousness X, you can
infer that you would want to handle an error of seriousness (X+1), but you can infer nothing about whether or not you would to
handle an error of seriousness (X-1), and therefore that is why a .GE. test is very much in line with common sense and an equality
test would be so obviously awkward and inconvenient that it wouldn't seem sensible at all.

  If you want an exact equality test, you have to say

if ERRORLEVEL x
if NOT ERRORLEVEL (x+1)
 ... 
endif
endif

but, again, common sense[**] tells me that that is the least frequent case I'm going to care about.

    cheers,
      DaveK

[*] ;-)
[**] That's _my_ common sense, of course, not anyone elses![***]
[***] Of course, common sense is what tells you the world is flat, so there are far deeper philosophical problems here than this one
minor semantic issue.[****]
[****] Hippos are natural-born philosophers.  All that standing about in rivers yawning all day long gives them plenty of time for
contemplation.
-- 
Can't think of a witty .sigline today....


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]