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
<h2>Problem</h2><p>There is currently no unified field access syntax between Clojure and ClojureScript.</p><p><em>(covered by ticket <a href="http://dev.clojure.org/jira/browse/CLJS-89">CLJS-89</a>)</em></p><p>Currently ClojureScript provides the following dot access syntaxes:</p><table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>(.p o) ;=> a property access (.m o <args>) ;=> a method call (. o p) ;=> a property access (. o p <args>) ;=> a method call (. o (m)) ;=> a method call (. o (m <args>)) ;=> a method call </pre></td></tr></table><p>This is potentially confusing. Especially considering that Clojure looks as follows:</p><table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>(.p o) ;=> a property access if p is a property (.p o) ;=> a method call if p is a method (.m o <args>) ;=> a method call (. o p) ;=> a property access if p is a property (. o p) ;=> a method call if p is a method (. o p <args>) ;=> a method call (. o (m)) ;=> a method call (. o (m <args>)) ;=> a method call </pre></td></tr></table><p>The divergence between the Clojure and ClojureScript way is due to first-class functions. That is, in JavaScript a property can be a field or a function or a method. There is currently no way to distinguish between the desire to call a method and retrieve a function as a property except through syntax.</p><h2>Potential Solution</h2><p>A way to shorten the gap between Clojure and ClojureScript is to use the following syntax for ClojureScript:</p><table class="wysiwyg-macro" data-macro-name="noformat" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e25vZm9ybWF0fQ&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre>(.p o) ;=> a method call (.m o <args>) ;=> a method call (. o p) ;=> a method call (. o p <args>) ;=> a method call (. o (m)) ;=> a method call (. o (m <args>)) ;=> a method call (. o -p) ;=> a property access (.-p o) ;=> a property access </pre></td></tr></table><p>Thus reserving the single hyphenated symbol form for property access. This functionality should also be created in Clojure. This would require a breaking change in ClojureScript and only an enhancement to Clojure.</p>
Attachments
Labels
Location
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced