infinisil changed the topic of #nix-lang to: Channel for discussing Nix as a language - https://nixos.org/nix/manual/#chap-writing-nix-expressions - Logs: https://logs.nix.samueldr.com/nix-lang/
pie___ has joined #nix-lang
pie__ has quit [Ping timeout: 245 seconds]
ddellacosta has quit [Ping timeout: 245 seconds]
__monty__ has joined #nix-lang
timor has joined #nix-lang
<timor> A quick test with `if true then trace "true" 1 else trace "false" 2` indicates that only one of if's branches is evaluated. Is that an optimization, or is this behavior guaranteed?
<ekleog> timor: this behavior is as guaranteed as nix behavior can be: without it all of nixpkgs would stop working
<timor> ekleog: why?
<srhb> timor: nixpkgs relies strongly on the lazy featyres of the nix lang. You might want to check the papers on the subject :)
<ekleog> timor: also, without going up to laziness, the entry point to nixpkgs looks like https://github.com/NixOS/nixpkgs/blob/master/default.nix ; if both were evaluated it'd always abort
<ekleog> (though laziness is actually the correct answer for why it can't easily change in nixpkgs)
<timor> While I understand that nix lazyness is important and beneficial, an evaluator could still choose to 'eval ahead' and discard the results if the branch has not been taken, no? (Not saying that anyone does this, or should)
<srhb> timor: Usually that changes semantics of the language. In a pure language, possibly^tm
<timor> So nix is "sufficiently impure".... Will have to check the papers again when I have some time...
<infinisil> laziness does not make it impure
<infinisil> Haskell is also lazy
<srhb> infinisil: Di something I said imply otherwise? If so, I certainly didn't intend that.
<timor> (me neither)
<infinisil> timor: Was directed at you, because you said "nix is sufficiently impure"
<srhb> Ah, got it
<infinisil> It's not really impure in that regard, lazy evaluation is not impure in any way
<infinisil> And strict evaluation isn't either
<srhb> What I meant to say is: You cannot generally do the "eval ahead" thing (at least, not without specifying further what exactly what you mean) without also changing the semantics of the language
<srhb> When I say "generally" I mean it may be possible in some cases, especially in pure languages, depending on what you mean.
<srhb> Or in other words "we can only handwave until you specify further" :-P
Taneb has joined #nix-lang
jasongrossman has joined #nix-lang
jtojnar has joined #nix-lang
jasongrossman has quit [Quit: ERC (IRC client for Emacs 26.1)]
ddellacosta has joined #nix-lang
pie___ has quit [Remote host closed the connection]
pie_ has joined #nix-lang
pie_ has quit [Remote host closed the connection]
pie_ has joined #nix-lang
ddellacosta has quit [Ping timeout: 245 seconds]
ddellacosta has joined #nix-lang
timor has quit [Ping timeout: 255 seconds]
__monty__ has quit [Quit: leaving]
joepie91 has quit [Ping timeout: 252 seconds]
joepie91 has joined #nix-lang
joepie91 has joined #nix-lang
joepie91 has quit [Changing host]