UFCS for D

Nick Sabalausky a at a.a
Fri Mar 30 02:15:10 PDT 2012


"Walter Bright" <newshound2 at digitalmars.com> wrote in message 
news:jl3qds$10ga$1 at digitalmars.com...
> On 3/30/2012 12:18 AM, Nick Sabalausky wrote:
>> While there are definitely times I need to access private state across
>> separate components within a module, I find such cases are fairly 
>> uncommon,
>> so I question the wisdom of making it the default behavior.
>
> If your module has grown so large that you need such encapsulation, 
> meaning that the "cognitive load" of understanding the module has exceeded 
> one's grasp, then I submit that the module needs to be broken up into 
> multiple modules.
>

It's not about cognitive load exceeding the brain's capacity (well, I'm sure 
it can be in some cases), it's about just simply keeping separate things 
separate without ending up in Java's world of "millions of tiny files for 
each trivial thing".

You should be able to look at a couple unrelated chunks of code in a module 
(ie they handle completely separate details of the implementation of the 
module's single conceptual task) and *know* there's no interplay going on 
simply by virtue of the code not specifically suggesting otherwise via 
permissive access specifiers. And if those "separate sub-tasks" are small, 
stucking them each in separate files is a Java-like burden. So if you don't 
want to go that route, then when you look at them as things are now, well, 
there might be interplay and there might not be.

> There has been a trend in Phobos of having some truly gigantic modules. I 
> believe this is indicative of a problem in the language.

I thought that was a deliberate Phobos style convention. I'm certain I 
remember you and/or Andrei talking here about a year or two ago about how 
you didn't want Phobos modules broken up into separate implemetation 
modules.

In fact, I definitely remember now, back early last year when Andrei first 
brought up the idea of having  generalized parser in Phobos, I mentioned my 
Goldie project and there was a small discussion about the possibility of 
using that as the "std.parser" or whatever. I specifically remember you 
saying that, were Goldie to go into Phobos, you'd want it all merged into 
one module. Ultimately, I backed off on the whole idea as I felt Goldie 
likely wouldn't be an appropriate fit for Phobos, and that was one of the 
reasons.

> Andrei and I have  talked about it, and we think it is because of 
> difficulties in breaking a module up into submodules of a package.
> We think it's something we need to address.

Eh? Other people have voiced concerns over that since waaay back in even 
pre-D1 times. In particular, many people have argued for allowing modules 
with the same name as a package. Ie: you could have both module "foo" and 
module "foo.bar". The reasons they gave for wanting this are right along the 
lines of what you're talking about here. Eventually they got the message 
that it wasn't gonna happen and they gave up asking for it.

Or is there a separate problem you're refering to?




More information about the Digitalmars-d-announce mailing list