From: Steve Zdancewic <stevez@cis.upenn.edu>
To: caml-list@inria.fr
Subject: Re: [Caml-list] use of ";;" when teaching Ocaml
Date: Mon, 22 Jun 2015 14:18:24 -0400 [thread overview]
Message-ID: <55885170.9070501@cis.upenn.edu> (raw)
In-Reply-To: <20150622160712.GF5472@xinutec.org>
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.
next prev parent reply other threads:[~2015-06-22 18:18 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-22 13:31 Alan Schmitt
2015-06-22 13:52 ` Ivan Gotovchits
2015-06-22 13:53 ` Daniil Baturin
2015-06-22 14:19 ` Gerd Stolpmann
2015-06-22 15:48 ` Damien Doligez
2015-06-22 15:56 ` Thomas Refis
2015-06-22 16:07 ` Mark Shinwell
2015-06-22 16:30 ` Gerd Stolpmann
2015-06-22 16:47 ` Mark Shinwell
2015-06-22 17:08 ` Daniel Bünzli
2015-06-22 18:56 ` Gerd Stolpmann
2015-06-22 17:18 ` Török Edwin
2015-06-22 17:42 ` Francois Berenger
2015-06-22 17:46 ` Ivan Gotovchits
2015-06-22 17:53 ` John Whitington
2015-06-22 16:07 ` Pippijn van Steenhoven
2015-06-22 16:25 ` Daniel Bünzli
2015-06-22 18:18 ` Steve Zdancewic [this message]
2015-06-22 16:42 ` Thomas Refis
2015-06-22 16:47 ` David House
2015-06-22 17:08 ` Daniil Baturin
2015-06-22 17:04 ` Daniel Bünzli
2015-06-22 23:41 ` Philippe Wang
2015-06-23 1:15 ` Kenichi Asai
2015-06-23 13:27 ` Alan Schmitt
2015-06-23 13:35 ` Ivan Gotovchits
2015-06-23 13:36 ` Ivan Gotovchits
2015-06-25 16:51 ` Philippe Wang
2015-06-29 0:12 ` Philippe Wang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55885170.9070501@cis.upenn.edu \
--to=stevez@cis.upenn.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox