[Nix-dev] Re: Attribute selection with default

Nicolas Pierron nicolas.b.pierron at gmail.com
Thu Sep 24 14:51:54 CEST 2009


On Thu, Sep 24, 2009 at 14:39, Eelco Dolstra <e.dolstra at tudelft.nl> wrote:
>> IIUC Nicolas’ proposal is more flexible than ‘or’, because
>> “as.a.b.c or default” could mean any one of:
>>
>>   - as.{a.b.c ? default}
>>   - as.a.{b.c ? default}
>>   - as.a.b.{c ? default}
>
> Mine also allows that:
>
> - as.a.b.c or default
> - (as.a).b.c or default
> - (as.a.b).c or default
>
> I.e. simply using the parentheses - no new syntax required.
>
> The idea is that the "." operator is changed from `expr "." attrname' to `expr
> "." attrpath ("or" expr)?'.  So putting parenthesis around as.a or as.a.b gives
> you two applications of the "." operator, one without a default and one with a
> default.

or changed to:

select:
  expr "." "{" attrpath "?" expr "}"
| expr "." attrname

IMO, this is an implementation reason which does not have a large
weight in this discussion unless a limitation exists (which is not the
case).

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron



More information about the nix-dev mailing list