Create a standard way to reference this

Description

Some js frameworks require you to implement 'methods' and those methods need to access js this. Currelty this forces you to js*.

the following is handled by CLJS-83

Currently deftype only supports implementing protocol functions. It could be enhanced to support 'method' fns, possibly by using the Object section:

(deftype Foo [a]
Object
(anyArbitraryMethod [a-name-for-this] ...))

Note that the arity of the actual fn would be one less than for protocol 'methods'.

Explore other options before going this way.

Supporting access to 'this' in stand-alone functions may cause gclosure to complain (it only wants to see traditional methods on prototypes), and is a non-objective for now.

Environment

None

Activity

Show:
Fogus
October 1, 2011, 6:17 AM

The plan is to start with a pair, this-as and extend-object!. used as such:

Fogus
October 2, 2011, 1:56 PM

I am going to split out the (deftype T ... Object ...) capability into its own ticket as it's scope is greater than the accessing of this. It's likely that the new ticket will eliminate the need for extend-object!.

Fogus
October 2, 2011, 2:19 PM

Added note about related ticket. (CLJS-83)

Fogus
October 2, 2011, 2:20 PM

The this-as macro provides a scoped way to access the implicit this.

Completed

Assignee

Fogus

Reporter

Rich Hickey

Labels

None

Approval

None

Patch

None

Priority

Critical