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 B273C7FD5B for ; Wed, 2 Dec 2015 22:24:43 +0100 (CET) IronPort-PHdr: 9a23:4snPyREqz3rST2S3lA9Mi51GYnF86YWxBRYc798ds5kLTJ75pMywAkXT6L1XgUPTWs2DsrQf27SQ6/iocFdDyKjCmUhKSIZLWR4BhJdetC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBybrysXNWC0YLvj6ibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu5blitCLFOXmAvgtI/rpMYwu3cYh/V0/MdFVeD+fr8kZb1eFjUvdW4vt+PxshyWBy6VoDM8X38M2FIcBgne8BzgXprrqAP0rOdw3iSGe8H7G+NnEQ++5rtmHUe7wBwMMCQ0pTna Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=misterherr@freenet.de; spf=None smtp.mailfrom=misterherr@freenet.de; spf=None smtp.helo=postmaster@mout0.freenet.de Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of misterherr@freenet.de) identity=pra; client-ip=195.4.92.90; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="misterherr@freenet.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of misterherr@freenet.de) identity=mailfrom; client-ip=195.4.92.90; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="misterherr@freenet.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mout0.freenet.de) identity=helo; client-ip=195.4.92.90; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="misterherr@freenet.de"; x-sender="postmaster@mout0.freenet.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AIAABXYF9WnFpcBMNegw9+hB28ZCOFIUoCgVA8EAEBAQEBAQEBEAEBAQEBBg0JCSEugi2CCAEFI1URCwQUCQwKCwICCQMCAQIBRRMIAQGIFQEWAwEIrxOLYgmBMgGDYAEBAQcCASCLUYUaDYJQgUQFkneDagGFLIozhnkEk0w4glKBXoZgAQEB X-IPAS-Result: A0AIAABXYF9WnFpcBMNegw9+hB28ZCOFIUoCgVA8EAEBAQEBAQEBEAEBAQEBBg0JCSEugi2CCAEFI1URCwQUCQwKCwICCQMCAQIBRRMIAQGIFQEWAwEIrxOLYgmBMgGDYAEBAQcCASCLUYUaDYJQgUQFkneDagGFLIozhnkEk0w4glKBXoZgAQEB X-IronPort-AV: E=Sophos;i="5.20,374,1444687200"; d="scan'208,217";a="190155968" Received: from mout0.freenet.de ([195.4.92.90]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Dec 2015 22:24:43 +0100 Received: from [195.4.92.141] (helo=mjail1.freenet.de) by mout0.freenet.de with esmtpa (ID misterherr@freenet.de) (port 25) (Exim 4.85 #1) id 1a4EtG-0000ol-4I for caml-list@inria.fr; Wed, 02 Dec 2015 22:24:42 +0100 Received: from localhost ([::1]:54171 helo=mjail1.freenet.de) by mjail1.freenet.de with esmtpa (ID misterherr@freenet.de) (Exim 4.85 #1) id 1a4EtF-0002Ru-Om for caml-list@inria.fr; Wed, 02 Dec 2015 22:24:41 +0100 Received: from mx7.freenet.de ([195.4.92.17]:35962) by mjail1.freenet.de with esmtpa (ID misterherr@freenet.de) (Exim 4.85 #1) id 1a4EqY-0001PM-VB for caml-list@inria.fr; Wed, 02 Dec 2015 22:21:54 +0100 Received: from x5ce04983.dyn.telefonica.de ([92.224.73.131]:35132 helo=suse132-intel.home.loc) by mx7.freenet.de with esmtpsa (ID misterherr@freenet.de) (TLSv1.2:DHE-RSA-AES128-SHA:128) (port 465) (Exim 4.85 #1) id 1a4EqZ-0005nY-72 for caml-list@inria.fr; Wed, 02 Dec 2015 22:21:55 +0100 To: caml-list@inria.fr References: From: "Mr. Herr" X-Enigmail-Draft-Status: N1110 Message-ID: <565F60F2.8090600@freenet.de> Date: Wed, 2 Dec 2015 22:21:54 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------080109070306020409040404" X-Originated-At: 92.224.73.131!35132 Subject: Re: [Caml-list] Unary negation parsing This is a multi-part message in MIME format. --------------080109070306020409040404 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 02.12.2015 19:59, Stanislav Artemkin wrote: > Hi all, > > I've just stumbled upon yet another question about unary negation parsing > (http://stackoverflow.com/questions/34044873/passing-negative-integer-to-a-function-in-ocaml): > > let f x = x + 1 in > f -1 > > is not valid in OCaml. > > I'm just wondering why this issue is still not addressed in the parser? For > example, F# parses "f -1" as unary negation, but "f - 1" and "f-1" as binary > operator. It looks a bit tricky (as whitespace is taken into account), but feels so > natural when writing code. > > Is there any reason we can't have the same in OCaml? > > PS. I understand that it may break existing code, but it should be solvable by a > compiler option similar to -safe-string etc. > I think this is a non-issue, and it is easily explained to every beginner. And you say yourself: ... tricky .. whitespace ... may break existing code ... /Str. --------------080109070306020409040404 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On 02.12.2015 19:59, Stanislav Artemkin wrote:
Hi all,

I've just stumbled upon yet another question about unary negation parsing (http://stackoverflow.com/questions/34044873/passing-negative-integer-to-a-function-in-ocaml):

let f x = x + 1 in
f -1

is not valid in OCaml.

I'm just wondering why this issue is still not addressed in the parser? For example, F# parses "f -1" as unary negation, but "f - 1" and "f-1" as binary operator. It looks a bit tricky (as whitespace is taken into account), but feels so natural when writing code.

Is there any reason we can't have the same in OCaml?

PS. I understand that it may break existing code, but it should be solvable by a compiler option similar to -safe-string etc.

I think this is a non-issue, and it is easily explained to every beginner. And you say yourself: ... tricky .. whitespace ... may break existing code ...

/Str.


--------------080109070306020409040404--