/*
 * NoR - There's No Return. A javascript reactive programming engine.
 * http://vic.github.com/NoR
 *
 * Copyright (c) 2012 Victor Borja
 * Licensed under the MIT license.
 */
;(function(exports, undefined) {

  /* A cell holds a value and notify observers when it has changed */
  var cell = function(name, value) {

    var zell = function() {
      if(arguments.length === 0) {
        return value
      } else if(value !== arguments[0]) {
        notifySubscribers(value = arguments[0])
      }
    }

    var subscribers = []

    var notifySubscribers = function(value) {
      for(var i in subscribers) {
        if(subscribers[i]) { subscribers[i](value) }
      }
    }

    var addSubscriber = function(subscriber) {
      if(subscriber === zell) { return }
      var i = subscribers.indexOf(subscriber)
      if(i < 0 ) { subscribers.push(subscriber) }
    }

    var removeSubscriber = function(subscriber) {
      var i = subscribers.indexOf(subscriber)
      if(i > -1) { subscribers[i] = null }
      // TODO: clean list when too big
    }

    zell.constructor = cell
    zell.cellName = name
    zell.toString = function() { return '{'+name+':'+value+'}' }
    zell.subscribe = addSubscriber
    zell.bind = function(other) {
      zell.subscribe(other)
      other.subscribe(zell)
    }

    return zell
  }

  var gate = function(impl, setup, self){
    var args = arguments
      , names = {}
      , cells = argCells(impl, names)
      , timeout
      , execute = function() {
        if(timeout) { clearTimeout(timeout) }
        timeout = setTimeout(function(){
          impl.apply(self(), cells)
        }, 0)
      }
      , invoke = function() {
        if(this instanceof arguments.callee){
          var g = gate.apply(undefined, args)
          for(var i in arguments){
            if(arguments[i] && arguments[i].constructor === cell){
              arguments[i].bind(g[i])
            } else {
              g[i](arguments[i])
            }
          }
          return g
        }
        for(var i in arguments) {
          cells[i](arguments[i])
        }
        return arguments.callee
      }
    self = names['self'] = cell('self', self)
    for(var i in cells) {
      invoke[cells[i].cellName] = invoke[i] = cells[i]
    }
    invoke.self = self
    invoke.length = cells.length
    invoke.toString = function(){
      var buff = []
      for(var i in cells) {
        buff.push(cells[i].cellName+':'+cells[i]())
      }
      return '{'+buff.join(', ')+'}'
    }
    if(setup){
      var innerCells = argCells(setup, names)
      setup.apply(self(), innerCells)
    }
    self.subscribe(execute)
    for(var i in cells) {
      cells[i].subscribe(execute)
    }
    return invoke
  }

  var ARGS_RE = /^function\s+\(([^\)]+)\)/, SEP_RE = /,?\s+/

  var argCells = function(impl, store){
    var names = impl.toString().match(ARGS_RE)[1].split(SEP_RE)
      , cells = []
      , store = store || {}
    for(var i in names){
      if(! store[names[i]]) {
        store[names[i]] = cell(names[i])
      }
      cells[i] = store[names[i]]
    }
    return cells
  }

  exports(gate)

}(typeof module === 'object' &&
  function(v){ module.exports = v } || function(v){ NoR = v }));

@@ -322,20 +322,20 @@
     var 
-zell
+port
  = funct
@@ -748,20 +748,20 @@
 ber === 
-zell
+port
 ) %7B retu
@@ -1057,20 +1057,20 @@
  %7D%0A%0A    
-zell
+port
 .constru
@@ -1085,20 +1085,20 @@
 ell%0A    
-zell
+port
 .cellNam
@@ -1110,20 +1110,20 @@
 ame%0A    
-zell
+port
 .toStrin
@@ -1171,28 +1171,28 @@
 e+'%7D' %7D%0A    
-zell
+port
 .subscribe =
@@ -1210,20 +1210,20 @@
 ber%0A    
-zell
+port
 .bind = 
@@ -1246,20 +1246,20 @@
 %7B%0A      
-zell
+port
 .subscri
@@ -1290,20 +1290,20 @@
 bscribe(
-zell
+port
 )%0A    %7D%0A
@@ -1318,12 +1318,12 @@
 urn 
-zell
+port
 %0A  %7D

Rename variable to port.