On Monday 21 June 2010 19:23:46 Marc Weber wrote: > 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.
I did indeed miss the fact that you can pass var=null and that asserts only for optional vars aren't enough. So how about adding a "nullGuard" to stdenv.mkDerivation? It isn't going to affect a single working package but would help to catch errors early. -- Evgeny _______________________________________________ nix-dev mailing list [email protected] https://mail.cs.uu.nl/mailman/listinfo/nix-dev
