I'm slowly winding my way up the learning curve by adapting Joel Dueck's 
work to a personal web-book I want to write. 
I've hit a snag due to my limited understanding of racket, probably. 


The template.pdf.p files contains the following line to generate a nicely 
formatted LaTex date:
\date{◊(pubdate->english (hash-ref metas 'doc-publish-date))}

*metas *is generated from meta values in the source files, with one of the 
keys being "doc-publish-date".

*pubdate->English * is a helper function to format everything nicely. 

This works perfectly if I don't forget the "doc-publish-date" key in the 
source files. If I do (or don't want to set it), the *hash-ref* fails and 
stops the rendering process. 

The *hash-ref* documentation (hash-ref 
<http://docs.racket-lang.org/reference/hashtables.html?q=hash-ref%20#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29>)
 mentions 
that one can write: 
     
hash-ref hash key [failure-result]

were *failure-result* is either a procedure or is a value and gets returned 
instead of the missing key-value. 

I've been trying to use this in order to fail gracefully when *doc-publish-date 
*is missing:
* either by returnnig a blank value (so the LaTex output will be " \date() 
" 
* or, even better, by skipping the whole \date function if the *hash-ref* 
function fails.  

Unfortunately all my efforts to set the failure-result have failed. I've 
tried e.g. 
\date{◊(pubdate->english (hash-ref metas 'doc-publish-date [] ))}
in order to return an empty string, but racket chokes by telling me [] is 
not a procedure.

And I can't find reference to something resembling if-error in the racket 
documentation. 

Any pointers would be greatly appreciated!

P. 


 

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to