Keys of a custom property array

Björnke von Gierke bvg at mac.com
Mon Mar 4 09:16:38 EST 2013


URL is not a function. The reason why it's very often used with parentheses is because of evaluation ordering being unhelpful. There used to be a little popup in the old 1.1.1 documentation that explained operator order, and included containers and keywords.

Consider these two statement:

put URL "file:" & it && "connected to host." into myVariable
put it & URL "file:" & "blah.txt" into myVariable

both will fail, because the url keyword come after & in the operator order (correct ordering is enforced in the commented versions with the help of parentheses). For completeness sake, here how those two lines would work:

put URL ("file:" & it) && "connected to host." into myVariable
put it & URL ("file:" & "blah.txt") into myVariable

As a reference here a more widely known example of that same problem:

put (1 + 3) * 2 -- results in 8
put 1 + 3 * 2 -- results in 7

Now of course LiveCode does it wrong. It should treat URL as the beginning of a container, until the end of the string supplied, and not put URL into the operation order at all. That way both of the above "wrong" examples would work. However there'd be problem in such a theoretical case with a statement like this:

put URL "file:" & "fake.txt" && "If empty, please check your file privileges." 
-- result would theoretically be: this file does not exist: "fake.txt If empty, please check your file privileges."


Maybe using URL like a function could actually help with peoples confusion, by making the parenthesis mandatory. But again, there'd be problems with lines like this (the weirdness of the statement also freaks me out):

 put the URL of "http://blah.com" & "is the result"


TL;dr: URL is a container, the parenthesis help with operator order, this is not going to be fixed because there's no win-win solution.

On 04.03.2013, at 07:11, J. Landman Gay wrote:

> On 3/3/13 9:37 PM, Monte Goulding wrote:
>> 
>> On 04/03/2013, at 2:21 PM, Mark Wieder wrote:
>> 
>>>> If you're in the right folder you can:
>>>> put url "file:index.html" into tHTML
>>> 
>>> Yes, but that's one of those cases where LC "helps" you along even
>>> though you're doing wrong.
>> 
>> I don't think so... It's documented as a keyword not a function.
> 
> When "URL" was introduced into the language, it was defined as a "container". Sort of like a field or a variable. I've never thought of it as a function, but the engine might treat it that way.


-- 

Use an alternative Dictionary viewer:
http://bjoernke.com/bvgdocu/

Chat with other RunRev developers:
http://bjoernke.com/chatrev/






More information about the use-livecode mailing list