4

During a code review, I noticed a phrasing in an error message that made me scratch my head a little. The message was something akin to:

The value is set for {}

where {} is a place-holder for a numeric or text value.

Somehow, it feels a bit off to me and personally, I'd go for

The value is set to {}

but that's just my instinct and I don't know a grammar rule to back it up.

Which (if any) of these two prepositions can be used in this context? For or to?

The entry for the word set [VERB] in the Macmillan English Dictionary mentions the context of device settings, which is a bit similar, as the line mentioned above pertains to a piece of software configuration.

3

...

a. to change the time on a clock or the controls on a piece of equipment

Can you help me set the VCR?

set something at something: Set the thermostat at 68 degrees.

set something for something: I’m setting the alarm for 6.30.

with no mention of to being used as the preposition.

I also found this thread on Quora, in which the OP is recommended to use the same phrasing I'd pick.

The stormtrooper in this opening scene of Star Wars, on the other hand, seems to prefer to set his weapon for stun.

Which is the most correct preposition one could use in this context and which one feels most natural?

Set the value to 3 / Set the value for 3 / Set the value at 3

Brownie points for pointing to a credible (even more so than Star Wars!) source.

2
  • 2
    You only set something for an outcome, which is why Set the alarm for 6:30, Set phasers for stun, Set a course for home are all credible. But in most contexts we use to anyway (all of those examples could reasonably use to instead), so if you're not sure just stick with that. Jan 23, 2016 at 12:51
  • If it's reporting the state of the variable I'd say "the value is".
    – Hot Licks
    Jan 23, 2016 at 13:18

1 Answer 1

3

The for option is incorrect in this context. In programming you set a value for the left-hand side, not the right-hand side. For instance, one could say "I set the configuration for the User class in user.json." In the offending statement, the most parsimonious phrasing is "x is set to {}", which is less wordy than the redundant "the value of x is set to {}". Set to is the English equivalent of JavaScript/Python/Java/C/C+* assignment operator =.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.