www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - How to overload new operator for all classes?

reply david <davidl 126.com> writes:
I know global operator overload is not supported in D, but I hope new  
could be an exception.
I want to write some kernel like program in D

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
Aug 05 2006
parent reply Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

david schrieb am 2006-08-06:
 I know global operator overload is not supported in D, but I hope new  
 could be an exception.
 I want to write some kernel like program in D

Simply add the operator to the Object class in src/phobos/internal/object.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE1ZsCLK5blCcjpWoRAo1aAJwIqfbIXXaPOceaczTFN1K3cflCwACdFmFa YE22zhE/7sZi4OOxymtxQTQ= =Iwzp -----END PGP SIGNATURE-----
Aug 05 2006
parent reply Hasan Aljudy <hasan.aljudy gmail.com> writes:
Thomas Kuehne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 david schrieb am 2006-08-06:
 
I know global operator overload is not supported in D, but I hope new  
could be an exception.
I want to write some kernel like program in D

Simply add the operator to the Object class in src/phobos/internal/object.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE1ZsCLK5blCcjpWoRAo1aAJwIqfbIXXaPOceaczTFN1K3cflCwACdFmFa YE22zhE/7sZi4OOxymtxQTQ= =Iwzp -----END PGP SIGNATURE-----

Are costume allocators inherited by subclasses?
Aug 05 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hasan Aljudy schrieb am 2006-08-06:
 Are costume allocators inherited by subclasses?

# import std.stdio; # # class A{ # new(size_t size){ # writefln("new(%s)", size); # return new byte[size]; # } # } # # class B : A{ # int dummy; # } # # int main(){ # writef("new A: "); # A a = new A(); # # writef("new B: "); # B b = new B(); # # return 0; # } Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFE1tzbLK5blCcjpWoRAsLzAJ9NXAM5o1JQeD+l1sm5jxN9iBGY8gCgpPNE d1WRyGfm6ZovD60vZ8pIaH8= =YwUc -----END PGP SIGNATURE-----
Aug 06 2006