Ali Çehreli:

Ali Çehreli's (first speaker) slides are at

It's a nice slides pack. Now in Phobos there's also assumeUTF ( ).

See also:

It essentially asks two functions (group and filter) to return a SortedRange if the input is a SortedRange, because those two functions don't change the items order.

In Haskell you do such things using "rewrite rules" ( ).

Those are two examples of conservation of assumptions (invariants).

assumeUnique returns an immutable instead of a Unique!T struct. So after calling assumeUnique you can't mutate the items. An Unique!T wrapper (like std.typecons.Unique) allows you to mutate the items if the needs arises but also to keep their property of having no shared references. Some functions like sort() are able to conserve the property of uniqueness, so sorting an array of Unique should return a SortedRange!(Unique!T[]) or something like that.

Another assumption that could be useful for Phobos is assumeAligned!(T[], 16), that specifies the assumption that a specific slice has its first item aligned to 16 bytes. This could be useful if you use SIMD instructions (time ago I have even suggested to put such array alignment inside the D type system, but I didn't raise much enthusiasm).


Reply via email to