Jump to page: 1 223  
Page
Thread overview
Fully dynamic d by opDotExp overloading
Apr 17, 2009
davidl
Apr 17, 2009
Daniel Keep
Apr 17, 2009
davidl
Apr 17, 2009
Don
Apr 17, 2009
davidl
Apr 17, 2009
bearophile
Apr 17, 2009
Denis Koroskin
Apr 17, 2009
BCS
Apr 17, 2009
Christopher Wright
Apr 18, 2009
Christopher Wright
Apr 17, 2009
BCS
Apr 18, 2009
Daniel Keep
Apr 18, 2009
Christopher Wright
Apr 17, 2009
Danny Wilson
Apr 17, 2009
Christopher Wright
Apr 17, 2009
Leandro Lucarella
Apr 17, 2009
Denis Koroskin
Apr 18, 2009
downs
Apr 18, 2009
bearophile
Apr 18, 2009
downs
Apr 18, 2009
bearophile
Apr 18, 2009
Daniel Keep
Apr 19, 2009
downs
Apr 18, 2009
bearophile
Apr 18, 2009
BCS
Apr 17, 2009
Christopher Wright
Apr 18, 2009
Jason House
Apr 18, 2009
BCS
Apr 18, 2009
Nick Sabalausky
Apr 17, 2009
davidl
Apr 17, 2009
davidl
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Nick Sabalausky
Apr 18, 2009
davidl
Apr 17, 2009
Don
Apr 17, 2009
Don
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Don
Apr 17, 2009
Nick Sabalausky
Apr 18, 2009
davidl
Apr 18, 2009
Don
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Michel Fortin
Apr 18, 2009
Daniel Keep
Apr 18, 2009
davidl
Apr 18, 2009
Michel Fortin
Apr 18, 2009
davidl
Apr 18, 2009
Don
Apr 19, 2009
Michel Fortin
Apr 19, 2009
Michel Fortin
Apr 19, 2009
Christopher Wright
Apr 20, 2009
Christopher Wright
Apr 20, 2009
Michel Fortin
Apr 20, 2009
BCS
Apr 20, 2009
Christopher Wright
Apr 20, 2009
Michel Fortin
Apr 21, 2009
Christopher Wright
Apr 19, 2009
BCS
Apr 17, 2009
Christopher Wright
Apr 17, 2009
Don
Apr 17, 2009
Denis Koroskin
Apr 17, 2009
Denis Koroskin
Apr 17, 2009
Christopher Wright
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Rainer Deyke
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Simen Kjaeraas
Apr 18, 2009
Danny Wilson
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
bearophile
Apr 17, 2009
Yigal Chripun
Apr 17, 2009
Yigal Chripun
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Nick Sabalausky
Apr 18, 2009
Don
Apr 18, 2009
Christopher Wright
Apr 18, 2009
Christopher Wright
Apr 19, 2009
Don
Apr 18, 2009
Denis Koroskin
Apr 18, 2009
Daniel Keep
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Yigal Chripun
Apr 18, 2009
Danny Wilson
Apr 18, 2009
BCS
Apr 18, 2009
Denis Koroskin
Apr 18, 2009
BCS
Apr 17, 2009
Nick Sabalausky
Apr 18, 2009
Danny Wilson
Apr 18, 2009
Danny Wilson
Apr 28, 2009
Benji Smith
Apr 17, 2009
Adam D. Ruppe
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Nick Sabalausky
Apr 18, 2009
Jason House
Apr 18, 2009
Adam Burton
Apr 18, 2009
Adam Burton
Apr 19, 2009
Adam D. Ruppe
Apr 19, 2009
BCS
Apr 19, 2009
Adam Burton
Apr 19, 2009
Adam Burton
Apr 19, 2009
BCS
Apr 19, 2009
Adam Burton
Apr 20, 2009
BCS
Apr 19, 2009
Denis Koroskin
Apr 19, 2009
Adam Burton
Apr 19, 2009
Denis Koroskin
Apr 20, 2009
BCS
Apr 20, 2009
Denis Koroskin
Apr 19, 2009
Simen Kjaeraas
Apr 17, 2009
Leandro Lucarella
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Leandro Lucarella
Apr 17, 2009
Yigal Chripun
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
bearophile
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
bearophile
Apr 17, 2009
Christopher Wright
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Christopher Wright
Apr 18, 2009
BCS
Apr 17, 2009
Leandro Lucarella
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Leandro Lucarella
Apr 18, 2009
Nick Sabalausky
Apr 18, 2009
Leandro Lucarella
Apr 18, 2009
SandeepK
Apr 18, 2009
bearophile
Apr 18, 2009
Don
Apr 18, 2009
bearophile
Apr 18, 2009
davidl
Apr 18, 2009
Yigal Chripun
Apr 18, 2009
BCS
Apr 19, 2009
Yigal Chripun
Apr 19, 2009
BCS
Apr 19, 2009
Yigal Chripun
Apr 19, 2009
BCS
Apr 20, 2009
BCS
Apr 20, 2009
Yigal Chripun
Apr 20, 2009
BCS
Apr 18, 2009
Simen Kjaeraas
Apr 18, 2009
Christopher Wright
Apr 17, 2009
davidl
Apr 17, 2009
davidl
Apr 17, 2009
davidl
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Don
Apr 17, 2009
Nick Sabalausky
Apr 17, 2009
Leandro Lucarella
Apr 17, 2009
Don
Apr 17, 2009
bearophile
Apr 17, 2009
davidl
Nov 28, 2009
Walter Bright
Nov 28, 2009
bearophile
Nov 29, 2009
Walter Bright
Nov 29, 2009
bearophile
Nov 29, 2009
Walter Bright
Nov 29, 2009
Simen kjaeraas
Nov 29, 2009
Walter Bright
April 17, 2009
After tweaking dmd a bit litte, i get the dotexp overloading work.

The following is the test code:
import std.stdio;
class c
{

    B opDotExp(char[] methodname,...)
    {
    	writefln("god it works ", methodname);
      return new B();
    }
    void opAdd(int j)
    {

    }
    void test()
    {
    }
}

class a:c
{

}

class B
{
  int i;
  B opAssign(int k){
    i=k;
    return this;
  }
}

char[] v1;

void func(char[] v, ...){}

void main()
{
   a v=new a;
   v.test();
   v.dynamicmethod(3,4);
   //v.qq = 5;
   writefln((v.qq = 5).i);
}

it generates the output:
god it works dynamicmethod
god it works qq
5

Any comments? Do you like this feature?

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
April 17, 2009
Very cool.  What I'd like to see is this, TypeInfo_Struct.getMembers and ClassInfo.getMembers.  Once we have all three, we could do some incredibly awesome things.

Like implement Objective C-style message passing as a library.  :D

  -- Daniel
April 17, 2009
davidl wrote:
> After tweaking dmd a bit litte, i get the dotexp overloading work.
> 
> class c
> {
> 
>     B opDotExp(char[] methodname,...)
>     {
>         writefln("god it works ", methodname);
>       return new B();
>     }

> it generates the output:
> god it works dynamicmethod
> god it works qq
> 5
> 
> Any comments? Do you like this feature?

That's very impressive. How did you do it? Are the syntax and semantic passes still independent?
April 17, 2009
在 Fri, 17 Apr 2009 14:52:30 +0800,Don <nospam@nospam.com> 写道:

> davidl wrote:
>> After tweaking dmd a bit litte, i get the dotexp overloading work.
>>  class c
>> {
>>      B opDotExp(char[] methodname,...)
>>     {
>>         writefln("god it works ", methodname);
>>       return new B();
>>     }
>
>> it generates the output:
>> god it works dynamicmethod
>> god it works qq
>> 5
>>  Any comments? Do you like this feature?
>
> That's very impressive. How did you do it? Are the syntax and semantic passes still independent?

Yes, it follows the rule of rewriting the c.unknownmethod(args) to c.opDotExp("unknownmethod", args);

Though it currently gets bugs of not supporting struct, opDotExp signiture must be (char[],...), and possibly break extension method. These should all be fixable.

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
April 17, 2009
在 Fri, 17 Apr 2009 14:44:46 +0800,Daniel Keep <daniel.keep.lists@gmail.com> 写道:

>
> Very cool.  What I'd like to see is this, TypeInfo_Struct.getMembers and
> ClassInfo.getMembers.  Once we have all three, we could do some
> incredibly awesome things.
>
> Like implement Objective C-style message passing as a library.  :D
>
>   -- Daniel

Thanks. I also hope for more runtime info.

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
April 17, 2009
davidl:
> Any comments? Do you like this feature?

It's cute.
Maybe "." can be used for static methods and some other syntax for dynamic ones, like:
v..dynamicmethod(x);
v->dynamicmethod(x);

It seems that after releasing DMD source code the head of the cat is finally starting to come out of Walter's bag :-) This is for the better.

Bye,
bearophile
April 17, 2009
davidl wrote:
> After tweaking dmd a bit litte, i get the dotexp overloading work.
> 
> The following is the test code:
> import std.stdio;
> class c
> {
> 
>     B opDotExp(char[] methodname,...)
>     {
>         writefln("god it works ", methodname);
>       return new B();
>     }
>     void opAdd(int j)
>     {
> 
>     }
>     void test()
>     {
>     }
> }
> 
> class a:c
> {
> 
> }
> 
> class B
> {
>   int i;
>   B opAssign(int k){
>     i=k;
>     return this;
>   }
> }
> 
> char[] v1;
> 
> void func(char[] v, ...){}
> 
> void main()
> {
>    a v=new a;
>    v.test();
>    v.dynamicmethod(3,4);
>    //v.qq = 5;
>    writefln((v.qq = 5).i);
> }
> 
> it generates the output:
> god it works dynamicmethod
> god it works qq
> 5
> 
> Any comments? Do you like this feature?
> 

Cool! I suggest the rewrite:

c.unknownmethod(args) -> c.opDotExp!("unknownmethod")(args)

That way you have the option of handling the method name statically or dynamically.


Andrei
April 17, 2009
On Fri, 17 Apr 2009 13:25:45 +0400, Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org> wrote:

> davidl wrote:
>> After tweaking dmd a bit litte, i get the dotexp overloading work.
>>  The following is the test code:
>> import std.stdio;
>> class c
>> {
>>      B opDotExp(char[] methodname,...)
>>     {
>>         writefln("god it works ", methodname);
>>       return new B();
>>     }
>>     void opAdd(int j)
>>     {
>>      }
>>     void test()
>>     {
>>     }
>> }
>>  class a:c
>> {
>>  }
>>  class B
>> {
>>   int i;
>>   B opAssign(int k){
>>     i=k;
>>     return this;
>>   }
>> }
>>  char[] v1;
>>  void func(char[] v, ...){}
>>  void main()
>> {
>>    a v=new a;
>>    v.test();
>>    v.dynamicmethod(3,4);
>>    //v.qq = 5;
>>    writefln((v.qq = 5).i);
>> }
>>  it generates the output:
>> god it works dynamicmethod
>> god it works qq
>> 5
>>  Any comments? Do you like this feature?
>>
>
> Cool! I suggest the rewrite:
>
> c.unknownmethod(args) -> c.opDotExp!("unknownmethod")(args)
>
> That way you have the option of handling the method name statically or dynamically.
>
>
> Andrei

Yes, this also helps to catch errors at compile-time (like, dynObject.lenght vs dynObject.length).
April 17, 2009
Op Fri, 17 Apr 2009 08:31:02 +0200 schreef davidl <davidl@nospam.org>:

> it generates the output:
> god it works dynamicmethod
> god it works qq
> 5
>
> Any comments? Do you like this feature?
>

Awesome, this is exactly what I thought was the point of 'opDot' when i first skimmed over it in the docs.
This is great for lots of purposes. A small nice example is: http://haxe.org/doc/advanced/xml_fast

April 17, 2009
davidl wrote:
> After tweaking dmd a bit litte, i get the dotexp overloading work.

Do want.

With this and extended runtime information, you can create a Variant that works exactly like the original type, allowing you to call methods on it without extracting it to the original type, just throwing an ArgumentException or MethodMissingException if you give it something bad.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11