Email list hosting service & mailing list manager


Re: Some Questions Taylor Campbell 01 Oct 2003 11:29 UTC

On Tuesday, September 30, 2003, at 05:35 PM, Phil Bewig wrote:

> 6)  Why did you decide to order the arguments to stream-ref as
> (stream-ref index s) instead of (stream-ref s index)?  In SRFI-40,
> I struggled quite a while with the proper order of the arguments
> to this function.  (stream-ref index s) seems more natural, with
> the index parameter first and the stream last; most functions that
> operate on concrete data types write the parameters first and the
> data-type argument last.

Really?  Let me show you a few procedure signatures from R5RS, SRFI 1,
SRFI
13, SRFI 43, and SRFI 44:

; R5RS
(list-ref  LIST K)
(list-tail LIST K)
            ^^^^
(string-ref   STRING K)
(string-set!  STRING K CHAR)
(substring    STRING START END)
(string-fill! STRING CHAR)
               ^^^^^^
(vector-ref   VECTOR K)
(vector-set!  VECTOR K OBJ)
(vector-fill! VECTOR K OBJ)
               ^^^^^^
; SRFI 1

(take         LIST I)
(drop         LIST I)
(take-right   LIST I)
(drop-right   LIST I)
(take!        LIST I)
(drop-right!  LIST I)
(split-at     LIST I)
(split-at!    LIST I)
(lset-adjoin  LIST ELT ...)
(lset-adjoin! LIST ELT ...)
               ^^^^
; SRFI 13

(string-copy             STRING [START END])
(substring/shared        STRING START [END])
(string-take             STRING I)
(string-drop             STRING I)
(string-take-right       STRING I)
(string-drop-right       STRING I)
(string-pad              STRING LEN [CHAR START END])
(string-pad-right        STRING LEN [CHAR START END])
(string-trim             STRING [CHAR/CHAR-SET/PRED START END])
(string-compare          STRING STRING* PROC< PROC= PROC>)
...many more comparison functions...
(string-prefix-length    STRING STRING* [START END START* END*])
...also STRING-SUFFIX-LENGTH[-CI], STRING-PREFIX?, etc...
(string-index            STRING CHAR/CHAR-SET/PRED [START END])
(string-skip             STRING CHAR/CHAR-SET/PRED [START END])
(string-count            STRING CHAR/CHAR-SET/PRED [START END])
(string-contains         STRING STRING* [START END START* END*])
(string-titlecase        STRING [START END])
(string-upcase           STRING [START END])
(string-downcase         STRING [START END])
(xsubstring              STRING FROM [TO START END])
(string-replace          STRING STRING* START END [START* END*])
(string-tokenize         STRING [TOKEN-SET START END])
(string-filter           STRING CHAR/CHAR-SET/PRED [START END])
(string-delete           STRING CHAR/CHAR-SET/PRED [START END])
(make-kmp-restart-vector STRING [C= START END])
                          ^^^^^^
; SRFI 43
(vector-copy             VECTOR [START [END]])
(vector-resize           VECTOR SIZE [FILL])
(vector-binary-search    VECTOR VALUE CMP)
(vector-swap!            VECTOR I J)
(vector-fill!            VECTOR OBJ [START [END]])
(vector-insert!          VECTOR I OBJ)
(vector-delete!          VECTOR I [OBJ])
(vector-rotate!          VECTOR [I])
                          ^^^^^^
; SRFI 44

(collection-count     COLLECTION VALUE)
                       ^^^^^^^^^^
(bag-contains?          BAG VALUE)
(bag-add[![!]]          BAG VALUE)
(bag-insert-left[![!]]  BAG VALUE)
(bag-insert-right[![!]] BAG VALUE)
...all the other insertion and mass deletion routines...
...well, you get the idea, and I'm not sure why I've wasted so much time
going through all those SRFIs to name a lot of procedure signatures.

> I don't think there is any particularly right or wrong answer to
> this question, I'm just curious what other people think.

I think it should be (stream-ref STREAM INDEX), especially given what's
in
SRFI 44 for sequences -- (sequence-ref SEQ INDEX [FK]) --.

> Phil