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

Re: N_ELEMENTS and WHERE: Scalar or Array ?

Stein Vidar Hagfors Haugan <steinhh@ulrik.uio.no> wrote:
>In article <36b5d66b.0@news.nwl.ac.uk> wmc@bas.ac.uk writes:

>> If this is necessary for legacy reasons, it might be possible to make
>> () and [] behave differently in this case? Possibly a missed
>> opportunity when [] came in!

>How'bout {} ? :-) I'm not *just* kidding. [] work as both array
>constructors and indexing brackets, so {} could work as both
>structure constructors and indexing brackets..

Hmm, having three different sorts of brackets to make arrays is
a bit of overkill. Anyway, {} might be needed for associative
arrays one day!

>>>   array[NaN] = 5        ; Would be allowed, but does nothing
>>This could well be possible as an easy-to-do work-around. In that
>>case, where would have to return NaN not -1.

>(Yes - though with a WHERE(..,/nan) switch)

Hmm, that would be acceptable. Or an nwhere function (a bit less typing).

>>Incidentally, I've just realised how dangerous the out-of-bounds stuff 
>>  array([where(array eq false)])='stoat'
>>assigns to the first element...

>And you can *bet* some program(mer)s out there are counting on
>exactly this as a *feature*! Sorry to say so, but...that's why
>you'd have to introduce a keyword switch in WHERE.

Well, they are very silly people then. Does anyone on this newsgroup want
to confess to using this "feature"?


William M Connolley | wmc@bas.ac.uk | http://www.nbs.ac.uk/public/icd/wmc/
Climate Modeller, British Antarctic Survey | Disclaimer: I speak for myself