caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Ceri Storey <cez@pkl.net>
To: Ryan Tarpine <rtarpine@hotmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Allowing many types
Date: Fri, 8 Feb 2002 16:37:00 +0000	[thread overview]
Message-ID: <20020208163700.GA1452@mandelbrot.house> (raw)
In-Reply-To: <F51Y3IMPWEAM9oQgGfJ00009180@hotmail.com>

On Thu, Feb 07, 2002 at 09:29:44PM -0500, Ryan Tarpine wrote:
> type Primitive =
> | PInt of int
> | PString of string
> | PFloat of float
>  ...

>  The problem is, I know that I will need new types in the future besides 
> these.  It's an object-oriented language, and I would like to add classes 
> that manage things like Tk.  Every object has a variable of type Primitive 
> that it stores its value in.  Is it possible to somehow allow other types, 
> like Tk's widgets, without changing the definition of Primitive to include 
> them and recompiling everything?

I've been trying to do something similar with something i'm writing, and
the only thing i could come up with is to store data in an object, and
then subclass it. The problem here is that once the object has been
coerced to the general type, it cannot be coerced back again. ie: if you
subclass the object to say, impliment integers, then it's not possible
for it to be coerced back to the integer type so you can retreive / act
on the value. (withoug using Obj.magic, that is)

If anyone has any good ideas, I'd be happy to hear about them too.
-- 
Ceri Storey <cez@pkl.net> http://pkl.net/~cez/
vi(1)! postfix(7)! pie(5)!
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


  reply	other threads:[~2002-02-08 16:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-08  2:29 Ryan Tarpine
2002-02-08 16:37 ` Ceri Storey [this message]
2002-02-08 16:53   ` Remi VANICAT
2002-02-10 17:42     ` Ceri Storey
2002-02-11  1:43 Ryan Tarpine
2002-02-11 10:53 ` Ceri Storey
2002-02-11 11:48   ` Remi VANICAT

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=20020208163700.GA1452@mandelbrot.house \
    --to=cez@pkl.net \
    --cc=caml-list@inria.fr \
    --cc=rtarpine@hotmail.com \
    /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).