Message from discussion Does go have a return value ?
From: Joshua Taylor <tay...@cs.rpi.edu>
Subject: Re: Does go have a return value ?
Date: Mon, 30 Nov 2009 11:25:08 -0500
Organization: A noiseless patient Spider
References: <AuGQm.57141$Ej6.email@example.com> <firstname.lastname@example.org> <xeHQm.34475$Pi.email@example.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
X-Trace: news.eternal-september.org U2FsdGVkX1+X51sTnOFAPHVmpBHn+EUATZm1NlgxoeDJpep3d5q9CyeEGGoUYYigq6aqHHZv3ash4ZwOy/A+3lh/689/fwrfZ5PUPqm3+gVa9msiE10tk9cRmOdfHp0iVoYOtJn03LC+8Vy/GDJo5g==
NNTP-Posting-Date: Mon, 30 Nov 2009 16:25:09 +0000 (UTC)
User-Agent: Thunderbird 220.127.116.11 (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 ï¿½18.104.22.168.4.2 Unconditional Transfer of
Control in the ``Syntax Section'' 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
CL-USER> (defparameter *x* 'x)
CL-USER > (tagbody
(setf *x* (go end))
CL-USER > *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 .