At 14:43 30.08.2000 +0100, Jon Roberts wrote:
>Why is it that Director sometimes incorrectly
>interprets the case of a symbol? Example;
>
>myList = [#F: "aValue"]
>put myList
>
>--[#f: "aValue"]
This one belongs to the "Oldies but Goldies" section of lingo questions, a
pity lingo-l has no archive.
Symbols are not case sensitive (compare the lingo dictionary), you could
say they have no case. A symbol is not 'a string with a leading hash',
rather, it is a 'named integer': all symbols a running director instance
encounters are listed in a table and remain there "for ever". Based on the
position in this table the symbol is translated to an integer for internal
usage. That's why they are faster - comparing integers is much faster than
comparing lists of chars.
in the messWin:
-- Welcome to Director --
put #aSymbol + 0
-- 1507
put #bSymbol + 0
-- 1508
put #cSymbol + 0
-- 1509
Apparently director 8 opens with about 1500 predefined symbols (lingo
keywords etc). Whenever a new symbol is used, it is appended to that list
with exactly the spelling which is used the first time:
aVar = #AsYmBoL
put avar
-- #aSymbol
When director opens a file, that file gets scanned for possible symbols
before we get the prompt. I once saw an example where a symbol #john in the
scripttext of an already deleted handler (invisible, but still part of the
*.dir) made director to "symbolize" a list of names as
[#john,#Paul,#Ringo,#George]. Hard to debug!
Opening another file will only add new symbols but never delete an old entry.
>When converting strings to symbols and then looking
>them up in a list this can be really annoying!
May be annoying (not to me) - but harmless. Symbols are not case sensitive
and will be found regardless. (Much unlike strings!)
aPropList = [#aSymbol:1,#bSymbol:2,#cSymbol:3]
put aPropList[#AsYmBoL]
-- 1
However, you will easily run into trouble when attempting to convert
symbols to strings as the resulting strings will have lost their originally
case information.
Things will brake when you try to find otherwise identical strings with
different spelling:
bPropList = [["aSymbol":1,"bSymbol":2,"cSymbol":3]]
put aPropList["AsYmBoL"]
-- <Void>
>Are
>there hard and fast rules as to what conditions this
>will happen under?
Any.
Here is a hard and fast rule how to avoid problems with case in strings
reconverted from symbols: don't do it. If you need the originally spelling
of a string, leave it as a string.
>____________________________________________________________
>Do You Yahoo!?
Not at all.
Best regards
Daniel Plaenitz
<http://www.lingo.de>
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]