[{"url":"https://api.github.com/gists/2346460/comments/246570","id":246570,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoyNDY1NzA=","user":{"login":"mjackson","id":92839,"node_id":"MDQ6VXNlcjkyODM5","avatar_url":"https://avatars.githubusercontent.com/u/92839?v=4","gravatar_id":"","url":"https://api.github.com/users/mjackson","html_url":"https://github.com/mjackson","followers_url":"https://api.github.com/users/mjackson/followers","following_url":"https://api.github.com/users/mjackson/following{/other_user}","gists_url":"https://api.github.com/users/mjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjackson/subscriptions","organizations_url":"https://api.github.com/users/mjackson/orgs","repos_url":"https://api.github.com/users/mjackson/repos","events_url":"https://api.github.com/users/mjackson/events{/privacy}","received_events_url":"https://api.github.com/users/mjackson/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"NONE","created_at":"2012-04-09T21:36:00Z","updated_at":"2012-04-09T21:47:45Z","body":"By way of explanation for anyone else who stumbles upon this gist, the `IFn` protocol is used for adding the ability to invoke an object as a function. In this example, instances of JavaScript's built-in `RegExp` constructor are made callable. This means you can use them in the same place you would normally use a function. As implemented, the result of invoking a `RegExp` object is the return value of the [re-matches function](http://clojuredocs.org/clojure_core/clojure.core/re-matches) using that regular expression and the given argument.\n\nFor those who understand JavaScript better than ClojureScript, this would be equivalent to the following JavaScript (which does not actually work, hence the _sweet_-ness):\n\n``` javascript\nvar re = /abc/;\nre('abc'); // \"abc\"\nre('def'); // null\n```\n"},{"url":"https://api.github.com/gists/2346460/comments/246753","id":246753,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoyNDY3NTM=","user":null,"author_association":"NONE","created_at":"2012-04-09T23:47:44Z","updated_at":"2012-04-09T23:47:44Z","body":"Appropos: proposal for something like this in JS and library \nhttps://mail.mozilla.org/pipermail/es-discuss/2012-March/021603.html\nhttps://github.com/Gozala/protocol\n"},{"url":"https://api.github.com/gists/2346460/comments/250495","id":250495,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoyNTA0OTU=","user":{"login":"fogus","id":12632,"node_id":"MDQ6VXNlcjEyNjMy","avatar_url":"https://avatars.githubusercontent.com/u/12632?v=4","gravatar_id":"","url":"https://api.github.com/users/fogus","html_url":"https://github.com/fogus","followers_url":"https://api.github.com/users/fogus/followers","following_url":"https://api.github.com/users/fogus/following{/other_user}","gists_url":"https://api.github.com/users/fogus/gists{/gist_id}","starred_url":"https://api.github.com/users/fogus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fogus/subscriptions","organizations_url":"https://api.github.com/users/fogus/orgs","repos_url":"https://api.github.com/users/fogus/repos","events_url":"https://api.github.com/users/fogus/events{/privacy}","received_events_url":"https://api.github.com/users/fogus/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"NONE","created_at":"2012-04-11T17:05:26Z","updated_at":"2012-04-11T17:35:39Z","body":"It's a little known fact that ClojureScript does this (extends) already with strings to support keyword and symbol lookup. :-)\n"},{"url":"https://api.github.com/gists/2346460/comments/250699","id":250699,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoyNTA2OTk=","user":{"login":"mjackson","id":92839,"node_id":"MDQ6VXNlcjkyODM5","avatar_url":"https://avatars.githubusercontent.com/u/92839?v=4","gravatar_id":"","url":"https://api.github.com/users/mjackson","html_url":"https://github.com/mjackson","followers_url":"https://api.github.com/users/mjackson/followers","following_url":"https://api.github.com/users/mjackson/following{/other_user}","gists_url":"https://api.github.com/users/mjackson/gists{/gist_id}","starred_url":"https://api.github.com/users/mjackson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mjackson/subscriptions","organizations_url":"https://api.github.com/users/mjackson/orgs","repos_url":"https://api.github.com/users/mjackson/repos","events_url":"https://api.github.com/users/mjackson/events{/privacy}","received_events_url":"https://api.github.com/users/mjackson/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"NONE","created_at":"2012-04-11T18:45:19Z","updated_at":"2012-04-11T18:45:19Z","body":"@fogus Interesting! Could you point me to the source for this so I can see how it's done? I ack'd the ClojureScript source for `extend-type` and `extend` but didn't find the magic. :)\n"},{"url":"https://api.github.com/gists/2346460/comments/251037","id":251037,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoyNTEwMzc=","user":{"login":"alandipert","id":26024,"node_id":"MDQ6VXNlcjI2MDI0","avatar_url":"https://avatars.githubusercontent.com/u/26024?v=4","gravatar_id":"","url":"https://api.github.com/users/alandipert","html_url":"https://github.com/alandipert","followers_url":"https://api.github.com/users/alandipert/followers","following_url":"https://api.github.com/users/alandipert/following{/other_user}","gists_url":"https://api.github.com/users/alandipert/gists{/gist_id}","starred_url":"https://api.github.com/users/alandipert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alandipert/subscriptions","organizations_url":"https://api.github.com/users/alandipert/orgs","repos_url":"https://api.github.com/users/alandipert/repos","events_url":"https://api.github.com/users/alandipert/events{/privacy}","received_events_url":"https://api.github.com/users/alandipert/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"OWNER","created_at":"2012-04-11T20:25:32Z","updated_at":"2012-04-12T03:16:36Z","body":"@mjijackson the behavior @fogus mentions is incidental, and is a result of the way `:keywords` are implemented atop JavaScript strings. That said, I would classify this behavior as _seekrit_ and not _sweet_ because it depends on implementation detail.\n\nBut then, maybe seekrit things _are_ sweet?\n"},{"url":"https://api.github.com/gists/2346460/comments/1188974","id":1188974,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoxMTg4OTc0","user":{"login":"devn","id":10421,"node_id":"MDQ6VXNlcjEwNDIx","avatar_url":"https://avatars.githubusercontent.com/u/10421?v=4","gravatar_id":"","url":"https://api.github.com/users/devn","html_url":"https://github.com/devn","followers_url":"https://api.github.com/users/devn/followers","following_url":"https://api.github.com/users/devn/following{/other_user}","gists_url":"https://api.github.com/users/devn/gists{/gist_id}","starred_url":"https://api.github.com/users/devn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devn/subscriptions","organizations_url":"https://api.github.com/users/devn/orgs","repos_url":"https://api.github.com/users/devn/repos","events_url":"https://api.github.com/users/devn/events{/privacy}","received_events_url":"https://api.github.com/users/devn/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"NONE","created_at":"2014-03-12T02:51:27Z","updated_at":"2014-03-12T02:51:27Z","body":"This Old Gistâ„¢\n\nDespite the fact that this is **seekrit** I still point it out to clojure journeyfolk because I think it teaches deep Clojure by way of radical ClojureScript in one beautiful motion.\n"},{"url":"https://api.github.com/gists/2346460/comments/1672122","id":1672122,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoxNjcyMTIy","user":{"login":"mfikes","id":1723464,"node_id":"MDQ6VXNlcjE3MjM0NjQ=","avatar_url":"https://avatars.githubusercontent.com/u/1723464?v=4","gravatar_id":"","url":"https://api.github.com/users/mfikes","html_url":"https://github.com/mfikes","followers_url":"https://api.github.com/users/mfikes/followers","following_url":"https://api.github.com/users/mfikes/following{/other_user}","gists_url":"https://api.github.com/users/mfikes/gists{/gist_id}","starred_url":"https://api.github.com/users/mfikes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mfikes/subscriptions","organizations_url":"https://api.github.com/users/mfikes/orgs","repos_url":"https://api.github.com/users/mfikes/repos","events_url":"https://api.github.com/users/mfikes/events{/privacy}","received_events_url":"https://api.github.com/users/mfikes/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"NONE","created_at":"2016-01-17T14:07:07Z","updated_at":"2016-01-17T14:07:07Z","body":"Nowadays, no longer need to hide _seekrits_. Keywords and symbols are actually types that support `IFn`:\n\nhttps://github.com/clojure/clojurescript/blob/r1.7.228/src/main/cljs/cljs/core.cljs#L2941-L2945\nhttps://github.com/clojure/clojurescript/blob/r1.7.228/src/main/cljs/cljs/core.cljs#L945-L949\n"},{"url":"https://api.github.com/gists/2346460/comments/1707551","id":1707551,"node_id":"MDExOkdpc3RDb21tZW50MjM0NjQ2MDoxNzA3NTUx","user":{"login":"alandipert","id":26024,"node_id":"MDQ6VXNlcjI2MDI0","avatar_url":"https://avatars.githubusercontent.com/u/26024?v=4","gravatar_id":"","url":"https://api.github.com/users/alandipert","html_url":"https://github.com/alandipert","followers_url":"https://api.github.com/users/alandipert/followers","following_url":"https://api.github.com/users/alandipert/following{/other_user}","gists_url":"https://api.github.com/users/alandipert/gists{/gist_id}","starred_url":"https://api.github.com/users/alandipert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alandipert/subscriptions","organizations_url":"https://api.github.com/users/alandipert/orgs","repos_url":"https://api.github.com/users/alandipert/repos","events_url":"https://api.github.com/users/alandipert/events{/privacy}","received_events_url":"https://api.github.com/users/alandipert/received_events","type":"User","user_view_type":"public","site_admin":false},"author_association":"OWNER","created_at":"2016-02-25T15:26:24Z","updated_at":"2016-02-25T15:35:56Z","body":"@mfikes I can understand keywords, but why are symbols functions of collections? That seems like a juicy one to leave open for users.\n\n_Edit_\nNevermind, answered my own question. Clojure does the same thing, which must have been the rationale. Fortunately regexes and many other atoms are available for IFn extension :smiling_imp: \n"}]