Browse thread
The Implicit Accumulator: a design pattern using optional arguments
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Jon Harrop <jon@f...> |
| Subject: | Re: [Caml-list] The Implicit Accumulator: a design pattern using optional arguments |
On Thursday 28 June 2007 14:33:15 Thomas Fischbacher wrote:
> Jon Harrop wrote:
> >>You are still evading the issue: you nevertheless pass multiple arguments
> >> to a continuation, rather than consing a return value.
> >
> > Continuations and consing have nothing to do with this.
>
> Continuations and consing was what the discussion was about
> before you changed the subject.
I am more than happy to talk about continuations and consing but you need to
post code that uses continuations or conses before anyone can help.
On Thursday 28 June 2007 12:18:44 Thomas Fischbacher wrote:
> > > Pattern matching requires constructors, which cons.
> ...
> You are evading the question.
You didn't ask a question. You made an incorrect statement: "Pattern matching
requires constructors, which cons".
In the context of avoiding allocation, that is a critical misunderstanding as
there was no allocation to avoid.
> How do you return two arguments from a function without constructing a
> 2-tuple (which is a consing operation).
You can rewrite:
let f() = 3, 4
let g() =
let x, y = f() in
x + y
in CPS as:
let f k = k 3 4
let g = f ( + )
Performance is within 1%.
> A continuation call to a higher order function is one way to get
> something similar to MULTIPLE-VALUE-*.
Not really. Lisp's MULTIPLE-VALUE-* is used to avoid Lisp's heinously slow
allocator. OCaml opted for a fast allocator and no MULTIPLE-VALUE-*.
> But often, this is a hack.
Using CPS to avoid inefficiencies that don't exist is certainly a bad idea.
> According to your usually-screwed-up metrics...
Time taken?
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?e