slang-users mailing list

[2009 Date Index] [2009 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

Re: [slang-users] Re: slang 2.2.0 release candidate 1 available


Jörg Sommer <joerg@xxxxxxxxxxxx> wrote:
> Can you extend this expression to evaluate to condition if val1 isn't
> present? I find it very helpful to write
>
>   exp = container.get(10) ? : default_object
>
> instead of
>
>   exp = container.get(10) != NULL ? container.get(10) : default_object

I do not want to add any new features to 2.2.0, but I will consider
this for 2.2.1.  

FWIW, here is an ugly hack that mimics the above:

   exp = (container.get(10), dup()) ? () : (pop(), default_object);

Note that NULL evaluates to 0 in a boolean context.

Thanks,
--John




[2009 date index] [2009 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]