[Nix-dev] A standard function to handle deps

Marc Weber marco-oweber at gmx.de
Mon Jun 21 18:23:46 CEST 2010


Hi Evgeny Egorochkin,


> I propose to add a standard function like this:
> 
> optionalInput =
>   cond: elem: assert cond -> elem != null; if cond then [elem] else [];
> 
> This removes a good deal of asserts clutter and is easy enough to use so that 
> maintainers will actually specify asserts as a byproduct instead of letting 
> things fail at buildtime or silently not compile in the needed functionality.
> 

Just some more ways:

A)
  buildInputs = nullGuard [ null ]; // guard fails if one element is null. Probably nullGuard does not exist yet.

B) remove the "? null" in the arg list. Assume that null is never
  passed. Usually the option is passed. Then also remove the
  assertion because you assume that null is never passed.

Usually you should keep code as is unless there is reason to change it.
That's how I think about it.

Marc Weber



More information about the nix-dev mailing list