Re: Does D have class' attributes like C#'s?

2017-12-17 Thread SealabJaster via Digitalmars-d-learn
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: Does D have something similar? As others have said, D has UDAs. An alternative to using __traits(getAttributes) is to use std.traits.getUDAs [1] I've made a small example using std.traits.getUDAs, based off of your example. [2]

Re: Does D have class' attributes like C#'s?

2017-12-17 Thread Jacob Carlborg via Digitalmars-d-learn
On 2017-12-16 22:11, Marc wrote: I can't "pack" an object, right? In C#, TextSize is a class and 256 is constructor's first argument. In D it's pretty much an array but I guess it's close enough. Thanks! In D it's an tuple of basically anything that is known at compile time, values or

Re: Does D have class' attributes like C#'s?

2017-12-16 Thread Basile B. via Digitalmars-d-learn
On Saturday, 16 December 2017 at 21:11:43 UTC, Marc wrote: On Saturday, 16 December 2017 at 20:05:15 UTC, Anonymouse wrote: On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: C# has a quite nice way to store metadata about a property by a feature called atributes[1]. For example, I can

Re: Does D have class' attributes like C#'s?

2017-12-16 Thread Jonathan M Davis via Digitalmars-d-learn
On Saturday, December 16, 2017 21:11:43 Marc via Digitalmars-d-learn wrote: > On Saturday, 16 December 2017 at 20:05:15 UTC, Anonymouse wrote: > > On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: > >> C# has a quite nice way to store metadata about a property by > >> a feature called

Re: Does D have class' attributes like C#'s?

2017-12-16 Thread Marc via Digitalmars-d-learn
On Saturday, 16 December 2017 at 20:05:15 UTC, Anonymouse wrote: On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: C# has a quite nice way to store metadata about a property by a feature called atributes[1]. For example, I can write something like this: class A { [TextSize(256)]

Re: Does D have class' attributes like C#'s?

2017-12-16 Thread Anonymouse via Digitalmars-d-learn
On Saturday, 16 December 2017 at 19:57:30 UTC, Marc wrote: C# has a quite nice way to store metadata about a property by a feature called atributes[1]. For example, I can write something like this: class A { [TextSize(256)] string Name { get; set; } } So using runtime/reflection I

Does D have class' attributes like C#'s?

2017-12-16 Thread Marc via Digitalmars-d-learn
C# has a quite nice way to store metadata about a property by a feature called atributes[1]. For example, I can write something like this: class A { [TextSize(256)] string Name { get; set; } } So using runtime/reflection I can retrieve the TextSize value associated to A.name

Re: Class attributes

2016-10-03 Thread Satoshi via Digitalmars-d-learn
On Sunday, 2 October 2016 at 17:22:57 UTC, Basile B. wrote: On Sunday, 2 October 2016 at 15:54:38 UTC, Satoshi wrote: Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ?? This is not specified but attributes aren't applied to

Re: Class attributes

2016-10-02 Thread Basile B. via Digitalmars-d-learn
On Sunday, 2 October 2016 at 15:54:38 UTC, Satoshi wrote: Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ?? This is not specified but attributes aren't applied to the scope created by the declaration. Which is a good thing,

Class attributes

2016-10-02 Thread Satoshi via Digitalmars-d-learn
Hello, why pure @safe nothrow @nogc struct Point { } isn't same as struct Point { pure: @safe: nothrow: @nogc: } ??