Language of your choice: library documentation
Represents a symbol, which is a singleton string that supports fast comparisons and extensible enums. More...
Represents a symbol, which is a singleton string that supports fast comparisons and extensible enums.
Symbols can be used like a global, extensible enumeration. Comparing symbols is as fast as comparing two integers; this is because '==' is not overloaded–equality is defined as reference equality, as there is only one instance of a given Symbol.
Symbols can also be produced in namespaces called "pools". Two Symbols with the same name, but in different pools, are considered to be different symbols. Using a derived class D of Symbol and a SymbolPool<D>, you can make Symbols that are as type-safe as enums.
A Symbol's ToString() function formerly returned the symbol name prefixed with a colon (:), following the convention of the Ruby language, from which I got the idea of Symbols in the first place. However, since Symbols are commonly used for extensible enums, I decided it was better that ToString() return just the Name alone, which makes Symbol more suitable as a drop-in replacement for enums.
Symbols are also useful in compilers and Loyc trees, where there may be a performance advantage in comparing identifiers by reference rather than character-by-character.
|Gets the name of the Symbol. More...|
|Gets the SymbolPool in which this Symbol was created. More...|
|Returns true if this symbol is in the global pool (GSymbol.Pool). More...|
|Returns a numeric ID for the Symbol. More...|
|override string||ToString ()|
|override int||GetHashCode ()|
|override bool||Equals (object b)|
|bool||Equals (Symbol b)|
|int||CompareTo (Symbol other)|
|static||operator Symbol (string s)|
|static||operator string (Symbol s)|
|static||operator Symbol (UString s)|
|static||operator UString (Symbol s)|
|static Symbol||For (string s)|
|Alias for GSymbol.Get(string). This function was introduced to match the equivalent ES6 API |
|Symbol (Symbol prototype)|
|For use by a derived class to produce a statically-typed enumeration in a private pool. See the example under SymbolPool (of SymbolEnum) More...|
For use by a derived class to produce a statically-typed enumeration in a private pool. See the example under SymbolPool (of SymbolEnum)
|prototype||A strictly temporary Symbol that is used to initialize this object. The derived class should discard the prototype after calling this constructor.|
Alias for GSymbol.Get(string). This function was introduced to match the equivalent ES6 API
Returns a numeric ID for the Symbol.
Normally the Id is auto-assigned and the Id corresponding to a particular Name may vary between different runs of the same program. However, SymbolPool.Get(string, int) can be used to assign a specific Id to a Name when setting up a new pool.
Referenced by Loyc.SymbolPool< SymbolE >.Get().
Returns true if this symbol is in the global pool (GSymbol.Pool).
Gets the name of the Symbol.
Referenced by Loyc.Syntax.CallNode.Calls(), Loyc.LLParserGenerator.RuleRef.ChooseGotoLabel(), Loyc.Ecs.Parser.EcsLexer.Error(), Loyc.LLParserGenerator.CodeGenHelperBase.ErrorBranch(), Loyc.LLParserGenerator.CodeGenHelperBase.GenerateTest(), Loyc.SymbolPool< SymbolE >.Get(), Loyc.Syntax.LNodeExt.GetCaptureIdentifier(), LeMP.MacroContext.GetOptions(), Loyc.Syntax.Les.Les2Printer.IsNormalIdentifier(), Loyc.Syntax.LNode.IsSpecialName(), Loyc.Syntax.Les.LesPrecedenceMap.IsSuffixOperatorName(), Loyc.Syntax.Les.Les3PrettyPrinter.Les3PrettyPrinter(), Loyc.LLPG.Macros.LllpgMacro(), Loyc.Localize.Passthru(), Loyc.Symbol.Symbol(), Loyc.Syntax.Lexing.Token.ToLNode(), and Loyc.Syntax.IdNode.WithArgs().