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

Re: Keyword precedence



Mark Hadfield and John-Cavid Smith had a long discussion in which
Mark wrote at some point:


> 
> I think the rule should be, where a choice has to be made between duplicate
> keywords, always choose the last one in the list.
> 

now for the slow-movers: does this mean that
  wrapper, color=12, _Extra=e
and
  wrapper, _Extra=e, color=12

should yield different results if there is a color tag in the
extra structure? I could see some benefits to this, but it would
alter the whole idea of keywords being position independent as
opposed to parameter arguments. 

   Although this may seem overly formal, I would argue that the
"convenience" gained by overriding keywords that are explicitely
set with values in the extra structure does not aid in writing
"clean" programs. If you are messing with any particular property
in your routines, this property should always be identified by
having its own keyword in my opinion. So, if you want a default
color, the procedure header should be something like:

  pro wrapper, color=color, _EXTRA=e

     IF N_Elements(color) EQ 0 THEN color = 12
     plot, x,y, color=color, _EXTRA=e

  end

and the "real" color keyword should be used (which I think and
hope it gets).

Conclusions (these tend to come near the end of an article ;-):

I agree with JD that IDL should be stricter and issue an error if
it finds more than 1 keyword of the same name in a _ref_extra
list, and perhaps it should even be possible to generate an error
if the two identical keywords appear in the _extra list (another
compile_opt flag?).

Cheers,
Martin




-- 
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie   
[[
[[                      Bundesstr. 55, 20146 Hamburg            
[[
[[                      phone: +49 40 41173-308                 
[[
[[                      fax:   +49 40 41173-298                 
[[
[[ martin.schultz@dkrz.de                                       
[[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[