Thanks for the input.
HotKeyIt wrote:
I thought this could enumerate trough the objects and A_LoopField would contain nextkey.
I got that. My point was that since it doesn't do any parsing, it would not make sense to use "Loop, Parse".
temp01 wrote:
If..in/contains ?
I think that your examples are inconsistent with the current semantics of If..in/contains, and that any implementation supporting objects will probably be ambiguous and not necessarily intuitive. However, I recognize that the functionality could be very useful so I'll consider implementing less ambiguous methods - e.g.
obj._HasValue(v) or
obj._KeyOfValue(v). The latter seems more useful.
_HasValue(v) would be equivalent to
_KeyOfValue(v)!="", except that "" is actually a valid key.
Perhaps it should be considered further if/when in/contains become supported in expressions, since they necessarily won't be consistent with the current syntax.
Quote:
; match keys instead of values
If "x" in Obj
That would be equivalent to
Obj.x!="" since assigning an empty string removes the item and its key. That is, unless "If in" (or whatever) bypasses the
meta-mechanism; I'm not sure whether that would be intuitive.
Tuncay wrote:
The simplicity and performance are main reason to use it. I love it. Not tested yet, hope ErrorLevel will be not changed also. ... What about subpatterns here?
I think it is simpler than you realise: When I said
A ~= B is
equivalent to
RegExMatch(A, B), I meant it precisely, not figuratively. It is nothing more than syntax sugar which is processed entirely at load-time. The two should not behave or perform any differently.
I'm reluctant to changes its functionality, partly because I think an operator's purpose and effect should be very clear (i.e. with no hidden side-effects, though ~= does set ErrorLevel) but moreso because I think its usefulness is too limited to justify spending much time on it. In fact, I spent approximately two minutes coding ~=, having already done something similar (translation of
x[y]:=z to
ObjSet(x,y,z)).
Quote:
But at named subpatterns: ... may could create variable Year directly.
That's an interesting suggestion, but I think it contradicts your earlier points about simplicity and not overloading ~=.
emmanuel d wrote:
is it posible to support h_icon in the menu?
It is not currently possibly. I had considered supporting it indirectly by extending LoadPicture (which is used by various commands) to accept an icon or bitmap handle. Since there didn't seem to be much demand for it, it "slipped off the list". I'll reconsider adding it in a future revision. Until then, you may use
MI.ahk, which can accept either an icon handle (HICON) or filename.
AHKControl uses it for a purpose similar to what you've shown.
tinku99 wrote:
Perhaps you should clarify that these object based arrays are still just associative arrays.
I would think it should be clear enough from the title "Associative Arrays", the (hopefully) consistent references to "keys" rather than "indices" and the fact that "[integer] keys do not need to be contiguous". Anyway, why do you say "
still just associative arrays"; why should they be anything else?
Quote:
I wonder how hard it would be to modify your implementation to create more c like arrays.
It shouldn't be too difficult; just extend the IObject interface or ObjectBase class.
I'd like to implement C-like user-defined structs, but I'm not confident that built-in functionality would be justified. Implementing it in script would be feasible, perhaps even easier (though less efficient) than in C++.
Quote:
and that allow binary values.
Objects
are binary values, and may also be written around "proper" binary arrays (i.e. with GlobalAlloc).
String fields in an object expand in the same way that a variable expands - when necessary, to avoid some repeated reallocations as strings of different lengths are assigned. (I realise I should try to work this into the documentation.) They could also be used to store binary data in the same way as variables, by extending _SetCapacity and adding _GetAddress. Actually, there's already code for it in L31, but it's commented out. It seemed to me that at the cost of added code and documentation size, its only benefit over simply storing a pointer returned by DllCall was that no extra code was needed to automatically manage the memory.
Oh! Now that I think of it, an important feature slipped my mind while I was writing the documentation. After the last reference to an object is released, the __Delete meta-function is invoked. If the object has no references after the function returns, it is deleted.
Code:
obj := Object("base", Object("__Delete", "x_Delete"))
obj.ptr := DllCall("GlobalAlloc", "uint", 0, "uint", 1024)
x_Delete(obj) {
if p := obj.ptr
DllCall("GlobalFree", "uint", p)
ListLines
Pause
}
temp01 wrote:
So basically, make A~=B equivalent to RegExMatch(A, B, A_LastMatch:=Object())
That's an example of a hidden side-effect, which I'd prefer to avoid. Also, typing RegExMatch out in full allows for much shorter or more meaningful variable names.
Chris wrote:
However, I'm disappointed that I wasn't invited to participate in the analysis and design for these major new features.
I hope you didn't take it personally. My thoughts are usually focused on the nitty-gritty of implementation rather than the larger picture, so I tend not to do much formal "analysis and design." I'm also a natural loner. (I'd like to have replied sooner, but I was at a loss for words.)