From: pbrisset@eis.enac.dgac.fr
To: John Gerard Malecki <johnm@vlibs.com>
Cc: caml-list@pauillac.inria.fr
Subject: Label Names Space - philosophy or implementation?
Date: Wed, 24 Jul 1996 09:37:56 +0200 [thread overview]
Message-ID: <199607240738.JAA05990@concorde.inria.fr> (raw)
In-Reply-To: <199607230040.RAA11401@owl.vlibs.com>
John Gerard Malecki writes:
>
> A co-worker has (vehemently) pointed out to me that record label names
> cannot be shared. For example, the following fails
>
> type foo = { name : string; x : int }
> let a = { name = "foo"; x = 1 }
>
> type bar = { name : string; y : float }
> let b = { name = "bar"; y = 9. }
> ...
> field with a standardized label. This makes it easier for him to
> write printers for his data-structure. Does anyone have a
> recommendation to make to him?
type 'a foobar = { name : string; x : 'a}
let print_name {name = s} = print_string s
print_name { name = "foo"; x = 1 }
print_name { name = "bar"; x = 9. }
or using classes and inheritance (I do not like it but ...) :
class named (s:string) =
val private name = s
method name = name
end
class foo n (x:int) =
inherit named n
val private x = x
method x = x
end
class bar n (y:float) =
inherit named n
val private y = y
method y = y
end
let print_name x = print_string x#name
print_name (new foo "foo" 1)
print_name (new bar "bar" 9.)
My 0.02 euros...
--Pascal
next prev parent reply other threads:[~1996-07-24 8:10 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-07-23 0:40 John Gerard Malecki
1996-07-23 11:36 ` Pierre Weis
1996-07-24 7:37 ` pbrisset [this message]
1996-07-24 9:40 ` Xavier Leroy
1996-07-23 18:13 Andrew Conway
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=199607240738.JAA05990@concorde.inria.fr \
--to=pbrisset@eis.enac.dgac.fr \
--cc=caml-list@pauillac.inria.fr \
--cc=johnm@vlibs.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