From: John Max Skaller <skaller@maxtal.com.au>
To: Jerome Vouillon <Jerome.Vouillon@inria.fr>
Cc: Francois.Pottier@inria.fr, caml-list@inria.fr
Subject: Re: Language Design
Date: Mon, 28 Aug 2000 09:21:55 +1100 [thread overview]
Message-ID: <39A99483.A1EDD4BC@maxtal.com.au> (raw)
In-Reply-To: <20000825174159.39156@pauillac.inria.fr>
Jerome Vouillon wrote:
> I think you should really consider using monads. Here is an example.
I will have to study this example in more detail: thank you very
much for spending the time writing it. My translator generates C++,
but it looks as if the generated code follows the pattern below.
> We define a value of type void to be either a continuation expecting a
> string or a final function that do not expect anything.
>
> type void = Cont of (string -> void)
> | Term of (unit -> unit)
>
> This is a procedure that does nothing.
My equivalent: a pointer to a C++ object of class 'continuation_t'
is returned when reading is desired, the dispatcher comes back
later with the message and stores it in the continuation object.
If there is no work to do, the routine returns a null pointer.
In fact, each procedure call returns control, and a flag tells whether
a read is desired, or whether to call the returned continuation
immediately.
> We can try this procedure. First we define an evaluator. It takes the
> input stream and a procedure call as inputs.
>
> let rec eval l p =
> match l, p with
> _, Term t -> t ()
> | s :: r, Cont c -> eval r (c s)
> | _ -> ((* Stuck evaluation *))
>
> Then we evaluate read2 when two strings "a" and "b" are given as
> input:
>
> let x = ref "" in eval ["a"; "b"] (read2 x); !x
This is very nice. It's much less code than my C++ version :-)
--
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-28 6:57 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
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 [this message]
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=39A99483.A1EDD4BC@maxtal.com.au \
--to=skaller@maxtal.com.au \
--cc=Francois.Pottier@inria.fr \
--cc=Jerome.Vouillon@inria.fr \
--cc=caml-list@inria.fr \
/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