Help us understand the problem. What is going on with this article?

# values and literals in terms of computer science

More than 3 years have passed since last update.

# 目次

• `literal``value`
• それぞれの違い

## `literal`と`value`

wikiによるとコンピューターサイエンスにおける`literal`とは

a notation for representing a value within programming language source code

ザックリ言うと`assignment statement`（i.g. x = 1）において`=`の右にくるもの（勿論全てではない）。

stackoverflowで見つけた例は以下のとおり：

Examples:

"hey" (a string)
false (a boolean)
3.14 (a real number)
[1,2,3] (a list of numbers)
(x) => x*x (a function)
/^1?\\$|^(11+?)\1+\$/ (a regexp)

Some things that are not literals:

std::cout (an identifier)
foo = 0; (a statement)
1+2 (an expression)

a literal is kind of container, so it'll be better to compare between values and containers.

`literals`を入れ物として考えたほうが分かりやすいと。

よって以下の引用が成り立つ：

A literal is a container that can be translated directly to a value without looking at it's surrounding - for example 1 can be translated directly to the number one. x can not be translated to a value in such a way, since it's a variable and we don't know what it holds unless we look at the surrounding code.

In computer science, a value is an expression which cannot be evaluated any further (a normal form).[1] The members of a type are the values of that type.[2] For example, the expression 1 + 2 is not a value as it can be reduced to the expression 3. This expression cannot be reduced any further (and is a member of the type Nat) and therefore is a value.

## それぞれの違い

@UCBerkeley
Why not register and get more from Qiita?
1. We will deliver articles that match you
By following users and tags, you can catch up information on technical fields that you are interested in as a whole
2. you can read useful information later efficiently
By "stocking" the articles you like, you can search right away