[Nix-dev] Re: Attribute selection with default

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


2009/9/24 Ludovic Courtès <ludo at gnu.org>:
> Hi,
>
> Eelco Dolstra <e.dolstra at tudelft.nl>
> writes:
>
>> Nicolas Pierron wrote:
>
>>>> The next question is how to handle multiple level like `attrByPath
>>>> ["a" "b" "c"] default as', one possible way is to attribute selections
>>>> inside the name of the selected attribute.
>>>>
>>>> as.{a.b.c ? default}
>>
>> I don't find this more intuitive than "as.a.b.c or default".
>
> 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}
>
> I.e., it provides finer control.


You can also do it with the "or" syntax if you do consider scope
created with parenthesis:

as.a.b.c or default
(as.a).b.c or default
(as.a.b).c or default

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
Lars Rasmussen (Google IO 2009) - Icland is an icland.



More information about the nix-dev mailing list