caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Satoshi Ogasawara <ogasawara@itpl.co.jp>
To: daniel.buenzli@erratique.ch
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] [ANN] PEC ver. 1.1
Date: Wed, 18 Apr 2012 20:44:28 +0900	[thread overview]
Message-ID: <4F8EA91C.3060001@itpl.co.jp> (raw)
In-Reply-To: <B2FE8DD50C9B4611809BC1F6B9CDD2E4@erratique.ch>

Hello,

Thank you very much for your prompt reply.

(2012/04/18 16:36), Daniel Bünzli wrote:
> 1) Thread-safety and compositionality. React has no global data structure.

I'm sorry about my misunderstanding that React has a global structure.

> 2) Semantic issues. As soon as primitive events are triggered by other primitive events you run into the problem of multiple occurences of the same event during an update cycle. Now given the synchrony hypothesis of update cycles (an update cycle is instantaneous), this is a violation of the semantics of events (an event has at most one occurence at any given time t). And then people ask you if you can somehow manage the order of updates in an update cycle and then you are not doing FRP anymore, you are doing RP. By loosing the F you also loose compositionality and the equational reasoning tools provided by the denotational semantics of events.

I see that React is implemented with intend to keep good semantics and able to
realize same functions as PEC.
But PEC dose not violate good semantics either. PEC treats only one event at any
given time t. Please see blow code.

module E = Pec.Event.Make (Pec.EventQueue.DefaultQueueM) (Pec.EventQueue.DefaultQueueI)
open Printf

let _ =
   let e, sender = E.make () in
   let e' = E.map (fun x -> sender 2; x + 1) e in   (* during update cycle, send 2. *)
   let _ = E.subscribe (printf "e=%d\n") e in
   let _ = E.subscribe (printf "e'=%d\n") e' in
   sender 1;
   ignore (E.run ());   (* run one event *)
   printf "---\n";
   ignore (E.run ());   (* run one event *)
   printf "end\n"

This program outputs:

e=1
e'=2
---
e=2
e'=3
end

The function (fun x -> sender 2; x + 1) is not purely functional. I see that violates
a part of good semantics and composability. But there is no problem of multiple
occurrences of the same event in one update cycle.

To write event driven systems such like GUI sometimes needs a event-event chain
without real-user actions. Sending events during update cycle is something unavoidable.

> Regarding the absence of Weak usage I'm curious in how you manage the garbage collections of events that depend on others.

Yes, weak-pointer-less implementation is one of my purpose. The key point is
that dependency of events are represented by nested variants.

Best Regards,
   Ogasawara

  reply	other threads:[~2012-04-18 11:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-17 16:40 Satoshi Ogasawara
2012-04-17 17:52 ` Adrien
2012-04-17 18:50   ` Satoshi Ogasawara
2012-04-17 19:23 ` Daniel Bünzli
2012-04-18  1:59   ` Satoshi Ogasawara
2012-04-18  7:36     ` Daniel Bünzli
2012-04-18 11:44       ` Satoshi Ogasawara [this message]
2012-04-18 13:27         ` Daniel Bünzli
2012-04-18 17:39           ` Satoshi Ogasawara
2012-04-18 22:32             ` Daniel Bünzli
2012-04-19  8:59               ` Satoshi Ogasawara
2012-04-19 10:31                 ` Daniel Bünzli
2012-04-19 10:57                   ` Daniel Bünzli
2012-04-19 13:31                     ` Satoshi Ogasawara
2012-04-19 13:02                   ` Satoshi Ogasawara
2012-04-19 14:09                     ` Daniel Bünzli
2012-04-20  9:24                       ` Satoshi Ogasawara

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=4F8EA91C.3060001@itpl.co.jp \
    --to=ogasawara@itpl.co.jp \
    --cc=caml-list@inria.fr \
    --cc=daniel.buenzli@erratique.ch \
    /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).