"Programming in D" book, "User Defined Attributes (UDA)" chapter

Ali Çehreli via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Sep 11 10:47:40 PDT 2014


On 09/09/2014 05:04 PM, Ali Çehreli wrote:

 > I have already tied many loose ends. I am currently
 > changing the operator overloading chapter to include the more proper
 > multi-dimensional indexing and slicing that came with 2.066.

Done.

I divided array operator overloading (indexing and slicing) into two 
categories:

1) I updated the existing Operator Overloading chapter to cover only 
single-dimensional uses by

- opIndex
- opIndexAssign
- opIndexUnary
- opIndexOpAssign
- opDollar
- opSlice

(I specifically took out the now-discouraged opSliceUnary, 
opSliceAssign, and opSliceOpAssign.)

   http://ddili.org/ders/d.en/operator_overloading.html

(Chuck Allison will be mad at me because I used one of his programming 
assignments as an example there: Double-ended queue implemented in terms 
of two D slices. :) )

2) I added the multi-dimensional operator overloading to the More 
Templates chapter under the section "Using templates in 
multi-dimensional operator overloading".

(That is admittedly a curious place for it but multi-dimensional 
operator overloading uses tuple template parameters, which are 
introduced in that chapter.)

There, I especially noted that the responsibility of opSlice is reduced 
to returning simply a Tuple!(size_t, size_t) or an equivalent type.

(In case others have missed it, returning a slice representing all of 
the elements of a container is now the responsibility of opIndex that 
takes no parameters.)

   http://ddili.org/ders/d.en/templates_more.html

Ali



More information about the Digitalmars-d-announce mailing list