My Reference Safety System (DIP???)

via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 26 10:14:01 PST 2015


On Wednesday, 25 February 2015 at 23:33:57 UTC, H. S. Teoh wrote:
> On Wed, Feb 25, 2015 at 09:26:31PM +0000, via Digitalmars-d 
> wrote:
> [...]
>> On Wednesday, 25 February 2015 at 01:12:15 UTC, Zach the 
>> Mystic wrote:
>> >Principle 3: Extra function and parameter attributes are the 
>> >tradeoff
>> >for great memory safety. There is no other way to support both
>> >encapsulation of control flow (Principle 2) and the
>> >separate-compilation model (indispensable to D). Function 
>> >signatures
>> >pay the price for this with their expanding size. I try to 
>> >create the
>> >new attributes for the rare case, as opposed to the common 
>> >one, so
>> >that they don't appear very often.
>> 
>> IIRC H.S. Teoh suggested a change to the compilation model. I 
>> think he
>> wants to expand the minimal compilation unit to a library or
>> executable. In that case, inference for all kinds of 
>> attributes will
>> be available in many more circumstances; explicit annotation 
>> would
>> only be necessary for exported symbols.
>
> I don't remember making any such suggestion...

I'm sorry then... I've pulled this from the back of my mind, and 
I'm sure something similar was actually suggested (not as a 
formal proposal, mind you). Maybe it was Martin Nowak, because 
he's working on DIP45 (export)? But better not to speculate, lest 
more innocent people get accused of proposing things ;-)

> the closest I can think
> of is the idea that attribute inference should always be done, 
> and saved
> as part of the emitted object file(s), perhaps even in 
> generated .di
> files that contain all inferred attributes. When importing some 
> module,
> the compiler would read the inferred attributes from the saved
> information. Programmers won't even need to write any 
> attributes except
> when they want to override the compiler's inference, but the 
> code will
> automatically get the benefit of all inferred attributes. 
> Library users
> would also benefit by having all inferred attributes available 
> in the
> auto-generated .di files. This can be made to work regardless 
> of what
> the minimal compilation unit is.
>
> Automatic inference also frees us from the concern that 
> functions have
> too many attributes -- if the compiler will automatically infer 
> most of
> them for us, we can freely add all sorts of attributes without 
> worrying
> that it will become impractically verbose to write. Saving this 
> info as
> part of the object file also lets the compiler take advantage 
> of these
> extra attributes even when source code isn't available, or 
> perform
> whole-program optmizations based on them.

Yes, I fully agree with that. The one thing that's then missing 
is a way to disable automatic inference (for stable interfaces); 
`export` fits that mold.


More information about the Digitalmars-d mailing list