剛剛看了一個貼子,某人想實現個LOGO,問LOGO的標準。結果回答是很出乎意料的,LOGO大會曾經討論過這個問題,但卻因爲各種LOGO實現之間的差別太大而沒有一個統一的標準。LOGO的語法本來就十分簡單,但是在這種簡單當中,各種LOGO的實現的語法是相當不同的。就連著名的“龜圖”也不是所有的LOGO實現都有的。最後一句話,所有LOGO共有的東西只有:
1. 數據結構:字和表。
2. 操作他們的FIRST, LAST, BUTFIRST等東西
貼子來自comp.lang.logo:
>Does anybody know of a good language definition available for logo.
At one of the Logo conferences several years ago I ran a session in
which the possibility of a standard was discussed. Many of the Logo
implementors were there, as well as many users. We ended up with
the conclusion that no standard was possible, because there were too
many serious disagreements about syntax, and also because the set of
primitive procedures was constantly in flux.
The main syntactic disagreement was about special forms. In LCSI Logo
and products derived from it, TO is the only exception to the rule that
inputs are evaluated before a procedure is invoked. For example, to
edit a procedure named FOO you must say
EDIT "FOO
so that the word FOO, the procedure's name, is the value of the input
to EDIT. By contrast, in MIT-derived dialects (such as Terrapin), several
primitive procedures are treated as exceptions, so you must say
EDIT FOO
to edit the procedure named FOO.
The advantage of the latter (special form) syntax is that it's more
obvious to a beginner, especially a young one.
The advantage of the former (evaluated) syntax is that it's a more
general mechanism. For example, suppose I have a bunch of procedures
that I want to consider as a unit. I can say
TO MYPROCS
OUTPUT [PROC1 PROC2 PROC3]
END
and then use the instruction
EDIT MYPROCS
to edit those three procedures. In Terrapin syntax it would instead
edit the procedure MYPROCS itself, which isn't what I want this time.
Also, in the long run (some of us think) it's easier to understand;
in MIT-derived dialects you still have to say
MAKE "VAR value
to assign a value to the variable VAR, so you have to explain to
students why you need quotes in that case but not for EDIT!
(Current Terrapin Logo accepts
EDIT (MYPROCS)
to mean that MYPROCS should be invoked to produce a list of procedures
to edit. This gives Terrapin the power of the LCSI notation, at the
cost of adding another special meaning, this time for parentheses, but
it's not documented in their manual.)
Some really recent versions have even more different notations, moving
away from the whole idea of variables, so instead of using MAKE to set
the value and using :VAR to retrieve it, you have procedures SETVAR
and VAR for those purposes, and there are no variables at all.
As for the semantics, what are the essential features of Logo? There
have been versions without turtle graphics, such as the "Music Logo"
that Terrapin sold for the Apple II in which graphics primitives were
replaced with sound generation primitives. At MIT there is a project
in which a small computer is mounted in a Lego brick; it has a different
primitive set from the typical keyboard-and-screen computer. At the
meeting all we agreed on was that anything called Logo should have
the word and list processing primitives (FIRST, BUTFIRST, LAST, BUTLAST,
WORD, SENTENCE, etc.).
[Posted and mailed.]