Skip to content

Commit ce16335

Browse files
committed
Tweaking grammar and spelling, translating various paragraphs in chapter 18
1 parent 6f062a1 commit ce16335

File tree

1 file changed

+31
-39
lines changed

1 file changed

+31
-39
lines changed

chapter18.textile

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ h4. `require`
3131

3232
`require` has four features:
3333

34-
* the file is searched in the load path
34+
* the file is searched for in the load path
3535
* it can load extension libraries
3636
* the `.rb`/`.so` extension can be omitted
3737
* a given file is never loaded more than once
3838

39-
Ruby's load path is in the global variable `$:` that contains an
39+
Ruby's load path is in the global variable `$:`, which contains an
4040
array of strings. For example, displaying the content of the `$:` in
4141
the environment I usually use would show:
4242

@@ -50,7 +50,7 @@ the environment I usually use would show:
5050
.
5151
</pre>
5252

53-
Calling `puts` on an array displays one element by line so it's easy
53+
Calling `puts` on an array displays one element on each line so it's easy
5454
to read.
5555

5656
As I ran `configure` using `--prefix=/usr`, the library path is
@@ -106,7 +106,7 @@ The are two reasons for adding the missing extension. The first one is
106106
not to load it twice if the same file is later `require`d with its
107107
extension. The second one is to be able to load both `nkf.rb` and
108108
`nkf.so`. In fact the extensions are disparate (`.so .dll .bundle`
109-
etc.) depending of the platform, but at locking time they all become
109+
etc.) depending on the platform, but at locking time they all become
110110
`.so`. That's why when writing a Ruby program you can ignore the
111111
differences of extensions and consider it's always `so`. So you can
112112
say that `ruby` is quite UNIX oriented.
@@ -193,10 +193,10 @@ For the second point, the functions that appear in this chapter come
193193
from 4 different files, `eval.c ruby.c file.c dln.c`. We'll look at
194194
the reason they are stretched in different places.
195195

196-
The third point is just like its name says. We will see how works the
196+
The third point is just like its name says. We will see how the
197197
currently popular trend of execution time loading, more commonly
198-
referred to as plug-ins. This is the most important part of this
199-
chapter so I'd like to use as many pages as possible to talk about it.
198+
referred to as plug-ins, works. This is the most important part of this
199+
chapter, so I'd like to use as many pages as possible to talk about it.
200200

201201
h2. Searching the library
202202

@@ -396,7 +396,7 @@ words locks the file.
396396

397397
The problem comes after. Like the comment says "the loading of Ruby
398398
programs is serialised". In other words, a file can only be loaded
399-
from one thread, and if during the loading a thread tries to load the
399+
from one thread, and if during the loading another thread tries to load the
400400
same file, that thread will wait for the first loading to be finished.
401401
If it were not the case:
402402

@@ -464,12 +464,12 @@ part inside `rb_f_require()`'s `load_rb` loading Ruby programs.
464464
(eval.c)
465465
</pre>
466466

467-
Here the `rb_load()` that is called is in fact the real form of the
468-
Ruby level load.
469-
470-
さてここで呼んでいる`rb_load()`、これは実はRubyレベルの`load`の実体である。
467+
The `rb_load()` which is called here is actually the "meat" of the
468+
Ruby-level `load`.
471469
ということは探索がもう一回必要になるわけで、同じ作業をもう一回見るなん
472470
てやっていられない。そこでその部分は以下では省略してある。
471+
472+
And since the second argument (`wrap`) passed to `rb_load` in the above code is 0, the call is wrapped in 0. (*** What is this supposed to mean??? That the nesting level is 0?)
473473
また第二引数の`wrap`も、上記の呼び出しコードで0なので、0で畳み込んである。
474474

475475
▼ `rb_load()` (simplified edition)
@@ -596,14 +596,14 @@ load_file(fname, /* script=0 */)
596596
}
597597
</pre>
598598

599-
(A) In practice, the try to open using `fopen()` is to check if the
599+
(A) The call to `fopen()` is to check if the
600600
file can be opened. If there is no problem, it's immediately closed.
601601
It may seem a little useless but it's an extremely simple and yet
602602
highly portable and reliable way to do it.
603603

604604
(B) The file is opened once again, this time using the Ruby level
605605
library `File.open`. The file was not opened with `File.open` from the
606-
beginning not to raise any Ruby exception if the file cannot be
606+
beginning so as not to raise any Ruby exception if the file cannot be
607607
opened. Here if any exception occurred we would like to have a
608608
loading error, but getting the errors related to `open`, for example
609609
`Errno::ENOENT`, `Errno::EACCESS`..., would be problematic. We are in
@@ -638,14 +638,13 @@ can be open, but in fact during the loading process other functions
638638
like for example `rb_find_file_ext()` also do checks using `open`. How
639639
many times is `open()` called in the whole process?
640640

641-
と思ったら実際に数えてみるのが正しいプログラマのありかただ。システムコー
642-
ルトレーサを使えば簡単に数えられる。そのためのツールはLinuxなら
643-
`strace`、Solarisなら`truss`、BSD系なら`ktrace`か`truss`、
641+
If you're wondering that, it's just a matter of having the right program available to count and see. You can easily find out using a system call tracer. On Linux, the tool to use would be `strace`; on Solaris, `truss`; or on BSD, `ktrace` or `truss`.
642+
644643
というように
645644
OSによって名前がてんでバラバラなのだが、Googleで検索すればすぐ見付かる
646-
はずだ。WindowsならたいていIDEにトレーサが付いている。
647645

648-
Well, as my main environment is Linux, I looked using `strace`.
646+
If you're using Windows, probably your IDE will have a tracer built in. Well, as my main environment is Linux, I looked using `strace`.
647+
649648
The output is done on `stderr` so it was redirected using `2>&1`.
650649

651650
<pre class="screen">
@@ -694,10 +693,10 @@ part about locking anymore so it was removed.
694693
(eval.c)
695694
</pre>
696695

697-
もはやほとんど目新しいものはない。タグはイディオム通りの使いかた
696+
By now, there is very little here which is novel. タグはイディオム通りの使いかた
698697
しかしていないし、可視性スコープの退避・復帰も見慣れた手法だ。
699-
残るのは`dln_load()`だけである。これはいったい何をしているのだろう。
700-
というところで次に続く。
698+
All that remains is `dln_load()`. What on earth is that for? For the answer, continue to the next section.
699+
701700

702701
h3. リンクについて復習
703702

@@ -722,15 +721,14 @@ Linuxで`gcc`を使っているので、次のようにすれば動くプログ
722721
Hello, World!
723722
</pre>
724723

725-
ちゃんとできている。
724+
It prints out just as expected.
726725

727-
ところで、いま`gcc`は実際には何をしたのだろうか。普段はコンパイル、
728-
コンパイルと言うことが多いが、実際には
726+
By the way, what is `gcc` actually doing here? Usually we just say is "compiles", but actually it...
729727

730-
# プリプロセス(`cpp`)
731-
# C言語をアセンブラにコンパイル(`cc`)
732-
# アセンブラを機械語にアセンブル(`as`)
733-
# リンク(`ld`)
728+
# Preprocesses (`cpp`)
729+
# Compiles C into assembly (`cc`)
730+
# Assembles the assembly language into machine code (`as`)
731+
# Links (`ld`)
734732

735733
という四つの段階を通っている。このうちプリプロセス・コンパイル・アセン
736734
ブルまではいろいろなところで説明を見掛けるのだが、なぜかリンクの段階だ
@@ -798,16 +796,10 @@ Hello, World!
798796

799797
h3. 真にダイナミックなリンク
800798

801-
さてそろそろ本題に入ろう。ダイナミックリンクの「ダイナミック」は当然
802-
「実行時にやる」という意味だが、普通に言うところのダイナミックリンクだ
803-
と実はコンパイル時にかなりの部分が決まっている。例えば必要な関数の名前
804-
は決まっているだろうし、それがどこのライブラリにあるかということももう
805-
わかっている。例えば`cos()`なら`libm`にあるから`gcc -lm`という
806-
感じでリ
807-
ンクするわけだ。コンパイル時にそれを指定しなかったらリンクエラーになる。
799+
And finally we get into our main topic. The "dynamic" in "dynamic linking" naturally means it "occurs at execution time", but what people usually refer to as "dynamic linking" is pretty much decided already at compile time. For example, the names of the needed functions, and which library they can be found in, are already known. For instance, if you need `cos()`, you know it's in `libm`, so you use `gcc -lm`. If you didn't specify the correct library at compile time, you'd get a link error.
808800

809-
しかし拡張ライブラリの場合は違う。必要な関数の名前も、リンクするライブ
810-
ラリの名前すらもコンパイル時には決まっていない。文字列をプログラムの実
801+
But extension libraries are different. Neither the names of the needed functions, or the name of the library which defines them are known at compile time.
802+
文字列をプログラムの実
811803
行中に組み立ててロード・リンクしなければいけないのである。つまり先程の
812804
言葉で言う「論理結合」すらも全て実行時に行わなければならない。そのため
813805
には普通に言うところのダイナミックリンクとはまた少し違う仕組みが必要に
@@ -910,7 +902,7 @@ dln_load(file)
910902

911903
h3. `dln_load()`-`dlopen()`
912904

913-
まず`dlopen`系のAPIのコードから行こう。
905+
First, let's start with the API code for the `dlopen` series.
914906

915907
▼ `dln_load()`-`dlopen()`
916908
<pre class="longlist">

0 commit comments

Comments
 (0)