(function(paw){
    function PawLang(){
        
    }

    /**
     * Extends prototypes of A and B.
     * 
     * @param {Function} A Constructor function A.
     * @param {Function} B Constructor function B.
     * @returns {Function} new extended prototype of
     */
    PawLang.prototype.extend = function (A, B) {
        
        // extend prototypes
        if (!(typeof A === "function" && typeof B === "function")) 
            throw "Exception when extending prototypes: One of the entities is not a function";
            
        // this kind of declaration offends "strict mode"
        function __() {
            this.constructor = A;
        }

        __.prototype = B.prototype;
        A.prototype = new __();
        return A;
    };

    /**
     * Merges two objects. It appends any new properties from object A to object B and it does not 
     * override any existing properties on B.<br />
     * Throws exception when any of the given parameters is not an object.
     * 
     * @throws {Exception} 
     * @param {Object} a
     * @param {Object} b
     * @returns {Object} object B.
     */
    PawLang.prototype.append = function (a, b) {

        // extend objects
        if (!(typeof a === "object" && typeof b === "object")) 
            throw "Exception when merging: One of the entities is not an object";
        
        for (var k in a) {
            if(b[k] === undefined && a[k] !== undefined){
                b[k] = a[k];
            }
        }

        return b;
    };

    paw.lang = new PawLang();
})(paw);
