[toronto-lisp] OCaml

Abram Hindle abram.hindle at softwareprocess.es
Fri Jan 14 01:04:07 UTC 2011

On 01/13/2011 04:23 PM, D. J. Penton wrote:

> Michael: You have hit the nail right on the head. Basically my
> complaint is about syntax, and perhaps also about too many features
> (not sure on the features issue). The syntax seems ad hoc and a
> little cryptic. Perhaps it is no coincidence that I have also always
> disliked C++.

The let syntax is mathetmatical. You're supposed to read it out.

So if I say let x be a value in the set I convert that into ocaml:

let x = choose set in

so let x equal a value IN

then the rest follows.

So what I recommend about syntax is avoid semi colons.

> I will admit that once I am past the worst part of the learning curve
> I'll probably wonder why I ever griped about OCaml. Who knows, maybe
> it will become my favourite language some day. And I really do accept
> that arguing about the merits of programming languages is like
> arguing about whether asparagus tastes good or not: it's largely a
> subjective judgment.
> But for now I am annoyed to be back in the position of looking at
> some syntactic construct in OCaml and asking myself "what the hell is
> this meant to do?" My irritation is probably amplified by having
> tackled Lisp and Scheme over the past year and a half. I adore these
> latter languages because there is so little syntactic stuff to wade
> through. Unless someone has gone berserk with bizarre macros, I spend
> very little time mentally unravelling the syntax of CL when I try to
> understand some code. Scheme and CL allow me to jump right to being
> baffled at level much deeper than the syntax!

Another problem with ML is that the module structure is pretty hairy. It
works great but it takes a while to really get it.

> As I suggested in my original post, some of my problems are the
> result of using a poorly written (IMHO) book. I grabbed a better one
> today. Maybe it will help me see the OCaml light at the end of the
> tunnel.

OCaml has bad syntax, but what it does have is great static typing,
pattern matching and performance.

So if you have a problem in OCaml and it doesn't make sense, add more
types! Type inference is your friend!

An example is mixing indices (ints), identifiers (ints), and counts (ints).

If you made 3 seperate types:

type index = Index of int
type ident = Identifier of int
type count = Count of int

Then when you type check you won't mistake an Index for an Identifier
and you won't mistake a Count for an int.

I've run into this with data versus frequency count.

type data = Data of int array
type freq = Freq of int array

It is very easy to confuse two arrays of integers, until they have
different types :)

Basically you'll like ocaml if you have to write parse trees. It's great
for trees :)


> End of rant.
> - Dave - _______________________________________________ toronto-lisp
> mailing list toronto-lisp at common-lisp.net 
> http://common-lisp.net/cgi-bin/mailman/listinfo/toronto-lisp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <https://mailman.common-lisp.net/pipermail/toronto-lisp/attachments/20110113/2e4cdc4f/attachment.sig>

More information about the toronto-lisp mailing list