Best way to "classify" sections of code

In Xojo you have Methods, Events, Properties

And in Swift you have these same things… but they are not denoted as such… So if you were looking at the code, what criteria would you use to classify things

A Property would be any simple or computed variable, but it COULD (or should?) be a FUNC that return a value???

While a Method would be a FUNC that doesn’t return a value. Or it might be an EVENT how could you easily tell by looking?

Note … this would all be code inside an object class… and would be relative to that object.

properti-ness as I liked to call it is achievable in Xojo in several ways

  • a simple intrinsic type
  • a “computed” property which has getter / setter (either both etc)
  • a method pair - a get function that returns then value and another that assigns it

in xojo these are almost entirely indistinguishable from a syntax point of vie to whatever code is manipulating the property

dont know if this is possible in Swift

An event is, in xojo, a method (sub or function) that handles an event :stuck_out_tongue:
The syntax shown on
is illustrative for both event definitions and event handlers

Methods are pretty straight forward after you handle all those

your third bullet might take a bit of doing :frowning: hmmmmm…

As to event… that is tricky, especially since some of what I would want to classify as an event is a “method” that the subclass code calls, sometimes from a true Apple event, sometimes in a chain of methods…

I’ll bet that for the Xojo LR… some of (most?) was arbitraily decided by who ever was writing a given section (I’ve seen some things that I

talk about confusing… this is legal and compiles!

var foobar : Int { get { return 5 } set { z999=3 } }
func foobar(x:Int) {}
func foobar(x:Int) -> Int { return 0 }

Yeah I cant thing of another language that lets me switch between the 3 ways of defining a “property” that are all syntactically interchangeable like Xojo does

That seems to be quite unique