Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] manual/variables.rst #7

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion manual/variables.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@

***********
Variables
変数
***********

A variable, in Julia, is a name associated (or bound) to a value. It's useful when you want to store a value (that you obtained after some math, for example) for later use. For example:

Juliaでは、変数は値に結び付けられた(束縛された)名前です。これは、(例えば計算結果などの)値を後で使うためにしまっておくのに便利です。以下に例を示します。

.. doctest::

# Assign the value 10 to the variable x
Expand All @@ -23,10 +25,31 @@ A variable, in Julia, is a name associated (or bound) to a value. It's useful wh
julia> x = "Hello World!"
"Hello World!"

.. doctest::

# 10という値を変数xに割り当てる
julia> x = 10
10

# xの値を使って計算する
julia> x + 1
11

# xに値を再度割り当てる
julia> x = 1 + 1
2

# 別の型の値、例えば文字列を割り当てることもできる
julia> x = "Hello World!"
"Hello World!"

Julia provides an extremely flexible system for naming variables.
Variable names are case-sensitive, and have no semantic meaning (that is,
the language will not treat variables differently based on their names).

Juliaでは、非常に柔軟に変数を命名することができます。
変数名の大文字と小文字は区別されますが、セマンティクスでの意味を持つわけではありません(言語は名前によって変数の扱いを変えない、ということです)。
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

セマンティクス
プログラム意味論的な
省いてしまっても良い?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

言語は名前によって変数の扱いを変えない
言語は、その変数の名前によって扱いを変えない
変数の名前が扱いに影響を与えない

名前によって、変数の取り扱いを変えない

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

意味(semantic meaning


.. raw:: latex

\begin{CJK*}{UTF8}{gbsn}
Expand Down Expand Up @@ -54,6 +77,8 @@ the language will not treat variables differently based on their names).

Unicode names (in UTF-8 encoding) are allowed:

(UTF-8エンコーディングの)ユニコードでの名前を使うこともできます。

.. raw:: latex

\begin{CJK*}{UTF8}{mj}
Expand All @@ -72,12 +97,16 @@ name followed by tab. For example, the variable name ``δ`` can be
entered by typing ``\delta``-*tab*, or even ``α̂₂`` by
``\alpha``-*tab*-``\hat``-*tab*-``\_2``-*tab*.

JuliaのREPLや、その他いくつかの編集環境では、バックスラッシュから始まるLaTeX記号名、そしてその後にタブを入力することで、様々なユニコード数学記号を入力することができます。 例えば、 変数名 ``δ`` は ``\delta``-*タブ* 、``α̂₂`` は ``\alpha``-*tab*-``\hat``-*tab*-``\_2``-*tab* とすることで入力することができます。

.. raw:: latex

\end{CJK*}

Julia will even let you redefine built-in constants and functions if needed:

もし必要であれば、Juliaでは、ビルトインの定数や関数を再定義することすらできます。

.. doctest::

julia> pi
Expand All @@ -99,9 +128,14 @@ Julia will even let you redefine built-in constants and functions if needed:

However, this is obviously not recommended to avoid potential confusion.

とはいえ、潜在的な混乱を避けるため、これはもちろん推奨されません。

Allowed Variable Names
======================

許可される変数名
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

利用可能な変数名

======================

Variable names must begin with a letter (A-Z or a-z), underscore, or a
subset of Unicode code points greater than 00A0; in particular, `Unicode character categories`_ Lu/Ll/Lt/Lm/Lo/Nl (letters), Sc/So (currency and
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コードポイント

other symbols), and a few other letter-like characters (e.g. a subset
Expand All @@ -111,6 +145,12 @@ as well as other Unicode code points: diacritics and other modifying
marks (categories Mn/Mc/Me/Sk), some punctuation connectors (category
Pc), primes, and a few other characters.

変数名の最初は、アルファベット(A-Zもしくはa-z)、アンダースコア、そして00A0より大きい場所を指し示すユニコードから始まる必要があります。
ユニコードは特に、`Unicode character categories`_ Lu/Ll/Lt/Lm/Lo/Nl(文字)、Sc/So (通貨とその他の記号)、そしていくつかの文字(letter)のような字(character)(例:Sm数学記号の一部)を使うことができます。
最初の文字以降は、!や数字(0-9とNd/Noカテゴリにあるその他の文字)、そしてその他のユニコードも使うことができます。
使用可能なユニコードとしては、 
発音区別記号(訳注: ``´`` や `````、 ``^`` など)やその他の修飾記号(Mn/Mc/Me/Skカテゴリ)、いくつかの句読点(punctuation connectors)(Pcカテゴリ)、プライム記号(訳注: xxx)、そしてその他いくつかの文字があります。

.. _Unicode character categories: http://www.fileformat.info/info/unicode/category/index.htm

Operators like ``+`` are also valid identifiers, but are parsed specially. In
Expand Down