Functions as public properties

Hello,

I’m searching for an efficient way to use functions as public properties of a class. For exemple:

object.Prop = 20 -- instead of object:SetProp(20)  
value = object.Prop -- instead of value = object:GetProp()  

This is one approach.

Does anyone know a more efficient way to make that?

Thanks in advance [import]uid: 29154 topic_id: 33124 reply_id: 333124[/import]

That way works. It’s simple assigning and reading table members (pretty much simple variables) which has way less overhead than Getter/Setter methods that have call stacks and returns.

It can’t be more efficient.

But in a purely object oriented mentality, you should encapsulate those values and have them as private and use getter/setter functions. But to me, its too much overhead. [import]uid: 19626 topic_id: 33124 reply_id: 131532[/import]

That way works. It’s simple assigning and reading table members (pretty much simple variables) which has way less overhead than Getter/Setter methods that have call stacks and returns.

It can’t be more efficient.

But in a purely object oriented mentality, you should encapsulate those values and have them as private and use getter/setter functions. But to me, its too much overhead. [import]uid: 19626 topic_id: 33124 reply_id: 131532[/import]

Thanks rob. I’ll make some performance tests using that approach. [import]uid: 29154 topic_id: 33124 reply_id: 131669[/import]

Thanks rob. I’ll make some performance tests using that approach. [import]uid: 29154 topic_id: 33124 reply_id: 131669[/import]