views:

29

answers:

3

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.

+1  A: 

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.

Oded
+1  A: 

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."

Matt
A: 

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".

leonbloy
Ah, thanks! The others are saying the same thing, but yours is the explanation I can really get. "John is assigned the task of painting the house" is the same as "The task of painting the house is assigned to John". So the preposition switches the order around. As I suspected.
njlarsson