Skip to content

Commit cd954bc

Browse files
authored
Merge pull request #1432 from johnkjellberg/master
Remove wrong information related to changes in float tokenisation.
2 parents 290ac29 + 7d80d82 commit cd954bc

File tree

8 files changed

+8
-114
lines changed

8 files changed

+8
-114
lines changed

Diff for: _de/tutorials/scala-for-java-programmers.md

+1-15
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,10 @@ der folgende
147147
exklusiv aus Methoden-Aufrufen, da es äquivalent zu folgendem Ausdruck ist, wie in vorhergehenden
148148
Abschnitt gezeigt wurde:
149149

150-
(1).+(((2).*(3))./(x))
150+
1.+(2.*(3)./(x))
151151

152152
Dies bedeutet außerdem, dass `+`, `*`, etc. in Scala gültige Bezeichner sind.
153153

154-
Die Zahlen umschließenden Klammern der zweiten Variante sind notwendig, weil Scalas lexikalischer
155-
Scanner eine Regel zur längsten Übereinstimmung der Token verwendet. Daher würde der folgende
156-
Ausdruck:
157-
158-
1.+(2)
159-
160-
in die Token `1.`, `+`, und `2` zerlegt werden. Der Grund für diese Zerlegung ist, dass `1.` eine
161-
längere, gültige Übereinstimmung ist, als `1`. Daher würde das Token `1.` als das Literal `1.0`
162-
interpretiert, also als Gleitkommazahl anstatt als Ganzzahl. Den Ausdruck als
163-
164-
(1).+(2)
165-
166-
zu schreiben, verhindert also, dass `1.` als Gleitkommazahl interpretiert wird.
167-
168154
### Funktionen sind Objekte
169155

170156
Vermutlich überraschender für Java-Programmierer ist, dass auch Funktionen in Scala Objekte sind.

Diff for: _es/tutorials/scala-for-java-programmers.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,10 @@ Ya que los números son objetos, estos también tienen métodos. De hecho, una e
9797

9898
Consiste exclusivamente de llamadas a métodos, porque es equivalente a la siguiente expresión, como vimos en la sección anterior:
9999

100-
(1).+(((2).*(3))./(x))
100+
1.+(2.*(3)./(x))
101101

102102
Esto también indica que `+`, `*`, etc. son identificadores válidos en Scala.
103103

104-
Los paréntesis alrededor de los números en la segunda versión son necesarios porque el analizador léxico de Scala usa la regla de "mayor coincidencia". Por lo tanto partiría la siguiente expresión:
105-
106-
1.+(2)
107-
108-
En estas partes: `1.`, `+`, y `2`. La razón que esta regla es elegida es porque `1.` es una coincidencia válida y es mayor que `1`, haciendo a este un `Double` en vez de un `Int`. Al escribir la expresión así:
109-
110-
(1).+(2)
111-
112-
previene que el `1` sea tomado como un `Double`.
113-
114104
### Las funciones son objetos
115105

116106
Tal vez suene más sorprendente para los programadores Java, las funciones en Scala también son objetos. Por lo tanto es posible pasar funciones como argumentos, almacenarlas en variables, y retornarlas desde otras funciones. Esta habilidad de manipular funciones como valores es una de las valores fundamentales de un paradigma de programación muy interesante llamado *programación funcional*.

Diff for: _it/tutorials/scala-for-java-programmers.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -168,26 +168,11 @@ un’espressione aritmetica come la seguente:
168168
consiste esclusivamente di chiamate a metodi e risulta equivalente alla
169169
seguente espressione, come visto nella sezione precedente:
170170

171-
(1).+(((2).*(3))./(x))
171+
1.+(2.*(3)./(x))
172172

173173
Questo significa anche che `+`, `*`, etc. sono identificatori validi in
174174
in Scala.
175175

176-
Le parentesi intorno ai numeri nella seconda versione sono necessarie
177-
perché l’analizzatore lessicale di Scala usa le regole di match più
178-
lunghe per i token quindi, dovrebbe dividere la seguente espressione:
179-
180-
1.+(2)
181-
182-
nei token `1.`, `+`, and `2`. La ragione per cui si è scelto questo tipo
183-
di assegnazione di significato è perché `1.` è un match più lungo e valido
184-
di `1`. Il token `1.` è interpretato come `1.0` rendendolo un `Double` e
185-
non più un `Int`. Scrivendo l’espressione come:
186-
187-
(1).+(2)
188-
189-
si evita che `1` sia interpretato come un `Double`.
190-
191176
### Le funzioni sono oggetti
192177

193178
Forse per i programmatori Java è più sorprendente scoprire che in Scala

Diff for: _ja/tutorials/scala-for-java-programmers.md

+1-16
Original file line numberDiff line numberDiff line change
@@ -138,25 +138,10 @@ Scala は、数値や関数を含む**あらゆるもの**がオブジェクト
138138
は、メソッド呼び出しのみから成り立っています。
139139
というのもこの式は、前節で見たように以下の式に相当するからです。
140140

141-
(1).+(((2).*(3))./(x))
141+
1.+(2.*(3)./(x))
142142

143143
これは `+``*` などが Scala では識別子として有効であることを意味します。
144144

145-
2つ目のバージョンでの数値の周りの括弧は必要です。
146-
というのも Scala の字句解析機(レキサー)は、字句(トークン)について最長マッチルールを使うからです。
147-
それゆえ、次の式
148-
149-
1.+(2)
150-
151-
は、字句 `1.``+`、そして `2` に分解されます。
152-
この字句分解が選ばれる理由は、`1.``1` よりも長い有効なマッチだからです。
153-
字句 `1.` はリテラル `1.0` として解釈され、`Int` ではなく `Double` となります。
154-
次のような書き方
155-
156-
(1).+(2)
157-
158-
は、`1``Double` として解釈されるのを防いでいます。
159-
160145
### 関数はオブジェクト
161146

162147
Scala では関数もオブジェクトです。

Diff for: _ko/tutorials/scala-for-java-programmers.md

+1-17
Original file line numberDiff line numberDiff line change
@@ -162,26 +162,10 @@ Java에서는 기본적인 타입(`boolean`이나 `int` 따위)과 참조 가능
162162
오직 함수 호출로만 이루어져 있다. 우리가 이전 장에서 보았듯이, 위의
163163
표현식은 아래의 표현식과 동일하다.
164164

165-
(1).+(((2).*(3))./(x))
165+
1.+(2.*(3)./(x))
166166

167167
위의 표현식처럼 `+`, `*` 등은 Scala에서 합법적인 식별자이다.
168168

169-
위의 두번째 표현식에서 괄호는 꼭 필요하다. 왜냐하면 스칼라의 렉서(lexer)는
170-
토큰들에 대하여 가장 긴 부분을 찾는 방법을 사용하기 때문이다. 아래의
171-
표현식은:
172-
173-
1.+(2)
174-
175-
세개(`1.`, `+`, `2`)의 토큰들로 분리된다. 이렇게 토큰들이
176-
분리되는 이유는 미리 정의되어 있는 유효한 토큰 중에 `1.`
177-
`1`보다 길기 때문이다. 토큰 `1.`은 리터럴 `1.0`으로
178-
해석 되어 `Double` 타입이 된다. 실제로 우리는 `Int` 타입을
179-
의도 했음에도 말이다. 표현식을 아래와 같이 쓰면:
180-
181-
(1).+(2)
182-
183-
토큰 `1``Double`로 해석 되는 것을 방지 할 수 있다.
184-
185169
### 함수마저 객체다
186170

187171
Java 프로그래머들에게는 놀라운 일이겠지만 Scala에서는 함수도

Diff for: _overviews/tutorials/scala-for-java-programmers.md

+1-17
Original file line numberDiff line numberDiff line change
@@ -167,27 +167,11 @@ arithmetic expression like the following:
167167
consists exclusively of method calls, because it is equivalent to the
168168
following expression, as we saw in the previous section:
169169

170-
(1).+(((2).*(3))./(x))
170+
1.+(2.*(3)./(x))
171171

172172
This also means that `+`, `*`, etc. are valid identifiers
173173
in Scala.
174174

175-
The parentheses around the numbers in the second version are necessary
176-
because Scala's lexer uses a longest match rule for tokens.
177-
Therefore, it would break the following expression:
178-
179-
1.+(2)
180-
181-
into the tokens `1.`, `+`, and `2`. The reason that
182-
this tokenization is chosen is because `1.` is a longer valid
183-
match than `1`. The token `1.` is interpreted as the
184-
literal `1.0`, making it a `Double` rather than an
185-
`Int`. Writing the expression as:
186-
187-
(1).+(2)
188-
189-
prevents `1` from being interpreted as a `Double`.
190-
191175
### Functions are objects
192176

193177
Functions are also

Diff for: _zh-cn/tutorials/scala-for-java-programmers.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,10 @@ Scala 是一个纯粹的面向对象语言,意即包括数字、函数在内
9797

9898
只有使用函数调用,因为像前一节一样,该式等价于
9999

100-
(1).+(((2).*(3))./(x))
100+
1.+(2.*(3)./(x))
101101

102102
这也表示着 `+``*` 之类的在 Scala 里是合法的标识符。
103103

104-
因为Scala的词法分析器对于符号采用最长匹配,在第二版的表达式当中,那些括号是必要的。也就是说分析器会把这个表达式:
105-
106-
1.+(2)
107-
108-
拆成 `1.``+``2` 这三个标记。会这样拆分是因为 `1.` 既是合法匹配的同时又比 `1` 长。 `1.` 会被解释成字面常数 `1.0`,使得它被视为 `Double` 而不是 `Int`。把表达式写成:
109-
110-
(1).+(2)
111-
112-
可以避免 `1` 被解释成 `Double`
113-
114104
### 函数是对象
115105

116106
Scala 中的函数也是对象,所以将函数当做对象传递、把它们存入变量、从其他函数返回函数都是可能的。能够像操作变量一样的操作函数这点是*函数式编程*这一非常有趣的程序设计思想的基石之一。

Diff for: _zh-tw/tutorials/scala-for-java-programmers.md

+1-11
Original file line numberDiff line numberDiff line change
@@ -97,20 +97,10 @@ Scala 是一個純粹的物件導向語言,這句話的意思是說,*所有
9797

9898
只有使用函式呼叫,因為像前一節一樣,該式等價於
9999

100-
(1).+(((2).*(3))./(x))
100+
1.+(2.*(3)./(x))
101101

102102
這也表示著 `+``*` 之類的在 Scala 裡是合法的識別符號。
103103

104-
因為Scala的詞法分析器對於符號採用最長匹配,在第二版的表示式當中,那些括號是必要的。也就是說分析器會把這個表示式:
105-
106-
1.+(2)
107-
108-
拆成 `1.``+``2` 這三個符號。會這樣拆分是因為 `1.` 既是合法匹配同時又比 `1` 長。 `1.` 會被解釋成字面常數 `1.0`,使得它被視為 `Double` 而不是 `Int`。把表示式寫成:
109-
110-
(1).+(2)
111-
112-
可以避免 `1` 被解釋成 `Double`
113-
114104
### 函式是物件
115105

116106
可能令 Java 程式員更為驚訝的會是,Scala 中函式也是物件。因此,將函式當做引數傳遞、把它們存入變數、從其他函式返回函式都是可能的。能夠像操作變數一樣的操作函式這點是*函數編程*這一非常有趣的程設典範的基石之一。

0 commit comments

Comments
 (0)