Search found 405 matches
- 11 Dec 2018, 17:19
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
quest to perfection is drawing near the end, my friend! =) but its still 2 globals ( deref and _deref ). 1 supernumerary global and 1 supernumerary line of code. I hope someone to chime in and help us out to reduce the code even further As a side effect, I think now it's almost as fast as the obj.st...
- 11 Dec 2018, 16:58
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
the code above with _deref instead of this didn't feel right, so I shrank it a bit again: class _deref{ static __Set:=(_, _s,_v) =>%(m:=StrSplit(_s, ".")).RemoveAt(1)%[m*]:=_v static __Get:=(_, _s) =>%(m := StrSplit(_s, ".")).RemoveAt(1)%[m*] __New() { static _:=new _deref() global deref:=this } } i...
- 11 Dec 2018, 16:46
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
when I use this as an object in __New() : this.__Set:=(_, _s,_v) =>%(m:=StrSplit(_s, ".")).RemoveAt(1)%[m*]:=_v ... for k,v in deref s.=k "=" Type(v) " " Format("at 0x{:p}", &v) "|" msgbox(clipboard:=s) it does add to deref __Set=Func at 0x000000000067E630 for k,v in _deref s.=k "=" Type(v) " " For...
- 11 Dec 2018, 16:25
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
bingo! I managed it. replaced this with _deref (this way it adds to the class.base properties/methods/keys) and added _ (just a placeholder for an argument b/c we don't use this in here) to arguments list: _deref.__Set:=(_, _s,_v) =>%(m:=StrSplit(_s, ".")).RemoveAt(1)%[m*]:=_v :D output: __Class=Str...
- 11 Dec 2018, 15:32
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Nice! and damn you with your fast pc! :D Just overclocked and optimized IvyBridge (2011 year's CPU) and de-bloated Win 7 x64 SP1 btw, when I tried to fat-arrow __Set metafunction declaration, it didn't work :D __New() { static _:=new _deref() global deref:=this this.__Set:=(_s,_v) =>%(m:=StrSplit(_...
- 11 Dec 2018, 15:21
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Result: 3375 | 2843 | 2704 (ms) for 1,000,000 runs of a.test.key++ They are all pretty close in terms of performance, so take your pick! ; Test Result clipboard := a1 " | " a2 " | " a3 " : " a.test.key msgbox(clipboard) :thumbup: EXCELLENT!!! Result: 2250 | 2000 | 1875 : 3000000 . last number prove...
- 11 Dec 2018, 15:14
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Seems to run fine for me... you sure you didn't use [] instead of () by accident? was my mistake - I re-set a1 accidentally. well, back to results: 1375|1343|1891 : new . set/get variant seems to be 39% as slow in my case. class a1{ class test { static key3:=0 } } class obj{ str[_s]{ get { return(%...
- 11 Dec 2018, 14:25
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Hey, I think you forgot to call the functions there Oh indeed! my bad :D It should be: t:=A_TickCount ostr3(p*) => p.length() > 1 ? obj.str[p[1]] := p[2] : obj.str[p[1]] loop(n) ostr3("a1.test.key3", "new") a3:=A_TickCount-t but 2 previous ostr1 and ostr2 give me an error. (ahk v2, last alpha build...
- 11 Dec 2018, 14:19
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
But then wouldn't your second example (even if it worked) be equivalent to normal get{....}, set{....}? don't know about run-time speed improvements, but we obviously get 1 line instead of 6 repetitive ones. Even more, with fat arrows we get a portable code snippet (just an expression) and can incl...
- 11 Dec 2018, 13:48
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
- 11 Dec 2018, 12:52
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Do you mean something like this? Not for this use case, :D I meant fat arrows used for property's half-methods declarations. the following code is not working ( "Unknown property" error), just to give u an idea. class a1{ static key1:="string1" } deref["aa.key1"]:="new" class deref{ static set:=(_s...
- 11 Dec 2018, 12:03
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
Maybe we can shorten it a little? I optimized it a bit. Removed intermediate var o and made the whole calculation as a single operation: class obj{ str[_s]{ ;deref string get{ ;v:=["obj1.objN.key"] return(%(m:=StrSplit(_s,".")).RemoveAt(1)%[m*]) ;[m*] =variadic multi-dimentional } set{ ;["obj1.objN...
- 10 Dec 2018, 19:03
- Forum: Ask For Help
- Topic: AHK v2: question about enumerating
- Replies: 4
- Views: 621
Re: AHK v2: question about enumerating
well, as for now I ended up with the following: try a:=o.__Arr ;trying to get a unique key catch{ ;"Unknown property" exception means its a built-in inenumerable object t:=Type(o) t = Object type instead of object content to pretty-print my instanced classes and other global vars like this: https://...
- 10 Dec 2018, 13:59
- Forum: Ask For Help
- Topic: AHK v2: question about enumerating
- Replies: 4
- Views: 621
Re: AHK v2: question about enumerating
Because there is curretnly no difference. thank u for the quick reply! yeah, I've seen it in the documentation. I, for one, hate ambiguity in programming languages and can't wait for the moment Lexicos decides these two array types become different. He already removed <> operator (as duplicate for ...
- 10 Dec 2018, 13:39
- Forum: Ask For Help
- Topic: a few bugs?
- Replies: 5
- Views: 1225
- 10 Dec 2018, 13:20
- Forum: Ask For Help
- Topic: AHK v2: question about enumerating
- Replies: 4
- Views: 621
AHK v2: question about enumerating
1. R there new ways in AHK v2 to distinguish between [] and {} types of user-created objects? a:=0 for i in object ;throws exc here if its not an object or doesn't have _NewEnum() method. if(!(a:=i=A_Index)) ;a=0:associative (have pairs "key":value) or sparse array ([1,,3]) break so knowing which a...
- 07 Dec 2018, 12:07
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
If you use one root object to store all the data you could access it all with the variadic parameter syntax. Good solution as well! We get rid of outdated %deref% syntax this way! It would be possible to wrap up all class prototypes and other globals, but that increases code size. Is it possible fo...
- 06 Dec 2018, 20:28
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
just wow! U've come back with a really handy one
- 06 Dec 2018, 19:33
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
You can wrap it in a function, too if you use it a lot. Here is the wrapped function as u suggested. :D Here we go into another trouble : when Name2Addr() returns the reference, that's not the original value's address: class a1 { static Key1:= "some string" static Key2:= "another string" class test...
- 06 Dec 2018, 19:12
- Forum: Ask For Help
- Topic: AHK v2: converting/optimizing scripts Topic is solved
- Replies: 266
- Views: 32885
Re: Problems with objects and legacy syntax Topic is solved
oif2003 , now I see parts* as a "variadic-dimensional" array, stupid me @ 3am =) A very handy cycle for dereffing nested objects! and it does work in v2 . But %objname% deref is still there. It was my afterthought 2nd question in the topic; do u have any ideas how to do it w/o deref? There r quite ...