[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: something like perl's 'require 5.4'
JD Smith <jdsmith@astro.cornell.edu> writes:
> > Umm, I never thought I'd be saying this, but aren't these a bit
> > overengineered? I have found that in 95% of the cases the DOUBLE
> > compare will work, and in 4% of the cases the STRING compare will
> > work.
>
> *cough*
>
> <REITERATE>
>
> IDL> print, double('5.4.1') gt 5.4
> 0
>
> </REITERATE>
>
>
> So I guess what you really you mean that in 95% of cases you don't care
> about the (possible) last digit on the version number. This is fine,
> just say so. Here's a good example of when that last digit matters,
> from the "What's New in IDL 5.2.1":
Right, so use the string compare in this case. I'm easy. Since you
*know* what version you need, you can code a test that will work in
that case.
IDL> print, '5.2' LT '5.2.1' -> 1
IDL> print, '5.2.1' LT '5.2.1' -> 0
IDL> print, '5.3' LT '5.2.1' -> 0
if !version.release LT '5.2.1' then $
message, 'ERROR: sorry, no histograms for you!'
This approach will have a problem when IDL version 10 comes around
though. :-)
The overengineering part was my gentle chide for using features and
complexity that are more likely to get one into trouble that they are
to solve the problem at hand.
Craig
--
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------