AutoHotkey Community

It is currently May 27th, 2012, 12:55 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: January 4th, 2012, 11:15 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
Contains++

_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun :wink:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 4th, 2012, 11:21 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
HotKeyIt wrote:
Contains++


Good question, what happens when you increment a function?

Code:
obj := { fn: Func("function") }

obj.fn++

msgbox % obj.fn()

function() {
    return A_ThisFunc " called!"
}


Hmm doesn't do much, just calls the function...

:P :lol: :P

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 12:49 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
great obfuscation technique too

_________________
Autofire, AutoClick, Toggle, SpamWindow Control Tools
Recommended: AutoHotkey_L


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 10:09 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
infogulch wrote:
Hmm doesn't do much, just calls the function...
That's a bug. The correct behaviour is to assign and return an empty string. Instead, it skips the assignment and returns an empty string. obj.fn := obj.fn + 1 and obj.fn += 1 should produce the correct result.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 5th, 2012, 5:03 pm 
Offline

Joined: March 27th, 2008, 2:14 pm
Posts: 700
Oh, uh well I totally meant to point out that bug...

In any case, what do you guys think of Max() and Min() ?

I've been thinking, I would actually prefer to have two additional built-in object functions: ObjMax() & ObjMin().

This would allow the greatest flexibility.
  • Use it on an existing object: myobject.max()
  • Create an object just to find the max value: ObjMax([1,12,123,1234])

If some crazy person (me) wants something that returns the min/max of args, a simple variadic function wrapper would work great:
Code:
max(x*) {
    return ObjMax(x)
}
min(x*) {
    return ObjMin(x)
}

max(a, 123, c * 4)

_________________
Scripts - License


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 7th, 2012, 10:22 am 
Offline
User avatar

Joined: May 10th, 2007, 10:54 am
Posts: 649
Location: .switzerland
I thought also about this. Even already implemented Methods seem to be inconsistent;
Code:
names := []
names.Insert("Mary")
names.Remove("Mary") ; won't work, as remove bases on indexes

This goes in the same direction of "obj.IndexOf(value)"

All in all, obj.contains(), obj.count() are very important, but actually just for lists and not required in the base Object.

Wouldnt it be a better idea, to provide a second Object called List/Collection, which provides that functionality? Is this possible with the current prototype implementation?

Code:
obj := {} ; create a standard key-value Object (which is actually a dictionary)
array := [] ; create Collection/List with .count(), .add(val), .remove(val), .sort() etc.


If this is not an option, we could at least provide a standard lib with classes for Collection, Delegate etc, which are shipped with AHK_L.

_________________
http://securityvision.ch
AHK 2D GAME ENGINE


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 9th, 2012, 6:51 am 
IsNull wrote:
Even already implemented Methods seem to be inconsistent;

Code:
; Compare
names.Insert(1, "Mary")
names.Remove(1)
; to
names.Insert("Mary") ; Push
names.Remove()       ; Pop


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

All times are UTC [ DST ]


Who is online

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