🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6452

Re: first class functions (opps)

#6452
From: The Cybermat Rider
Date: Sun, 07 May 1989 20:41
44 lines
2540 bytes
In article <451@sdti.SDTI.COM> (Prescott K. Turner, Jr.) writes:
>I'm somewhat familiar with Scheme's "first-class" functions, and like them.
>But isn't it false advertising to claim first-class functions unless you
>can compare functions for equality just like other types?  This means that
>the implementation will return "not-equal" if the functions are different,
>return "equal" if they can be proved equivalent, and otherwise continue
>searching for a proof or counterexample indefinitely.  Are there any
>languages which support this?

As a matter of fact, Scheme does something akin to this.  You can compare
functions, but there's a catch:

> (equal? (lambda (x) (+ x 1)) (lambda (x) (+ x 1)))
()

The thing about Scheme is that each lambda expression above creates a
separate procedure body, even though the two are similar.  The following
would work, though, since test1 and test2 point to the same procedure body:

> (define test1 (lambda (x) (+ x 1)))
test1
> (define test2 test1)
test2
> (equal? test1 test2)
#t

If I understand you correctly, you consider two functions to be "equal" if
they are _functionally identical_.  Certain languages I know might allow you
to write functional equality tests for functions that return numbers, but I
daresay that it'll be more than a little difficult to compare functions that
return strings, to say nothing of functions that return functions!  Take
into account the target functions' side-effects, and the problem now takes on
gargantuan proportions.

>--
>Prescott K. Turner, Jr.
>Software Development Technologies, Inc.
>P.O. Box 366, Sudbury, MA 01776 USA         (508) 443-5779
>UUCP: ...{harvard,mit-eddie}!sdti!turner    Internet: turner@sdti.sdti.com

----------------------------------------------------------------------------
Adrian Ho a.k.a. The Cybermat Rider	  University of California, Berkeley
laba-4he@web.berkeley.edu		(WEB Evans, Home of The CS Freakies)
Disclaimer:  Nobody takes me seriously, so is it really necessary?
Technical Details
Message-ID: <24122@agate.BERKELEY.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!e260-4g.berkeley.edu!laba-4he
References: <10253@orstcs.CS.ORST.EDU> <2400023@otter.hpl.hp.com> <451@sdti.SDTI.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!agate!e260-4g.berkeley.edu!laba-4he
From: laba-4he@e260-4g.berkeley.edu (The Cybermat Rider)
Newsgroups: comp.lang.misc
Subject: Re: first class functions (opps)
Message-ID: <24122@agate.BERKELEY.EDU>
Date: 7 May 89 20:41:11 GMT
References: <10253@orstcs.CS.ORST.EDU> <2400023@otter.hpl.hp.com> <451@sdti.SDTI.COM>
Sender: usenet@agate.BERKELEY.EDU
Organization: University of California, Berkeley
Lines: 44