| View previous topic :: View next topic |
| Author |
Message |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Thu Apr 12, 2007 10:13 am Post subject: Problem with one line expresssions. |
|
|
Why can't I write this
| Code: | | LV_Delete(), x := 4 |
_________________
 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Thu Apr 12, 2007 10:38 am Post subject: |
|
|
For some reason functions can't come first, instead you could use x := 4, fx() or null := fx(), x := 4. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Thu Apr 12, 2007 12:12 pm Post subject: |
|
|
OK, so it is a bug, like I suspected.
Thx Titan.
Or is it by bad design? Chris would possible argue that single function call is not an expression. But then, it can not be that way as
also have single func call where expression can be put so this time it is treated as expression.
On the other hand this works
| Code: | if (True(), x:=4)
msgbox %x%
return
True(){
return true
}
|
While this doesn't
| Code: | True(), x:=4
msgbox %x% |
So, it seems like a special case again although I think I understand why.
This will soon ruin AHK as a language if continues that way IMO for anything more serious then 10-liners. _________________
 |
|
| Back to top |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5068 Location: imaginationland
|
Posted: Thu Apr 12, 2007 4:35 pm Post subject: |
|
|
fx() ? yes() : no() also works so there is definitely an inconsistency. _________________
RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2") |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4016 Location: Pittsburgh
|
Posted: Thu Apr 12, 2007 6:28 pm Post subject: |
|
|
Because of the rule-based syntax, there will always be some funny, unexpected AHK behavior. You can argue, that "x:=1, a=b=c" is intuitive or not. I have to consult the help when I see something like this, which would not be necessary with "pure", context-free grammar. There is this undocumented restriction, that a comma separated list of sub-expressions must not start with a function call, except if it is part of the ternary operator or the list is in parentheses. The shortest (undocumented) workaround is pre-pending ++: | Code: | ++sin(x:=1), y := 2
MsgBox [%x%] [%y%] | Of course, this should be an error, but it is a wonderful tool to obfuscate your code, such that nobody can easily steal your IP. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Apr 14, 2007 6:54 pm Post subject: |
|
|
It's unintentional. This bug will be fixed in the next release.
Thanks. |
|
| Back to top |
|
 |
majkinetor
Joined: 24 May 2006 Posts: 3626 Location: Belgrade
|
Posted: Sat Apr 14, 2007 7:34 pm Post subject: |
|
|
Thx, it was really anoying for me cus I use new inline syntax a lot. _________________
 |
|
| Back to top |
|
 |
|