AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Which feature is most needed for current AHK (before V2)
Goto page Previous  1, 2
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat
View previous topic :: View next topic  

What will you take if you can get a built-in feature right now
Unicode
17%
 17%  [ 3 ]
Array
35%
 35%  [ 6 ]
Structure
17%
 17%  [ 3 ]
Networking Commands (TCP/UDP/FTP/HTTP)
11%
 11%  [ 2 ]
Console Commands (read/write/wait for input)
0%
 0%  [ 0 ]
Additional macro related commands
0%
 0%  [ 0 ]
Other (describe)
17%
 17%  [ 3 ]
Total Votes : 17

Author Message
TheIrishThug



Joined: 19 Mar 2006
Posts: 381

PostPosted: Mon Jul 07, 2008 1:38 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website AIM Address
majkinetor



Joined: 24 May 2006
Posts: 3652
Location: Belgrade

PostPosted: Mon Jul 07, 2008 1:47 pm    Post subject: Reply with quote

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.
_________________
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> General Chat All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group