Article View: comp.lang.functional
Article #656Re: Why curry? (Re: Why functional languages?)
From: Nick Haines
Date: Mon, 05 Oct 1992 21:09
Date: Mon, 05 Oct 1992 21:09
34 lines
2337 bytes
2337 bytes
In article <CARLTON.92Oct5110856@scws8.harvard.edu> carlton@scws8.harvard.edu (david carlton) writes:
Why does SML support functions of multiple arguments using both tuples
and curried functions, anyways?
1. All functions in SML take one argument. Thinking of "functions of
multiple arguments" results in confusion of the sort you show in your
questions.
2. SML supports curried functions because in some contexts they are
nice to use.
3. Tuples in SML are merely glossed-over record types:
(42,true,"foo") = {1 = 42, 2 = true, 3 = "foo"}
int * bool * string = {1 : int, 2 : bool, 3 : string}
("1", "2", and "3" on the RHS are labels for record elements)
[...]. And how much of a problem is it in practice?
None at all in my experience.
[...] Also, what sorts of order-of-evaluation constraints does SML
impose? If you are compiling "f g h", say, and the compiler can't
prove that evaluating "f g" won't have side effects, does it have
to evaluate "f g" before evaluating "h"? And is it required to
evaluate "f" before "g"?
Yes to both questions, for a single reason, rules 112-118 in the
Definition require that in function applications, the function should
be evaluated before the argument. This applies to the "f g h"
question, because this is an application of the function value "f g"
to the argument "h".
Nick Haines nickh@cmu.edu
Technical Details
Message-ID:
<NICKH.92Oct5160904@VOILA.VENARI.CS.CMU.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!nickhReferences:
<TMB.92Sep28144424@arolla.idiap.ch> <annius.717696151@freyr> <TMB.92Sep28223555@arolla.idiap.ch> <26463@castle.ed.ac.uk> <BvGz2u.2rv.1@cs.cmu.edu> <NICKH.92Oct2134230@VOILA.VENARI.CS.CMU.EDU> <TMB.92Oct4181821@arolla.idiap.ch> <CARLTON.92Oct5110856@scShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!nickh From: nickh@CS.CMU.EDU (Nick Haines) Newsgroups: comp.lang.functional Subject: Re: Why curry? (Re: Why functional languages?) Message-ID: <NICKH.92Oct5160904@VOILA.VENARI.CS.CMU.EDU> Date: 5 Oct 92 21:09:04 GMT Article-I.D.: VOILA.NICKH.92Oct5160904 References: <TMB.92Sep28144424@arolla.idiap.ch> <annius.717696151@freyr> <TMB.92Sep28223555@arolla.idiap.ch> <26463@castle.ed.ac.uk> <BvGz2u.2rv.1@cs.cmu.edu> <NICKH.92Oct2134230@VOILA.VENARI.CS.CMU.EDU> <TMB.92Oct4181821@arolla.idiap.ch> <CARLTON.92Oct5110856@sc Sender: news@cs.cmu.edu (Usenet News System) Organization: School of Computer Science, Carnegie Mellon University Lines: 34 In-Reply-To: carlton@scws8.harvard.edu's message of 5 Oct 92 11:08:56 Originator: nickh@VOILA.VENARI.CS.CMU.EDU Nntp-Posting-Host: voila.venari.cs.cmu.edu