Newsgroups: comp.lang.forth,comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!gatech!usenet.eel.ufl.edu!news.mathworks.com!news-res.gsl.net!news.gsl.net!swrinde!howland.erols.net!vixen.cso.uiuc.edu!newsfeed.internetmci.com!in2.uu.net!hearst.acc.Virginia.EDU!murdoch!faraday.clas.Virginia.EDU!jvn
From: jvn@faraday.clas.Virginia.EDU (Julian V. Noble)
Subject: subroutines that return variable #'s of results
X-Nntp-Posting-Host: faraday.clas.virginia.edu
Message-ID: <Dw3v4w.A8u@murdoch.acc.Virginia.EDU>
Sender: usenet@murdoch.acc.Virginia.EDU
Organization: University of Virginia
Date: Wed, 14 Aug 1996 02:05:20 GMT
Lines: 26
Xref: glinda.oz.cs.cmu.edu comp.lang.forth:29687 comp.lang.scheme:16440

There is nothing in principle wrong with words that return
complex stuff on the stack. I commonly use defining words
whose children return a (long) address and a data type, e.g

The problems arise when words return different numbers of
results, depending on the circumstances. They require an extra
level of worry when you combine them with other words. Frankly,
I feel nervous about this even with ?DUP which returns 1 or 2
items. I am by no means sure that the slight additional
optimization is worth the potential problems caused by (mis)
using such words.

The difficulties arising from variable numbers of return
values are not restricted to Forth. If memory serves, C
permits functions that return variable numbers of results.

Someone complained about Forth being conducive to stack errors
caused by having the wrong number of things returned. This is
of course likely, if one tries to debug code in large swathes.
But if one proceeds a word at a time and keeps things well factored,
such problems rarely arise. I have, at any rate, not experienced
one in several years. MY bugs are all far subtler now...

-- 
Julian V. Noble
jvn@virginia.edu
