Page 2 of 2

Re: v1.1.16 alpha - Properties

Posted: 08 Aug 2014, 03:40
by just me
But how? Maybe I have a mental block.

Code: Select all

#NoEnv
Msgbox, 0, IsObject(Prop), % IsObject(Prop := Dummy.Property) ; shows 1
MsgBox, 0, Prop.Get(), % Prop.Get() ; shows ""
MsgBox, 0, Prop.Get, % Prop.Get ; shows ""
MsgBox, 0, Prop, % Prop ; shows ""
For Key In Prop
   MsgBox, 0, Key %A_Index%, %Key% ; no MsgBox
ExitApp
Class Dummy {
   Property {
      Get {
         Return "Hello!"
      }
      Set {
         Return "Hello!"
      }
   }
}

Re: v1.1.16 alpha - Properties

Posted: 08 Aug 2014, 03:52
by just me
Got it! You need to pass the "hidden" parameter.

Re: v1.1.16 alpha - Properties

Posted: 01 Sep 2014, 05:27
by lexikos
Currently, static properties aren't really possible since the property has to be defined in a base -- or to put it another way, x.Property has different meaning depending on whether x is the exact class which defines Property, or a subclass or instance. Although this is consistent with meta-functions, it's inconsistent with methods and falls short of the goal, which was to provide a "more foolproof" alternative to meta-functions (for the most common cases).

Instead, I'm considering changing it so that properties are also invoked when the class which defines the property is accessed. The cost would be:
  • A small amount of flexibility. Invoking a property from a specific class on some other object (formerly Class.Prop.get(obj)) would involve retrieving the property using a more roundabout method, such as a for-loop or hypothetical ObjRawGet function. However, rather than designing a property to be used that way, one could put the needed code in a separate method. It's also true that flexibility isn't the real purpose here; meta-functions already provide that.
    .
  • A marginal performance hit. If retrieving an object from within another object takes 0.00014ms, it might take 0.00001ms longer due to a dynamic type check (is this object a Property?). However, I think the added user-friendliness is worth the price.
Anyone have thoughts on the matter?

Re: v1.1.16 alpha - Properties

Posted: 01 Sep 2014, 07:23
by just me
I'd appreciate the change.

Re: v1.1.16 alpha - Properties

Posted: 02 Sep 2014, 08:39
by Coco
Something like??:

Code: Select all

class Test
{
	;// can be accessed by both class object and instance
	static ClassProperty {
		get {
			;// code here
		}

		set {
			;// code here
		}
	}
	;// instance of class only
	InstanceProperty {
		get {
			;// code here
		}

		set {
			;// code here
		}
	}
}

Re: v1.1.16 alpha - Properties

Posted: 02 Sep 2014, 10:20
by RobertL
My simple custom property lib
Not interrelated too much. Extemporaneous, maybe enlighten on Property.
Also, easy to expand I think.

I still think the new syntax is an integrate, but don't know the background module, which seems unknown and mysterious.

Re: v1.1.16 alpha - Properties

Posted: 02 Sep 2014, 16:27
by lexikos
Coco wrote:Something like??:
No, the same as methods: just define one property, and it can serve both purposes.

Re: v1.1.16 alpha - Properties

Posted: 09 Sep 2014, 16:59
by lexikos
v1.1.16.01 is now available.

Changes since v1.1.16.00-a01:
  • Changed Object to invoke Property even if defined directly. Found a way to negate the performance hit (and possibly even improve performance in some cases).
  • Fixed half-defined properties messing with __Set parameter order.
  • A long list of unrelated fixes.