Source location info in tag functions
#28
Open
opened 5 years ago by otherjoel
·
0 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
In #27 @odanoburu asked about tag functions having info about where they are located in the Pollen source doc:
This info is available at compile time, so if you write your tag function as a macro you absolutely can get to it. I recently cooked up a proof of concept:
Paste this into
example.html.pm
and save it into the same folder:“Running” it in DrRacket produces:
So you see that the output
div
contains the file and line number where◊note
occurs in the Pollen source. In order to make full use of this code you really need to delve into how macros and syntax objects work. I found it kind of brain-melting at first (still do, a bit). But it’s another example of Racket’s power, and it’s really cool that this is available to us in Pollen.I haven’t used this for error reporting (I do as little error reporting in Pollen as possible since I’m the only user of my tag functions and can spot any issues pretty quickly). But I wanted to make it possible to have output that could link back to its source file and location.