ObjRawGet/ObjRawSet abnormal

Post AHK_H specific scripts & libraries and discuss the usage and development of HotKeyIt's fork/branch
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

ObjRawGet/ObjRawSet abnormal

28 Jan 2020, 06:04

It seems that it cannot read and write the object as a key normally?

Code: Select all

	m:={}
	t:=[]
	ObjRawSet m,t,4
	b:=[]
	MsgBox ObjRawGet(m,b)	;> 4
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: ObjRawGet/ObjRawSet abnormal

28 Jan 2020, 09:47

this is not an AHK_H issue, its for regular v2 also

in v2, ObjRawSet says that it sets a property, it does not set a "key". And that the 2nd func parameter is a "Name". that leads me to believe that you should be passing a string, not an empty array t

https://lexikos.github.io/v2/docs/objects/Object.htm#RawSet

same with ObjRawGet, probably b resolves to an empty string, and so this code produces the same result:

Code: Select all

	ObjRawSet m,t,4
	MsgBox ObjRawGet(m,"")	;> 4
or

Code: Select all

	ObjRawSet m,"",4
	MsgBox ObjRawGet(m,"")	;> 4
i'm surprised v2 doesn't throw a type mismatch error.. maybe because these funcs are deprecated

arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: ObjRawGet/ObjRawSet abnormal

28 Jan 2020, 13:09

it's a pity. Its performance is excellent.
loop 1000000

t:=ObjRawGet(p,x) 150ms
t:=o.has(x)?o[x]:"" 260ms/570ms
t:=o[x] 270ms
guest3456
Posts: 3463
Joined: 09 Oct 2013, 10:31

Re: ObjRawGet/ObjRawSet abnormal

28 Jan 2020, 15:45

arcticir wrote:
28 Jan 2020, 13:09
it's a pity. Its performance is excellent.
loop 1000000

t:=ObjRawGet(p,x) 150ms
t:=o.has(x)?o[x]:"" 260ms/570ms
t:=o[x] 270ms
ask @lexikos maybe he can tell you an alternative way

lexikos
Posts: 9665
Joined: 30 Sep 2013, 04:07
Contact:

Re: ObjRawGet/ObjRawSet abnormal

07 Feb 2020, 22:05

ObjRawGet is effectively "ObjGetOwnProp". Because I wasn't sure that I wanted to keep it, I made only the minimal changes needed to get it working.

If you want to map object references to values, use a Map.
arcticir
Posts: 694
Joined: 17 Nov 2013, 11:32

Re: ObjRawGet/ObjRawSet abnormal

09 Feb 2020, 09:12

Most of the time, I care more about its simplicity and performance. For example
if t:=ObjRawGet(o,"t") is much better than if t:=o.has("t")?o["t"]:"" ,simpler and more efficient, although it is not standardized.

Return to “AutoHotkey_H”

Who is online

Users browsing this forum: No registered users and 6 guests