# Please support properties in class interfaces

**URL:** <https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269>\
**Category:** Bugs and Feature Requests\
**Created:** [May 11, 2024, 6:08am UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269 "2024-05-11T06:08:59Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [May 11, 2024, 1:23pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/21 "2024-05-11T13:23:56Z")

</div>

I can’t see it working in tests.

Using accessors is ok:

 ![image](https://forum.xojo.com/uploads/default/original/3X/6/7/671a19e2457f3d1334c62f777c291e870243a9a5.png)

A “regular one” is forbidden…

 ![image](https://forum.xojo.com/uploads/default/original/3X/5/8/58eefbe31b627ae98f8e47269429af6580108ee0.png)

---

<div class="post-metadata">

**Author:** ![GarryPettet](https://forum.xojo.com/user_avatar/forum.xojo.com/garrypettet/32/31_2.png) [@GarryPettet](https://forum.xojo.com/u/GarryPettet)\
**Post date:** [May 11, 2024, 1:24pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/22 "2024-05-11T13:24:43Z")

</div>

DerkJ and Christian are thinking exactly as I am.

I believe the programmer should be able to choose to implement either a property or computed property. I don’t believe the interface should enforce a computed property.

What the interface is saying is “make sure this class has a property called `Name`”. If the programmer wants to make it a regular property the compiler should be smart enough to figure that out. Many other programming languages support this.

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [May 11, 2024, 1:26pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/23 "2024-05-11T13:26:33Z")

</div>

Probably needs a read/write definition (empty computed)

But the implementations can have normal or computed if read and write

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [May 11, 2024, 1:30pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/24 "2024-05-11T13:30:05Z")

</div>

> [@GarryPettet](#):
>
> either a property or computed property. I don’t believe the interface should enforce a computed property. … Many other programming languages support this.

Show me an example please. As Swift is your current domain, what’s wrong with this:

```auto
protocol Greet {
  
  // blueprint of property
  var name: String;

  // blueprint of a method 
  func message() 
} 

// conform class to Greet protocol
class Person: Greet {

  // implementation of property
  var name = "Peter"

  // implementation of method
  func message() {
    print("Hello", name)
  }
}

var spider = Person()
spider.message()

```

```auto
ERROR!
/tmp/65BkNnTOmJ.swift:4:7: error: property in protocol must have explicit { get } or { get set } specifier
  var name: String;
      ^
                   { get <#set#> }

// seems TO DEMAND being "computed", i.e. needs accessors.

```

The fix is:

```auto
protocol Greet {
  
  // blueprint of property
  var name: String {get} // computed

  // blueprint of a method 
  func message() 
}

```

---

<div class="post-metadata">

**Author:** ![DerkJ](https://forum.xojo.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@DerkJ](https://forum.xojo.com/u/DerkJ)\
**Post date:** [May 11, 2024, 1:37pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/25 "2024-05-11T13:37:00Z")

</div>

@Rick_Araujo it’s all in the docs  
[https://docs.swift.org/swift-book/documentation/the-swift-programming-language/protocols/](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/protocols/)

Xojo is not swift and vice versa but the implementation explained there is the most flexible and probably the best fit.

---

<div class="post-metadata">

**Author:** ![Rick\_Araujo](https://forum.xojo.com/user_avatar/forum.xojo.com/rick_araujo/32/251_2.png) [@Rick\_Araujo](https://forum.xojo.com/u/Rick_Araujo)\
**Post date:** [May 11, 2024, 1:37pm UTC](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269/26 "2024-05-11T13:37:28Z")

</div>

Show me it working, please.

[Previous page](https://forum.xojo.com/t/please-support-properties-in-class-interfaces/80269.md?page=1)
