Some heretic operator definitions for embedded HTML

Without the discussion here, I wouldn’t have tried that!

Is this for real? Recently the following worked for me.
Unlike other Prolog systems, SWI-Prolog allows the overloading
of > both infix and postfix in the first operator directive:

:- op(900, xf, >).
:- op(910, fx, <).
:- op(910, fx, </).
:- op(0, fx, table).

I can then enter a Prolog text:

table :-
    <table>,
    rows,
    </table> .

And the SWI-Prolog system can even list it:

?- listing(table/0).
table :-
    <table>,
    rows,
    </table> .

Was this already used by somebody? Would it be possible to define that
<...> respectively </...> call some html_begin/1 respectively
html_end/1. But without the need for DCG, they would simple write

immediately to the standard output. But is this operator definition
somehow safe to write code. What are the pitfalls?

2 Likes