From: Don Syme <dsyme@microsoft.com>
To: "'John Max Skaller'" <skaller@maxtal.com.au>
Cc: "'caml-list@inria.fr'" <caml-list@inria.fr>
Subject: RE: additions to standard library?
Date: Tue, 21 Mar 2000 13:43:18 -0800 [thread overview]
Message-ID: <39ADCF833E74D111A2D700805F1951EF1801452B@RED-MSG-06> (raw)
> > I've often wondered why languages don't support "extensions" to library
> > namespaces (and perhaps even to functors). e.g. one could define
> >
> > let String.explode s = ....
> > let String.implode s = ...
> > let myfun = ...
>
> The reason is that it is hard to localise these changes.
> It isn't acceptable to extend the actual module, since two clients
> could provide conflicting "extensions". This would break the
> Open/Closed principle [Meyer, OOSC]
With regard to conflicts, I don't see that taking a strict approach is
particularly wonderful. Scoping and locality are, of course, important, and
of course you still have to be able to know exactly the signatures you are
compiling against (i.e. the sum of all the extensions you've imported).
Conflicts can be detected whenever you try to combine extensions (compile
time or link time) - of course conflicts can occur, but that doesn't mean
the facility is not very useful when they do not. Effectively the same
problem occurs when you do this "module List2 = struct include List ... end"
nonsense, with the horrible proliferation of modules and extensions that
result, and nightmarish management of extensions. Even in this setting
there's no way around the potential for conflicts, but, if you assume they
aren't going to occur (e.g. because of some agreed project management of a
namespace), then what's the best way forward? I think optimistic is better
than pessimistic: make the most pleasant system to use, assuming conflicts
won't occur, but if they do give errors at compile time.
[ I also think you could implement it so that only conflicts at compile time
(rather than link time) were significant, by qualifying names in generated
code according to their compilation units. This gives you quite a high
degree of locality, and even if conflicts occur between two extensions
you're using, you can choose, by restricting one signature or another
appropriately, which parts of which extension you want to make use of. Or
something like that. ]
With regard to open/closed, in ML, the signature mechanism provides the way
to close structures and restrict access. Thus I don't think allowing
clients to extend the underlying _structures_ contravenes this. I wouldn't
want to be able to extend _signatures_ that other clients rely upon, unless
they see and explicitly make use of my extension. And the extender would
not receive any special rights to access aspects of the structure hidden
from me.
Thus, for example, you could still implement an abstract data type and
restrict access globally via a signature. No one could mess with your data
type by extending your module, because no one has the privileges necessay to
access the underlying representation. However they could augment your
module with their own stuff, which could be very, very useful, as the Set
functor example indicates.
In an OO setting, particularly with overriding, the question may be
different, but that's not quite what we're talking about here. However,
even Java binary compatibility, for example, specifies ways in which the
classes you run against may be "richer" than the ones you compiled against.
The question is just one of who gets to extend, what rights they have, and
how this maps onto the namespace facility of a language.
Cheers!
Don
-----Original Message-----
From: John Max Skaller [mailto:skaller@maxtal.com.au]
Sent: 21 March 2000 21:08
To: Don Syme
Cc: 'caml-list@inria.fr'
Subject: Re: additions to standard library?
Don Syme wrote:
>
> I've often wondered why languages don't support "extensions" to library
> namespaces (and perhaps even to functors). e.g. one could define
>
> let String.explode s = ....
> let String.implode s = ...
> let myfun = ...
The reason is that it is hard to localise these changes.
It isn't acceptable to extend the actual module, since two clients
could provide conflicting "extensions". This would break the
Open/Closed principle [Meyer, OOSC]
--
John (Max) Skaller, mailto:skaller@maxtal.com.au
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net
next reply other threads:[~2000-03-22 16:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-03-21 21:43 Don Syme [this message]
-- strict thread matches above, loose matches on Subject: below --
2000-03-14 17:24 Don Syme
2000-03-21 21:08 ` John Max Skaller
2000-03-10 17:55 Manuel Fahndrich
2000-03-07 15:24 Markus Mottl
2000-03-08 19:03 ` Jean-Christophe Filliatre
2000-03-08 22:29 ` Markus Mottl
2000-03-10 10:51 ` Christian RINDERKNECHT
2000-03-09 13:18 ` Thorsten Ohl
2000-03-10 10:04 ` Francisco Valverde Albacete
2000-03-10 20:33 ` Markus Mottl
2000-03-14 23:15 ` Max Skaller
2000-03-11 18:49 ` Brian Rogoff
2000-03-12 1:54 ` Jerome Vouillon
[not found] ` <200003120239.DAA18581@miss.wu-wien.ac.at>
2000-03-14 17:53 ` Pierre Weis
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=39ADCF833E74D111A2D700805F1951EF1801452B@RED-MSG-06 \
--to=dsyme@microsoft.com \
--cc=caml-list@inria.fr \
--cc=skaller@maxtal.com.au \
/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