!avYyleMexqjFHoqrME:nixos.org

Nix Documentation

398 Members
Discussion about documentation improvements around the Nix ecosystem81 Servers

Load older messages


SenderMessageTime
29 Apr 2024
@mjolnir:nixos.orgmjolnirchanged room power levels.15:29:10
30 Apr 2024
@stablejoy:matrix.org@stablejoy:matrix.org

Also known as “let expression” or “let binding”

let expressions allow assigning names to values for repeated use.

12:26:51
@stablejoy:matrix.org@stablejoy:matrix.orgI see the word assignment is used apr in the nix tutorial on nix dev12:27:06
@stablejoy:matrix.org@stablejoy:matrix.org* I see the word assignment is used a lot in the nix tutorial on nix dev12:27:18
@stablejoy:matrix.org@stablejoy:matrix.org* I see the word assignment is used alot in the nix tutorial on nix dev12:27:38
@stablejoy:matrix.org@stablejoy:matrix.orgIm curious why not bind or binding12:27:53
@toonn:matrix.orgtoonn Most people are probably more familiar with the concept of variable assignment. 12:28:22
@stablejoy:matrix.org@stablejoy:matrix.org I see Eelco uses the word assignment twice in thesis and binding more than 60 times. 12:29:24
@stablejoy:matrix.org@stablejoy:matrix.orgOh ok how do you say usually?12:29:47
@toonn:matrix.orgtoonn I'd probably say assign more often. One difference is you assign a value to a variable, while you bind an identifier to a value. 12:32:45
@stablejoy:matrix.org@stablejoy:matrix.orgOh like the assigned value changes while the identifier binds to that value12:34:52
@toonn:matrix.orgtoonn Well, in a pure language values assigned to variables don't actually change. 12:36:43
@toonn:matrix.orgtoonn You can shadow a name but that's not really the value changing. 12:36:59
@stablejoy:matrix.org@stablejoy:matrix.org Yes thats where my question is coming from. 12:41:43
@stablejoy:matrix.org@stablejoy:matrix.org

x = 2
x = 3

x is 3

let x = 5; in x
5

x stays 3

12:42:20
@stablejoy:matrix.org@stablejoy:matrix.orgUh formatting.. sorry. So assingment is said as convention in nix?12:42:49
@toonn:matrix.orgtoonn I wouldn't say it's a Nix convention per se. More of a general programmer's convention. 12:44:21
@toonn:matrix.orgtoonn I also wouldn't worry about it much but maybe that's just me. 12:46:45
@stablejoy:matrix.org@stablejoy:matrix.org Yeah I was curious because its used in the nix tutorial. 13:01:18
@stablejoy:matrix.org@stablejoy:matrix.org *
x = 2
x = 3
x is 3
let x = 5; in x
5
x stays 3
13:02:23
@stablejoy:matrix.org@stablejoy:matrix.org *

x = 2
x = 3

x is 3

let x = 5; in x
5

x stays 3

13:08:54
@stablejoy:matrix.org@stablejoy:matrix.org *
x = 2
x = 3
# x is 3
let x = 5; in x
5
# x stays 3
13:09:35
@stablejoy:matrix.org@stablejoy:matrix.org
In reply to @toonn:matrix.org
I'd probably say assign more often. One difference is you assign a value to a variable, while you bind an identifier to a value.
Oh I see now, its like describing two directions. The assignment is describing direction from value to variable and the binding from identifier to value?
13:18:42
@toonn:matrix.orgtoonn Yes. Though I'm not saying that is the only difference. 13:32:52
@kha13d:matrix.org@kha13d:matrix.org left the room.14:18:04
@stablejoy:matrix.org@stablejoy:matrix.org
In reply to @toonn:matrix.org
Yes. Though I'm not saying that is the only difference.
Thats very interesting
15:30:20
@nasrally:matrix.orgnasrally
In reply to @stablejoy:matrix.org
Oh I see now, its like describing two directions. The assignment is describing direction from value to variable and the binding from identifier to value?

Also, sorry it's long, but in terms of basic lambda calculus thingies you don't get to have named functions or values at all, all you have is 1) functions that accept values (1 value to be precise) and that value being applied into the body of that function (that is the input value is substituted for the name inside the body as-is and the "head" of the function is plucked off, e.g. in λx.x λx is the head and . is a separator and x is the body and if you get something inside, you put it in λ__x__, it is piped through . and the inner x is replaced with the value you put inside the head, then head is removed and you are left with is the body!, also body can be xxx that would mean the input value is duplicated into three, so functions control WHERE you place something which directly affects in what order things are evaluated (applied to each other) later on which is key) 2) a rule is at the moment of evaluation (application) no free variable can be used for substitution, that is if you take something that does not represent anything concrete (has no actual value in its place) that value cannot be applied further into the body.

So because all you do is apply something from the head into the body, basically you view programs in pure languages as humongous onion functions that take some input and propagate it somewhere deeper modifying it in only god knows what ways, as the program evaluates, with every outer level of that huge onion removed, some inner layers gets a variable bound further and further until in the end you're left with some final value where everything that can be applied was applied.
In reality you're greatly abstracted away from the crazy logic of OG lambda calculus (and to some extent limited by practical computer design) with types like numbers strings and (I think) some operations on those types (you get typed lambda calculus), but the basic principles don't change.

What you see with named values (value being anything from a number to a function) is simply a programmer abstraction, you assign names to your values for pure convenience because in the end any such program can be rewritten without any names with only values as a bunch of functions and values nested inside each other, that is unlike the imperarive mindset where variables are used as storage spaces and not simply as names for values to be substituted

So again, yes, you bind names to values so that you can effectively as a programmer use those values in a short and concise way, not to actually store anything in them

17:31:19
@nasrally:matrix.orgnasrally *

Also, sorry it's long, but in terms of basic lambda calculus thingies you don't get to have named functions or values at all, all you have is 1) functions that accept values (1 value to be precise) and that value being applied into the body of that function (that is the input value is substituted for the name inside the body as-is and the "head" of the function is plucked off, e.g. in λx.x λx is the head and . is a separator and x is the body and if you get something inside, you put it in λx, it is piped through . and the inner x is replaced with the value you put inside the head, then head is removed and you are left with is the body!, also body can be xxx that would mean the input value is duplicated into three, so functions control WHERE you place something which directly affects in what order things are evaluated (applied to each other) later on which is key) 2) a rule is at the moment of evaluation (application) no free variable can be used for substitution, that is if you take something that does not represent anything concrete (has no actual value in its place) that value cannot be applied further into the body.

So because all you do is apply something from the head into the body, basically you view programs in pure languages as humongous onion functions that take some input and propagate it somewhere deeper modifying it in only god knows what ways, as the program evaluates, with every outer level of that huge onion removed, some inner layers gets a variable bound further and further until in the end you're left with some final value where everything that can be applied was applied.
In reality you're greatly abstracted away from the crazy logic of OG lambda calculus (and to some extent limited by practical computer design) with types like numbers strings and (I think) some operations on those types (you get typed lambda calculus), but the basic principles don't change.

What you see with named values (value being anything from a number to a function) is simply a programmer abstraction, you assign names to your values for pure convenience because in the end any such program can be rewritten without any names with only values as a bunch of functions and values nested inside each other, that is unlike the imperarive mindset where variables are used as storage spaces and not simply as names for values to be substituted

So again, yes, you bind names to values so that you can effectively as a programmer use those values in a short and concise way, not to actually store anything in them

17:31:34
@nasrally:matrix.orgnasrallyCorrect me if I'm wrong, my understanding is rather superfluous unlike some here, so just please make sure I didn't put out any misinformation please17:31:51
@nasrally:matrix.orgnasrally *

Also, sorry it's long, but in terms of basic lambda calculus thingies you don't get to have named functions or values at all, all you have is 1) functions that accept values (1 value to be precise) and that value being applied into the body of that function (that is the input value is substituted for the name inside the body as-is and the "head" of the function is plucked off, e.g. in λx.x λx is the head and . is a separator and x is the body and if you get something inside, you put it in λx, it is piped through . and the inner x is replaced with the value you put inside the head, then head is removed and you are left with is the body!, also body can be xxx that would mean the input value is duplicated into three etc any combinations, so functions control WHERE you place something which directly affects in what order things are evaluated (applied to each other) later on which is key) 2) a rule is at the moment of evaluation (application) no free variable can be used for substitution, that is if you take something that does not represent anything concrete (has no actual value in its place) that value cannot be applied further into the body.

So because all you do is apply something from the head into the body, basically you view programs in pure languages as humongous onion functions that take some input and propagate it somewhere deeper modifying it in only god knows what ways, as the program evaluates, with every outer level of that huge onion removed, some inner layers gets a variable bound further and further until in the end you're left with some final value where everything that can be applied was applied.
In reality you're greatly abstracted away from the crazy logic of OG lambda calculus (and to some extent limited by practical computer design) with types like numbers strings and (I think) some operations on those types (you get typed lambda calculus), but the basic principles don't change.

What you see with named values (value being anything from a number to a function) is simply a programmer abstraction, you assign names to your values for pure convenience because in the end any such program can be rewritten without any names with only values as a bunch of functions and values nested inside each other, that is unlike the imperarive mindset where variables are used as storage spaces and not simply as names for values to be substituted

So again, yes, you bind names to values so that you can effectively as a programmer use those values in a short and concise way, not to actually store anything in them

17:32:58

Show newer messages


Back to Room ListRoom Version: 6