Skip to content

Remove wrong information related to changes in float tokenisation. #1432

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

Merged
merged 2 commits into from
Jul 22, 2019
Merged
Show file tree
Hide file tree
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
16 changes: 1 addition & 15 deletions _de/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,10 @@ der folgende
exklusiv aus Methoden-Aufrufen, da es äquivalent zu folgendem Ausdruck ist, wie in vorhergehenden
Abschnitt gezeigt wurde:

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

Die Zahlen umschließenden Klammern der zweiten Variante sind notwendig, weil Scalas lexikalischer
Scanner eine Regel zur längsten Übereinstimmung der Token verwendet. Daher würde der folgende
Ausdruck:

1.+(2)

in die Token `1.`, `+`, und `2` zerlegt werden. Der Grund für diese Zerlegung ist, dass `1.` eine
längere, gültige Übereinstimmung ist, als `1`. Daher würde das Token `1.` als das Literal `1.0`
interpretiert, also als Gleitkommazahl anstatt als Ganzzahl. Den Ausdruck als

(1).+(2)

zu schreiben, verhindert also, dass `1.` als Gleitkommazahl interpretiert wird.

### Funktionen sind Objekte

Vermutlich überraschender für Java-Programmierer ist, dass auch Funktionen in Scala Objekte sind.
Expand Down
12 changes: 1 addition & 11 deletions _es/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,10 @@ Ya que los números son objetos, estos también tienen métodos. De hecho, una e

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

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

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:

1.+(2)

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í:

(1).+(2)

previene que el `1` sea tomado como un `Double`.

### Las funciones son objetos

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*.
Expand Down
17 changes: 1 addition & 16 deletions _it/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,11 @@ un’espressione aritmetica come la seguente:
consiste esclusivamente di chiamate a metodi e risulta equivalente alla
seguente espressione, come visto nella sezione precedente:

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

Le parentesi intorno ai numeri nella seconda versione sono necessarie
perché l’analizzatore lessicale di Scala usa le regole di match più
lunghe per i token quindi, dovrebbe dividere la seguente espressione:

1.+(2)

nei token `1.`, `+`, and `2`. La ragione per cui si è scelto questo tipo
di assegnazione di significato è perché `1.` è un match più lungo e valido
di `1`. Il token `1.` è interpretato come `1.0` rendendolo un `Double` e
non più un `Int`. Scrivendo l’espressione come:

(1).+(2)

si evita che `1` sia interpretato come un `Double`.

### Le funzioni sono oggetti

Forse per i programmatori Java è più sorprendente scoprire che in Scala
Expand Down
17 changes: 1 addition & 16 deletions _ja/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,25 +138,10 @@ Scala は、数値や関数を含む**あらゆるもの**がオブジェクト
は、メソッド呼び出しのみから成り立っています。
というのもこの式は、前節で見たように以下の式に相当するからです。

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

2つ目のバージョンでの数値の周りの括弧は必要です。
というのも Scala の字句解析機(レキサー)は、字句(トークン)について最長マッチルールを使うからです。
それゆえ、次の式

1.+(2)

は、字句 `1.`、`+`、そして `2` に分解されます。
この字句分解が選ばれる理由は、`1.` は `1` よりも長い有効なマッチだからです。
字句 `1.` はリテラル `1.0` として解釈され、`Int` ではなく `Double` となります。
次のような書き方

(1).+(2)

は、`1` が `Double` として解釈されるのを防いでいます。

### 関数はオブジェクト

Scala では関数もオブジェクトです。
Expand Down
18 changes: 1 addition & 17 deletions _ko/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,26 +162,10 @@ Java에서는 기본적인 타입(`boolean`이나 `int` 따위)과 참조 가능
오직 함수 호출로만 이루어져 있다. 우리가 이전 장에서 보았듯이, 위의
표현식은 아래의 표현식과 동일하다.

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

위의 두번째 표현식에서 괄호는 꼭 필요하다. 왜냐하면 스칼라의 렉서(lexer)는
토큰들에 대하여 가장 긴 부분을 찾는 방법을 사용하기 때문이다. 아래의
표현식은:

1.+(2)

세개(`1.`, `+`, `2`)의 토큰들로 분리된다. 이렇게 토큰들이
분리되는 이유는 미리 정의되어 있는 유효한 토큰 중에 `1.`이
`1`보다 길기 때문이다. 토큰 `1.`은 리터럴 `1.0`으로
해석 되어 `Double` 타입이 된다. 실제로 우리는 `Int` 타입을
의도 했음에도 말이다. 표현식을 아래와 같이 쓰면:

(1).+(2)

토큰 `1`이 `Double`로 해석 되는 것을 방지 할 수 있다.

### 함수마저 객체다

Java 프로그래머들에게는 놀라운 일이겠지만 Scala에서는 함수도
Expand Down
18 changes: 1 addition & 17 deletions _overviews/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,11 @@ arithmetic expression like the following:
consists exclusively of method calls, because it is equivalent to the
following expression, as we saw in the previous section:

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

The parentheses around the numbers in the second version are necessary
because Scala's lexer uses a longest match rule for tokens.
Therefore, it would break the following expression:

1.+(2)

into the tokens `1.`, `+`, and `2`. The reason that
this tokenization is chosen is because `1.` is a longer valid
match than `1`. The token `1.` is interpreted as the
literal `1.0`, making it a `Double` rather than an
`Int`. Writing the expression as:

(1).+(2)

prevents `1` from being interpreted as a `Double`.

### Functions are objects

Functions are also
Expand Down
12 changes: 1 addition & 11 deletions _zh-cn/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,10 @@ Scala 是一个纯粹的面向对象语言,这句话的意思是说,*所有

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

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

因为Scala的词法分析器对于符号采用最长匹配,在第二版的表达式当中,那些括号是必要的。也就是说分析器会把这个表达式:

1.+(2)

拆成 `1.`、`+`、`2` 这三个标记。会这样拆分是因为 `1.` 既是合法匹配的同时又比 `1` 长。 `1.` 会被解释成字面常数 `1.0`,使得它被视为 `Double` 而不是 `Int`。把表达式写成:

(1).+(2)

可以避免 `1` 被解释成 `Double`。

### 函数是对象

可能令 Java 程序员更为惊讶的会是,Scala 中函数也是对象。因此,将函数当做对象传递、把它们存入变量、从其他函数返回函数都是可能的。能够像操作变量一样的操作函数这点是*函数式编程*这一非常有趣的程序设计思想的基石之一。
Expand Down
12 changes: 1 addition & 11 deletions _zh-tw/tutorials/scala-for-java-programmers.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,10 @@ Scala 是一個純粹的物件導向語言,這句話的意思是說,*所有

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

(1).+(((2).*(3))./(x))
1.+(2.*(3)./(x))

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

因為Scala的詞法分析器對於符號採用最長匹配,在第二版的表示式當中,那些括號是必要的。也就是說分析器會把這個表示式:

1.+(2)

拆成 `1.`、`+`、`2` 這三個符號。會這樣拆分是因為 `1.` 既是合法匹配同時又比 `1` 長。 `1.` 會被解釋成字面常數 `1.0`,使得它被視為 `Double` 而不是 `Int`。把表示式寫成:

(1).+(2)

可以避免 `1` 被解釋成 `Double`。

### 函式是物件

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