Transcript language design.

Alex Tweedly alex at tweedly.net
Wed Jun 9 21:46:29 EDT 2004


At 17:41 09/06/2004 -0700, Richard Gaskin wrote:

>Alex Tweedly wrote:
>
>>I had
>>     put URL "file:" & fileName into myVar
>>of course, I meant
>>     put URL ("file:" & fileName) into myVar
>>or similar.
>>I don't think I've ever encountered a language where a valid expression 
>>could cause unwanted side-effects in an expression using only a single 
>>instance of an operator. Sigh.
>
>The operator is fine.
>
>The error you should have encountered was something to the effect of using 
>a reserved word for a variable name.  "fileName" is a property of media 
>container objects like players and images, used to reference 
>externally-stored media files. It's also a property of a mainStack, 
>referring to the file it's associated with.

Sorry - my fault for cleaning up the example before sending it. The real 
script had
>>     put URL "file:" & myVar into myVar

The problem wasn't the clash with fileName - it was the non-obvious 
"binding" of concatenation.
The statement I wrote is (I think) evaluated as
    URL "file:"   - evaluates to the empty string
                   & myVar   - concatenated to myVar
   put ....   into myVar  - assign the result (i.e. the file name) into myVar

when I was expecting
      "file:" & myVar   - concatenate the strings
     URL "file:name.txt"  - take that as  a URL
   put ... into myVar   - put the content of the file into myVar

The reason I ascribed this to the operator is that Transcript is unique (in 
my experience) of allowing the flexibility to use keywords and operators at 
the same syntactic level - hence requiring the unwary programmer to 
remember the need to parenthesize accordingly. Concatenation is "normally" 
immune from the issues common in math type expressions (e.g. (2 + 4) * 5 ) 
because there are few string operators; traditional languages using 
libraries require the parens around the function calls so don't give you 
this particular piece of rope :-)

Thanks again (everyone) for the encouragement.
I'll read another couple of months worth of archives before my next post ....

-- Alex.

   
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.699 / Virus Database: 456 - Release Date: 04/06/2004


More information about the use-livecode mailing list