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 8C5F97EEEF for ; Mon, 22 Jun 2015 20:18:26 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of stevez@cis.upenn.edu) identity=pra; client-ip=158.130.67.106; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stevez@cis.upenn.edu"; x-sender="stevez@cis.upenn.edu"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of stevez@cis.upenn.edu designates 158.130.67.106 as permitted sender) identity=mailfrom; client-ip=158.130.67.106; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stevez@cis.upenn.edu"; x-sender="stevez@cis.upenn.edu"; 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@talbot.seas.upenn.edu) identity=helo; client-ip=158.130.67.106; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="stevez@cis.upenn.edu"; x-sender="postmaster@talbot.seas.upenn.edu"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AMAQA5UIhVnGpDgp5cFoNOX793hXwCggcBAQEBAQESAQEBAQEICwkJIS6EIwEBBDhAEQsYCRYPCQMCAQIBRRMIAQEXiBTFdoUTAQEIAiCLRYRTOhaEFQEEk32ccIcPhDtUgkcBAQE X-IPAS-Result: A0AMAQA5UIhVnGpDgp5cFoNOX793hXwCggcBAQEBAQESAQEBAQEICwkJIS6EIwEBBDhAEQsYCRYPCQMCAQIBRRMIAQEXiBTFdoUTAQEIAiCLRYRTOhaEFQEEk32ccIcPhDtUgkcBAQE X-IronPort-AV: E=Sophos;i="5.13,660,1427752800"; d="scan'208";a="166701293" Received: from coyote.seas.upenn.edu (HELO talbot.seas.upenn.edu) ([158.130.67.106]) by mail2-smtp-roc.national.inria.fr with ESMTP; 22 Jun 2015 20:18:25 +0200 Received: from 31-35-154.wireless.csail.mit.edu (31-35-154.wireless.csail.mit.edu [128.31.35.154]) (authenticated bits=0) by talbot.seas.upenn.edu (8.14.5/8.14.5) with ESMTP id t5MIIOWX016360 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Mon, 22 Jun 2015 14:18:24 -0400 Message-ID: <55885170.9070501@cis.upenn.edu> Date: Mon, 22 Jun 2015 14:18:24 -0400 From: Steve Zdancewic User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: caml-list@inria.fr References: <1434982765.31996.19.camel@e130.lan.sumadev.de> <20150622160712.GF5472@xinutec.org> In-Reply-To: <20150622160712.GF5472@xinutec.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=5400 definitions=5800 signatures=585085 X-PP-Spam-Details: rule=add_spam_details policy=default score=0 spamscore=0 ipscore=0 suspectscore=1 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=7.0.1-1111160001 definitions=main-1506220306 Subject: Re: [Caml-list] use of ";;" when teaching Ocaml At Penn we use a slightly different idiom: at the top level all "commands" should be _prefixed_ by ;;. We don't think of ;; as terminating a declaration, instead we think of it as preceding a stateful operation. This has the nice property of marking effectful code syntactically in the program, and students don't seem to mind. Some examples would be: ;; open Foo let f x = let y = x ^ x in y ^ y ;; print_string f "x" let g x = ... let test () = assert_eq (g 3) 7 ;; run_test "testing g" test let main () = ... ;; main () --Steve Steve Zdancewic Professor, Dept. of Computer and Information Science University of Pennsylvania http://www.cis.upenn.edu/~stevez On 6/22/15 12:07 PM, Pippijn van Steenhoven wrote: > On Mon, Jun 22, 2015 at 11:48:21AM -0400, Damien Doligez wrote: >> Gerd has totally nailed it, and that's the reason why I always use ;; >> in my code. >> If we had another keyword for toplevel let (let without in) the >> situation would be quite different. > I have a rule (which I introduced recently, and thus don't yet follow > much in my code) to use ;; to terminate all unit-returning (therefore > effectful) functions. Pure functions or effectful functions with a proper > return value never have the trailing-semicolon issue. An alternative > solution is to always return () from unit-returning functions, but I > found ;; more appealing.