commands and brackets.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
commands and brackets.
I've noticed that when calling commands, if you use brackets then the parameters passed can be combined into the first parameter value.
I'm just wondering under what circumstances you should use brackets and when they should be avoided?
Does this happen with functions as well?
I'm just wondering under what circumstances you should use brackets and when they should be avoided?
Does this happen with functions as well?
Re: commands and brackets.
It happens everywhere, including in the body of handlers. Parentheses force evaluation before anything else happens. In the case of function or handler calls, the evaluation occurs before the function/handler being called ever receives the parameters.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: commands and brackets.
Hi.
Just a note, because this threw me. "Parentheses", or "()", as Jacque assumed and explained, are surely what you were referring to.
"Brackets", or sometimes "Braces", either "{}", or "[]" are entirely different.
Craig Newman
Just a note, because this threw me. "Parentheses", or "()", as Jacque assumed and explained, are surely what you were referring to.
"Brackets", or sometimes "Braces", either "{}", or "[]" are entirely different.
Craig Newman
Re: commands and brackets.
So I guess the default should be to never use them...
Re: commands and brackets.
Not necessarily as long as you know how they work. And there are times where they are required, like when using URLs as containers or when constructing some types of "if" statements.MrFollies wrote:So I guess the default should be to never use them...
I don't usually use them in parameters but you could.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: commands and brackets.
I did not mean that at all. It was just that the terms were not quite accurate, at least in the United States. Brackets are not commonly used to mean "()".
Parentheses are not only required (as Jacque said) now and then for the parser to make sense of your code, they are often very useful in simple reading, where code fragments may be isolated by function or by their sense:
put temp into field ("yourField" & y) --required
put temp into field (y + 1) -- merely helpful
Craig
Parentheses are not only required (as Jacque said) now and then for the parser to make sense of your code, they are often very useful in simple reading, where code fragments may be isolated by function or by their sense:
put temp into field ("yourField" & y) --required
put temp into field (y + 1) -- merely helpful
Craig
Re: commands and brackets.
Sorry Craig,
I was replying to Jacque's comment. I understand now that () always means eval(). It's just strange for that to happen also for procedure calls.
I was replying to Jacque's comment. I understand now that () always means eval(). It's just strange for that to happen also for procedure calls.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: commands and brackets.
PEMDAS is pretty common:
http://en.wikipedia.org/wiki/Order_of_o ... #Mnemonics
http://en.wikipedia.org/wiki/Order_of_o ... #Mnemonics
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn