Quasi-quotations, again

While I am interested in what you are doing with quasiquotations with SWI-Prolog, in doing some back research for my own understanding a few weeks ago found the following of value:

Quasiquotation in Lisp by Alan Bawden
Why It’s Nice to be Quoted: Quasiquoting for Haskell by Geoffrey B. Mainland
Why It’s Nice to be Quoted: Quasiquoting for Prolog by Jan Wielemaker
and Michael Hendricks
library(quasi_quotations): Define Quasi Quotation syntax
Package uri_qq by Michael Hendricks - This seems to predate the implementation of quasiquotations in SWI-Prolog and shows some of the same steps others have taken. The reason this is interesting is that it is a natural stepping stone from formatting text to quasiquotations but shows a different syntax than the SWI-Prolog implementation. It reminds me more of string interpolation.
Haskell: Quasiquotation
Wikipedia - String interpolation
Wikipedia - Quasi-quotation

IMHO one should read the history in the papers for what quasiquotations solve or why it was added to a programming language. This then gives one an understanding of why certain options were not used and what specific problems quasiquotations solve. This then helps to understand how to use quasiquotations, etc.

Remember the post about parsing JSON and the difference between parsing JSON with syntax rules and parsing JSON with semantic rules. I plan to see how effective quasiquotations are for the semantic check.

One other thing I am finding is that in some ways quasiquotations used with DCGs are like BNF and BNF is like algebraic data types and algebraic data types can be used like a typing system, so if you have some input that you want to type check, you don’t need to decorate the text with types, but instead pass the text to a quasiquotation and if the quasiquotation is done correctly will do the semantic check and the typing check. I don’t know how close this is to Hindley–Milner type system but the bonus is that you can infer types from untyped text.

So what is the point of all of this for where I am headed and why my interest in quasiquotations? When you have a web server or such receiving text input you want to make sure it is not an attack. Thus create a quasiquotation for the allowed text and it should toss out all but valid input. Also along the way the quasiquotation should pull out the needed argument values, (think Command-line argument parsing but on steroids).
:slightly_smiling_face:

1 Like