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

Re: Top 10 IDL Requests




landsman@my-deja.com writes:
> In article <on66q4a433.fsf@cow.physics.wisc.edu>,
>   craigmnet@cow.physics.wisc.edu wrote:
> 
> > * A way to index strings like arrays.
> >
> >   I know we can use STRMID and STRPUT, but it seems that an array-like
> >   notation would fit so much better with the philosophy of IDL.
> >
> 
...deletia...
> 
> But I am not sure that such a change would be desirable.     First of
> all would be the difficulty in making a syntax change backwards
> compatible.  The change of the string syntax from  V1 to V2  probably
> required more coding  changes than any other syntax change ever made to
> IDL. Also, some syntax would become more complicated -- for example, the
> current extraction of elements of a string array st1 = st[3:5] would
> have to become st1 = st[*,3:5].    V5.3 introduced many string
> processing enhancements (e.g. STRMID now accepts vector parameters), so
> I think all the functionality of the array notation is now available in
> then string processing functions.  Finally, one can always index strings
> like arrays by first converting them  with BYTE().

I agree that standard array indexing syntax wouldn't mix too well with
accessing strings.  On the other hand we do already have the
X.(SUBSCRIPT) notation for structures, which could perhaps be adapted
for strings as well.

IDL> value = '0123456789'
IDL> value.(4:5) = '--'    ;; pre-beta!
IDL> print, value
0123--6789

This is intuitive to me at some level.  You use the "." notation to
get at the internals of a structure.  The same notation could get at
the internals of a string.

For that matter, it would be nice, but probably hard to implement, to
be able to use range and "*" notation for structures in the same way.

Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------