← Back to team overview

ooc-dev team mailing list archive

Re: New ORC draft - Properties

 

It was my understanding that nddrylliog's plan was to generate getter/setter methods in the generated C for all properties, including the ones that look just like plain old attributes. This is for ease of C calling ooc code. The C generated from the ooc code will still use the fastest way of accessing the variable (direct-access if there is no custom accessor).

As for the syntax, we could do:

age: Int {
    set: func (.age) {
        // ...
    }
    get: func -> Int {
        // ...
    }
}

But personally, I prefer the short form.

On Wed, 31 Mar 2010, Friedrich Weber wrote:

Hi all,

looks good to me, too, thanks for this!

Some things:

name: String {
    set
    get
}

// The above example is exactly equivalent to this:
name: String

IMHO the variable might be equivalent on the ooc level, but not on the C
level: The property would create a setter and a getter method, which
would create ..._setName and ..._getName functions on the C level. This
means: These two examples generate different C APIs.

Also, I just want to note that this getter / setter syntax does not
conform to our original `name: Type` or `name: func ...` syntax - we're
missing the colon. But I see no better solution, since we couldn't use
empty getters / setters with the colon syntax. So, +1 for keeping your
suggested syntax :)

I think allowing multiple values for setters is an interesting idea, but
I'm not sure if we should do this. `1, 2` is not an expression in
"normal" ooc, making it an expression that is only used in the context
of properties would lead to confusion IMHO.

What Do You Think? ;)

_______________________________________________
Mailing list: https://launchpad.net/~ooc-dev
Post to     : ooc-dev@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~ooc-dev
More help   : https://help.launchpad.net/ListHelp




References