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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id CC4C27FCCB for ; Tue, 28 Apr 2015 10:11:25 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=pra; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of alain.frisch@lexifi.com) identity=mailfrom; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="alain.frisch@lexifi.com"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mx20.yaziba.net) identity=helo; client-ip=85.233.204.164; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="alain.frisch@lexifi.com"; x-sender="postmaster@mx20.yaziba.net"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BAAQC/Pz9VnKTM6VVcg1+DdsU5hgwCgTQ8EAEBAQEBAQERAQEBAQEICwkJIS6EIQEBBCMEEUABEAsYAgIFFgsCAgkDAgECAUUGDQEHAQGIK7I7lAUBAQEBBgEBAQEBHYEhiheEUjMHgmiBRQEElVaGOIc5hGaJQAKEGYMxAQEB X-IPAS-Result: A0BAAQC/Pz9VnKTM6VVcg1+DdsU5hgwCgTQ8EAEBAQEBAQERAQEBAQEICwkJIS6EIQEBBCMEEUABEAsYAgIFFgsCAgkDAgECAUUGDQEHAQGIK7I7lAUBAQEBBgEBAQEBHYEhiheEUjMHgmiBRQEElVaGOIc5hGaJQAKEGYMxAQEB X-IronPort-AV: E=Sophos;i="5.11,662,1422918000"; d="scan'208";a="113769454" Received: from mx20.yaziba.net ([85.233.204.164]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/ADH-AES256-SHA; 28 Apr 2015 10:11:25 +0200 Received: from mta10.int.yaziba.net (unknown [10.4.20.30]) by mx20.yaziba.net (mx10.yaziba.net) with ESMTP id 608611A7466; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 7B20ACA66D; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YIkJn4Yzg4cs; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mta10.int.yaziba.net (Postfix) with ESMTP id 5BB22CA66F; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) X-Virus-Scanned: amavisd-new at mta10.int.yaziba.net Received: from mta10.int.yaziba.net ([127.0.0.1]) by localhost (mta10.int.yaziba.net [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id IVxfSwMLRvhM; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) Received: from [10.0.48.241] (unknown [185.23.92.144]) by mta10.int.yaziba.net (Postfix) with ESMTPSA id 4192FCA65E; Tue, 28 Apr 2015 10:11:24 +0200 (CEST) Message-ID: <553F40AC.3040202@lexifi.com> Date: Tue, 28 Apr 2015 10:11:24 +0200 From: Alain Frisch Organization: LexiFi User-Agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?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: 7bit X-DRWEB-SCAN: ok X-VRSPAM-SCORE: -100 X-VRSPAM-STATE: legit X-VRSPAM-CAUSE: gggruggvucftvghtrhhoucdtuddrfeektddrieekgddufeegucetufdoteggodetrfcurfhrohhfihhlvgemucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefkfffhohgfggfvufhfjggtgfesthejrgdttdefjeenucfhrhhomheptehlrghinhcuhfhrihhstghhuceorghlrghinhdrfhhrihhstghhsehlvgigihhfihdrtghomheq X-VRSPAM-EXTCAUSE: mhhouggvpehsmhhtphhouhht Subject: Re: [Caml-list] js_of_ocaml with node On 04/28/2015 09:53 AM, Alain Frisch wrote: > 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). Just to clarify: the issue here is that node.js documents the function as: fs.mkdir(path[, mode], callback) and its implementation is more liberal: ================= function modeNum(m, def) { if (util.isNumber(m)) return m; if (util.isString(m)) return parseInt(m, 8); if (def) return modeNum(def); return undefined; } fs.mkdir = function(path, mode, callback) { if (util.isFunction(mode)) callback = mode; ... modeNum(mode, 511 /*=0777*/) ... }; ================= (welcome to Javascript wonderful calling conventions!) So both conventions are supported to omit the mode argument: fs.mkdir(path, undefined, callback) fs.mkdir(path, callback) (one could actually pass anything as the second argument as long as it is not a number, not a string and not a function). So it is ok to bind it simply as: val mkdir_async: string -> ?mode:int -> (js_exn option -> unit) -> unit [@@js.global "fs.mkdir"] Alain