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 

Problem with one line expresssions.

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Bug Reports
View previous topic :: View next topic  
Author Message
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Thu Apr 12, 2007 10:13 am    Post subject: Problem with one line expresssions. Reply with quote

Why can't I write this

Code:
   LV_Delete(), x := 4

_________________
Back to top
View user's profile Send private message MSN Messenger
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Thu Apr 12, 2007 10:38 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Thu Apr 12, 2007 12:12 pm    Post subject: Reply with quote

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

Code:
 if ( IsThere() )

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
View user's profile Send private message MSN Messenger
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Thu Apr 12, 2007 4:35 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Laszlo



Joined: 14 Feb 2005
Posts: 4016
Location: Pittsburgh

PostPosted: Thu Apr 12, 2007 6:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Apr 14, 2007 6:54 pm    Post subject: Reply with quote

It's unintentional. This bug will be fixed in the next release.

Thanks.
Back to top
View user's profile Send private message Send e-mail
majkinetor



Joined: 24 May 2006
Posts: 3626
Location: Belgrade

PostPosted: Sat Apr 14, 2007 7:34 pm    Post subject: Reply with quote

Thx, it was really anoying for me cus I use new inline syntax a lot.
_________________
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 -> Bug Reports All times are GMT
Page 1 of 1

 
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