Reputation: 2330
This always confuses me. I hope for help from native English speakers who mind their language.
Let's say I have:
x := 5
I can say "x is assigned 5". Fine. But then I bring in a preposition. Which of the following expresses what happens: "5 is assigned to x" or "x is assigned to 5"?
I can get one intuition by drawing an analogy to "the name is assigned to the value", so that would indicate "x is assigned to 5". But then, I can also say "the value is assigned the name" without the "to", which would indicate that "5 is assigned x" would be right, and I absolutely think that is backwards.
Upvotes: 3
Views: 1006
Reputation: 75926
I'm not a native english speaker, but I think It's roughly the same as "John has been assigned the role R" ( = "the role R has been assigned to John"). In your example, I'd say "the value 5 is assigned to X", or (a little more confusing) "X is assigned the value 5".
Upvotes: 3
Reputation: 562
The value of X is 5. 5 is assigned to x.
This of it this way. 5 exists. x := 5, and y := 5. x isn't assigned to 5, because then that would imply that y can't be assigned to 5. A variable can at most refer to 1 thing. So, x can only have 1 value, and y can only have 1 value, right? 5, IS a value. Many things can refer to 5.
So, it is correct to say that "5 is assigned to x."
Upvotes: 1
Reputation: 499062
I would read this as "the value 5 is assigned to the variable x".
Or, in your terminology - the literal value 5 is assigned to the variable named x.
Upvotes: 1