
Reusable Abstractions in CoffeeScript - raganwald
https://github.com/raganwald/homoiconic/blob/master/2012/01/reuseable-abstractions.md#readme
======
swannodette
As I mentioned in a tweet to raganwald the problem with this approach is that
the object becomes opaque and can no longer be manipulated. ClojureScript
allows you to preserve the dual use.

~~~
Cushman
Since JavaScript functions can have properties, you can construct such a
function in pure CoffeeScript:

    
    
      ofunc =(obj = {})->
        fn =(k)->@[k]
        bound =(args...)=>
          fn.apply(bound, args)
        bound extends obj
      
      o = ofunc [1,2,3]
      > o(0)
      1
      > o[0] = 10
      10
    

Not that I recommend this, for the obvious reasons.

~~~
raganwald
interesting, although I think this code creates a copy of the original
object’s properties rather than proxying them. Mind you, that could be what
you want some times...

------
beggi
Great article. Just want to point out Katy
(<https://github.com/raganwald/Katy>) is a fantastic addition to CoffeeScript.

