AutoHotkey Community

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

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: =. operator
PostPosted: May 26th, 2011, 2:33 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
Just an idea :)
As the .= operator is more efficient than var := var "append" and more convenient, what about a 'insert before' operator?
Code:
var := "hi"
var .= " bye" ; var now contains 'hi bye'
var =. "nimda, " ; var now contains 'nimda, hi bye'

Obviously not pressing.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 4:19 am 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
+1

creepy, just last night I was thinking of the same concept, but didn't know how it could be added in. This is a good answer.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 8:18 am 
Offline

Joined: September 15th, 2009, 1:14 am
Posts: 562
Location: Tempe, Arizona
+2 :D

_________________
Disclaimer: I'm not an expert by any means; I just try to help out where I can.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 8:30 am 
Offline

Joined: November 28th, 2009, 4:45 am
Posts: 3089
Can only be applied in v2 because of ambiguity with = assignment
Code:
var=7
var=.2 ;should this var be equal to 27 or .2


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 2:35 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
I personally think it would be better if you could leave the concatenation operator as is and just switch the terms around:

Code:
"hi" .= var

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 6:48 pm 
Offline

Joined: October 2nd, 2009, 12:43 pm
Posts: 283
sinkfaze wrote:
I personally think it would be better if you could leave the concatenation operator as is and just switch the terms around:

Code:
"hi" .= var


a := "1"
b := "2"
a .= b
Huh?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 7:53 pm 
Offline
User avatar

Joined: March 19th, 2008, 12:43 am
Posts: 5482
Location: the tunnel(?=light)
Obviously I'm meaning in the sense of appplying literal text and numerals, but you've pointed out something I hadn't considered, which is variable confusion. Consider that thought rescinded, but adding another equals operator just for that purpose seems kind of...wonky.

Perhaps there's an operator that can be used after the equals which can designate to append to the front or tail of a string.

_________________
Image
Try Quick Search for Autohotkey or see the tutorial for newbies.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 8:03 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
I like the =. but it doesn't comply with all of the others such as -= += .= := etc.

Maybe regex-ish like $= ? (As in the needle "^a$")

Too bad ^= is taken

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 8:10 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
`= was going to be used for literal strings, but apparently that is not going to happen, afaik.

so is `= open for use? :) it looks pretty similar to .=, only the (deformed) dot is at the top. which makes sense:
    top (`): usually means the beginning of something (a list, paragraph, newspaper, etc)
    bottom (.): is usually at the end of something (end of a sentence, paragraph, list, etc)

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 26th, 2011, 8:18 pm 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
So the ideas are:
Quote:
var =. prepend
var $= prepend
var `= prepend

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2011, 3:15 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
nimda wrote:
I like the =. but it doesn't comply with all of the others such as -= += .= := etc.
What do you mean? Naturally, =. =- =+ =: could all be reversed assignments. I personally don't think it would useful enough, though.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2011, 3:28 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
I just meant that the = comes before the dot in =. whereas in all other operators, the = comes after.

Obviously, 'var =- var2' as syntax sugar for 'var2 -= var' is pointless. However, a prepend operator seems to be gathering support.

It might also be a speed improvement in the same way the .= operator is faster, but I never look at that part of the source, so it's just a maybe.

Still, there are open operators :) (though it is true =. would be a v2 thing, while `= or $= could be v1.1.x)

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2011, 3:42 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
nimda wrote:
I just meant that the = comes before the dot in =. whereas in all other operators, the = comes after.
Wasn't that the whole point? =. is the reverse of .=
Quote:
It might also be a speed improvement in the same way the .= operator is faster,
If there is room at the end of the variable, var .= "string" only needs to copy "string". This optimization could not be applied to a prepend operator since there's never going to be any room at the beginning of the variable unless it is completely empty - i.e. both strings will need to be copied at least once.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2011, 3:51 am 
Offline

Joined: December 26th, 2010, 7:40 pm
Posts: 4172
Location: Awesometown, USA
You're making a good case for =. but I kinda want to see this before v2 :)

You still sort of miss my point. Yes .= and =. are reverses, which logically makes sense. Also, . is the concat operator, so =. once again makes sense.

However, afaik there is not a single operator where the = comes before the operator, so in that regard =. is totally breaking the 'rules' and being that much harder to understand.

I'd like some more feedback from other members but now I'm leaning towards `= based off of tidbit's explanation.

However, you could make it «= if you wanted. The question isn't really about which symbols but is it feasible and will it be useful. In the latter, I have only seen positive feedback.

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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 27th, 2011, 5:16 am 
Btw, -= could not be reversed to =- because it could be confused with unary minus (negative)

-- infogulch


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

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