🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6436

Re: Polymorphism

#6436
From: Alan Lovejoy
Date: Sat, 29 Apr 1989 16:15
51 lines
2912 bytes
In article <1859@etive.ed.ac.uk< nick@lfcs.ed.ac.uk (Nick Rothwell) writes:
<In article <6000@pdn.paradyne.com> alan@rnms1.paradyne.com (Alan Lovejoy) writes:
<>It should be pointed out, however, that there is no inherent reason that
<>function-values cannot or should not be compared for equality.  

<It depends how you define "equality" on functions. Consider:

<		let val F = lambda x. lambda y. x+y
<		in
<		   (F 1) = (F 2)
<		end

<Then, "F 1" and "F 2" are both functions. Are they equal? They've
<evaluated to different dynamic objects, they have different closures,
<and they will give different results. However, they both derive from
<the static definition of F. The only sensible definition of equality
<is equality of dynamic occurrence; but then, two functions may behave
<identically (this is undecidable) but not be "equal".

(F 1) and (F 2) are different functions, both logically and physically.

However, F = F should evaluate to true.

<>Rebinding is what functional languages do instead of value modification.  So
<>rephrase my definition so that "rebinding" replaces "modification" in the 
<>case of functional languages.

<But, consider:
<
<	let i = 1
<	in  (let i = 2 in i end, i)
<	end;

<there's no assignment going on here; just a (local) rebinding of the name.
<If it was assignment, the value of the above expression would be (2, 2),
<not (2, 1).
<Binding is a static properly, and doesn't imply dynamic update-in-place
<or anything like that. Functional programs have to model update by using
<accumulating parameters and self-recursion.

Of course.  But there is a data structure (not "i") that IS being dynamically
updated in place in your example: the dictionary that maps names to values.
The "let" command has an implied operand: the "environment," which includes
the name-value dictionary.  The "end" command restors the previous binding.
So the dictionary permits the "pushing" and "popping" of bindings. So not
only do we have a dynamically modifiable dictionary, but a stack as well.
Whether this updating actually occurs at run time or compile time is a feature
of the implementation, not a property of the language definition.

<Nick Rothwell,	Laboratory for Foundations of Computer Science, Edinburgh.
<		nick@lfcs.ed.ac.uk    <Atlantic Ocean>!mcvax!ukc!lfcs!nick
Technical Details
Message-ID: <6032@pdn.paradyne.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!pdn!oz!alan
References: <5957@pdn.paradyne.com< <1810@etive.ed.ac.uk< <5973@pdn.paradyne.com< <1834@etive.ed.ac.uk> <6000@pdn.paradyne.com> <1859@etive.ed.ac.uk>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!pdn!oz!alan
From: alan@oz.nm.paradyne.com (Alan Lovejoy)
Newsgroups: comp.lang.misc
Subject: Re: Polymorphism
Message-ID: <6032@pdn.paradyne.com>
Date: 29 Apr 89 16:15:58 GMT
References: <5957@pdn.paradyne.com< <1810@etive.ed.ac.uk< <5973@pdn.paradyne.com< <1834@etive.ed.ac.uk> <6000@pdn.paradyne.com> <1859@etive.ed.ac.uk>
Sender: news@pdn.paradyne.com
Reply-To: alan@oz.paradyne.com (Alan Lovejoy)
Organization: AT&T Paradyne, Largo, Florida
Lines: 51