[m-dev.] Re: functor and arg break encapsulation

Fergus Henderson fjh at cs.mu.oz.au
Mon Feb 10 16:56:08 AEDT 1997


Tyson Richard DOWD, you wrote:
> 
> > A down-side to functor/3 and arg/3 is that they break encapsulation:
> > they can be used to traverse even abstract data types.
[...]
> > One thing we might consider, however, is providing both "safe"
> > and "unsafe" versions, with "unsafe" versions behaving as they do now,
> > and with the "safe" versions failing if called for an ADT from
> > a module other than the module that defined the ADT.
> 
> The implementation of this is somewhat tricky, and raises a few issues.
> 
> foo.m defines type foo as an abstract type. 
> bar.m imports type foo. 
> 	- If I get a foo, then call functor on it from bar, it fails.
> 	- If I get a foo, then call functor on it from foo, it succeeds.
> 	- If I get a foo, then create a closure of the call to functor,
> 	  pass this back to a predicate in foo.m, which calls it, what 
> 	  happens?
> 	- If I get a foo, then create a closure of the call to functor,
> 	  curry the first argument in bar.m, pass this back to a 
> 	  predicate in foo.m, which calls it, what happens?
> 	- If I get a closure from foo.m, which happens to be a call
> 	  to functor of something of type foo, and them call it in
> 	  bar.m what happens?
> 	- Any other variations of above.

Urk.

Let's not bother with the "safe" versions ;-)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>   |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>   |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3         |     -- the last words of T. S. Garp.



More information about the developers mailing list