/jEdit/tags/jedit-4-4-2/org/gjt/sp/jedit/bsh/commands/extend.bsh
# · Unknown · 50 lines · 39 code · 11 blank · 0 comment · 0 complexity · 87fe0d7551c6104ae7a00d37903caacd MD5 · raw file
- /**
- Return a new object that is a child of the specified object.
- <strong>
- Note: this command will likely change along with a better inheritance
- mechanism for bsh in a future release.</strong>
- <p>
- extend() is like the object() command, which
- creates a new bsh scripted object, except that the namespace of
- the new object is a child of the parent object.
- <p>
- For example:
- <p>
- <pre>
- foo=object();
- bar=extend(foo);
- is equivalent to:
-
- foo() {
- bar() {
- return this;
- }
- }
- foo=foo();
- bar=foo.bar();
- and also:
-
- oo=object();
- ar=object();
- ar.namespace.bind( foo.namespace );
- </pre>
- <p>
- The last example above is exactly what the extend() command does.
- In each case the bar object inherits variables from foo in the usual way.
- @method This extend( This object )
- */
- bsh.help.extend= "usage: extend( This parent )";
- extend( org.gjt.sp.jedit.bsh.This parent )
- {
- this.namespace.setParent( parent.namespace );
- return this;
- }