AutoHotkey Community

It is currently May 27th, 2012, 1:16 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

What will you take if you can get a built-in feature right now
Unicode
Array
Structure
Networking Commands (TCP/UDP/FTP/HTTP)
Console Commands (read/write/wait for input)
Additional macro related commands
Other (describe)
You may select 1 option

View results
Author Message
 Post subject:
PostPosted: July 7th, 2008, 2:38 pm 
Offline

Joined: March 19th, 2006, 5:52 am
Posts: 419
Quote:
in hindsite i should have voted other and said OOP
but arrays are a close second

Structs are really just a small step away from objects, so that's why I voted for them.
I also agree that real arrays are second on the to-do list.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 7th, 2008, 2:47 pm 
Offline

Joined: May 24th, 2006, 2:49 pm
Posts: 4511
Location: Belgrade
I already told you,
Code:
associative arrays + syntax suggar = objects = structs


as structs are just simple objects, without member functions. They must be handled differently then eventual AHK objects as AHK doesn't have anything but string varables so you don't need to define them, and structs are ment for communication with C APIs. One possible solution would be to add special array member that defines structure and DllCalls to be updated to receive arrays as input.

C structure
Code:
struct {
 int field1
 char field2
 dword field3
} S


can be seen as associative array with 1 special array member, the one used to define structure in DllCall manner:

Code:
S["_DEF_"] = "Int field1, Char field2, Uint field"
S["field1"] = -1
S["field2"] = "a"
S["field3"] = 14



If we imagine AHK supports true arrays with above notation then we would use struct as this:

Code:
s._DEF_ := "Int field1, Char field2, Uint field3"
s.field1 := -1
s.field2 := "a"
s.filed3 := 14

DllCall(.... , "struct", S)


s.field is syntax suggar for s["field"], usual notation for associative arrays. You can ask here why not allowing this notation generaly, but struct member names are different then general associative array keys - C variable name can't have space or special character while associatve array keys can be any type of string, for example s["my nasty $$ _/ key"] so dot notation in this case is not possible, but it suits fine for structures (and objects, for the same reason)

"struct" keyword in dllcall would say AHK to check for _DEF_ array member, and make appropriate binary structure based on it and values of struct fields.


If you need binary structure for your own things, we could have function struct( array ) that returns binary structure mentioned above so that above DllCall
is equal to

Code:
DllCall(..., "uint*", struct(S))


Some additinal effort is needed for complex structures (those containing other structers or arrays of bits but everything can be thought out with associative arrays implemented.

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 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