-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Saaa wrote:
>>> The problem lies more in that I'd like to point to something which is not
>>> there yet.
>>> In the code 'c.method()' is not there yet, as c is null.
>>> Maybe I should create a dummy object for c to point to in stead of null ?
>>> That way I point the delegate to the dummy method and ignore it as long 
>>> as
>>> it is pointing
>>> to the dummy method :)
>>> The only drawback to this is that all objects I want to point the 
>>> delegate
>>> to,
>>> need to somehow be convertable to the dummy type (interface/abstract 
>>> class),
>>> meaning it will be less flexible.
>> Hm... I'm still confused.  Why not just set the delegate to null?  Why do 
>> you need to have the delegate set to something?
> It is for the gui. I give it a list of things to display.
> And some of these things don't yet exist or can be deleted at any time.
> I'd like it to display the last valid value.
> 
>> There are ways to do it, without having a class instance, but it is messy.
> how messy? :D

The only way I've found so far to do static binding like you are talking
about is using string mixins. My port of Atl's window classes uses a MFC
like message map:

mixin messageMap!(
  msgRangeHdlr!(WM_MOUSEFIRST, WM_MOUSELAST, "wmMouseEvents"),
  msgHdlr!(WM_PAINT, "wmPaint"),
  msgHdlr!(WM_SIZE, "wmSize"),
  msgHdlr!(WM_KEYUP, "wmKeyUp"),
  msgHdlr!(WM_CHAR, "wmChar"),

  msgHdlr!(WM_SHOWWINDOW, "wmShow"),
  msgHdlr!(WM_CLOSE, "wmClose"),
  msgHdlr!(WM_CREATE, "wmCreate")
);

Having to put the classes method in a string is a bit ugly, but without
c++ style pointer to members I don't see any other way of doing it.

If you want to have a look in more detail:

http://www.sstk.co.uk/atlWinD.php


> Kind of related:
> If you delete an object and later create a new object, what are the chances 
> they are located on the
> same place (deleted.ptr is new.ptr) ?
> Does the garbage collector try to reuse locations or is it the opposite (or 
> random) ? 

Dunno, but the full source code is in dmd zip @
src\druntime\src\gc\basic\gcx.d if you are really that interested.

- --
My enormous talent is exceeded only by my outrageous laziness.
http://www.ssTk.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iD8DBQFKppg7T9LetA9XoXwRApS4AJ0f+SI6MhonTiwLqC6LPD1lq4GzUACfU/oC
TY+3D6isjNKUt9zVxgoSDJ4=
=foxA
-----END PGP SIGNATURE-----

Reply via email to