Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!news.funet.fi!tut!pk From: pk@cs.tut.fi (Kellom{ki Pertti) Newsgroups: comp.lang.scheme Subject: Using the return value of set! et al Message-ID: Date: 2 Apr 91 12:49:13 GMT References: <1991Mar24.064144.4256@daffy.cs.wisc.edu> <2977@kraftbus.cs.tu-berlin.de> <1991Mar26.155905.12906@daffy.cs.wisc.edu> Sender: news@funet.fi (#Kotilo NEWS system ) Organization: Tampere Univ. of Technology, Finland. Lines: 33 In-Reply-To: quale@saavik.cs.wisc.edu's message of 26 Mar 91 15:59:05 GMT Nntp-Posting-Host: talitiainen.cs.tut.fi >>>>> On 26 Mar 91 15:59:05 GMT, quale@saavik.cs.wisc.edu (Douglas E. Quale) said: > Re: using values returned by set! et al mentioned in a previous post > I've never seen any Scheme code that depended on the value returned by set!, > but it would be easy to make this mistake. Some Schemes return something > like #[undefined value] for these cases. Although not defining the return > values of these functions can enable a compiler to generate faster code, I > think it would be better to define return values for them. The return values > wouldn't be used very frequently and often the compiler can see this and > generate the same code as if the return value were undefined. I have lately seen a lot of Scheme code that depends on the reutrn value of set!, vector-set! etc. I'm currently teaching a course in data structures and algorithms, and as a class project the students are writing a program to simulate a mouse in a maze. The first assignment was to write a data sructure modeling the maze, and a lot of the students are writing code like (define (make-maze ...) (let ((vec (make-vector ...))) (vector-set! vec [whatever initialization is needed]))) The interpreter they are using returns vec as the return value of vector-set!, so the students happily use the return value. I have seen a lot of code like this, and I don't think you can entirely blame the students for it. They are new to the language, and they already have enough to think about. If multiple values become part of the standard, I would very much like to see set! etc. return zero values, because that would eliminate most of the problem from the teacher's point of view. -- Pertti Kellom\"aki (TeX format) # These opinions are mine, Tampere Univ. of TeXnology # ALL MINE ! Software Systems Lab # (but go ahead and use them, if you like)