Message from discussion
Does go have a return value ?
Path: g2news1.google.com!news4.google.com!feeder.news-service.com!188.40.43.213.MISMATCH!feeder.eternal-september.org!eternal-september.org!not-for-mail
From: Joshua Taylor <tay...@cs.rpi.edu>
Newsgroups: comp.lang.lisp
Subject: Re: Does go have a return value ?
Date: Mon, 30 Nov 2009 11:25:08 -0500
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <hf0rl5$s9g$1@news.eternal-september.org>
References: <AuGQm.57141$Ej6.33195@newsfe04.ams2> <20091129192135.85@gmail.com> <xeHQm.34475$Pi.15686@newsfe30.ams2>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: news.eternal-september.org U2FsdGVkX1+X51sTnOFAPHVmpBHn+EUATZm1NlgxoeDJpep3d5q9CyeEGGoUYYigq6aqHHZv3ash4ZwOy/A+3lh/689/fwrfZ5PUPqm3+gVa9msiE10tk9cRmOdfHp0iVoYOtJn03LC+8Vy/GDJo5g==
X-Complaints-To: abuse@eternal-september.org
NNTP-Posting-Date: Mon, 30 Nov 2009 16:25:09 +0000 (UTC)
In-Reply-To: <xeHQm.34475$Pi.15686@newsfe30.ams2>
X-Auth-Sender: U2FsdGVkX194ccSaZLDzDKAU/WIo4jh3c16y/2AlXZM=
Cancel-Lock: sha1:nTZ2fLHhnL7SDrhxXPqQi1vBsFY=
User-Agent: Thunderbird 2.0.0.23 (Macintosh/20090812)
Spiros Bousbouras wrote:
> On Mon, 30 Nov 2009 03:31:14 +0000 (UTC)
> Kaz Kylheku <kkylh...@gmail.com> wrote:
>> On 2009-11-30, Spiros Bousbouras <spi...@gmail.com> wrote:
>>> Does a go form have a return value ?
>> Does a one-handed clap make a sound?
>
> If you hit it against your thigh it most definitely does.
>
>> Why would something that doesn't return have a return value?
>
> Since the vast majority of Lisp forms return a value for reasons of
> uniformity perhaps ? To make the language more functional ? Which makes
> me wonder whether pure functional languages gave gotos and if they do
> how they handle similar constructs.
It's true that the most Lisp forms return a value, and you are looking
at an exception. Although functions may return zero values (via
VALUES), we're looking at something that isn't a function; GO is a
special operator. Some special operators, of course, produce values,
but some don't. The syntax for "|" (I had to dig for it, but I was
curious too) is documented in �1.4.4.20.4.2 Unconditional Transfer of
Control in the ``Syntax Section''[1] which states (notice that it
specifically uses the term "operators"):
""Some operators perform an unconditional transfer of control, and so
never have any return values. Such operators are notated using a
notation such as the following:
F a b c =>|""
As Kaz mentioned, there's no way for anything to consume the result of
GO, even if it did produce a result. A simpler example using assignment
shows that in (setf *x* (go end)), the value of *x* doesn't get changes
at all:
CL-USER> (defparameter *x* 'x)
*X*
CL-USER > (tagbody
(setf *x* (go end))
end)
NIL
CL-USER > *x*
X
Although CL isn't a pure functional language, there are similarities and
CL can often be used purely and functionally. It would be interesting
to see how other pure and not-so-pure functional-ish languages handle
these sorts of situations. Another good thing to compare is condition
handling. And sure enough, of five restart functions in CL (ABORT,
CONTINUE, MUFFLE-WARNING, STORE-VALUE and USE-VALUE), two (ABORT and
CONTINUE) use the "=>|" notation [2].
//JT
[1] http://www.lispworks.com/documentation/HyperSpec/Body/01_ddtdb.htm
[2] http://www.lispworks.com/documentation/HyperSpec/Body/f_abortc.htm