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 6FB788239C for ; Thu, 15 Feb 2018 00:03:03 +0100 (CET) Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=murthy.chet@gmail.com; spf=Pass smtp.mailfrom=murthy.chet@gmail.com; spf=None smtp.helo=postmaster@mail-pg0-f51.google.com Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of murthy.chet@gmail.com) identity=pra; client-ip=74.125.83.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="murthy.chet@gmail.com"; x-sender="murthy.chet@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of murthy.chet@gmail.com designates 74.125.83.51 as permitted sender) identity=mailfrom; client-ip=74.125.83.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="murthy.chet@gmail.com"; x-sender="murthy.chet@gmail.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@mail-pg0-f51.google.com) identity=helo; client-ip=74.125.83.51; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="murthy.chet@gmail.com"; x-sender="postmaster@mail-pg0-f51.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3Apv7FNxD8f/Rn05j0+wfUUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSPT/rsbcNUDSrc9gkEXOFd2Cra4c0KyO6+jJYi8p2d65qncMcZhBBVcuqP?= =?us-ascii?q?49uEgeOvODElDxN/XwbiY3T4xoXV5h+GynYwAOQJ6tL1LdrWev4jEMBx7xKRR6?= =?us-ascii?q?JvjvGo7Vks+7y/2+94fcbglUijexe69+IAmrpgjNq8cahpdvJLwswRXTuHtIfO?= =?us-ascii?q?pWxWJsJV2Nmhv3+9m98p1+/SlOovwt78FPX7n0cKQ+VrxYES8pM3sp683xtBnM?= =?us-ascii?q?VhWA630BWWgLiBVIAgzF7BbnXpfttybxq+Rw1DWGMcDwULs5Qiqp4bt1RxD0iS?= =?us-ascii?q?cHLz85/3/Risxsl6JQvRatqwViz4LIfI2ZMfxzcaTAc9MHXmpBRtheWDBdAo2y?= =?us-ascii?q?aIsPCvAOPeder4Lgo1cDoh+zCQyqCejyyDFHm2X20LU43OQvEQ/I0g8uEc8Qvn?= =?us-ascii?q?vIt9j6LrseXPqvwaXU0TnObfVb0ir95ojSdRAhpOmBUKxwccXP1UkkCgTLjkiK?= =?us-ascii?q?qYz5PzOU1vkGvm+e7+p9T+Kvl24nqgFrrjezxscjlJXJi5kaylDB7yp5wYI1Kc?= =?us-ascii?q?ekR058ZN6pCZ1dvDyUOYtxR8MtWWBouCAix70Hv567ZikKx449yx7RcfyLa4iJ?= =?us-ascii?q?7QjjVOaWJjd0nm5qeLW6hxu07EOuyfX8W9G23VtFtCZJj8fAu3AX2xHQ5MWLUP?= =?us-ascii?q?tw8lqn1D2SzQ7c8PtELloxlafDK54u3Lowlp0LvETGBCD2mUH2gLaOdkUr5uSk?= =?us-ascii?q?8urnb7X7qpOGOI90jQb+MqsqmsOhG+g3Lg8OX22D9eS90r3s41H5Ta1Ig/A5iK?= =?us-ascii?q?XVrY7WKMQBqqO6DQJZyIYu5wunAzejytsYnH0HLFxfeBKAiojkI1TOIO3iDfej?= =?us-ascii?q?g1StkC1nyOzGPrL/HpXANXfDkLL7crZ8705Q0hY8zdda555MELEOPOrzWlPttN?= =?us-ascii?q?zfFhI2Lxa7w+PjCNlk0oMeWHmPArOCPaPJsV6I4/ovLPOWaI8Uvjb9Mfkl6OT0?= =?us-ascii?q?gX83g19ONZWuiLwTaW61BLxMKkOVbH6k1tAFEHkHpCIwTfbxlBuDV3tZamy2Xq?= =?us-ascii?q?R66jxtW6y8CoKWbYCgnPSkwT2nHoweMmVbEEyMADHjd4iYc/gJYSOWZMRml2pX?= =?us-ascii?q?BvCaV4Y92ET250fBwL19I7+Rp3RB5MDTkeNt7uiWrikcsDl9DsCTyWaIFjgmkW?= =?us-ascii?q?YBRjtw16d68xUklgWzlJNgivkdLuR9outTW15jZ5HZxu1+Tdv1X1CZJ4rbeBOd?= =?us-ascii?q?WtyjRAoJYJcxztsJORsvHtyjilXb0HLvDeJM0bOMA5Mw/+TX2H2jf8s=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0DDBACav4RahjNTfUpdHAEBAQQBAQoBA?= =?us-ascii?q?YN5AT5wKAqDW4E5lm+CAoEXgVCBGoYNh3CHcwojhRgCgnYHGQcENBQBAgEBAQE?= =?us-ascii?q?BAQEBARIBAQEICwsIKC+COCSCSAEEASMEGQEbEgsBAwwGBQQHGh0CAiIBEQEFA?= =?us-ascii?q?QoSBhMSigoBAw0IEKMrQIwXgW0YBQEcgwwFg20KGScDCllZghMBAQEBAQEBAQI?= =?us-ascii?q?BAQEBAQEBAQEXAgYShHCCFYY3NoMkgiuCaoJlAQSIdgyKYpBLCYgghAiJXXeCD?= =?us-ascii?q?5E/jgKKAxQFIIEXDyeBcjMaI1IyghQJghMqH4IzIDeOAgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0DDBACav4RahjNTfUpdHAEBAQQBAQoBAYN5AT5wKAqDW4E?= =?us-ascii?q?5lm+CAoEXgVCBGoYNh3CHcwojhRgCgnYHGQcENBQBAgEBAQEBAQEBARIBAQEIC?= =?us-ascii?q?wsIKC+COCSCSAEEASMEGQEbEgsBAwwGBQQHGh0CAiIBEQEFAQoSBhMSigoBAw0?= =?us-ascii?q?IEKMrQIwXgW0YBQEcgwwFg20KGScDCllZghMBAQEBAQEBAQIBAQEBAQEBAQEXA?= =?us-ascii?q?gYShHCCFYY3NoMkgiuCaoJlAQSIdgyKYpBLCYgghAiJXXeCD5E/jgKKAxQFIIE?= =?us-ascii?q?XDyeBcjMaI1IyghQJghMqH4IzIDeOAgEBAQ?= X-IronPort-AV: E=Sophos;i="5.46,514,1511823600"; d="scan'208,217";a="313629877" Received: from mail-pg0-f51.google.com ([74.125.83.51]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 15 Feb 2018 00:03:02 +0100 Received: by mail-pg0-f51.google.com with SMTP id a11so2748092pgu.13 for ; Wed, 14 Feb 2018 15:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=UsOPW0+gH3UtrCyGJZ1fKKIpfbnbb93+c8KZD/WLKis=; b=cFLiMAE0uvO+Rm0MCxd7GnYT41zFS52p4DCv0Wn9x4slmOlYQuBVQkUgJN2SsjEfsQ tnb1Q3/4cDRhPYBqoJ23ihkx8JKZZmkzA02ztfXwh8yCqwOKiJ9EdBmJDNyk5dT/qTU6 EX+qG9qA7O7reXfsS19qz9gBKh6aWu0F4hRIzkct/GOxY4GKzN+WnlVBPFbMYi97Au0n NB3fMOTnyVzwKGv4ZRw43QY/56XYaCANSoBr//IqxDguavkvWgweszy1fMMaFUPlEnb3 K9hhKlKi6zkktN5VhD1873417cEIjEFlhZ8VAPc3HeX/ly5elIkXyltdiCLt2WenRyDC rxHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=UsOPW0+gH3UtrCyGJZ1fKKIpfbnbb93+c8KZD/WLKis=; b=AwiG9lyGswcKRFXQ179cTAqD6WaXPCsycW4xb0T9o1Ymc3jdOIGWCtZN0sdA61Zo06 m5CDNrO4xheu4DJva/LMfwaIvHyal6o9zXoNEA6pob826VG3yW+Oghfbuti1Oi6ovnSh xNv4bEi34yDEqNWIGjLZEAgOcpStwrW0SCRq6j9VDL/+QVWJfda3m7GUBNs+vlHIADCg YUOvY8ngtBt/0PtFsjGWilO18A0rBTeeFKNsY5W46ZvcwRTdY4Pt+WiUNoZhL6DcPy8a iV7WkjAWfH0sa4q8LKOnIGOpZrEeDJU4vSAjE5FqCcTay5Eq/QIINcka3fF/L7sh5nzk PRbg== X-Gm-Message-State: APf1xPDR6U9iN1ZkjrGYOlkBrKP/Y0F5Gjc6A7n/pGRL9bsRQBGFWrCf vnW9vQvPVmawxUIke/KbnoWKRBlO3JznLaCQzUQ= X-Google-Smtp-Source: AH8x227OmjYXM7+710fXIvGFTXN5OqTC+OnkgVxX/3H1o7H+ZWY2PBMU28nD1i4PQFRO1wl0OfMdDgOwgDh/EBukgEo= X-Received: by 10.98.232.24 with SMTP id c24mr595292pfi.227.1518649380480; Wed, 14 Feb 2018 15:03:00 -0800 (PST) MIME-Version: 1.0 Received: by 10.100.133.136 with HTTP; Wed, 14 Feb 2018 15:02:59 -0800 (PST) In-Reply-To: <20180214195046.Horde.mSIwdxq5Yo9xUKgfzIss4Ey@webmail.in-berlin.de> References: <21BC6EDE-DB27-460B-A4D5-BBD583C9E899@TimLeonard.us> <20180214195046.Horde.mSIwdxq5Yo9xUKgfzIss4Ey@webmail.in-berlin.de> From: Chet Murthy Date: Wed, 14 Feb 2018 15:02:59 -0800 Message-ID: To: Oliver Bandel Cc: caml-list Content-Type: multipart/alternative; boundary="f4f5e80653c0dcaa5d0565341c9d" Subject: Re: [Caml-list] a question about syntax --f4f5e80653c0dcaa5d0565341c9d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I remember back in the day Pierre Weis explaining to me that this syntactic trade-off was made in order to allow that "let" and "match" didn't have ending key-words (e.g. "end"). Unlike in SML/NJ. --chet-- On Wed, Feb 14, 2018 at 10:50 AM, Oliver Bandel wrote: > > Zitat von Tim Leonard (Tue, 13 Feb 2018 22:31:14 > -0500) > > A simple question of syntax: why does the first definition of function f >> cause a syntax error? >> Shouldn=E2=80=99t the semicolon syntactically terminate the match expres= sion? >> > > No. > You can use semicolon to put more then one expression together. > So the "field2 =3D 2" is seen as part of the match. > > If you have a pattern matching, this way you can put multiple > commands/expressions in a row, > without the need to use begin/end or ( ) in any match-case. > It's the other way around: you need to put begin/end or ( ) around a > match-statement. > > This way you have to add one such enclosing around a match-statement, > instead of one such enclosing in any match-case of such a statement. > > > >> type my_record =3D { field1 : bool; field2 : int };; >> >> let f x =3D { field1 =3D match x with _ -> true ; field2 =3D 2 };; (*= this >> fails *) >> > > Here I get "Error: Unbound value field2", > which is, because the match-case reaches until the }. > > > > >> let f x =3D { field1 =3D ( match x with _ -> true ); field2 =3D 2 };; (*= this >> is ok *) >> > > Here it works, because the match-statement is sorrounded / enclosed by ( > and ). > > Ciao, > Oliver > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > --f4f5e80653c0dcaa5d0565341c9d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I remember back in the day Pierre Weis explaining to me th= at this syntactic trade-off was made in order to allow that
"let&q= uot; and "match" didn't have ending key-words (e.g. "end= ").=C2=A0 Unlike in SML/NJ.

--chet--


On Wed, Feb 14, 2018 at 10:50 AM, Oliver Bandel <oliver@first.in-= berlin.de> wrote:

Zitat von Tim Leonard <Tim@timleonard.us> (Tue, 13 Feb 2018 22:31:14 -0500)

A simple question of syntax: why does the first definition of function f ca= use a syntax error?
Shouldn=E2=80=99t the semicolon syntactically terminate the match expressio= n?

No.
You can use semicolon to put more then one expression together.
So the "field2 =3D 2" is seen as part of the match.

If you have a pattern matching, this way you can put multiple commands/expr= essions in a row,
without the need to use begin/end or ( ) in any match-case.
It's the other way around: you need to put begin/end or ( ) around a ma= tch-statement.

This way you have to add one such enclosing around a match-statement,
instead of one such enclosing in any match-case of such a statement.



type my_record =3D { field1 : bool; field2 : int };;

let f x =3D { field1 =3D=C2=A0 =C2=A0match x with _ -> true=C2=A0 ; fiel= d2 =3D 2 };; (* this fails *)

Here I get "Error: Unbound value field2",
which is, because the match-case reaches until the }.




let f x =3D { field1 =3D ( match x with _ -> true ); field2 =3D 2 };; (*= this is ok *)

Here it works, because the match-statement is sorrounded / enclosed by ( an= d ).

Ciao,
=C2=A0 Oliver



--
Caml-list mailing list.=C2=A0 Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

--f4f5e80653c0dcaa5d0565341c9d--