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

Re: AW: Various comments

This page is part of the web mail archives of SRFI 44 from before July 7th, 2015. The new archives for SRFI 44 contain all messages, not just those from before July 7th, 2015.

On Wed, 30 Apr 2003, Michael Burschik wrote:

>> (Besides tradition, I've nothing against returning useful values from
>> destructive ops, though.)
>I totally agree with you, but the procedures in question do not require an
>iterator. I am thinking of (list-remove! (list 1 2 3) 44), for instance.

actually there was a long tradition of useful values returned
from mutators before scheme went and made them all "Undefined."

The schema as I recall went like this....

When you were setting a subvalue within a structure, the former
subvalue got returned.  Thus something like

  (define pr (cons 'a 'b))
  (set-car! pr 'c)                 => b


  (define vc (vector 'a 'b 'c 'd))
  (vector-set! vc 2 'e)            => c

When you defined something, the return value was its name.  Thus:

  (define foo 'bar)  ==> foo

   This convention is still followed in most schemes.

When you were deleting something from a structure, you got back
a value that was still available for deleting.  Thus

  (define (liszt (list 'a 'b 'c 'd 'e 'f 'g)))

  (list-remove! liszt 'b)        => c
     ;; returned the "next" cell after the deleted one

  (list-remove! liszt 'z)        => g
     ;; returned the "last" cell after an unsuccessful search

  (list-remove! liszt 'g)        => f
     ;; returned the "first" cell when the last one was deleted

Many modern schemes return a special value labeled "undefined",
which it is an error to refer to or store.  But I think MITscheme
still does the old-school value returns.