I have just started playing with nim and like it enormously so far.
I have written a nimble module 'elvis' to expose some syntactic sugar for
working with truthy, ternary and conditional assignment operators which is
avialable
[https://github.com/mattaylor/elvis](https://github.com/mattaylor/elvis) . All
is looking good and working well but any advice from more experienced nim folks
(nims?, nimers?, nimblers?) would be much appreciated.
I would also like to add a conditional access operator 'a .? b' which only
invokes the right operand if the left operand is 'truthy' and otherwise returns
am uninitiated instance of whatever a.b would have returned.
I have trying with templates like..
template `?.`*[T,U,V](left: T, right: proc (x: T, y: U): V): V =
if ?left: right(left) else: (var r:V)
template `?.`*[T,U](left: T, right: U): U =
if ?left: left.right else: (var r:U)
Run
But the compiles seems to be getting confused when I call it eg..
nim> import elvis
nim> assert ?""
false` [AssertionError]
nim> ""?.len
template/generic instantiation from here
../../Volumes/Mat/work/nimby/elvis/elvis.nim(50, 35) Error: invalid type:
'HSlice[len.U, len.V]' in this context: 'proc (x: HSlice[len.U, len.V]):
int{.inline, noSideEffect.}' for var
Run
Not sure what I am doing wrong here.