caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: caml-list@inria.fr (OCAML)
Subject: Polymorphic variants for basic types?
Date: Sat, 15 Jan 2000 20:06:30 +0100 (MET)	[thread overview]
Message-ID: <200001151906.UAA05127@miss.wu-wien.ac.at> (raw)

Hello,

this idea has probably already been considered: what do you think about
translating basic values prefixed by "`" to polymorphic variants
automatically during compilation?

E.g.

  match foo with                        match foo with
  | `"Some string" -> ...        to     | `String "Some string" -> ...
  | `42 ->                              | `Int 42 -> ... 
  | `[x; y; z] ->                       | `List [x; y; z] -> ...
  ...
  
As far as I can see, this would not be a difficult thing to do, because it
only seems to require syntactic information. Probably even the preprocessor
could be used for this.

Some nice things would be possible then, like the one above or conveniently
writing down complex datastructures (e.g. trees with arbitrary numbers of
subnodes):

  let tree = `[ `3; `[`4; `5]; `[ `[`6] ] ] in ...

which is probably much easier to write than:

  let tree =
    `List [ `Int 3;
            `List [`Int 4; `Int 5];
            `List [ `List [`Int 6] ] ] in ...

Anyway, this is just a small feature suggestion - I am sure there are more
important language properties at the moment to reason about.

Regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




                 reply	other threads:[~2000-01-16 21:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=200001151906.UAA05127@miss.wu-wien.ac.at \
    --to=mottl@miss.wu-wien.ac.at \
    --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;
as well as URLs for NNTP newsgroup(s).