Jump to page: 1 26  
Page
Thread overview
Poll: do you use @property semantics?
Sep 14, 2022
Rikki Cattermole
Sep 14, 2022
Daniel N
Sep 14, 2022
ryuukk_
Sep 14, 2022
monkyyy
Sep 14, 2022
IGotD-
Sep 14, 2022
Adam D Ruppe
Sep 14, 2022
rikki cattermole
Sep 14, 2022
Ali Çehreli
Sep 14, 2022
Adam D Ruppe
Sep 14, 2022
Guillaume Piolat
Sep 14, 2022
Ogi
Sep 15, 2022
Ruby The Roobster
Sep 15, 2022
rikki cattermole
Sep 15, 2022
Ruby The Roobster
Sep 15, 2022
rikki cattermole
Sep 15, 2022
Max Samukha
Sep 15, 2022
Max Samukha
Sep 15, 2022
bauss
Sep 15, 2022
Dukc
Sep 15, 2022
H. S. Teoh
Sep 15, 2022
Timon Gehr
Sep 16, 2022
rikki cattermole
Sep 16, 2022
max haughton
Sep 16, 2022
Quirin Schroll
Sep 18, 2022
Olivier Pisano
Sep 18, 2022
ikelaiah
Sep 26, 2022
Dom DiSc
Sep 26, 2022
Ali Çehreli
Sep 26, 2022
Dom DiSc
Sep 28, 2022
Salih Dincer
Sep 27, 2022
Timon Gehr
Sep 28, 2022
Sönke Ludwig
Sep 29, 2022
Quirin Schroll
Sep 29, 2022
Dom DiSc
Sep 30, 2022
Tejas
Sep 30, 2022
Salih Dincer
Sep 29, 2022
Salih Dincer
Sep 30, 2022
razyk
Oct 01, 2022
Dom DiSc
Oct 01, 2022
rikki cattermole
Oct 01, 2022
Dom DiSc
Oct 01, 2022
deadalnix
Oct 01, 2022
deadalnix
Oct 01, 2022
Walter Bright
Oct 01, 2022
Timon Gehr
Oct 02, 2022
razyk
Oct 02, 2022
Timon Gehr
Oct 02, 2022
razyk
Oct 02, 2022
Timon Gehr
Oct 02, 2022
deadalnix
Oct 01, 2022
deadalnix
September 14, 2022

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, 2022

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, 2022

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

September 14, 2022

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, 2022

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, 2022
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, 2022
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, 2022

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, 2022

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, 2022
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 5 6