DIP 1009--Improve Contract Usability--Preliminary Review Round 1
Moritz Maxeiner via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jun 21 10:56:29 PDT 2017
On Wednesday, 21 June 2017 at 17:38:02 UTC, Moritz Maxeiner wrote:
>
> Well, for me it would be this:
> - The compact syntax with `in (cond)` and `out (ident)(cond)`
> - Don't lower those contracts directly to any fixed
> implementation; lower them to a template (similar to what I
> posted) that you stick in druntime instead
> - Allow configuring the template's checking semantics via D
> versions (you can still then have one implementation choice in
> the template be asserts, if you want, though I would go with a
> more riguruous kill switch such as the one I posted)
>
> I would definitely be interested in helping out with the
> template implementation for druntime, btw.
I think this should be taken even further and follow the
footsteps of std.experimental.allocator (being thus consistent
with what's becoming idiomatic D):
- Introduce the abstract concept of an Allocator analogue called
"Insister", which can provide DbI-detectable "insist" functions
(e.g. for in contracts, for out contracts, etc.)
- Introduce an interface like IInsister akin to IAllocator, with
insisterObject akin to allocatorObject
- Create a thread-local `IInsister theInsister` that can be
swapped out at will
- Lower contracts to calls to `theInsister.insist(...)`
- Create some Insister implementations and load theInsister up
with one that uses `assert` semantics
More information about the Digitalmars-d
mailing list