March 29, 2013
On Friday, 29 March 2013 at 01:13:36 UTC, Jonathan M Davis wrote:
> In either case, I'd suggest reading this if you want to know more about
> ranges:
>
> http://ddili.org/ders/d.en/ranges.html

Thank you, I will read that (when the time is not 0400).
I feel I need to stress that this is something that quite possibly will scare away newcomers, that static arrays, dynamic arrays and ranges looks very similar to each other, but behaves differently. This is not the first time I fall in this pit, and I suspect it's not the last time either.
And well, sorry for continuing to nag about this, but take a look at the documentation for read(), write() and append() in std.bitmanip:
T read(T, En­dian en­di­an­ness = Endian.​bigEndian, R)(ref R range);
void write(T, En­dian en­di­an­ness = Endian.​bigEndian, R)(R range, T value, size_t index);
void ap­pend(T, En­dian en­di­an­ness = Endian.​bigEndian, R)(R range, T value);
append() and write() are practically identical, just with write() having an extra parameter. The documentation even comes with examples for write() that use "ubyte[] buffer; buffer.write!ubyte(42, 0);", is it really odd that I assumed I could use append() in a similar matter when its parameters are exactly the same as for write() (minus the index)? Or is it unthinkable that I mistook arrays and Ranges for being interchangeable when the examples pass an array to a function that takes a Range?
Ranges is something that's going to be new for a lot of people entering this language. When you know how arrays and ranges works in D I'm sure this makes perfect sense, but until you learn that, this is something that likely will confuse many people.

Hopefully the article about ranges will clear things up for me.
March 29, 2013
On Friday, March 29, 2013 04:01:40 Vidar Wahlberg wrote:
> Or is it
> unthinkable that I mistook arrays and Ranges for being
> interchangeable when the examples pass an array to a function
> that takes a Range?

I don't think that it's unthinkable at all (and arrays _are_ ranges; it's just that in the case of output ranges, arrays act a bit oddly). The documentation should probably be improved to make such a mistake less likely.

> Ranges is something that's going to be new for a lot of people entering this language. When you know how arrays and ranges works in D I'm sure this makes perfect sense, but until you learn that, this is something that likely will confuse many people.
> 
> Hopefully the article about ranges will clear things up for me.

Yes. Ranges are incredibly powerful, but while the concept doesn't originate with D, AFAIK, actually using them in a serious API (particularly in a standard library) is unique to D. And our lack of good tutorials on them is probably our biggest documentation problem. It definitely needs to be fixed.

- Jonathan M Davis
March 29, 2013
On Friday, 29 March 2013 at 02:39:59 UTC, Jonathan M Davis wrote:

> Only having append would actually be problematic, as there
> are cases where you really do need write and not append. And neither of them
> have been in Phobos for all that long (peek, read, write, and append were
> added in 2.060).
>
> - Jonathan M Davis

Ah, I was just going by the docs when I wrote this. I apparently got it wrong. write doesn't using indexing it uses opSliceAssign (which isn't in its constraints). I'm also not familiar with the use cases and there are definitely reasons to stray from idiomatic D.
March 29, 2013
On Friday, March 29, 2013 16:33:33 Jesse Phillips wrote:
> Ah, I was just going by the docs when I wrote this. I apparently got it wrong. write doesn't using indexing it uses opSliceAssign (which isn't in its constraints).

I'll have to take a look at that. I think that it was pretty much assuming that all of the slicing stuff would work with hasSlicing, but that stuff doesn't check for opSliceAssign, so clearly the template constraints need some work. Thanks for pointing that out.

- Jonathan M Davis
October 08, 2013
28.03.2013 0:28, Andrei Alexandrescu пишет:
> On 3/27/13 3:18 PM, H. S. Teoh wrote:
>> Which is what Denis' multidimensional array implementation does. As does
>> my implementation as well.
>>
>> This seems to be quite a common use-case; we should put this into Phobos
>> IMO.
>
> Agree. Do you (or Denis) have something in reviewable form?
>
> Andrei

No. The module is 2 years old and I only made changes on dmd requests. But if such functionality is really needed I will be happy to revise API and prepare my implementation for review.

P.S.
It's an accident I have seen this post. I think in the case of such questions it is obligatory to e-mail the author or there is a big risk the question will bot be delivered.

-- 
Денис В. Шеломовский
Denis V. Shelomovskij
1 2 3 4 5 6 7
Next ›   Last »