Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
September 21, 2016 Question about __treats | ||||
---|---|---|---|---|
| ||||
It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference https://dlang.org/spec/traits.html https://dlang.org/phobos/std_traits.html Could you explain the difference? |
September 21, 2016 Re: Question about __treats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 21/09/2016 7:06 PM, Suliman wrote:
> It's seems that __treats is language keyword that help to get info from
> compile-time. But there is also lib named std.traits
>
> and I can't understand difference
>
> https://dlang.org/spec/traits.html
> https://dlang.org/phobos/std_traits.html
>
> Could you explain the difference?
Simple, __traits or __treats as you called it is implemented by the compiler.
But std.traits is all implemented in the standard library as user D code.
If you can do it with std.traits you should. Otherwise __traits.
So std.traits is a bit higher level and there are more things available there as adding more __traits is a bit rare.
|
September 21, 2016 Re: Question about __treats | ||||
---|---|---|---|---|
| ||||
Posted in reply to rikki cattermole | On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote:
> On 21/09/2016 7:06 PM, Suliman wrote:
>> It's seems that __treats is language keyword that help to get info from
>> compile-time. But there is also lib named std.traits
>>
>> and I can't understand difference
>>
>> https://dlang.org/spec/traits.html
>> https://dlang.org/phobos/std_traits.html
>>
>> Could you explain the difference?
>
> Simple, __traits or __treats as you called it is implemented by the compiler.
> But std.traits is all implemented in the standard library as user D code.
>
> If you can do it with std.traits you should. Otherwise __traits.
> So std.traits is a bit higher level and there are more things available there as adding more __traits is a bit rare.
So for example to get All Members of class I should use allMembers from __traits, because it's seems that std.traits do not have such future.
|
September 21, 2016 Re: Question about __treats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 21/09/2016 7:38 PM, Suliman wrote:
> On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote:
>> On 21/09/2016 7:06 PM, Suliman wrote:
>>> It's seems that __treats is language keyword that help to get info from
>>> compile-time. But there is also lib named std.traits
>>>
>>> and I can't understand difference
>>>
>>> https://dlang.org/spec/traits.html
>>> https://dlang.org/phobos/std_traits.html
>>>
>>> Could you explain the difference?
>>
>> Simple, __traits or __treats as you called it is implemented by the
>> compiler.
>> But std.traits is all implemented in the standard library as user D code.
>>
>> If you can do it with std.traits you should. Otherwise __traits.
>> So std.traits is a bit higher level and there are more things
>> available there as adding more __traits is a bit rare.
>
> So for example to get All Members of class I should use allMembers from
> __traits, because it's seems that std.traits do not have such future.
Yeah exactly.
|
September 21, 2016 Re: Question about __treats | ||||
---|---|---|---|---|
| ||||
Posted in reply to Suliman | On 9/21/16 3:38 AM, Suliman wrote:
> On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote:
>> On 21/09/2016 7:06 PM, Suliman wrote:
>>> It's seems that __treats is language keyword that help to get info from
>>> compile-time. But there is also lib named std.traits
>>>
>>> and I can't understand difference
>>>
>>> https://dlang.org/spec/traits.html
>>> https://dlang.org/phobos/std_traits.html
>>>
>>> Could you explain the difference?
>>
>> Simple, __traits or __treats as you called it is implemented by the
>> compiler.
>> But std.traits is all implemented in the standard library as user D code.
>>
>> If you can do it with std.traits you should. Otherwise __traits.
>> So std.traits is a bit higher level and there are more things
>> available there as adding more __traits is a bit rare.
>
> So for example to get All Members of class I should use allMembers from
> __traits, because it's seems that std.traits do not have such future.
Yes, you can think of __traits as the basic building blocks the compiler provides, and std.traits as providing more features using those building blocks.
-Steve
|
Copyright © 1999-2021 by the D Language Foundation