LINUX.ORG.RU

ГЫ.

Мне вот это очень понравилось:

The whole notion of data vs. programs sucks. XML is based on that notion, sexprs aren't. This is why sexprs are superior. To illustrate this point, here is a macro in Common Lisp:

 (defmacro dictionary (&rest words)
  `(progn
	(format t "<dictionary>~%")
	(dolist (word ',words)
	(format t "  <word>~%")
	(format t "	<id>~A</id>~%" (first word))
	(format t "	<def>~S</def>~%" (second word))
	(format t "  </word>~%"))
	(format t "</dictionary>~%")))

Now, when I enter the following sexpr...

 (dictionary
	(xml "data language")
	(java "programming language")
	(lisp "programming and data language"))

...I get the following result:

 <dictionary>
	<word>
	<id>xml</id>
	<def>"data language"</def>
	</word>
	<word>
	<id>java</id>
	<def>"programming language"</def>
	</word>
	<word>
	<id>lisp</id>
	<def>"programming and data language"</def>
	</word>
 </dictionary>

Conclusion: sexprs include XML as a subset (or any other representation) qua Lisp. (Note that the macro is also written as an sexpr, and is in fact also just a data structure that is compiled/interpreted by the Lisp runtime. See MetaCircularInterpreter for more insights into the resolution of the prorgram/data dichotomy.)
-------------
 The whole notion of data vs. programs sucks. XML is based on that notion, sexprs aren't. This is why sexprs are superior.

Interestingly, the exact opposite -- i.e., that s-expressions are based on that notion and XML isn't, and hence that XML is superior to s-expressions -- is equally true (i.e., completely untrue). To illustrate this point, here is a pair of XSLT templates (arguably even more straightforward than the CL macro):

 <xsl:template match="dictionary">
	<xsl:text>(dictionary</xsl:text>
	<xsl:apply-templates />
	<xsl:text>)&#10;</xsl:text>
 </xsl:template>


 <xsl:template match="word">
	<xsl:text>&#10; (</xsl:text>
	<xsl:value-of select="id" />
	<xsl:text> &quot;</xsl:text>
	<xsl:value-of select="def" />
	<xsl:text>&quot;)</xsl:text>
 </xsl:template>

Now, when I enter the following XML,

 <dictionary>
	<word>
	<id>xml</id>
	<def>data language</def>
	</word>
	<word>
	<id>java</id>
	<def>programming language</def>
	</word>
	<word>
	<id>lisp</id>
	<def>programming and data language</def>
	</word>
 </dictionary>

I get the following result:

 (dictionary
	(xml "data language")
	(java "programming language")
	(lisp "programming and data language"))

Conclusion: XML includes s-expressions (or any other representation) as a subset qua XSLT. (Note that the templates are also written as XML, and are in fact also just data structures that are compiled/interpreted by the XML processor.) [Note in case this gets taken out of context: This was meant as a parody of a corresponding claim for s-expressions and against XML.] -- DanielBrockman

CrazyPit ★★★
()

Infoset XML не тождественнен семантике S-выражений - нет аналога точки .

Ну и из того, что XSLT - Тьюринг-полный язык, ещё вовсе не следует, что на этом угрёбище можно что либо путное написать. Brainfuck - и тот лучше. ;)

Howler
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.