Hi all,
at PilCon three days ago we discussed about FEXPRs like
(de <p> Prg
(prin "<p>")
(run Prg)
(prin "</p>") )
(de <div> (Col . Prg)
(prin "<div class=\"" Col "\">")
(run Prg)
(prin "</div>") )
which can be called as
(<div> "red" (<p> (prin "Text")))
giving such output:
<div class="red"><p>Text</p></div>
One question that came up was why FEXPRs could not be replaced with normal
functions (EXPRs), simply 'pack'ing strings:
(de <p> (Str)
(pack "<p>" Str "</p>") )
(de <div> (Col Str)
(pack
"<div class=\""
Col
"\">"
Str
"</div>" ) )
: (<div> "red" (<p> "Text"))
-> "<div class=\"red\"><p>Text</p></div>"
While this would surely work, I answered that it is a big overhead to generate
the whole page as strings just to print them.
But I forgot to explain: The real reason for FEXPRs goes beyond that. They have
the power of passing executable code bodies, with arbitrary flow control, to the
function.
To pick just a minimal example:
(<div> "red"
(for S '("ABC" "DEF" "GHI")
(prinl)
(<p> (prin S)) )
(prinl) )
<div class="red">
<p>ABC</p>
<p>DEF</p>
<p>GHI</p>
</div>
This cannot be done with EXPRs.
☺/ A!ex
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe