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

Re: something like perl's 'require 5.4'



JD Smith wrote:
> 
> Paul van Delst wrote:
> >
> > wot about
> >
> > IDL> print, double('5.4.1') ge 5.4d0
> >    1
> >
> 
> Because it's exactly the same!  Yes it's ge, but is it gt?
> 
> IDL>  print, double('5.4.1') gt 5.4d0
>    0
> 
> IDL>  print, double('5.4.1') eq 5.4d0
>    1
> 
> No it's not, it's eq.  Same problem.  So use this if you don't care
> about the last digit and don't want to be open about it (it's not
> exactly obvious this is the case).  Use the string compare method
> otherwise.
> 
> > Doesn't assuage your other concerns regarding the significance of the last digit however.
> > I use comparisons like the above for code that contains BREAK, CONTINUE, SWITCH, etc
> > statements. Or similar for the version in which pointers and objects were introduced (5.2?
> > can't remember).
> 
> The problem here is you'll not err cleanly... unknown control statements
> will cause compile errors.  Not a lot that we can do about this.

Nuh-uh. They're interpreted as user functions/procedures.

IDL> $more testit.pro
pro testit
  for i = 0, 10 do begin
    if ( i eq 5 ) then break
  endfor
end
IDL> print, !version
{ mipseb IRIX unix 5.3 Nov 11 1999}
IDL> .run testit
% Compiled module: TESTIT.
IDL> testit
% Attempt to call undefined procedure/function: 'BREAK'.
% Execution halted at:  TESTIT              5 /modishome/paulv/tmp/testit.pro
%                       $MAIN$                 


So:

IDL> $more testit.pro
pro testit
  if ( double( !version.release ) lt 5.4d0 ) then begin
    message, 'Need IDL 5.4 to use this procedure', /continue
    return
  endif
  for i = 0, 10 do begin
    if ( i eq 5 ) then break
  endfor
end
IDL> .run testit
% Compiled module: TESTIT.
IDL> testit
% TESTIT: Need IDL 5.4 to use this procedure
IDL>


Pre-5.2, nothing says I can't have a function/array called PTRARR or PTR_NEW (or the OBJ
equivalent).

paulv

-- 
Paul van Delst           A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP        Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274  There shallow draughts intoxicate the brain,
Fax:(301)763-8545        And drinking largely sobers us again.
paul.vandelst@noaa.gov                   Alexander Pope.