DMD 0.170 release

BCS BCS at pathlink.com
Tue Oct 17 09:26:33 PDT 2006


Ary Manzana wrote:



  class Tree {

      int inorder(int delegate(inout int)) {
              // inorder traversal
      }

      int preorder(int delegate(inout int)) {
              // preorder traversal
      }

     int postorder(int delegate(inout int)) {
              // postorder traversal
      }

  }

  void main() {
      Tree t = giveMeSomeTree();

      foreach(int i : &t.inorder) {
          // something
          }

      foreach(int i : &t.preorder) {
          // something
          }

      foreach(int i : &t.postorder) {
          // something
          }

  }

If I understand correctly, the above works with what is there now.

The things with the foreach_reverse is (I think) mostly for actuals 
arrays, and the opApplyReverse is really there more for orthogonality 
than need. that orthogonality has some cool side effects* so I'd say 
leave them in.

*: I have noticed recently that good orthogonality allows for some vary 
cool compile time options (think code generation). It almost lets 
c/c++/d act as dynamicly typed languages.



More information about the Digitalmars-d-announce mailing list