0

I have two cases that I'd like to cover. For example you can either assign to a variable:

var x = 3;

Or you can indirectly assign to a variable with a function (passing function arguments):

my_func(3);

Is there a word to refer to both of these cases? Basically, these are the ways to "use" a value in programming, via variables or function scoping.

I want to use the word like the following:

This syntax alone is not useful but when you <WORD> it, yadda yadda...

which would be equivalent to:

This syntax alone is not useful but when you assign it to a variable or pass it into a function, yadda yadda...

The closest words I could come up with were either "use" or "store", both of which are a little bit too ambiguous. Thanks in advance!

closed as off-topic by Hot Licks, Chappo, K J, Cascabel, TaliesinMerlin May 3 at 13:23

  • This question does not appear to be about English language and usage within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Which variable is being indirectly assigned in my_func(3)? – Jim May 1 at 20:02
  • You would have a copy of the integer 3 in the function body. This is different than just typing 3 followed by a semicolon; then that integer is never stored anywhere, so it, in essence, disappears. – connectyourcharger May 1 at 20:03
  • So you are mean ’pass-by-value’ is an assigment to the function parameter. – Jim May 1 at 20:06
  • 1
    But the function notation is just shorthand for an assignment: my_func( x=3, y=1) The values are still being set by assignment, it’s just that in one case the syntax allows implicit assigment by position. – Jim May 1 at 20:13
  • 4
    I'm voting to close this question as off-topic because belongs on a computer-related site. (I think there's one somewhere on Stack Exchange.) – Hot Licks May 1 at 21:50
1

The word is assignment in both cases.

The first example is of explicit assignment:

x = 3

The second is of implicit assignment:

my_func(3)

This is because the function invocation syntax of many languages allow for implicit assignment to function arguments by position. This is just shorthand for the explicit assignment that many languages (also) allow:

my_func( x=3, y=1)

2

I have PhD. in computer science, so I'm unusually well-connected to this question. :)

var x = 3;

This is indeed called assignment to a variable; it can also be called initializing a variable, since it's being done initially. (This also declares the variable x, but you were talking about the use of the value.)

function my_func (z)

begin

...

end

my_func(3);

This last line is passing in a parameter; or passing a value into a function (since 3 is a value); and if we instead say

my_func (x);

it may be called passing in a variable.

You could say we're really passing in an argument not a parameter, as 3 is an argument and z is the parameter. But I often hear "passing in a parameter."

I do not hear the latter case referred to as assignment, though it can be viewed as such.

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