On Wed, 29 Jul 2009, Sven Schreiber wrote:
Allin Cottrell schrieb:
> On Mon, 20 Jul 2009, Sven Schreiber wrote:
>
>> in light of the recent discussion concerning mreverse() --for example we
>> don't want too many different functions for doing similar things-- I
>> would like to raise the following issues:
>>
>> 1) sort() and dsort(); IMHO it would be good to unify them into one
>> function with an optional argument to specify descending sorting, like so:
>> sort(a) or sort(a,0) : sorts ascending
>> sort(a,1): sorts descending
>
> Maybe so. My only misgiving is that I prefer not to use magic
> numbers (or magic booleans) as function arguments -- though we
> already do this to some extent.
I can understand both points of view, but what's the priority then? I
tend to think that if sort() and dsort() are better than magic booleans,
then the recently introduced mreverse(a) and mreverse(a,1) should also
be replaced by rowreverse() and colreverse(). Don't know what other
functions have similar issues. Having a mixture of "philosophies" with
respect to function signatures is unnecessarily confusing IMHO.
You're right on that. I'll have to take a look at what we have in
place and take stock.
>> 2) strcmp(): would it be possible to handle this with a
comparison
>> operator like mystr1 == mystr2 and scrap the function?
>
> Ah, perhaps I had forgotten that we already implement s1 == s1 for
> strings, when I added strcmp. So maybe strcmp is redundant.
>
>> 3) if not, at least unify strcmp() and strncmp(), again using an
>> optional argument:
>> strcmp(a,b,5) would work just like strncmp(a,b,5)
>> Actually, this looks very straightforward, or am I missing something?
>
> Well, for "str" functions that have the same names as C functions
> I think it's desirable that they have the same syntax as the C
> versions.
Ok, as you know I don't know much about C. When was strcmp() added, is
it worth discussing further?
Frankly, I would be very surprised if anyone has used gretl's
strcmp(). In CVS I have removed it in favour of strncmp (with the
possibility of the trailing 'n' argument being omitted to give the
behaviour of C's strcmp). If anyone is upset, let us hear from
them!
Allin.