caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Newbie comment on constructor syntax
@ 2015-11-06  9:33 Soegtrop, Michael
  2015-11-06 10:04 ` Nicolas Ojeda Bar
                   ` (3 more replies)
  0 siblings, 4 replies; 47+ messages in thread
From: Soegtrop, Michael @ 2015-11-06  9:33 UTC (permalink / raw)
  To: caml-list

Dear Ocaml users,

I just started to develop in OCaml, and must say it is smoother than expected. Although I did C/C++ for decades, I do less errors in Ocaml, both syntactically and in terms of if programs behave as expected. It appears to be much closer to human thinking than C/C++ and I already wonder how I could live without currying and type inference before.

The one thing I find rather non intuitive is that variant constructors can take only one argument - or a tuple. Although I know it is wrong, I always write "Constr a b" instead of "Constr (a, b)". I know syntax is only a minor thing and mostly a matter of taste, but a large fraction of my syntax errors in new code are of this kind (when modifying code it is a bit different). Somehow I think this doesn't go together well with the function call syntax of OCaml. I guess deep in my brain a constructor is a function which takes arguments and returns an element of the type it constructs, so I guess I want to use the usual function call syntax.

My question: Is there some syntax to give a constructor more than one argument which escaped me? Something like if I leave away the * in the definition I can use usual function call syntax in constructions and expressions? I would find this easier to read and to write, especially in matches or nested constructs. Does everybody use camlp4/p5/ppx to customize the syntax to his liking (as chapter 5 of the camlp4 manual suggests)? Or are there some long term advantages of this syntax I don't see as yet?

Best regards,

Michael

Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


^ permalink raw reply	[flat|nested] 47+ messages in thread

end of thread, other threads:[~2015-11-21 18:56 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-06  9:33 [Caml-list] Newbie comment on constructor syntax Soegtrop, Michael
2015-11-06 10:04 ` Nicolas Ojeda Bar
2015-11-06 10:31 ` Francois Berenger
2015-11-06 12:20   ` Soegtrop, Michael
2015-11-06 12:34     ` Gabriel Scherer
2015-11-06 13:09       ` Soegtrop, Michael
2015-11-06 14:10         ` Ashish Agarwal
2015-11-06 15:19           ` Soegtrop, Michael
2015-11-06 15:21             ` Ashish Agarwal
2015-11-21 17:24       ` [Caml-list] Notation for currying Hendrik Boom
2015-11-21 17:41         ` Gabriel Scherer
2015-11-21 18:05         ` David Rajchenbach-Teller
2015-11-21 18:55           ` Gabriel Scherer
2015-11-06 12:29 ` [Caml-list] Newbie comment on constructor syntax Jonas Jensen
2015-11-06 12:46   ` Soegtrop, Michael
2015-11-06 12:54     ` Gabriel Scherer
2015-11-08 21:16 ` Florian Weimer
2015-11-08 22:50   ` Norman Hardy
2015-11-09  6:27     ` Florian Weimer
2015-11-09 13:27       ` Stefan Monnier
2015-11-09  8:09     ` Soegtrop, Michael
2015-11-09 10:00       ` Hendrik Boom
2015-11-09 10:16       ` Alain Frisch
2015-11-09 10:35         ` Andreas Rossberg
2015-11-09 12:28           ` Alain Frisch
2015-11-09 17:33           ` Alain Frisch
2015-11-09 18:08             ` Gabriel Scherer
2015-11-09 18:16               ` Andreas Rossberg
2015-11-09 21:11                 ` Gabriel Scherer
2015-11-09 22:06                   ` Alain Frisch
2015-11-09 22:27                   ` Andreas Rossberg
2015-11-09 22:57                     ` Jeremy Yallop
2015-11-10  0:11                   ` Hendrik Boom
2015-11-10  8:27                   ` Soegtrop, Michael
2015-11-10 10:25                     ` Romain Bardou
2015-11-10 10:44                       ` Alain Frisch
2015-11-10 10:55                         ` Romain Bardou
2015-11-10 13:17                           ` Alain Frisch
2015-11-10 13:41                             ` Romain Bardou
2015-11-10 14:01                               ` Alain Frisch
2015-11-13 15:36                           ` Romain Bardou
2015-11-10 11:17                         ` Soegtrop, Michael
2015-11-10 14:11                     ` Hendrik Boom
2015-11-10 14:40                       ` immanuel litzroth
2015-11-10 15:30                       ` Soegtrop, Michael
2015-11-10 17:27                         ` Gerd Stolpmann
2015-11-09 20:32               ` Alain Frisch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).