views:

319

answers:

11

Is there a term to represent a set of all possible values a variable can assume?

Analogy:
In mathematics a domain of a function is a set of values a function is defined on (function can take as an argument).

Examples:

  • A variable of type UInt16 can hold values in range [0-65536).
  • Completion status (represented by a double value) can hold a value in range [0-100].
  • Gender (represented by an Enum) can hold one of { Male, Female }.

Q:
What is a term to describe all possible values a variable can (contextually) assume?

Basically need a short version of "set of values for a variable". I have seen term type being used to describe such a range, but Type often encompasses other bits of information (e.g. a name, operations, module).

+1  A: 

I don't know of programming-specific jargon with that meaning, but "domain" itself seems like a pretty good one...

[EDIT] Read the comments to this, and I actually prefer "range".

Promit
I'd disagree, assuming he was going to use this in some sort of programming context. If someone asked me "what's this variable's domain?", I wouldn't have a clue what they were trying to find out.
Chad Birch
I didn't even think of domain. +1
TheTXI
I remember it in math as "domain of possible values" or something along that sort.
TheTXI
Domain refers to functions though...
Beau Martínez
In fact I think I'd say range myself if I were discussing with a colleague. It's not unreasonable to consider a variable as a function, and the values are the range of that function. (It has no domain, as it has no inputs.) That's how functional programming works, after all.
Promit
+7  A: 
  • value set
  • domain
  • value range
Adam Robinson
+2  A: 

I would just call it the "range", or "range of values".

Matthew Flaschen
Range could confuse the mathematicians.
David Hodgson
True, but when has that ever stopped us?
Matthew Flaschen
A: 

I don't know if this is the exact terminology (if it even has one) but I have always referred to it as a range or in the case of enums options.

TheTXI
+2  A: 

Domain would be the math term.

Brian
Domain would define the set of inputs that are acceptable, but not the set of all possible values a variable can assume.
McWafflestix
That depends. Suppose you have, "int monkey;" The domain of int and the domain of monkey could be different. But it's perfectly possible to say either "domain of monkey" or "domain of int."
Brian
@McWafflestix so you're saying that the set of values the variable can legally be set to ( the domain of variable.set(value) ) is different from the set of values it can assume ( the range of variable.get() )?
Pete Kirkham
A: 

Range is the proper term, as in "this method will return values within the range of..."; "The expected range of this variable is:..." etc.

McWafflestix
But the range of valid workign days for December is between 01 and 31. Yet weekends are not valid.
MaSuGaNa
yes, 01 to 31 is the acceptable set of all POSSIBLE values; not necessarily all valid values for all situations (such as different years). 0 to 31 is the valid range; the solution set for any given problem does not need to include all values in the range.
McWafflestix
A: 

For atomic types, the type itself describes the range (e.g. int has a range of -2,147,483,648 to 2,147,483,647).

Anything that is a custom type may or may not have a range because custom types (e.g. struct, class, interface) are composite types that can be made up of atomic or other custom types.

The definition of a type will also vary between different languages.

The long and short of it is generally you will only be able to apply a range to atomic types based on a specific language.

Scott Lance
A: 

It depends on the type system. In some programming laguages, a "string" can hold a sequence of characters, and an "unsigned int" can only hold positive whole numbers. In others like python, a variable can hold anything at all because it doesn't have a certain type.

Michael
+2  A: 

I've also heard "value space" as a term for this.

Lasse V. Karlsen
Unambiguous and short. Perfect. See also: http://www.stylusstudio.com/w3c/schema2/value-space.htm
A: 

Our quants here say it is called a value set. They get paid tons of money to create them so I believe them!

MaSuGaNa
A: 

You may think of a variable as containing an element that is a member of a set of numbers.

As such, domain is a good descriptor for the possible values of this set.

Range is also often used in a similar context. Here we talk of the range of a function, as the set of values the function can take on. Since a variable always contains the result of some expression or computation, range clearly makes sense too.

Either is appropriate in the proper context.

woodchips