23 points · by akkartik · 14y ago · 15 comments
* 'code-as' is a bit of a strange statement as it implies two-steps from an original object - as you are taking something encoded ('code') and translating it to something else ('as').
* 'code-as-text' should be 'code-as-representation' at least (you needn't represent anything as text if you dont want to - it could be coloured geometric shapes...)
* I don't understand what 'code-as-procedure' means either. Is this an abstract-syntax-tree or just platform-executable-code?
* 'code-as-data' is meaningless because everything is data, both the text and procedure... Does the OP mean something platform-executable? Or something within a type system?
Good topic to launch discussion on though....
'behaviour-as-text' is the serialization of the behaviour model according to the grammar of the language.
'behaviour-as-data' is the model representation as it is viewed and modified in the model.
'behaviour-as-procedure' is the meaning of the model in the sense of execution. The semantics of the model.
So this text says that the semantics of the behaviour model need to be easily expressed as data, and the textual representation of the model must clearly show both its semantics and its data representation.
1 "data must express procedure"
2 "text must express procedure"
3 "text must express data"
This shows that text both directly expresses procedure by rule 2, and indirectly by rule 1 via rule 3. This indirection step allows recursion to take place (i.e. the data contains a model in the same language as it is defined in) that is used for the model to reason about itself.
> Metaprogramming is the language feature that helps you write code that you won't be able to understand once the cocaine wears off.
From: http://c2.com/cgi/wiki?HomoiconicLanguages
I didn't.
A program always has both kinds of representation. Without a textual representation, no one could write or read it. Without a runtime representation, it couldn't be executed. But usually it is complicated to translate between the two. In Lisp (the classic homoiconic language), these representations are so similar that it is trivial to translate from one to the other and back again. That's what makes Lisp good for metaprogramming (writing programs that manipulate other programs): it's so easy to go back and forth between the human-friendly representation (source code) and the runtime representation (data) that a whole class of new techniques arises.
And how could "code-as-procedure" fail to be easy to express using "code-as-data"?
Isn't it more essential that "code-as-data" should be easy to express in "code-as-text"? (As that's where languages like Lisp and ML, that have quasiquotation, excel).
I suspect this is a reflection on me more than the koan, but I also think my reaction would probably not be uncommon among the unenlightened.
Metaprogramming involves three things: the code as text, the code as program, and the code as data.
The text (often called the source code) is what programmers read and write. The program is what the code does. The data is how the code is represented to other programs.
A good language for metaprogramming requires two things: the program must be easily expressible as data, and the text must clearly evoke both the program and the data in the mind of the coder.
...but, AFAIK, a Koan tries to thwart understanding in order to communicate an otherwise impossible to describe concept. By preventing understanding yet asking for investigation, a koan communicates its actual content through your investigation, rather than the successful translation of the words into your thoughts.