[Nix-dev] Re: @ and default arguments

Yury G. Kudryashov urkud+nix at ya.ru
Fri Aug 27 14:03:18 CEST 2010


Eelco Dolstra wrote:

> Hi,
> 
> On 08/25/2010 11:36 PM, Yury G. Kudryashov wrote:
> 
>> The following returns false:
>> 
>> (a@{ b ? true }: a ? b) { }
>> 
>> It seems that after a@{...} a is not populated by default values. Is it a
>> bug, or a feature?
> 
> This is the intended behaviour.  The fact that there is a "{b ? true}"
> does not cause an attribute to be "added" to the passed argument set
> ("a"), it merely causes a "b" with value "true" to be added to the lexical
> scope.
Could you please make it clear in the documentation?

Another proposal: what about "rec" for formal arguments? May be, in double 
braces or something like that. This will simplify "url vs urls" part of 
fetchurl header to

{{ url ? null, urls ? [url]}}:

assert head urls != null;

I think that it is easier to read this code.

P.S.: I'll think whether the current syntax is enough for me. If not, I'll 
post the use case.





More information about the nix-dev mailing list