On Sun, Nov 23, 2008 at 13:32, Eelco Dolstra <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Nicolas Pierron wrote:
>
>> I have a problem with the NixOS implementation.  I have remarked the
>> following problem:
>>
>> let
>>   v = {foo=true;bar=false;};
>>   a = builtins.trace v v;
>>   b = a;
>> in
>>   assert a == b; true
>>
>> where "v" is printed.  "v" should not be printed because unprocessed
>> values of "a" and "b" are identical.
>
> The `==' operator evaluates both terms to weak head normal form.  There is no
> realistic way that it could see that "a" and "b" are the same without 
> evaluating.
>
> Also, `==' doesn't work on lists and attribute sets (not to mention functions)
> because the list elements / attributes are not evaluated to normal form.  So 
> `{a
> = "foo" + "bar";} == {a = "foobar";}' will evaluate to false.  In fact, even 
> `{a
> = "foobar";} == {a = "foobar";}' evaluates to false because of the position
> information in the attributes.  The evaluator should really print an error 
> when
> trying to compare lists and attribute sets...

In this problem terms have the same content and the same position
information (in NixOS, they are supposed to be extracted from one
file), this is the reason why I was asking this question.  ATerm
allows to have pointer to pointer comparison in order to compare full
terms so this should be possible.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.
_______________________________________________
nix-dev mailing list
[email protected]
https://mail.cs.uu.nl/mailman/listinfo/nix-dev

Reply via email to