May 12, 2008
Which buzz-word would that be?

I find your remark/analogy off-topic.

Walter clearly states that Phobos is demand driven.
Also, his floating point analogy is right on mark.

> The last thing I ever thought I would see, was D become "buzz-word
> complient".
> It's such a shame to see such a promising beginning get sidetracked off
> into a
> world of academic theory and computer science correctness. The promise was
> that
> because one guy with a pragmatic vision and the skills to make them so,
> held
> the ropes and was steering the thing, that D wouldn't be subject to the
> pull &
> push of academic group think nor the quagmire of design by committee.
>
> b.
> -- 
> 


May 12, 2008
Saaa wrote:

> Which buzz-word would that be?

"const", "invariant", "pure", take your pick.
> 
> I find your remark/analogy off-topic.

The topic is "dynamic arrays in Dv1". I replied to a post suggesting that the support for dynamic arrays in Dv1 was missing some fundamental features. I concur.

Analogies are, by their nature "off-topic". They seek to clarify a point by reference to something more easiily understood.

> 
> Walter clearly states that Phobos is demand driven.
> Also, his floating point analogy is right on mark.
> 

You like Walter's analogy. Okay.

Not all flosting point operations have to be built-in to the compiler. But if you had to resort to bit-twiddling the IEEE format in order to  do exponentiation, you might wonder at the competeness., Or if summing an bunch of reals caused a new 10-bytes to be allocated to accomodate each intermediary subtotal, you might be a little taken aback.

Dynamic arrays are superior to fixed sized arrays, not just because you don't have to know their size at compile time, but because they grow and shrink to accomodate the demands the algorithm places upon them. Insert and delete are about as fundamental to strings and exponentiation is to reals.

b.
-- 

May 12, 2008
>> Which buzz-word would that be?
>
> "const", "invariant", "pure", take your pick.

It sounded like you meant buzz-word to cover a broader audience than this
newsgroup.
I didn't know those where buzz-words in that sense, I just thought they were
keywords in the whole const-discussion on this newsgroup.

>>
>> I find your remark/analogy off-topic.
>
> The topic is "dynamic arrays in Dv1". I replied to a post suggesting that
> the
> support for dynamic arrays in Dv1 was missing some fundamental features. I
> concur.
>
> Analogies are, by their nature "off-topic". They seek to clarify a point
> by
> reference to something more easiily understood.
By this definition I can't agree that analogies are by nature off-topic, but going further into this would certainly yield that way and would end in a good old fashioned dictionary fight ;)

>
>>
>> Walter clearly states that Phobos is demand driven.
>> Also, his floating point analogy is right on mark.
>>
>
> You like Walter's analogy. Okay.
>
> Not all flosting point operations have to be built-in to the compiler. But
> if
> you had to resort to bit-twiddling the IEEE format in order to  do
> exponentiation, you might wonder at the competeness., Or if summing an
> bunch of
> reals caused a new 10-bytes to be allocated to accomodate each
> intermediary
> subtotal, you might be a little taken aback.
>
> Dynamic arrays are superior to fixed sized arrays, not just because you
> don't
> have to know their size at compile time, but because they grow and shrink
> to
> accomodate the demands the algorithm places upon them. Insert and delete
> are
> about as fundamental to strings and exponentiation is to reals.
>
I won't go into the being superior part, but why hasn't anybody asked about
delete and inserts before? (not rhetorical)
I think slicing and concatenation are fundamental in D.


May 12, 2008
在 Mon, 12 May 2008 03:44:38 +0800,Bill Baxter <dnewsgroup@billbaxter.com> 写道:

> Janice Caron wrote:
>> On 11/05/2008, Edward Diener <eddielee_no_spam_here@tropicsoft.com> wrote:
>>> In D 1.0 dynamic arrays are the equivalent of C++'s std::vector<T>, with
>>> slicing replacing iterators in order to access some subrange of the
>>> sequence. In C++ there is functionality in std::vector::erase for erasing
>>> elements from the vector and std::vector::insert for inserting new elements
>>> into the vector. Where is that functionality in D's dynamic arrays ?
>>  To erase the elements from index i to index j in place:
>>      array[i..$+i-j][] = array[j..$].dup;
>>     array = array[0..$+i-j];
>
> It can be done more efficiently using memmove to shift contents down. Also if you're dropping the tail end, you can just change .length. Cashew's erase routine (called "dropRange") does both.
>
> --bb

I will imagine D already calls memmove to perform array overlap copy.

-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
May 12, 2008
I think it's because erase and insert are really just the inverse of slicing and concatenation.

int[] a, c;

// insert
c = a.insert(b, 10);
c = a[0..10] ~ b ~ a[10..$];

// delete
c = a.delete(&a[10..20]);
c = a[0..10] ~ a[20..$];

I essence delete and insert are just another way of expressing slices and concatenations. Personally I prefer slicing and concatting stuff, because it expresses better what's actually happening.

Delete and Insert on the other hand are higher level and generally more intuitive. They leave optimization to the compiler/library. And I think most D-users like more control of optimizations than users of more high level languages.

Cheers,
Boyd

---------
On Mon, 12 May 2008 06:11:35 +0200, Saaa <empty@needmail.com> wrote:

> I won't go into the being superior part, but why hasn't anybody asked about
> delete and inserts before? (not rhetorical)
> I think slicing and concatenation are fundamental in D.
May 12, 2008
Bill Baxter wrote:
> Edward Diener wrote:
>> In D 1.0 dynamic arrays are the equivalent of C++'s std::vector<T>, with slicing replacing iterators in order to access some subrange of the sequence. In C++ there is functionality in std::vector::erase for erasing elements from the vector and std::vector::insert for inserting new elements into the vector. Where is that functionality in D's dynamic arrays ?
> 
> Yes, erase & insert and many other things are conspicuously missing from D1 Phobos (not sure about D2 Phobos).  I like the collection of such routines provided by the Cashew library in the cashew.utils.Array module.

I've been using tango's HashSet instead, since I don't need ordering. How do the Cashew collections compare?

>> Furthermore in D 1.0 a char[], a dynamic array of characters, is the equivalent of the C++ std::string. In the C++ std::string class there is a rich set of functionality for manipulating the char elements in the string, for finding particular elements in the string, and for comparing the character elements in strings with other strings, but I see little of this in dynamic array functionality. What am I missing ?
> 
> Those functions are in std.string in Phobos.  And scattered all over the place in Tango.

If by 'scattered all over the place' you mean 'most everything suitable for all array types is in tango.core.Array and everything else is in tango.text.*', yes.
May 12, 2008
boyd wrote:

> Delete and Insert on the other hand are higher level and generally more intuitive. They leave optimization to the compiler/library. And I think most D-users like more control of optimizations than users of more high level languages.

You really think that slice and join will be more efficient, or afford greater opportunities for optimisation than insert & delete?

Can I suggest that you produce a simple (or complex) benchmark to demonstrate
that?

b.
-- 

May 12, 2008
I'm not saying either way is more efficient. I'm saying that slicing and concatenation are lower level functionality than insert and delete. So most optimizations when using slicing and concatenation will be done by the programmer, rather than the compiler or library.

In the end any delete or insert function implementation will have to use lower level functionality like concatenating, slicing, memory movement or something like that, whereas concatenation and slicing are about as low as you can get.

Cheers,
Boyd

----------
On Mon, 12 May 2008 18:36:59 +0200, Me Here <p9e883002@sneakemail.com> wrote:

> boyd wrote:
>
>> Delete and Insert on the other hand are higher level and generally more
>> intuitive. They leave optimization to the compiler/library. And I think
>> most D-users like more control of optimizations than users of more high
>> level languages.
>
> You really think that slice and join will be more efficient, or afford greater
> opportunities for optimisation than insert & delete?
>
> Can I suggest that you produce a simple (or complex) benchmark to demonstrate
> that?
>
> b.
May 12, 2008
boyd wrote:

> I'm not saying either way is more efficient. I'm saying that slicing and concatenation are lower level functionality than insert and delete. So  most optimizations when using slicing and concatenation will be done by  the programmer, rather than the compiler or library.

You don't think that this is stuff that should be got right once and then just
reused?
You're not a /real D programmer/ unless reimplement these well-documented
algorithms yourself?

b.
-- 

May 12, 2008
Christopher Wright wrote:
> Bill Baxter wrote:
>> Edward Diener wrote:
>>> In D 1.0 dynamic arrays are the equivalent of C++'s std::vector<T>, with slicing replacing iterators in order to access some subrange of the sequence. In C++ there is functionality in std::vector::erase for erasing elements from the vector and std::vector::insert for inserting new elements into the vector. Where is that functionality in D's dynamic arrays ?
>>
>> Yes, erase & insert and many other things are conspicuously missing from D1 Phobos (not sure about D2 Phobos).  I like the collection of such routines provided by the Cashew library in the cashew.utils.Array module.
> 
> I've been using tango's HashSet instead, since I don't need ordering. How do the Cashew collections compare?

Oh, Cashew doesn't provide collections.  Cashew.utils.Array is just a bunch of functions for working on D's built-in arrays.  Things like insert, remove, bisection search, etc.

>>> Furthermore in D 1.0 a char[], a dynamic array of characters, is the equivalent of the C++ std::string. In the C++ std::string class there is a rich set of functionality for manipulating the char elements in the string, for finding particular elements in the string, and for comparing the character elements in strings with other strings, but I see little of this in dynamic array functionality. What am I missing ?
>>
>> Those functions are in std.string in Phobos.  And scattered all over the place in Tango.
> 
> If by 'scattered all over the place' you mean 'most everything suitable for all array types is in tango.core.Array and everything else is in tango.text.*', yes.

I mean the * part of tango.text.*, which consitutes about 30 different files.  Not saying it's a bad design, but it does make it a little harder for me to find things.

--bb