3 ms·
Can someone explain the difference between an S-expression and an X-expression? Even after reading the blog post I'm not following, seem like the same thing to
by didibus 7y ago
Can someone explain the difference between an S-expression and an X-expression? Even after reading the blog post I'm not following, seem like the same thing to me.
- tartoran 7y agoStarted dabling recently so Im not an expert on the subject, but from my understanding, Racket represents XML data as an X-expression. On the other hand symbolic expressions aka s-expressions are the syntactic elements of the Lisp programming language. Both programs and data are represented as s-expressions: an s-expression may be either an atom or a list. So x-expressions relate to XML
- soegaard 7y agoGenerating HTML is a common task. Over the years we have seen multiple approaches in the Racket community. Representing HTML as S-expressions is common. There is even two approaches in use `xexprs` and `sxml`. There are other solutions, such as representing HTML as structures (often called records in other languages). This is what I prefer - this allows a little static checking. (See `scribble/html` or `urlang/html`). Others prefer to work with `templates`. My point got lost: There is more than one "Racket way" of working with html.
- soegaard 7y agoX-expressions (as [1]) is simply a subset of S-expressions. [1] https://docs.racket-lang.org/teachpack/2htdpbatch-io.html?q=xepr#%28def._%28%28lib._2htdp%2Fbatch-io..rkt%29._xexpr~3f%29%29 https://docs.racket-lang.org/teachpack/2htdpbatch-io.html?q=...