IZ release 0.6.11, now with SafeAccess (?.) chains and more
Basile B.
b2.temp at gmx.com
Thu Mar 29 09:56:54 UTC 2018
Iz 0.6.11 is available now. While parts of the library are no
really usable by a wide audience (memory management things)
There's been a bunch of interesting additions in the iz.sugar.d
module, which can be used independently from the "big stuff"
(memory-classes-properties-serialization).
SafeAccess:
===========
A typecons like structure that wraps a class instance and allows
to write safe-access chains:
http://bbasile.github.io/iz/iz/sugar/SafeAccess.html
```
// like and && chain but working even if any of the member is
null.
if (auto m = safeAccess(stuff).member.member.member) {}
```
With DMD, the overhead is small. With LDC there are even case
where surprisingly SafeAccess is faster than && (when getters are
used).
CoercionSafeFloat:
==================
After a discussion on the topic in the General section, i made
DMD emitting a warning in case of coercion from a float type to a
smaller one. While this worked it was certainly a too big
breaking change (and unjustified in some) case.
sugar.d contains a wrapped float struct that prevents such
coercion, when needed:
http://bbasile.github.io/iz/iz/sugar/CoercionSafeFloat.html
Other:
======
sugar.d and types.d contains other small interesting bits that
are usable independently from the "big stuff". Coming next is a
getopt-like function, much faster and based on
UDA...unfortunately it requires 2.080 for now.
links:
- https://github.com/BBasile/iz
- https://code.dlang.org/
- http://bbasile.github.io/iz/
More information about the Digitalmars-d-announce
mailing list