Printing categories
I/O, Modules and System Interface
WCL syntax
Reading

WCL syntax [XL]

XL CLAIRE comes with a new printing facility called WCL syntax standing for Web CLaire syntax due to its design originally meant for web oriented applications with generation of dynamic content. WCL syntax draws its inspiration from HTML and the ability to embed CLAIRE code in such language. It comes as a printing alternative to printf and also perform inline substitution. For instance, here is a simple WCL fragment and its printf equivalent :
 ?>Hello world<? <=> printf("Hello world")
A WCL fragment is introduced with the keyword ?> which is the beginning of a static string terminated by the corresponding keyword <? substituted at read time by a call to princ. As a convenience a WCL fragment may not be delimited with a coma as shown in the following equivalent forms :
 ?>toto<? princ("titi"?>tata<?
 ?>toto<? princ("titi"), ?>tata<?
 ?>toto<? princ("titi"), ?>tata<?
 ?>toto<? princ("titi"?>tata<?
 princ("tototititata")
As in a printf construction a WCL fragment can invoke a method take an argument, this is achieved by postfixing the selector of the call to the <? keyword as in :
 ?>toto<?princ "titi" <=> princ("tototiti")
As a notation shortcut, three special forms are allowed for the postfixed selector :
 ?>toto<?= <exp<=> princ("toto"), echo(<exp>)
 ?>toto<?== <exp<=> princ("toto"), self_html(<exp>)
 ?>toto<?oid <exp<=> princ("toto"), princ(Core/Oid(<exp>))
Where echo and self_html and both extensible. The last form (oid) may be used to produce a unique printed value for the given expression <exp>. By default echo behave like princ for primitive objects (integers, floats, chars and strings) and self_print for other objects. self_html behave like echo but also perform conversion for special HTML entities :

As a summary, a WCL fragment as the following syntax :
 <wcl fragment= < ?> <text> <? < <= | == | oid | property> <exp> >opt >
As a last sample here is a code that would generate an HTML table with 10 rows and ten columns where each cell contains its coordinates in the table :
 ?><table><?
     for y in (1 .. 10)
         ( ?><tr><?
             for x in (1 .. 10) ( ?><td><?= x ?>,<?= y))
 ?></table><?