July 20, 2010
On Tue, 20 Jul 2010 18:35:12 +0200, Simen kjaeraas <simen.kjaras@gmail.com> wrote:

> Rory McGuire <rmcguire@neonova.co.za> wrote:
>
> [snip]
>
> Rory, is there something wrong with your newsreader? I keep seeing your
> posts as replies only to the top post.
>

I'm using opera mail. Any suggestions for Linux+Windows, excluding thunderbird(slow)?
July 20, 2010
Jérôme M. Berger wrote:
> 	And what about this one:
> 
> void func(T) (T range) {
>     foreach (elem; range)
>         assert (is (typeof (elem) == ElementType!(T)));
> }
> 
> func ("azerty");
> auto a = [ 1, 2, 3, 4, 5];
> func (a);

You can specialize the template for strings:

void func(T:string)(T range) { ... }
July 20, 2010
Steven Schveighoffer wrote:
> The omission of dchar is on purpose.  Phobos has characterized string as a bidirectional range of dchars.  For every range where I do:
> 
> foreach(e; range)
> 
> e is of the type of the range.  Except for char and wchar.  This schizophrenia of type induction is very bad for D, and it's a good argument of why strings should not simply be arrays.

For many algorithms on strings, iterating by char is preferred over dchar, even for multibyte strings.
July 20, 2010
On Tue, 20 Jul 2010 15:21:34 -0400, Walter Bright <newshound2@digitalmars.com> wrote:

> Steven Schveighoffer wrote:
>> The omission of dchar is on purpose.  Phobos has characterized string as a bidirectional range of dchars.  For every range where I do:
>>  foreach(e; range)
>>  e is of the type of the range.  Except for char and wchar.  This schizophrenia of type induction is very bad for D, and it's a good argument of why strings should not simply be arrays.
>
> For many algorithms on strings, iterating by char is preferred over dchar, even for multibyte strings.

Huh?  Which ones?  AFAIK, all of std.algorithm treats strings as ranges of dchar.

I am 100% in agreement with you that indexing and length should be done by char.  All I'm talking about is foreach.

-Steve
July 20, 2010
Walter Bright wrote:
> Jérôme M. Berger wrote:
>>     And what about this one:
>>
>> void func(T) (T range) {
>>     foreach (elem; range)
>>         assert (is (typeof (elem) == ElementType!(T)));
>> }
>>
>> func ("azerty");
>> auto a = [ 1, 2, 3, 4, 5];
>> func (a);
> 
> You can specialize the template for strings:
> 
> void func(T:string)(T range) { ... }

	Sure, i can also not use a template and write however many
overloaded functions I need. So what are templates for?

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr



July 20, 2010
Jérôme M. Berger wrote:
> Walter Bright wrote:
>> You can specialize the template for strings:
>>
>> void func(T:string)(T range) { ... }
> 
> 	Sure, i can also not use a template and write however many
> overloaded functions I need. So what are templates for?

The overloaded template specialization capability is exactly because it is often advantageous to write custom versions for certain types. The user of the template doesn't see that, it looks generic to him.
July 20, 2010
Steven Schveighoffer wrote:
> On Tue, 20 Jul 2010 15:21:34 -0400, Walter Bright <newshound2@digitalmars.com> wrote:
> 
>> Steven Schveighoffer wrote:
>>> The omission of dchar is on purpose.  Phobos has characterized string as a bidirectional range of dchars.  For every range where I do:
>>>  foreach(e; range)
>>>  e is of the type of the range.  Except for char and wchar.  This schizophrenia of type induction is very bad for D, and it's a good argument of why strings should not simply be arrays.
>>
>> For many algorithms on strings, iterating by char is preferred over dchar, even for multibyte strings.
> 
> Huh?  Which ones?

Searching, for one.


> AFAIK, all of std.algorithm treats strings as ranges of dchar.

Andrei posted elsewhere that there were specializations for strings to do it one way or the other based on which was more efficient.
July 20, 2010
Rory McGuire wrote:
> I'm using opera mail. Any suggestions for Linux+Windows, excluding thunderbird(slow)?

I use thunderbird on both windows & linux, haven't noticed speed problems other than my slow internet connection.

I have noticed that thunderbird uses multithreading fairly effectively to speed itself up.
July 20, 2010
Walter Bright wrote:
> Steven Schveighoffer wrote:
>> On Tue, 20 Jul 2010 15:21:34 -0400, Walter Bright <newshound2@digitalmars.com> wrote:
>>
>>> Steven Schveighoffer wrote:
>>>> The omission of dchar is on purpose.  Phobos has characterized string as a bidirectional range of dchars.  For every range where I do:
>>>>  foreach(e; range)
>>>>  e is of the type of the range.  Except for char and wchar.  This schizophrenia of type induction is very bad for D, and it's a good argument of why strings should not simply be arrays.
>>>
>>> For many algorithms on strings, iterating by char is preferred over dchar, even for multibyte strings.
>>
>> Huh?  Which ones?
> 
> Searching, for one.
> 
> 
>> AFAIK, all of std.algorithm treats strings as ranges of dchar.
> 
> Andrei posted elsewhere that there were specializations for strings to do it one way or the other based on which was more efficient.

Boyer-Moore comes to mind.


Andrei
July 20, 2010
On Tuesday, July 20, 2010 11:45:41 Rory McGuire wrote:
> On Tue, 20 Jul 2010 18:35:12 +0200, Simen kjaeraas
> 
> <simen.kjaras@gmail.com> wrote:
> > Rory McGuire <rmcguire@neonova.co.za> wrote:
> > 
> > [snip]
> > 
> > Rory, is there something wrong with your newsreader? I keep seeing your posts as replies only to the top post.
> 
> I'm using opera mail. Any suggestions for Linux+Windows, excluding
> thunderbird(slow)?

Well, since I'm a kde user, I use knode if I want a newsreader and kmail if I want a mail client. I prefer knode for dealing with newsgroups rather than using a mail list with kmail, but I do sometimes end up using kmail with mail lists rather than knode because I can take advantage of imap and have stuff properly synced between my machines.

- Jonathan M Davis