www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - IZ release 0.6.11, now with SafeAccess (?.) chains and more

reply Basile B. <b2.temp gmx.com> writes:
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/
Mar 29
parent reply Adam D. Ruppe <destructionator gmail.com> writes:
On Thursday, 29 March 2018 at 09:56:54 UTC, Basile B. wrote:
 links:
Alternative docs: http://iz.dpldocs.info/iz.html
Mar 29
parent Basile B. <b2.temp gmx.com> writes:
On Thursday, 29 March 2018 at 12:52:36 UTC, Adam D. Ruppe wrote:
 On Thursday, 29 March 2018 at 09:56:54 UTC, Basile B. wrote:
 links:
Alternative docs: http://iz.dpldocs.info/iz.html
thanks for your help, on IRC, with the missing return, btw.
Mar 29