tinku99 wrote:
1. That is consistent with the the old ways of ahk,
I disagree. Think of it like NumPut or some DllCalls, which won't work if the variable hasn't been initialized in some way.
Quote:
2. I wonder if you define a new type such as
binobject, you could also define a meta function: binobject.is(UFO) that checks if the metafunctions match.
Why would a new type need to be defined to build-in that functionality? Why not merely compare them yourself, in script? Why compare them at all?
Quote:
3. But I don't see a necessary conflict,
You cannot catch all such errors
and automatically initialize objects in variables. I stand by my use of words. Anyway, you asked why it wasn't the default behaviour, and I answered. It's your choice to use it or not; in fact, that's why I implemented the "default base" feature, and obviously the reason I put those examples in the documentation.
Quote:
4. The problem with the current way is that if nonobj is not initalized, the following fails silently:
What problem?
This is consistent with "the old ways of ahk;" at least for expressions. Take
(var+=1) for instance.
Quote:
You're going to find yourself atleast implementing list processing functionality,
Speak for yourself.
Quote:
otherwise objects will remain even less efficient than lisp.
I'm always skeptical about apparently baseless claims of performance. I'd ask you to show some facts, but to be honest I'm not interested.
Quote:
For example Fasto reimplemented my
ahksearch using objects, but reported "consumes a lot of resources".
I'm certain that fasto wasn't referring to speed. Notice the SQLite example; which is "a bit slower".
Quote:
One thing that might help is special treatment for multidimensional rectangular objects.
I chose the current implementation because it is simple, useful and works for all types of keys. I see no specific need to optimize it soon, if ever. Anyway, it has nothing to do with efficiency of objects in general, so I don't see how this "one thing" "might help".
Quote:
how many elements can you store if capacity is 256? Is it 4 ?
If you set the capacity to 256, you can store up to 256 "elements" before the capacity must be increased. Objects hold key-value pairs, not characters or bytes.
Quote:
Object._SetCapacity(new_capacity): Adjusts the maximum number of key-value pairs the object can contain before it must be automatically expanded.
Source: AutoHotkey_L - Objects FYI, individual key-value pairs (elements) are currently 16 bytes. String keys and values are allocated separately, as necessary. If _SetCapacity is not used, the capacity of an object begins at 4 (on first assignment) and doubles when a higher capacity is needed. This is all subject to change.
Quote:
The default capacity of variables in ahk is normally 63...
Variable capacity is measured in characters, and in fact, you're wrong.
Code:
Loop 2 {
MsgBox % VarSetCapacity(v := 1) ; Pure integer, no string.
t := v "" ; Causes a string to be cached, note not assigning to v!
;v .= "" ; Convert it to a string.
MsgBox % VarSetCapacity(v) ; String with cached integer.
MsgBox % VarSetCapacity(v .= "111") ; 4 chars
MsgBox % VarSetCapacity(v .= "1111") ; 8 chars
VarSetCapacity(v,64),VarSetCapacity(v,0) ; First iteration: discard persistent mem.
}
; In v1.0.48.05, the output is: 0, 3, 7, 63; 0, 15, 15, 15
Quote:
On the contrary, with objects, we don't have access to contents, and &object gives access to the interface...
Where do you think the interface is, if not in the Object? In fact, &object is currently both the address of the Object and the address of its IObject interface. I had not mentioned this as it is obscure and the structure is more likely to change than Var, Line, Func, etc. If there is really a need to access it directly, a built-in feature of some sort should be implemented to alleviate it. (Then again, maybe allowing it will allow scripts to "prototype" useful features.)
Code:
x := Object()
MsgBox % "vftable: " NumGet(&x) ; hidden virtual function table
. "`nmRefCount: " NumGet(&x,4) ; inherited from ObjectBase
. "`nmBase: " NumGet(&x,8) ; first field defined in Object
Quote:
How about a metafunction object._
ascontiguousarray,
Why?
Quote:
Object._SetCapacity(element_size, number_of_elements).
There would be no benefit in allowing scripts to specify the size of an element, as it is not something that can change/be changed at run-time, and it shouldn't be relevant to scripts.
Quote:
... so the keytype, keys, and values can be kept in separate arrays ?
Why?
Quote:
get and assign don't need to become more complicated
They don't need to become more complicated; I can I leave them the way they are. If you're trying to say that splitting the keys and values
won't complicate the code, I disagree.
Quote:
Edited 101 times really?
Oh yes, really.
