caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: skaller <skaller@users.sourceforge.net>
To: oleg@pobox.com
Cc: psnively@mac.com, caml-list@inria.fr
Subject: Re: [Caml-list] Incremental, undoable parsing in OCaml as the general parser inversion
Date: Thu, 05 Jul 2007 22:39:11 +1000	[thread overview]
Message-ID: <1183639151.12890.19.camel@rosella.wigram> (raw)
In-Reply-To: <20070705081338.D090BAD43@Adric.metnet.fnmoc.navy.mil>

On Thu, 2007-07-05 at 01:13 -0700, oleg@pobox.com wrote:
> Paul Snively wrote:
> > I've attempted to rewrite this in terms of your  
> > monadic version of delimited continuations, as included in the  
> > pa_monad syntax extension distribution.
> 
> I'm afraid that cannot be done. That is, short of re-writing
> make_lexer and all other library functions in the monadic style. 

That was my original point. You wrote:

"This message is to show that the incremental parsing in OCaml is a
solved problem -- essentially for any parser. Moreover, the procedure
to convert from a regular parser to an incremental one is independent
of the parser implementation."

But this isn't so, because you confuse the meaning of 'parser'
and 'implementation' to a programmer, as compared to a
theoretician. A programmer thinks an 'implementation' is
concrete syntax .. i.e. an actual text file.. a theoretician's
'concrete syntax' is still an abstract encoding.

What you've shown is that it is possible to *manually*
control invert a given algorithm.

Now you should note what Felix does. It *mechanically*
control inverts any algorithm encoded with Felix procedures.
And I mean *concrete syntax* here :)

That translation is universal and generated code is expensive
to run due to many closures,  but the cost is reduced by the
optimiser so that code not requiring control inversion reduces
to plain old subroutines.

[Literally, procedure calls are converted to yielding
the procedure to call, etc .. it's continuation passing]

I am guessing my technique differs from what you describe
in that the 'continuations' aren't statically delimited.

That's a serious drawback of the current Felix implementation.
The effect is that the inverted code only works with channels
at the top level, that is, not inside a functional closure,
because the latter use the machine stack and do cannot
yield to the driver (scheduler).

BTW: procedural code is just 'code written in a monadic
style'. Every imperative programming language is just a 
purely functional one with monads..

This shows that monads have all the same problems as
ordinary imperative code if you over use them
(as of course is common practice in low level procedural
programming languages).


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


  reply	other threads:[~2007-07-05 12:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-03 11:38 oleg
2007-07-03 15:28 ` [Caml-list] " skaller
2007-07-04 19:41 ` Paul Snively
2007-07-04 23:42   ` Paul Snively
2007-07-05  8:13     ` oleg
2007-07-05 12:39       ` skaller [this message]
2007-07-05 23:00         ` [Caml-list] Incremental, undoable parsing in OCaml as the oleg
2007-07-06  4:40           ` skaller
2007-07-05 13:23       ` [Caml-list] Incremental, undoable parsing in OCaml as the general parser inversion skaller
2007-07-05 13:54       ` Paul Snively

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=1183639151.12890.19.camel@rosella.wigram \
    --to=skaller@users.sourceforge.net \
    --cc=caml-list@inria.fr \
    --cc=oleg@pobox.com \
    --cc=psnively@mac.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;
as well as URLs for NNTP newsgroup(s).