From: John Max Skaller <skaller@maxtal.com.au>
To: David McClain <dmcclain@azstarnet.com>
Cc: caml-list@inria.fr
Subject: Re: Language Design
Date: Wed, 23 Aug 2000 15:55:36 +1000 [thread overview]
Message-ID: <39A36758.E474CC1E@maxtal.com.au> (raw)
In-Reply-To: <000d01c00bb8$fb3e3560$210148bf@dylan>
David McClain wrote:
> I, for one, have fought for many years with languages that insisted on a
> division between functions and procedures as you describe them. I have found
> the unified "everything is a function" approach to be most appealing. In
> particular, the worst offenders are those languages that insist on syntactic
> distinctions such as Fortran, RSI/IDL, and Basic. I cannot be alone in
> having difficulty remembering when a routine, whose result I don't really
> need, is to be called as a function, or as a procedure.
There are two reasons for the distinction. The crucial one is this:
my translator performs an operation called 'control inversion',
in which a primitive 'read x', which reads input, is implemented
by returning a continuation, that is, by yielding control
and waiting until the input is available. Any procedure containing
a read (directly or indirectly on the call chain) must also return
a continuation (which is immediately invoked) so that the dynamic
call chain is not represented on the machine stack.
This technique allows a dispatcher to _call_ the program with messages,
that is, it translates an algorithmic form of the code into
an event driven form. This allows a program handling millions
of instances of something (telephone calls in my case), to dispatch
in log n time (amortised constant time in fact), rather than
the linear time required for OS threads. [the alternative,
writing event driven code, is a severe regression back to the bad
old days of totally unstructured coding]
On the other hand, returning continuations has a high constant
time overhead. To solve this problem, purely functional code
is executed using the machine stack.
The second reason for the distinction is the 'usual' one:
purely functional code has a useful property, namely
referential transparency.
[Technically, the identification of 'needs to be control inverted'
with 'procedure' is incorrect: only some procedures can lead
to elaboration of the read primitive: I plan to handle this later
by analysis and optimisation, but without a further distinction
in the procedure type, this analysis cannot cross compilation
unit boundaries, and I suspect that users will be less than
happy with two kinds of procedures as well as functions :-]
What is _actually_ required is a seamless way to integrate
stateful and function code: the recent (obvious :-) discovery
that the basic duality principle of category theory when applied
to functional theory yields a stateful theory promises
to yield significant progress in the near future.
But this is too cutting edge for me to try for in what my employer
thinks is a simple 4GL for handling telephone calls. :-)
--
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
next prev parent reply other threads:[~2000-08-24 8:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-08-21 21:44 David McClain
2000-08-23 5:55 ` John Max Skaller [this message]
2000-08-24 9:12 ` Francois Pottier
2000-08-24 20:16 ` John Max Skaller
2000-08-25 9:52 ` Andreas Rossberg
2000-08-27 22:00 ` John Max Skaller
2000-08-28 23:11 ` Daan Leijen
2000-08-25 15:41 ` Jerome Vouillon
2000-08-27 22:21 ` John Max Skaller
2000-09-01 11:57 Dave Berry
2000-09-01 17:48 ` Markus Mottl
2000-09-01 19:12 ` Marcin 'Qrczak' Kowalczyk
[not found] ` <39B5DD81.E2500203@maxtal.com.au>
2000-09-06 6:33 ` Marcin 'Qrczak' Kowalczyk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=39A36758.E474CC1E@maxtal.com.au \
--to=skaller@maxtal.com.au \
--cc=caml-list@inria.fr \
--cc=dmcclain@azstarnet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox