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 8005A7EE34 for ; Fri, 18 Mar 2016 19:52:50 +0100 (CET) IronPort-PHdr: 9a23:BgOrmhFjaqChjZtGJbW4B51GYnF86YWxBRYc798ds5kLTJ75o8WwAkXT6L1XgUPTWs2DsrQf27qQ6/6rAD1IyK3CmU5BWaQEbwUCh8QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4Ov7yUtaLyZ/nh6bqpdaKMk1hv3mUX/BbFF2OtwLft80b08NJC50a7V/3mEZOYPlc3mhyJFiezF7W78a0+4N/oWwL46pyv50IbaKvdK09SflcDS86G2Ez/szi8xfZHiWV4X5JeWUMkwFUBBDF2zFkUZrr+n/xtvB8wzWdJc2wTbc5Vjm4x7t2DRXlkiMGMXg1/TeE2YRLkKtHrUf59FREyInObdTNOQ== Authentication-Results: mail2-smtp-roc.national.inria.fr; spf=None smtp.pra=christoph.hoeger@tu-berlin.de; spf=None smtp.mailfrom=christoph.hoeger@tu-berlin.de; spf=None smtp.helo=postmaster@mail.tu-berlin.de Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=pra; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of christoph.hoeger@tu-berlin.de) identity=mailfrom; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="christoph.hoeger@tu-berlin.de"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.tu-berlin.de) identity=helo; client-ip=130.149.7.33; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="christoph.hoeger@tu-berlin.de"; x-sender="postmaster@mail.tu-berlin.de"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AmAQCtTexWkyEHlYJehQm8GYYNAoEwOxEBAQEBAQEBARABAQEBCQsJCSEvgi2CFQEBBCMPATkKAhELGgIFFgsCAgkDAgECAUUTBgIBAYgjBLE2j0UBKXyJZoUIgjSCVgWXV4hjjlCFWI8GNoIvEQiBSmmKYwEBAQ X-IPAS-Result: A0AmAQCtTexWkyEHlYJehQm8GYYNAoEwOxEBAQEBAQEBARABAQEBCQsJCSEvgi2CFQEBBCMPATkKAhELGgIFFgsCAgkDAgECAUUTBgIBAYgjBLE2j0UBKXyJZoUIgjSCVgWXV4hjjlCFWI8GNoIvEQiBSmmKYwEBAQ X-IronPort-AV: E=Sophos;i="5.24,356,1454972400"; d="scan'208";a="208690157" Received: from mail.tu-berlin.de ([130.149.7.33]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Mar 2016 19:52:49 +0100 X-tubIT-Incoming-IP: 91.65.203.239 Received: from ip5b41cbef.dynamic.kabel-deutschland.de ([91.65.203.239] helo=[192.168.178.42]) by mail.tu-berlin.de (exim-4.76/mailfrontend-7) with esmtpsa [UNKNOWN:AES128-SHA:128] for id 1agzVw-0000ls-0N; Fri, 18 Mar 2016 19:52:49 +0100 To: caml-list@inria.fr References: <56EC4318.2020701@freenet.de> From: =?UTF-8?Q?Christoph_H=c3=b6ger?= Organization: =?UTF-8?Q?Technische_Universit=c3=a4t_Berlin?= Message-ID: <56EC4E7F.8060602@tu-berlin.de> Date: Fri, 18 Mar 2016 19:52:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56EC4318.2020701@freenet.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2016.3.18.184815 X-PMX-Spam: Gauge=IIIIIII, Probability=0%, Report='' Subject: Re: [Caml-list] what does let () = ... define? It defines a match-expression with a single case, that is why you get the warning on None. In case of let () = ..., everything is fine, since unit has exactly one constructor (that is, how unit is defined, btw.). You could also have written let my_unit = ..., but since my_unit = () (even == (), I think), you do not gain anything from this variable (and hopefully the compiler gets rid of it). In order to provide more readable and safe code, you should thus use the ()-syntax (since now everyone, including the typechecker sees that the rhs is intended to yield unit). The same holds for records, tuples etc. think of it as a shallow and cheap type annotation. regards, Christoph Am 18.03.2016 um 19:04 schrieb Mr. Herr: > Hi, > > in a small presentation of OCaml (Linux User Group Bremen) I got some > interesting questions, and > trying to answer I noticed I took something for granted that was not > fully understood. > > Looking at this in the toplevel: > > # let () = () ;; > # () ;; > - : unit = () > # let _ = () ;; > - : unit = () > # let None = None;; > Warning 8: this pattern-matching is not exhaustive. > Here is an example of a value that is not matched: > Some _ > # > > ... the question is: okay, pattern matching left of the equal sign, but > what does it define? > It defines unit and None in the environment, and then that value is just > sitting there? > > /Str. -- Christoph Höger Technische Universität Berlin Fakultät IV - Elektrotechnik und Informatik Übersetzerbau und Programmiersprachen Sekr. TEL12-2, Ernst-Reuter-Platz 7, 10587 Berlin Tel.: +49 (30) 314-24890 E-Mail: christoph.hoeger@tu-berlin.de