2007年10月20日土曜日

Metacircular Semantics for Common Lisp Special Forms (2)

This is done not just because such definitions can be entered and
quickly checked using a standard Common Lisp
implementation, but also because we feel that the
Common Lisp "macro" is the sanctioned mechanism for
adding new "special forms".

これら一連の考察において、我々の定義を標準的なの
Common Lispの実装を使用して手短に試すことができた、
というだけではなく、Common Lispのマクロは、新しい"
特殊形式"を加えるための手段として広く認知できるものだ、
という実感を持つことができた。
[ワカランナ]

While this view of
special forms is not evident from CLtL2
[Steele90], it should be obvious by the end of
this paper.

In short, the choice of which "macros"
are "special forms" is just as arbitrary as the
choice of a axes in a coordinate system for the
Cartesian X-Y plane--e.g., some sets of macros are
"linearly independent", and some sets of macros
"span" the space of special forms.

また一連の検証はCLtL2[Steele90]には準拠するもので
はない。このことは、この論文の文末にて詳細を述べる。

要約すると、"マクロ"を"特殊形式"とすることは、
あたかも、カーテシアン座標系のX-Y面で座標系の軸を
任意に選択することといえる--例えば、特殊形式の座標
空間において、いくつかのマクロは、線形独立で、また、
いくつかのマクロは範囲とみなせる。
[ナンデスカソレ]

Some of our emulations may only be approximate, in
the sense that certain syntactic variations are
not supported, and certain error conditions are
not recognized.
These emulations are meant to be
only a starting point for a serious effort in
pinning down the semantics of Common Lisp, and
significant additional effort will be required to
complete this task.[3]

いくつかの我々の試みは、これらが適切に文法的な変化
に対応できておらず、また適切にエラーを補足できない
という点で、大まかな外観を与えるに留まるかもしれな
いが、本格的なCommon Lispの意味論を明確にする取り
組みのまさに出発点に過ぎず、完遂には、多大な追加努
力が必要とするだろう。

The "Portable Common Loops" ("PCL") version of the
Common Lisp Object System (CLOS) exemplifies the
need for a more reflexive view of Common Lisp
special forms.

"Portable Common Loops" ("PCL")版のCommon Lisp
Object System (CLOS)は
よりCommon Lispの特殊形式の性質をより反映させた視
点が必要であることを例示している。

PCL does not quite live up to its
name, since it needs to diddle the representation
of function closures, which is different in every
Common Lisp implementation. Through the techniques
we exhibit here, a truly portable version of PCL
could be produced, thereby eliminating the need to
include CLOS in a Common Lisp standard.

PCLは、その名前の通り「ポータブル」なものにはなっ
ていないのが現状である。
Common Lispの実装ごとに違っている関数のクロージャ
表現については、実装ごとに対処するというごまかしも
必要になっている。
我々がここで述べる一連の技法のなかで、本来の意味で
「ポータブル」なPCLというものの実現が可能となった。
結果として、Common Lispの標準規格にCLOSを含める必
要性も排除することができた。

LAZY EVALUATION OF "IF"

The Common Lisp special form if is often thought
to be primitive, in the sense that it cannot be
defined in terms of other special forms.
Of
course, if can be defined in terms of cond or
case, so one of these macros could have been
chosen as the primitive conditional special form
rather than if.

Nevertheless, the lazy evaluation
of the "then" and the "else" arms of if can be
emulated by means of lambda, as the following
macro shows:

遅延評価版"IF"

Common Lispの特殊形式のプリミティブなものといえば、
他の特殊形式で再定義できないという意味で"if"が想起
されるのではないだろうか。
もちろん、実際には、"if"は、"cond"もしくは、"case"
によって定義可能であるし、これらのマクロはプリミティ
ブな特別形式による条件式として、"if"より好ましかっ
たかもしれないが、それはともかく、"if"の"then"節と、
"else"節のlambdaを使用した遅延評価による模倣は下記
の様なマクロとなる:
(setf (get 't 'select-function) #'(lambda (x y) (funcall x))
(get 'nil 'select-function) #'(lambda (x y) (funcall y)))

(defmacro if (be te &optional (ee ''nil))
`(funcall (get (not (not ,be)) 'select-function)
#'(lambda () ,te)
#'(lambda () ,ee)))

2007年10月19日金曜日

Metacircular Semantics for Common Lisp Special Forms (1)

Emacs(というテキストエディタ)の文章の選択範囲をGoogle翻訳に送って翻訳して返してくれるという拡張機能が非常に便利で、これなら英検の試験を受けたことさえない自分でもなんとか英語Lispの技術文章も読めるかも!という淡い期待を抱いた。
早速、面白そうな文章を拾って来ては訳してみることにした。

とりあえず、これ。
Metacircular Semantics for Common Lisp Special Forms
Henry G. Baker

で、早速開始。

Metacircular Semantics for Common Lisp Special Forms
Henry G. Baker

McCarthy's metacircular interpreter for Lisp has
been criticized by Reynolds and others for not
providing precise semantics.


マッカーシーによる「Lispのための超循環評価器」の提案はレイノルズを筆頭にそれが正確な意味論を提供していないものであると人々に評された。

Unfortunately, the alternative of English prose
currently favored by the ANSI X3J13 and ISO
committees for the definition of Common Lisp is
even less precise than a metacircular
interpreter.

しかし、残念ながら、現在(91年)ANSI X3J13とISO委員
会によって支持されている代替手段としての「英語の散
文」は超循環評価器にさえ、その正確さは及んでいない。
[ナンダ英語ノ散文ッテ]

Thus, while a system of denotational semantics á
la Scheme or ML could be developed for Common
Lisp, we believe that a carefully fashioned system
of metacircular definitions can achieve most of
the precision of denotational semantics.


SchemeもしくはML風の表層的な意味論をCommon Lisp上
に構築可能であった経験に基き、我々は、注意深く構築
された超循環的な定義は、表層的な意味論の大方を実現できるものと確信している。

Furthermore, a metacircular definition is also
more readable and understandable by the average
Common Lisp programmer, since it is written in
terms he mostly understands.


加えて、超循環的定義は、その定義がCommon Lispの用
語法に則したものとなっているため平均的なCommon Lisp
プログラマに理解しやすいものともなっている。

Finally, a metacircular definition
for Common Lisp special forms enables us to
transparently customize the representation of
certain "built-in" mechanisms such as function
closures, to enable sophisticated systems like
"Portable Common Loops" to become truly portable.


結論として、Common Lispの特殊形式の代替手段として
の超循環的定義は、あたかも関数のクロージャのような
"組み込み"の機構である表現を透過的にカスタマイズす
るような手段、もしくは、"Portable Common Loops"を
真にポータブルなものにすることを可能とするような手
段を提供するといえるだろう。

INTRODUCTION


序論

Members of software standards committees should be
required to take the Hippocratic Oath, which
admonishes the neophyte physician to "first, do no
harm!".


ソフトウェア規格委員会のメンバーは「ヒポクラテスの
誓い」(「第一に、害を与えない」というヒポクラテス
による新米医師への戒しめの言葉)を手本とするべきで
ある。

[1] In other words, before any therapy is
prescribed, first make sure that it will not make
the patient worse off.

We believe that the use of
natural language (e.g., English) in the currently
proposed Lisp standards is much worse than
McCarthy's metacircular interpreter, even with its
faults.


[1] 言い換えれば、どんな治療法であれ、施術が患者を
より悪くすることがあってはならない。
現在提案されている自然言語(例えば、英語)の適用
は、多少の欠陥を含むマッカーシーの超循環評価器
よりも、はるかに劣ったものであると我々は考える。
[批判ノ歴史的背景がワカンネカラ意味ワカンネ]

[2] We suggest that a Lisp software
standard has much to gain by utilizing its own
uniquely powerful tools to make the language
standard both readable and precise.


[2] 我々は、Lispのソフトウェア規格とは、実際に利用
する上で、可読性においても、定義の正確さにおい
ても、言語自身の性格がより良く、より強く反映さ
れた言語規格でなくてはならないと提案したい。
[ナニイッテルカ分カンネ]

In the following sections, we will develop a
series of definitions of various Common Lisp
special forms in terms of one another. While these
definitions, by themselves, will not pin down the
semantics of Common Lisp completely, they can be
used in conjunction with a rough understanding of
Common Lisp semantics to understand the less usual
cases of interactions of the various features.


以下のセクションで我々は、一連のCommon Lispの特殊
形式をそれぞれの代替法へと逐次展開させる。
これらの定義の中には、Common Lisp的意味論を完全に
は満足させないものもあるだろうが、それらは逆にCommon
Lispの意味論の大まかな理解を促すことにつながるだろう。
また、それが多数を占めることはないことは理解して欲しい。
[ナニイッテルカ分カンネ]

We use defmacro to define a special form in terms
of other forms,
and perhaps in terms of simpler
versions of the form itself.


我々は、特殊形式で定義されているものを新たな代替形
式へと定義するにあたって"defmacro"を使用するが、恐
らく、元の形式より単純なものとして定義されることに
なるだろう。

----- 続く。---------

感想:
やっぱり便利なツールがあっても英語力がさっぱりだから全然無理だなー。まあ、良いや。とりあえず薄ぼんやりとは分かるから。
Yahoo翻訳の方がもっと気の効いた訳を返してくれるので、Yahoo翻訳使えないかなー。