AutoHotkey Community

It is currently May 27th, 2012, 3:59 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: May 18th, 2011, 9:12 pm 
Offline

Joined: May 16th, 2010, 2:38 pm
Posts: 185
[Moderator's note: Moved topic from Bug Reports to Ask for Help.]

AHK_L ver v1.1.00.00 x32 Unicode

I wonder if this is intended behaviour, but i didn't found any explanation in help
Seems like __Get function works only for class instance:

Code:
class cc
{
   __Get(aName)
   {
      return aName
   }   
}

cc2 := {__Get: "ProGetFunc"}

ProGetFunc(this,aName)
{
   return aName
}

msgbox % cc.SomeStrangeParameter   ;doesnt work
p := new cc()
msgbox % p.SomeStrangeParameter      ;works
msgbox % cc2.SomeStrangeParameter   ;doesnt work
p2 := new cc2()
msgbox % p2.SomeStrangeParameter   ;works


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2011, 2:56 am 
Offline

Joined: May 3rd, 2009, 7:16 pm
Posts: 345
Location: OH, USA
Your example clearly shows that it works for both object syntaxes. Meta-functions are methods defined by an object's base. Derived objects can be defined using the base key or the new operator. This is all explained rather clearly in the documentation.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 19th, 2011, 12:30 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
Code:
class cc
{
   __Get(aName)
   {
      return aName
   }   
}

cc2 := {base:{__Get: "ProGetFunc"}}

ProGetFunc(this,aName)
{
   return aName
}

msgbox % cc.SomeStrangeParameter   ;doesnt work
p := new cc()
msgbox % p.SomeStrangeParameter      ;works
msgbox % cc2.SomeStrangeParameter   ;works
p2 := new cc2()
msgbox % p2.SomeStrangeParameter  ;works   


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 8:16 pm 
Offline

Joined: May 16th, 2010, 2:38 pm
Posts: 185
thanks, flak
so there is no way to make __Get working just from class definition as in first case?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 20th, 2011, 8:44 pm 
The metafunctions are designed to be in the base - so you could just extend the class:
Code:
class meta {
   __Get(key) {
      MsgBox, Get MetaFunction :: %key%
   }
}
class cc extends meta {
}

cc.SomeStrangeParameter


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Leef_me, rbrtryn and 48 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group