Hi 4tH-ers!
If you don't like OOP, stop reading. You might remember I turned the dynamic array library into an OOP vector library some time ago.
You might be happy to know I added a FOREACH like method to it. It takes an execution token, which it will apply to the contents of every element. You read that correctly - the contents, not the address of the element. The dynamic array library doesn't support raw addresses anyway, but requires the address of the entire array and an index.
But if you stored pointers to objects there, it is quite useful. It really simplified the FOOS ARRY.4pp example. E.g. the deconstructor of the Dogs vector can be reduced to:
:delete [: delete ;] this -> veach ;method
And the barking method is simply:
:method barking [: -> bark ;] this -> veach ;method
I hope you like this addition. MAP and REDUCE seem to be a bit harder, but given enough interest, I might give it a go as well.
Hans Bezemer