From: Markus Mottl <mottl@miss.wu-wien.ac.at>
To: Frank Atanassow <franka@cs.uu.nl>
Cc: John Gerard Malecki <johnm@artisan.com>, OCAML <caml-list@inria.fr>
Subject: Re: [newbie] Define and use records in sum types
Date: Sat, 22 Jul 2000 20:31:17 +0200 [thread overview]
Message-ID: <20000722203116.A8157@miss.wu-wien.ac.at> (raw)
In-Reply-To: <14713.41688.558933.239829@silvester.cs.uu.nl>; from franka@cs.uu.nl on Sat, Jul 22, 2000 at 15:34:16 +0200
On Sat, 22 Jul 2000, Frank Atanassow wrote:
> > But how about "capturing logical invariants"? You need both ways of
> > information hiding there: restricting the number of exported functions
> > *and* restricting their types! Otherwise there could be ways to destroy the
> > invariant.
>
> Can you be more specific about "capturing logical invariants"? I don't know
> quite what you mean.
If you have axioms that specify invariant properties about the types and
functions in question. E.g. that removing an element from a set results
in a set that does not contain it and that this is true for all sets.
Exporting auxiliary functions from the module might allow the programmer
to violate this condition. The same is true for not restricting the types
of the functions. Therefore, you need both means of information hiding to
guarantee correctness (i.e. the properties in question).
> An instance I can think of where access to names could have semantic
> significance is if it has to do with generativity. I hate generativity with a
> passion, but eliminating it from ML modules would require a wholesale revision
> of the module system, which it is not my object to propose here. So, I will
> concede that generativity may cause name access to acquire semantic
> significance. (But I hope you agree that it is at least desirable that names
> and namespaces should have no semantic significance whatsoever.)
I guess you mean that it is only the structure of the module that counts
and not the naming? But how about ambiguities then? You need a way to
refer to the right function, whatever, if it has the same signature as
another one.
> > I'd rather use different namings like "r1_name" and "r2_name" for the
> > field: although this requires me to always include the name of the type,
> > one cannot get confused either: it makes the sources easier to understand.
>
> I don't find that argument very convincing; Ocaml _already_ allows type, value
> and field label definitions to shadow each other, which many people consider a
> cognitive burden. I don't have an opinion on that issue; I'm just trying to be
> consistent with the way Ocaml treats bindings currently, and add a little bit
> more flexibility.
There's not much you can do about shadowing of value bindings unless you
prohibit it which would cause other problems: you'd have to invent a new
name each time even if you just want to "transform" a value using the same
name - this could cause horror if you wanted to add such a transformation
in the middle of a function body...
What concerns type names: I guess this is a consequence of having
an "open"-statement for modules, which shadows previous type
declarations. Otherwise, forbidding it would probably be a good idea
since its scope is the whole module from the point of definition.
Now, accessing fields more flexibly is surely possible. The question is
whether adding this feature is really of so much help: the only case
where it pays off is when you have large records which share a great
deal of names. Then it might be a bit more convenient to have an initial
declaration that tells the compiler what kind of record you are talking
about instead of inventing new names for records. A rather statistical
question...
> In fact, I don't see how this makes programs any less readable.
It adds another construct that people have to learn. Reading constructs
that you are not familiar with is confusing. I bet that there are plenty
of people who do not even know about the "with"-construct for records...
> If you don't add this mechanism, then the rule remains, "an identifier X
> refers to the last definition of X in scope".
Yes.
> If you do add this mechanism, then that doesn't change (since the identifier
> [path] "t.x" is still distinct from "x").
Right. But you have to invent additional syntax for doing this. Even
though it seems to be a rather marginal addition, it also adds to making
the language more complex. I haven't felt the need for it so far, but
if other people have other requirements, they are free to ask for it...
Regards,
Markus Mottl
--
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl
next prev parent reply other threads:[~2000-07-22 22:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-11 11:32 David Mentré
2000-07-17 10:01 ` Markus Mottl
[not found] ` <14709.63462.792269.194367@ish.artisan.com>
2000-07-19 20:10 ` Markus Mottl
2000-07-21 12:23 ` Frank Atanassow
2000-07-21 20:00 ` Markus Mottl
2000-07-22 13:34 ` Frank Atanassow
2000-07-22 18:31 ` Markus Mottl [this message]
2000-07-23 13:55 ` Frank Atanassow
2000-07-23 15:20 ` Markus Mottl
2000-07-24 9:28 ` Frank Atanassow
2000-07-25 5:26 ` Alan Schmitt
2000-07-19 19:21 ` Jean-Christophe Filliatre
2000-07-20 7:08 ` David Mentré
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=20000722203116.A8157@miss.wu-wien.ac.at \
--to=mottl@miss.wu-wien.ac.at \
--cc=caml-list@inria.fr \
--cc=franka@cs.uu.nl \
--cc=johnm@artisan.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