caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Allowing many types
@ 2002-02-11  1:43 Ryan Tarpine
  2002-02-11 10:53 ` Ceri Storey
  0 siblings, 1 reply; 7+ messages in thread
From: Ryan Tarpine @ 2002-02-11  1:43 UTC (permalink / raw)
  To: caml-list

>polymorphic variant me be the answer, because you can get back the
>type :
>...

I'm probably missing something obvious, but how do you store a polymorphic 
variant in a field in a record?  Before, when I just used a normal variant 
type I called "primitive", all I did was
  type my_object = { object_data : primitive; (* etc. *) }

Is there a type that means "any polymorphic variant"?  Trying to set
  type primitive = [ `PTest ]
forces only `PTest to be the value of object_data.  How can I allow anything 
to be stored there?

Thanks,

Ryan Tarpine, rtarpine@hotmail.com
"To err is human, to compute divine.  Trust your computer but not its 
programmer."
  - Morris Kingston

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

-------------------
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


^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Caml-list] Allowing many types
@ 2002-02-08  2:29 Ryan Tarpine
  2002-02-08 16:37 ` Ceri Storey
  0 siblings, 1 reply; 7+ messages in thread
From: Ryan Tarpine @ 2002-02-08  2:29 UTC (permalink / raw)
  To: caml-list

  Recently, I've been playing with writing my own language.  With some good 
books, and inspiration from existing languages, it's not that hard, really, 
even for a beginner  :)  The only problem I've found is setting the possible 
data types, the so-called "primitives" of the language.  Currently, I have 
something like this:

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?

Thanks in advance,

Ryan Tarpine, rtarpine@hotmail.com
"To err is human, to compute divine.  Trust your computer but not its 
programmer."
  - Morris Kingston

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

-------------------
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


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

end of thread, other threads:[~2002-02-11 11:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-02-11  1:43 [Caml-list] Allowing many types Ryan Tarpine
2002-02-11 10:53 ` Ceri Storey
2002-02-11 11:48   ` Remi VANICAT
  -- strict thread matches above, loose matches on Subject: below --
2002-02-08  2:29 Ryan Tarpine
2002-02-08 16:37 ` Ceri Storey
2002-02-08 16:53   ` Remi VANICAT
2002-02-10 17:42     ` Ceri Storey

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).