Class LAcond

Object
   |
   +--Lens
         |
         +--LAcond

class LAcond
extends Lens


Applies one of two lenses based on predicates on the concrete and abstract trees. LAcond behaves like LCcond, only a separate predicate pa determines which lens to use during putback, making this lens (slightly) more oblivious.

The lens is not oblivious because different lenses may be used for get and putback; if this is the case, then the undefined is given instead of c.

LAcond is typically used to dispatch subtypes to appropriate lenses. For an example, see LRenameIfPresent, which is essentially:

acond (function (c) { return has_prop(c, from); }, function (a) { return has_prop(a, to); }, new LRename(from, to), new LId())

For simply dispatching, LCcond may be sufficient.


See:Defined in lens.js


Field Summary
 Object name
          
   
Fields inherited from class Lens
name
 
Constructor Summary
LAcond(<Predicate> pc, <Predicate> pa, <Predicate> pass_lens, <Predicate> fail_lens)
           
 
Method Summary
 Object get(c)
          
 Object putback(a, c)
          
 
Methods inherited from class Lens
error, getput, putget, putput, get_is, putback_is, get_throws, putback_throws
 

Field Detail

name

Object name

Constructor Detail

LAcond

LAcond(<Predicate> pc, <Predicate> pa, <Predicate> pass_lens, <Predicate> fail_lens)

Method Detail

get

Object get(c)

putback

Object putback(a, c)


Documentation generated by JSDoc on Wed Feb 14 15:36:01 2007