Thread: [Objectscript-users] Addition to OScript syntax
Brought to you by:
rob_d_clark
|
From: <ar...@va...> - 2005-12-02 13:59:31
|
Rob,
Is it difficult to add the following to the OScript syntaxt:
function A() {
public function print() {}
}
function B() {
mixin new A();
public function print() {
A::print();
^^^^^^^^^^^
// do other print stuff
}
}
"::" means in this case that you specifically point to the object "A" and
call its print method. I don't think that this is a difficult addition to
the syntaxt, but i'm completely unknown to JavaCC and how you used it in
OScript.
Maybe you can point me in some direction to have this included.
thank you very much.
Regards,
Arjen van Efferen
|
|
From: Rob C. <ro...@ti...> - 2005-12-02 16:58:42
|
Hmm, I've recently just added a qualified "this" syntax, for example =20
"Foo.this"... the way it is currently supported is "Foo.this" =20
evaluates to the nearest "this" which is a "Foo". As in:
function Outer()
{
private var a =3D 1;
function Inner()
{
private var a =3D 2;
public function test()
{
private var a =3D 3;
{
var a =3D 4;
writeln("a: " + a);
writeln("test.this.a: " + test.this.a);
writeln("this.a: " + this.a);
writeln("Inner.this.a: " + Inner.this.a);
writeln("Outer.this.a: " + Outer.this.a);
}
}
}
}
maybe it would sense to support mixin's in a similar way, so you =20
could do something like "A.this.print()"?
thoughts?
On Dec 2, 2005, at 6:49 AM, <ar...@va...> wrote:
> Rob,
>
> Is it difficult to add the following to the OScript syntaxt:
>
> function A() {
> public function print() {}
> }
>
> function B() {
> mixin new A();
>
> public function print() {
> A::print();
> ^^^^^^^^^^^
> // do other print stuff
> }
> }
>
> "::" means in this case that you specifically point to the object =20
> "A" and
> call its print method. I don't think that this is a difficult =20
> addition to
> the syntaxt, but i'm completely unknown to JavaCC and how you used =20
> it in
> OScript.
>
> Maybe you can point me in some direction to have this included.
>
> thank you very much.
>
> Regards,
>
> Arjen van Efferen
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc. Do you grep through =20
> log files
> for problems? Stop! Download the new AJAX search engine that makes
> searching your log files as easy as surfing the web. DOWNLOAD =20
> SPLUNK!
> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick
> _______________________________________________
> Objectscript-users mailing list
> Obj...@li...
> https://lists.sourceforge.net/lists/listinfo/objectscript-users
-- Rob
____________________
CONTACT INFORMATION:
email: ro...@ti...
IM: rob@sandjabber
desk: 1 858 552 2946
cell: 1 619 300 9661
|
|
From: <ar...@va...> - 2005-12-03 11:28:28
|
I'm glad you understand what i mean. I was not sure if it was clearly
stated below. I have based this on the LPC language created by Lars Pensj=
=F6
for his LP-MUD. It supports the "::" to point at specific inherited
objects. It also uses "::method()" as the "super" qualifier used in Java.
But i think it is just a matter of syntax choice on how to implement this=
.
I think what you proposed will get the job done as well.
In what version of OScript did you implement the qualified "this" syntax?
> Hmm, I've recently just added a qualified "this" syntax, for example
> "Foo.this"... the way it is currently supported is "Foo.this"
> evaluates to the nearest "this" which is a "Foo". As in:
>
> function Outer()
> {
> private var a =3D 1;
> function Inner()
> {
> private var a =3D 2;
>
> public function test()
> {
> private var a =3D 3;
>
> {
> var a =3D 4;
>
> writeln("a: " + a);
> writeln("test.this.a: " + test.this.a);
> writeln("this.a: " + this.a);
> writeln("Inner.this.a: " + Inner.this.a);
> writeln("Outer.this.a: " + Outer.this.a);
> }
> }
> }
> }
>
> maybe it would sense to support mixin's in a similar way, so you
> could do something like "A.this.print()"?
>
> thoughts?
>
>
> On Dec 2, 2005, at 6:49 AM, <ar...@va...> wrote:
>
>> Rob,
>>
>> Is it difficult to add the following to the OScript syntaxt:
>>
>> function A() {
>> public function print() {}
>> }
>>
>> function B() {
>> mixin new A();
>>
>> public function print() {
>> A::print();
>> ^^^^^^^^^^^
>> // do other print stuff
>> }
>> }
>>
>> "::" means in this case that you specifically point to the object
>> "A" and
>> call its print method. I don't think that this is a difficult
>> addition to
>> the syntaxt, but i'm completely unknown to JavaCC and how you used
>> it in
>> OScript.
>>
>> Maybe you can point me in some direction to have this included.
>>
>> thank you very much.
>>
>> Regards,
>>
>> Arjen van Efferen
>>
>>
>> -------------------------------------------------------
>> This SF.net email is sponsored by: Splunk Inc. Do you grep through
>> log files
>> for problems? Stop! Download the new AJAX search engine that makes
>> searching your log files as easy as surfing the web. DOWNLOAD
>> SPLUNK!
>> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick
>> _______________________________________________
>> Objectscript-users mailing list
>> Obj...@li...
>> https://lists.sourceforge.net/lists/listinfo/objectscript-users
>
> -- Rob
>
> ____________________
> CONTACT INFORMATION:
> email: ro...@ti...
> IM: rob@sandjabber
> desk: 1 858 552 2946
> cell: 1 619 300 9661
>
>
>
>
|
|
From: Rob C. <ro...@ti...> - 2005-12-03 17:26:20
|
the qualified "this" (and "super") syntax is introduced in =20 oscript-2.10, which I've unfortunately not had time to upload to =20 sf.net yet. (Sorry.. been very busy with my day job.) But you can =20 see it in the SVN repository (https://objectscript.kicks-ass.org/=20 svn). I'll try and make a 2.10.1 to upload this weekend after I've =20 had a chance to merge Lysander's patches. Anyways, the way qualified "this" works is I added to Scope a getThis=20 (Value) method. So "Foo.this" is implemented as "currentScope.getThis=20= (Foo)". The way it works is that in FunctionScope: public Value getThis( Value val ) { if( fxn =3D=3D val.unhand() ) return new OThis(this); return super.getThis(val); } so the nearest enclosing function-scope for the function "Foo" will =20 return the "this". So to do what you describe, in BasicScope (where mixin is handled), =20 it would have to do something like: public Value getThis( Value val ) { for( int i=3D0; i<mixins.length; i++ ) { if( mixins[i] instanceof Scope ) { if( mixins[i].bopInstanceOf(val) ) return mixins[i]; } } return super.getThis(val); } ------ background notes: in Scope, the base class for all scopes (FunctionScope, BasicScope, =20 etc): public Value getThis( Value val ) { return previous.getThis(val); } so the default behavior is to pass the request for "this" up the =20 scope chain. On Dec 3, 2005, at 4:17 AM, <ar...@va...> wrote: > I'm glad you understand what i mean. I was not sure if it was clearly > stated below. I have based this on the LPC language created by Lars =20= > Pensj=F6 > for his LP-MUD. It supports the "::" to point at specific inherited > objects. It also uses "::method()" as the "super" qualifier used in =20= > Java. > > But i think it is just a matter of syntax choice on how to =20 > implement this. > I think what you proposed will get the job done as well. > > In what version of OScript did you implement the qualified "this" =20 > syntax? > > > >> Hmm, I've recently just added a qualified "this" syntax, for example >> "Foo.this"... the way it is currently supported is "Foo.this" >> evaluates to the nearest "this" which is a "Foo". As in: >> >> function Outer() >> { >> private var a =3D 1; >> function Inner() >> { >> private var a =3D 2; >> >> public function test() >> { >> private var a =3D 3; >> >> { >> var a =3D 4; >> >> writeln("a: " + a); >> writeln("test.this.a: " + test.this.a); >> writeln("this.a: " + this.a); >> writeln("Inner.this.a: " + Inner.this.a); >> writeln("Outer.this.a: " + Outer.this.a); >> } >> } >> } >> } >> >> maybe it would sense to support mixin's in a similar way, so you >> could do something like "A.this.print()"? >> >> thoughts? >> >> >> On Dec 2, 2005, at 6:49 AM, <ar...@va...> wrote: >> >>> Rob, >>> >>> Is it difficult to add the following to the OScript syntaxt: >>> >>> function A() { >>> public function print() {} >>> } >>> >>> function B() { >>> mixin new A(); >>> >>> public function print() { >>> A::print(); >>> ^^^^^^^^^^^ >>> // do other print stuff >>> } >>> } >>> >>> "::" means in this case that you specifically point to the object >>> "A" and >>> call its print method. I don't think that this is a difficult >>> addition to >>> the syntaxt, but i'm completely unknown to JavaCC and how you used >>> it in >>> OScript. >>> >>> Maybe you can point me in some direction to have this included. >>> >>> thank you very much. >>> >>> Regards, >>> >>> Arjen van Efferen >>> >>> >>> ------------------------------------------------------- >>> This SF.net email is sponsored by: Splunk Inc. Do you grep through >>> log files >>> for problems? Stop! Download the new AJAX search engine that makes >>> searching your log files as easy as surfing the web. DOWNLOAD >>> SPLUNK! >>> http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick >>> _______________________________________________ >>> Objectscript-users mailing list >>> Obj...@li... >>> https://lists.sourceforge.net/lists/listinfo/objectscript-users >> >> -- Rob >> >> ____________________ >> CONTACT INFORMATION: >> email: ro...@ti... >> IM: rob@sandjabber >> desk: 1 858 552 2946 >> cell: 1 619 300 9661 >> >> >> >> > ____________________ CONTACT INFORMATION: email: ro...@ti... IM: rob@sandjabber desk: 1 858 552 2946 cell: 1 619 300 9661 |