[haXe] Getters, Setters and Interfaces

Luke Schreur luke.schreur at profero.com.au
Thu Aug 2 07:22:59 CEST 2007


Yeah, it pretty quiet on this list during the day :)


On 02/08/2007, at 3:10 PM, Glen Blanchard wrote:

> Hi Luke,
>
> Yes I thought it was weird as well, and would have thought the two  
> methods getP and setP would need
> to be defined in the interface as well.  Good to see another Aussie  
> using haxe and another user that
> is awake at the same time.
>
> Glen.
>
> On 8/2/07, Luke Schreur <luke.schreur at profero.com.au> wrote:
> Hi Glen,
>
> So that basically means that the implementation of the getter/ 
> setter is known to the interface and not just reserved for the  
> implementation. Thats kinda weird. But, it seems to work though.
>
> Thanks!
>
>
>
> On 02/08/2007, at 2:38 PM, Glen Blanchard wrote:
>
>> Hi Luke,
>>
>> Changing Testable to the following works for me.
>>
>> interface Testable
>> {
>>     public var p(getP, setP) : Int;
>> }
>>
>> Glen.
>>
>> On 8/2/07, Luke Schreur <luke.schreur at profero.com.au> wrote:
>> Hi guys,
>>
>> I need to add a property, to be implemented as a getter/setter, to  
>> an interface and after doing do I can't seem to get the class that  
>> implements the interface to work.
>>
>> This is my interface:
>>
>> interface Testable
>> {
>>  	 public var p : Int ; 	
>> }
>>
>> and this is my class:
>>
>> class Test implements Testable
>> {
>>  	private var m_p : Int ;
>> 	
>>  	public var p(getP, setP) : Int ;
>> 	
>>  	public function getP() : Int
>> 	{
>> 	 	return m_p;
>> 	}
>>  	
>> 	public function setP(p : Int) : Int
>> 	{
>> 	 	m_p = p;
>> 		
>> 		return m_p;
>> 	}
>> 	
>> 	public function new()
>> 	 {
>> 		p = 0;
>> 	}
>>  	
>>     public static function main()
>>     {
>>         var t : Test = new Test();
>>     }
>> }
>>
>> When I compile I get the following error:
>>
>> Field p has different property access than in Testable
>>
>> What am I doing wrong here?
>>
>> Thanks!
>>
>>
>> PS: Sorry to bombard this list with stupid questions, just trying  
>> to get up and running.
>>
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>>
>>
>>
>> Click here to report this email as spam.
>>
>> -- 
>> haXe - an open source web programming language
>> http://haxe.org
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>
> -- 
> haXe - an open source web programming language
> http://haxe.org


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.motion-twin.com/pipermail/haxe/attachments/20070802/d74c646d/attachment.htm


More information about the Haxe mailing list