My Reference Safety System (DIP???)

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Feb 25 15:31:35 PST 2015


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... 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.


T

-- 
They say that "guns don't kill people, people kill people." Well I think the gun helps. If you just stood there and yelled BANG, I don't think you'd kill too many people. -- Eddie Izzard, Dressed to Kill


More information about the Digitalmars-d mailing list