|
|
|
|
|
by danprager
6567 days ago
|
|
Most languages short-circuit ands and ors already, but adding additional short-circuiting demands macros: My practical example of this is my desire for a short-circuit "implies" operator to use in assertions (typically in post-conditions). I want to able to write checks like assert (foo != null _implies_ foo.someProperty);
where the _implies_ operator short-circuits.Writing my own implies(a,b) function is no good in most languages, because strict evaluation would yield a null-reference exception in the example when a is null. Without macros I end-up writing: assert(a == null || a.someProperty);
or worse if (a != null) { assert(a.someProperty);
With lisp-strength macros I could easily add an implies operator and get readable rather than clever code. |
|