AutoHotkey Community

It is currently May 27th, 2012, 9:08 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 741 posts ]  Go to page Previous  1 ... 40, 41, 42, 43, 44, 45, 46 ... 50  Next
Author Message
 Post subject:
PostPosted: October 18th, 2011, 4:41 am 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
Frankie wrote:
Is the convenience of leaving off a trailing % worth the logical errors it's bound to cause?
I think not; however, the syntax to force an expression seems more awkward to me than "unclosed" variable derefs. I might suggest a new syntax to force expressions, but I don't have any better idea. :?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 4:59 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
Frankie wrote:
So why not have a binary ? operator,
I think a better question is: Why have a binary ? operator? How would it differ from and in v2?
Quote:
It would essentially be a 1 line If statement (with no else), which isn't otherwise possible; due to autoconcat ambiguity.
One-line IF is supported, but requires a delimiter to remove ambiguity:
Code:
if var = "val", CallFunc()

Quote:
var = "val" ? CallFunc()
It can be written like this:
Code:
(var = "val") and CallFunc()


jethrow wrote:
what about commands that have multiple output vars?
Here, I wrote:
The remaining output variables are handled like ByRef parameters,

Quote:
Have you considered returning an object?
I think that in many cases it is more convenient to have multiple explicit output vars, especially where short names like "x" and "y" are common. The code may also be easier to understand for anyone that hasn't memorized the order and names of the output parameters. Something else to keep in mind is that objects aren't supported by the command syntax. Even if and when this is changed, the syntax would be more verbose (e.g. %(x.y) vs %y or %y%).

jaco0646 wrote:
I might suggest a new syntax to force expressions,
Since I want to support %(expression) embedded in text anyway, that is a possibility.
Code:
MsgBox The function returned %(function()).
WinMove %(x+10), %(y+20)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 7:52 am 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
Quote:
It can be written like this:
Hmm maybe I'm in mistake, but ternary don't need to exist also, we can write this:
Code:
msgbox % var="value" && "then" || "else"
msgbox % (((var="value") && ("then")) || ("else"))
; in brief, replace  && by ? and || by :
So it's the "why not" have a binary because we have a ternary operator. Everybody doesn't will look into "logic gate" and "short-circuit" concepts... (as other people who use math operation instead of AND(*) or OR(+) for fun/art code, or other smart form) Sorry to still annoy you :D

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 9:09 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
You're right; the ternary operator doesn't need to exist. It's been redundant from the very beginning.

However, there are important differences between a ? b : c and a && b || c:
  • If a evaluates to true and b evaluates to false, a && b || c evaluates both b and c whereas a ? b : c evaluates only b. This would commonly be a problem when the true branch calls a function which has no return value.
  • Order of evaluation. For example, a ? b := x : c := y works without parentheses whereas a && b := x || c := y would be evaluated as a && (b := (x || (c := y))).
  • Readability. It is easier to see the boundaries of each branch in a ternary operation.
I could rephrase my previous question: Why have ?, and and && all do the same thing? Why not? It would increase code size/complexity and syntax redundancy. Having multiple ways to do something isn't always a good thing. Allowing ? without : may also complicate the rules for order of evaluation.

One final point. For any change, there are always reasons not to make it:
  • My time is limited.
  • My level of interest is limited.
  • Existing users would need to adjust.
If there aren't good reasons to make a change, these reasons not to make it are usually enough.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 10:33 am 
Offline

Joined: October 13th, 2009, 10:09 pm
Posts: 1389
I think a single ? operator without the following : might be good for conditionally calling functions, it doesn't need to support assignments this way IMO.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 18th, 2011, 2:57 pm 
Offline
User avatar

Joined: November 2nd, 2008, 4:23 pm
Posts: 2906
Location: 127.0.0.1
I didn't realise && could do the same thing; never mind.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2011, 3:48 pm 
Offline
User avatar

Joined: October 31st, 2008, 9:39 am
Posts: 641
Location: France
First, thx for your time Lexikos !
I tested more with your explanation, the binary have similar false returned feature. I tested to convert binary and ternary:
Code:
; how to be unreadable, it's an art...
R:="value", A:=1, B:=0, C:=4
msgbox % "[R:=A?B(:R)]`nr=" (A&&R:=B) "`tR=%R" ; and not R:=A&&B (first intuition)
msgbox % "[R:=A?B:C]`nr=" (((A)&&((R:=(B))||"fix"))||(R:=(C))) "`tR=%R"
But I understand you haven't interest in binary opeartor.

_________________
"You annoy me, therefore I exist."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 19th, 2011, 5:08 pm 
Offline

Joined: October 7th, 2006, 4:50 pm
Posts: 3157
Location: MN, USA
I don't find another binary operator interesting either, if that means anything. I'm interested in unary assignment! :P


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2011, 11:57 am 
Offline

Joined: February 19th, 2010, 6:11 pm
Posts: 150
Location: California
Quote:
Legacy commands to consider keeping (for convenience): IfWinActive, IfWinExist, IfInString, IfExist. I personally don't find IfInString all that convenient. Should it be kept? Should the others be kept? [v2.0-a004-abad6fe: Removed.]



But why? I dont care about the instring but the others? why? :(


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2011, 1:47 pm 
KooKsTeR wrote:
But why? I dont care about the instring but the others? why? :(

...cuz they are legacy & not needed...

Code:
IfWinActive, Example
Code:
if (WinActive("Example"))

Code:
IfWinExist, Example
Code:
if (WinExist("Example"))

Code:
IfInString, var, Example
Code:
if (InStr(var, "Example"))

Code:
IfExist, Example
Code:
if (FileExist("Example"))


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2011, 6:41 pm 
Offline

Joined: February 19th, 2010, 6:11 pm
Posts: 150
Location: California
i only like the legacy because they are more logical. Yes the function based way is better. But the legacy way just makes sense.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2011, 7:09 pm 
Offline

Joined: November 7th, 2006, 9:47 pm
Posts: 1934
Location: Germany
KooKsTeR wrote:
i only like the legacy because they are more logical.

I don`t understand this. Why does the command / legacy syntax makes more sense to you? The functions are connected with the If-Expression. The expression form is preferred in the future, because functions allow connection in a lot of situations. In contrast every command have to be written on its own line.

In the future with v2, it does not matter if the original feature is a function or command.
Lexikos wrote:
Added capability to call functions using traditional command syntax, with some limitations.
Added capability to call commands using function() syntax.

_________________
{1:"ahkstdlib", 2:"my libs", 3:"my apps", 4:"my license"}
--> Don't feed the troll! <--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2011, 7:21 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7503
Location: Australia
v2.0-a027-7b2f825
  • Fixed calling of variadic functions with command syntax.
  • Changed GuiSize and GuiDropFiles to use A_EventInfo exclusively (not ErrorLevel).
  • Removed If..is/in/contains (to be replaced with operators in a future update).
  • Merged bug fixes from v1.1.05.02.

I think this thread has gotten too long to be useful. Anyone have ideas for cleaning it up?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2011, 7:57 am 
Thanks for sharing your work.
Lexikos wrote:
Anyone have ideas for cleaning it up?
What about to post new alpha releases in the Announcement section?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 23rd, 2011, 8:01 am 
Offline

Joined: February 19th, 2010, 6:11 pm
Posts: 150
Location: California
Tuncay wrote:
KooKsTeR wrote:
i only like the legacy because they are more logical.

I don`t understand this. Why does the command / legacy syntax makes more sense to you? The functions are connected with the If-Expression. The expression form is preferred in the future, because functions allow connection in a lot of situations. In contrast every command have to be written on its own line.

In the future with v2, it does not matter if the original feature is a function or command.
Lexikos wrote:
Added capability to call functions using traditional command syntax, with some limitations.
Added capability to call commands using function() syntax.


Im mostly ranting because of change, you can really just ignore what I said. I just dont want to have to update my crap. But i probably will anyway.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 741 posts ]  Go to page Previous  1 ... 40, 41, 42, 43, 44, 45, 46 ... 50  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Rajat and 8 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