Jump to page: 1 24  
Page
Thread overview
Poll: do you use @property semantics?
Sep 14
Daniel N
Sep 14
ryuukk_
Sep 14
monkyyy
Sep 14
IGotD-
Sep 14
Ogi
Sep 15
bauss
Sep 15
Dukc
Sep 18
ikelaiah
4 days ago
Dom DiSc
4 days ago
Ali Çehreli
4 days ago
Dom DiSc
2 days ago
Salih Dincer
4 days ago
Timon Gehr
2 days ago
Sönke Ludwig
2 days ago
Quirin Schroll
2 days ago
Dom DiSc
1 day ago
Tejas
1 day ago
Salih Dincer
2 days ago
Salih Dincer
1 day ago
razyk
26 minutes ago
Dom DiSc
13 hours ago
deadalnix
September 14

Recently Walter has been wanting to remove language features that don't need to be kept to simplify the language.

It seems everybody agrees that binary literals are not a worthy candidate for removal, but one thing that I kept thinking about was @property. As far as I know, hardly anyone actually uses its semantic behaviors, and the ones that it does have which are incomplete are special cases that don't benefit us all that much.

I was going to post this yesterday, but it turns out I am not alone in thinking this can be removed safely (can be swapped to a UDA to prevent code breakage without any language additions).

So, who uses @property semantics?

https://dlang.org/spec/function.html#property-functions

September 14

On Wednesday, 14 September 2022 at 19:20:04 UTC, Rikki Cattermole wrote:

>

Recently Walter has been wanting to remove language features that don't need to be kept to simplify the language.

So, who uses @property semantics?

https://dlang.org/spec/function.html#property-functions

Not using.

September 14

I don't use it, and i don't understand why it exist to be honest

September 14

On Wednesday, 14 September 2022 at 19:20:04 UTC, Rikki Cattermole wrote:

>

Recently Walter has been wanting to remove language features that don't need to be kept to simplify the language.

It seems everybody agrees that binary literals are not a worthy candidate for removal, but one thing that I kept thinking about was @property. As far as I know, hardly anyone actually uses its semantic behaviors, and the ones that it does have which are incomplete are special cases that don't benefit us all that much.

I was going to post this yesterday, but it turns out I am not alone in thinking this can be removed safely (can be swapped to a UDA to prevent code breakage without any language additions).

Delete all @ related features

>

So, who uses @property semantics?

https://dlang.org/spec/function.html#property-functions

September 14

On Wednesday, 14 September 2022 at 19:20:04 UTC, Rikki Cattermole wrote:

>

I was going to post this yesterday, but it turns out I am not alone in thinking this can be removed safely (can be swapped to a UDA to prevent code breakage without any language additions).

So, who uses @property semantics?

https://dlang.org/spec/function.html#property-functions

So @property is similar to C# get/set? C# get/set are useful if you want an assignment of a member run a function for example. I can see that such a thing can be useful in D as well. If @property is removed can the same be achieved by other means?

September 14
On Wednesday, 14 September 2022 at 21:42:48 UTC, IGotD- wrote:
> So @property is similar to C# get/set?

Frankly, if you have to ask, then no, you don't use it. The semantics are pretty subtle.
September 15
On 15/09/2022 9:42 AM, IGotD- wrote:
> So @property is similar to C# get/set?

No. Getting and setting behavior via a method is not associated with @property.

https://dlang.org/spec/function.html#property-functions

Works:

```d
struct Foo
{
    int data() { return m_data; } // read property

    int data(int value) { return m_data = value; } // write property

  private:
    int m_data;
}

void main() {
    Foo foo;
    foo.data = 234;
}
```
September 14

On Wednesday, 14 September 2022 at 19:20:04 UTC, Rikki Cattermole wrote:

>

Recently Walter has been wanting to remove language features that don't need to be kept to simplify the language.

Please consider "pure". :)

>

It seems everybody agrees that binary literals are not a worthy candidate for removal

Don't care.

>

I was going to post this yesterday, but it turns out I am not alone in thinking this can be removed safely (can be swapped to a UDA to prevent code breakage without any language additions).

So, who uses @property semantics?

https://dlang.org/spec/function.html#property-functions

Not me. And if I see one, I remove it.

Still, there are 44 @property occurence in my whole code base (because stuff get copy-pasted) that I never really wanted there.

September 14

On Wednesday, 14 September 2022 at 19:20:04 UTC, Rikki Cattermole wrote:

>

So, who uses @property semantics?

I would use @property a lot if it was actually useful.

struct S {
    int _x;
    @property int x() const {
        return _x;
    }
    @property void x(int value) {
        _x = value;
    }
}
void main() {
    S s;
    // Doesn’t work:
    //s.x += 1;
    // Neither does this:
    //s.x++;
}
September 14
On 9/14/22 14:50, rikki cattermole wrote:
> 
> On 15/09/2022 9:42 AM, IGotD- wrote:
>> So @property is similar to C# get/set?
> 
> No. Getting and setting behavior via a method is not associated with @property.
> 
> https://dlang.org/spec/function.html#property-functions
> 
> Works:
> 
> ```d
> struct Foo
> {
>      int data() { return m_data; } // read property
> 
>      int data(int value) { return m_data = value; } // write property
> 
>    private:
>      int m_data;
> }
> 
> void main() {
>      Foo foo;
>      foo.data = 234;
> }
> ```

I think I heard about supporting the following as well, which is currently missing:

    foo.data++;

An exception to that is the .length property of arrays, which is practically a property function with privileges. :)

Ali
« First   ‹ Prev
1 2 3 4