Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Clojure Design
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
Colour
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Undo
Redo
Keyboard Shortcuts Help
<h1>Motivation</h1><p>To add extensibility to the Clojure reader in a composable way.</p><h1>General Goals</h1><ul><li>new syntax for "tagged" literals in the reader</li><li>tags can be namespaced</li><li>non-namespace-qualified tags are reserved for Clojure</li><li>when the reader encounters a tagged literal, it invokes a function associated with that tag</li><li>users may define new tags and tag-reader functions</li><li>users may override functions for built-in tags</li></ul><h3>Non-goals</h3><ul><li>Common Lisp-style reader macros</li><li>Custom parsing of the character stream<ul><li>Reader will parse tagged literals as data and pass that to the tag function</li></ul></li></ul><h1>Open Questions</h1><ul><li>What is the syntax for tags?<ul><li>Keywords, like <code>#:tag form</code><ul><li>One character longer</li><li>Slightly easier to parse</li></ul></li><li>Symbols, like <code>#tag form</code><ul><li>One character shorter</li><li>Slightly harder to parse</li><li>Ambiguous with record constructors?<ul><li>Not if we assume that: <ul><li>1) record names always contain a dot<ul><li>Which they must, because deftypes occur in namespaces</li></ul></li><li>2) user-defined tags are always namespace-qualified</li><li>3) built-in tags do not contain a dot</li></ul></li></ul></li></ul></li></ul></li><li>What happens when the reader encounters a tag for which no function is defined?<ul><li>Error (YES)</li><li>Return form unchanged?</li><li>Return form with extra metadata?<ul><li>Only possible if form supports metadata, ignore otherwise?</li></ul></li></ul></li></ul><ul><li>How to associate tags with reader functions?<ul><li>file containing mapping from tags to Vars<ul><li>"magic" file name gets loaded before other files</li><li>doesn't load any code directly</li><li>If 2 JARs on classpath have a magic file, who wins?<ul><li>throw an exception</li></ul></li></ul></li><li>map stored in dynamic var<ul><li>thread-local binding for each source file<ul><li><p>created in <code>Compiler.load and Compiler.compile</code></p></li></ul></li><li>can be set! within a source file</li><li>can be rebound when invoking the reader at runtime</li></ul></li></ul></li></ul><h1>References / See Also</h1><ul><li><a href="http://dev.clojure.org/jira/browse/CLJ-890">CLJ-890</a></li><li><a href="/pages/viewpage.action?pageId=950382" data-linked-resource-id="950382" data-linked-resource-type="page" data-linked-resource-default-alias="Clojure Instant Literal &amp; Library" data-base-url="http://dev.clojure.org">Clojure Instant Literal & Library</a></li></ul>
Attachments
Labels
Location
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced