From: Ike Date: 2006-07-29T10:15:09+09:00 Subject: Re: does ":" have an anolog in another language? wrote in message news:072820061953.19665.44CA6B2700073D1500004CD1219791280203010CD2079C080C03BF9C020A9F9F0E08090207089B0102@mchsi.com... > Sorry if anyone's beat me to this, I find it hard to keep up with such a > busy list... > > : is used to denote a symbol. The idea of a symbol has a rather broad > interpretation, but I think that technically any identifier you make in a > program -- a variable name or function name, for instance -- is a symbol. > > Lisp languages have symbols in a similar sense that Ruby does, and they > are usually used in much the same capacity as variable names -- they get > evaluated into any binding they currently have to a function or piece of > data. However, if quoted with a single quote (like 'this) they are left > unevaulated and treated as the symbols themselves. > > Lisp symbols don't have to start with :, but certain uses of them where > they have semantic significance use that convention, which might be where > Ruby borrows the syntax from. For example, a common idiom in Common Lisp > is the associative list, where elements are alternated with symbols that > must start with : and elements can be referenced by the :-symbol right > before them. So you might have a list like (:a 1 :b 2 :c 3) called > mylist, and (getf mylist :b) will return the 2. Similarly, :-symbols are > used a lot in argument lists for many Common Lisp functions, to denote > values meant to be passed to named parameters (aka keyword parameters). > > I think there's also something like it in Smalltalk but I'm not sure. > > So basically, a symbol is this little constant singleton identifier thing, > that you can use to mean whatever ;) > > --ch-- > Doesn;t that therefore make it the same thing as a reference in c++ ? -Ike