From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 8E1DD7FCCB for ; Tue, 28 Apr 2015 13:18:01 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of drupyog+caml@zoho.com) identity=pra; client-ip=74.201.84.155; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="drupyog+caml@zoho.com"; x-sender="drupyog+caml@zoho.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of drupyog+caml@zoho.com designates 74.201.84.155 as permitted sender) identity=mailfrom; client-ip=74.201.84.155; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="drupyog+caml@zoho.com"; x-sender="drupyog+caml@zoho.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@sender1.zohomail.com) identity=helo; client-ip=74.201.84.155; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="drupyog+caml@zoho.com"; x-sender="postmaster@sender1.zohomail.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BKAQAfaz9VlZtUyUpcg19cgxrFOoYMAoE2PBABAQEBAQEBEQEBAQEHDQkJHzCEIQEBBCMECwEFCwEoCgMCDgsYAgIFIQICDwJGBgEMAQcBAYgSAQMBBAyxRnCEZwKJEyIoJYUcAQEBAQEBBAEBAQEBAQEUB4EhiheFBQeCaIFFAZJhgnmGOII6hH+EZolChBltgkQBAQE X-IPAS-Result: A0BKAQAfaz9VlZtUyUpcg19cgxrFOoYMAoE2PBABAQEBAQEBEQEBAQEHDQkJHzCEIQEBBCMECwEFCwEoCgMCDgsYAgIFIQICDwJGBgEMAQcBAYgSAQMBBAyxRnCEZwKJEyIoJYUcAQEBAQEBBAEBAQEBAQEUB4EhiheFBQeCaIFFAZJhgnmGOII6hH+EZolChBltgkQBAQE X-IronPort-AV: E=Sophos;i="5.11,663,1422918000"; d="scan'208";a="137933526" Received: from sender1.zohomail.com ([74.201.84.155]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-MD5; 28 Apr 2015 13:18:00 +0200 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=zapps768; d=zoho.com; h=message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type; b=GxR6jBtPLyVqb+EV7DtackkqwrRLZaczop2hI5EbU2yWe4o2klJs0XQYLuOr2kw33OTXt6PGQxUq YqCwUA9ScgkSK5GUX4CyQ0Kww1MqPn8uea+Of/fkAPrGVZ3FxDEx Received: from [192.168.1.117] (perens.inria.fr [128.93.60.79]) by mx.zohomail.com with SMTPS id 1430219867579459.5207611342569; Tue, 28 Apr 2015 04:17:47 -0700 (PDT) Message-ID: <553F6C57.50407@zoho.com> Date: Tue, 28 Apr 2015 13:17:43 +0200 From: Drup User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Alain Frisch , =?UTF-8?B?RGFuaWVsIELDvG56bGk=?= CC: Helmut Brandl , caml-list@inria.fr References: <553E9CD0.5040203@gmx.net> <553EB228.9080801@frisch.fr> <0AF7BAC7BE62417CB13C1B30392B80CC@erratique.ch> <553F3C86.4060809@frisch.fr> In-Reply-To: <553F3C86.4060809@frisch.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Caml-list] js_of_ocaml with node You can go one step further here and expose lwt threads instead. It could be done automatically too, since transforming callbacks into lwt thread is always done the same way. Le 28/04/2015 09:53, Alain Frisch a écrit : > On 04/28/2015 12:41 AM, Daniel Bünzli wrote: >> Le mardi, 28 avril 2015 à 00:03, Alain Frisch a écrit : >>> val mkdir: string -> int -> unit >>> [@@js.global "fs.mkdirAsync"] >> >> That should be "fs.mkdirSync". > > Indeed! > >> Just curious, how would the binding to the async fs.mkdir look like ? > > Something like: > > val mkdir_async: string -> int -> (js_exn option -> unit) -> unit > [@@js.global "fs.mkdir"] > > assuming some predefined bindings for js_exn. (One could also decide > to bind JS exception to OCaml's exn type, but the gain is not clear.) > > There are other possible variations, such as making the mode optional: > > val mkdir_async: > string -> > ?mode:(int[@js.default 0o777]) -> > (js_exn option -> unit) -> > unit > [@@js.global "fs.mkdir"] > > > Here js.default forces the default value for the optional mode > argument. Without it, a missing value will send an `undefined` as the > second argument (I don't know if fs.mkdir would be happy with it). > This is currently not supported, but one could also extend the tool to > allow: > > val mkdir_async: > string -> > ?mode:(int[@js.drop_if_missing]) -> > (js_exn option -> unit) -> unit > [@@js.global "fs.mkdir"] > > so that the second argument is dropped in the JS call if not provided > (but I don't see how to support that for OCaml callbacks in full > generality, since the function needs to check the type of arguments to > decide how to interpret them). > > > Alain >