February 15, 2017
On 02/15/2017 12:18 PM, Seb wrote:
>
> uint getAttributes(R)(R name)
> if (isInputRange!R && !isInfinite!R &&
> isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R);
>
>
> Now as this same block is used > 30x in Phobos one could argue that it
> makes sense to use a convenience trait like:

isStringLike. I wanted to add this for a while already. Please do! -- Andrei
February 15, 2017
On 2017-02-15 15:01, Andrei Alexandrescu wrote:

> That's nice, could you please submit as an enhancement request on bugzilla?

https://issues.dlang.org/show_bug.cgi?id=17186

-- 
/Jacob Carlborg
February 15, 2017
On 02/15/2017 02:22 PM, Jacob Carlborg wrote:
> On 2017-02-15 15:01, Andrei Alexandrescu wrote:
>
>> That's nice, could you please submit as an enhancement request on
>> bugzilla?
>
> https://issues.dlang.org/show_bug.cgi?id=17186

Thanks. I'll take it up to Walter for preapproval. -- Andrei

February 15, 2017
On 02/15/2017 06:20 AM, Daniel N wrote:
> On Wednesday, 15 February 2017 at 09:22:14 UTC, Daniel N wrote:
>> template every(T...)
>> {
>>     template satisfies(U...)
>>     {
>>         enum satisfies = true;
>>     }
>> }
>
> (lunch-break => time to hack D!)
>
> template every(T...)
> {
>   template satisfies(U...)
>   {
>     enum satisfies = {
>       foreach(t; T)
>         foreach(u; U)
>       if(!u!t)
>             return false;
>       return true;
>     }();
>   }
> }

That looks pretty neat. Can you find 4-5 cases in which this could be used gainfully in Phobos? Thanks! -- Andrei


February 15, 2017
This thread completely diverged from the original post, which was propsing `::` instead of `from!`:

```
void fun(T)(std.stdio::File input, T value) if (std.traits::isIntegral!T)
{...}
```

instead of:

```
void fun(T)(Module!"std.stdio".File input, T value) if
(Module!"std.traits".isIntegral!T)
{...}
```

I see it as a clear improvment in readability (see original post for details along with shortcomings of `from!` approach )


On Wed, Feb 15, 2017 at 11:39 AM, Andrei Alexandrescu via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> On 02/15/2017 06:20 AM, Daniel N wrote:
>
>> On Wednesday, 15 February 2017 at 09:22:14 UTC, Daniel N wrote:
>>
>>> template every(T...)
>>> {
>>>     template satisfies(U...)
>>>     {
>>>         enum satisfies = true;
>>>     }
>>> }
>>>
>>
>> (lunch-break => time to hack D!)
>>
>> template every(T...)
>> {
>>   template satisfies(U...)
>>   {
>>     enum satisfies = {
>>       foreach(t; T)
>>         foreach(u; U)
>>       if(!u!t)
>>             return false;
>>       return true;
>>     }();
>>   }
>> }
>>
>
> That looks pretty neat. Can you find 4-5 cases in which this could be used gainfully in Phobos? Thanks! -- Andrei
>
>
>


February 15, 2017
On Wednesday, 15 February 2017 at 18:51:40 UTC, Andrei Alexandrescu wrote:
> On 02/15/2017 12:18 PM, Seb wrote:
>>
>> uint getAttributes(R)(R name)
>> if (isInputRange!R && !isInfinite!R &&
>> isSomeChar!(ElementEncodingType!R) && !isConvertibleToString!R);
>>
>>
>> Now as this same block is used > 30x in Phobos one could argue that it
>> makes sense to use a convenience trait like:
>
> isStringLike. I wanted to add this for a while already. Please do! -- Andrei

https://github.com/dlang/phobos/pull/5137
February 15, 2017
On Wednesday, 15 February 2017 at 20:09:46 UTC, Timothee Cour wrote:
> This thread completely diverged from the original post, which was propsing `::` instead of `from!`:
>
> ```
> void fun(T)(std.stdio::File input, T value) if (std.traits::isIntegral!T)
> {...}
> ```
>
> instead of:
>
> ```
> void fun(T)(Module!"std.stdio".File input, T value) if
> (Module!"std.traits".isIntegral!T)
> {...}
> ```
>
> I see it as a clear improvment in readability (see original post for details along with shortcomings of `from!` approach )

I really think allowing `with (module_!"std.foo")` before declarations is a better solution from a DRY perspective, plus it works for UFCS. This is a more general change that has other benefits that apply to any static aggregate e.g. enum names - `with(Enum)`, not just imports.
February 15, 2017
On Wednesday, February 15, 2017 14:30:02 Andrei Alexandrescu via Digitalmars-d wrote:
> On 02/15/2017 02:22 PM, Jacob Carlborg wrote:
> > On 2017-02-15 15:01, Andrei Alexandrescu wrote:
> >> That's nice, could you please submit as an enhancement request on bugzilla?
> >
> > https://issues.dlang.org/show_bug.cgi?id=17186
>
> Thanks. I'll take it up to Walter for preapproval. -- Andrei

It's one of those features that I was surprised when you couldn't do it.

- Jonathan M Davis

February 15, 2017
On 2/15/2017 10:51 AM, Andrei Alexandrescu wrote:
> isStringLike. I wanted to add this for a while already. Please do! -- Andrei

What I've found messy and confusing with string overloads in Phobos is there are at least 6 kinds of strings:

1. auto decoding dynamic arrays
2. not auto decoding arrays
3. static arrays
4. aggregates with an 'alias this' to a string
5. ranges of characters
6. something convertible to a string

These classifications seem to be tested for in a unique ad-hoc manner in every case.

I'd like to take a step back and devise a consistent taxonomy of these things, based on how Phobos uses them, before adding more names.

February 15, 2017
Please fix your newsreader so it submits postings in text format, not html.