From mboxrd@z Thu Jan 1 00:00:00 1970 X-Sympa-To: caml-list@inria.fr Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id q1EAdQtE017808 for ; Tue, 14 Feb 2012 11:39:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AoIBACE5Ok/RVdQ2kGdsb2JhbABEn2GQNwgiAQEBAQkJDQcUBCOBcgEBAQMBEgITGQEbHQEDAQsGBQQHOyIBEQEFARwGEyKHWgmfNAqLcYJwhSQ/gQsCBQuMTRoCg0wfNgMVgzsElTKOJT2EAw X-IronPort-AV: E=Sophos;i="4.73,416,1325458800"; d="scan'208";a="131271196" Received: from mail-vw0-f54.google.com ([209.85.212.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Feb 2012 11:39:22 +0100 Received: by mail-vw0-f54.google.com with SMTP id fa15so7162418vbb.27 for ; Tue, 14 Feb 2012 02:39:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=ai4kwOLynPn6F17TzqBhpzuWdZCDdTcHIyUmJmzMbt4=; b=vY/I7QeLoBBzAGWoxtEIRt5+eanEJaF9oJ9CJ9IsIUQs2Kq40ZIPgzRh4DDPxHkUx4 qGon1VBkhLUl0R9cwlnaIZ05wtvfBjQBUjadW/SBs4TAFh21pSah4o0NlK4FrVLXrL9Q ciXeD8/N+8ubgD2EUrt1yh7aoKsMFvxqGVkj8= Received: by 10.52.22.46 with SMTP id a14mr8521787vdf.27.1329215962293; Tue, 14 Feb 2012 02:39:22 -0800 (PST) MIME-Version: 1.0 Received: by 10.52.90.140 with HTTP; Tue, 14 Feb 2012 02:39:02 -0800 (PST) In-Reply-To: <4EE9238E9F474D96925E5920255FD691@erratique.ch> References: <4EE9238E9F474D96925E5920255FD691@erratique.ch> From: Philippe Veber Date: Tue, 14 Feb 2012 11:39:02 +0100 Message-ID: To: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Cc: caml users Content-Type: multipart/alternative; boundary=20cf3071c9104324b004b8ea3500 X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] Functional GUI programming: looking for good practices --20cf3071c9104324b004b8ea3500 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Daniel, 2012/2/14 Daniel B=FCnzli > Le mardi, 14 f=E9vrier 2012 =E0 11:02, Philippe Veber a =E9crit : > > > In other words, am I allowed to call a primitive in a lifted function? > No. This is documented here [1]. Well I did read the paragraph, but thought the described limitation might be about updating a signal from different threads. Of course it makes sense that even in a single-threaded code, an update cycle should not be interrupted by another if there are shared dependencies. May I nevertheless humbly suggest to add the "not calling a primitive inside a lifted function" rule more explicitely, as it is a tempting sin for a beginner? > One way to side-step the issue is to put these updates in a queue and > execute them after the update cycle ended. > That seems a good work-around, to gather all side-effects in one place, namely a (unit -> unit) Queue.t where to defer all calls to the primitives. That do help, thanks ! ph. > Best, > > Daniel > > [1] http://erratique.ch/software/react/doc/React#update > --20cf3071c9104324b004b8ea3500 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi Daniel,

2012/2/14 Daniel B=FCnzli <daniel.bu= enzli@erratique.ch>
Le mardi, 14 f=E9vrier 2012 =E0 11:02, Philippe Veber a =E9crit :

> In other words, am I allowed to call a primitive in a lifted function?=
No. This is documented here [1].
Well I did read th= e paragraph, but thought the described limitation might be about updating a= signal from different threads. Of course it makes sense that even in a sin= gle-threaded code, an update cycle should not be interrupted by another if = there are shared dependencies. May I nevertheless humbly suggest to add the= "not calling a primitive inside a lifted function" rule more exp= licitely, as it is a tempting sin for a beginner?
=A0
One way to side-= step the issue is to put these updates in a queue and execute them after th= e update cycle ended.
=A0That seems a good work-around, to gather all side-effe= cts in one place, namely a (unit -> unit) Queue.t where to defer all cal= ls to the primitives.
That do help, thanks !
ph.


Best,

Daniel

[1] http://erratique.ch/software/react/doc/React#update

--20cf3071c9104324b004b8ea3500--