Singleton Pattern - sgml/signature GitHub Wiki

The language parser is a singleton controller, the symbol table is a singleton model, the language runtime is a singleton view. So overloading or overriding the global or local symbols with delegation, decoration, or memoization is a temporary extension to the language itself.

ES6 has a global resource for creating symbols: the symbol registry. The symbol registry provides us with a one-to-one relationship between strings and symbols. The registry returns symbols using Symbol.for( key ).

Symbol.for( key1 ) === Symbol.for( key2 ) whenever key1 === key2. This correspondance works even across service workers and iframes.

Symbols can be given a description, which is really just used for debugging to make life a little easier when logging them to a console: var symbol = Symbol.for('foo')

Symbol.toPrimitive is used when the JavaScript engine needs to convert your Object into a primitive value. There is one really bad feature of all this, which is that ToPrimitive does not enforce any type-checking on the return values, other than that they are primitive

Given a symbol symbol, Symbol.keyFor(symbol) returns the key that was associated with symbol when the symbol was added to the global registry. console.log(Symbol.keyFor(symbol))

Symbol.iterator also lets developers redefine navigation patterns without cloning the object or modifying its order in-place.

These patterns can then be written once in a function, class, or module and used anywhere. That means you can loop through an Array forwards, backwards, randomly, or infinitely in a modular fashion.

Operator Overloading Getter

function addPointOrVector(a, b) {
    if (a instanceof Point) a = new Vector([a])
    if (b instanceof Point) b = new Vector([b])
    return new Vector(...a.points, ...b.points])
  }
  class Vector() {
    constructor(points) { ... }
    get [Symbol.operator('+')]() { return addPointOrVector }
  }
  class Point() {
    constructor(x, y) { this.x = x, this.y = y }
    get [Symbol.operator('+')]() { return addPointOrVector }
  }
  Point(1, 0) + Point(1, 1) == Vector([[1,1], [1,0]])

References

https://www.tonymarston.net/php-mysql/singletons-are-not-evil.html

https://medium.com/front-end-weekly/thank-u-symbol-iterator-next-aef9f09ff78

https://javascript.info/async-iterators-generators

https://medium.com/@chanakyabhardwaj/es6-reverse-iterable-for-an-array-5dae91c02904

https://codeburst.io/a-simple-guide-to-es6-iterators-in-javascript-with-examples-189d052c3d8e

https://www.keithcirkel.co.uk/metaprogramming-in-es6-symbols/

https://www.keithcirkel.co.uk/metaprogramming-in-es6-part-3-proxies/

https://0x00sec.org/t/linux-internals-the-art-of-symbol-resolution/1488

https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Tables.html#Syntax-Tables

https://github.com/Microsoft/TypeScript/issues/980

https://dassur.ma/things/reading-specs-2/

https://lwn.net/Kernel/LDD2/ch11.lwn

https://www.gnu.org/software/kawa/Mangling.html

https://hsivonen.fi/no-json-ns/

https://www.bennadel.com/blog/1370-ask-ben-instantiating-nested-java-classes-in-coldfusion.htm

https://academy.realm.io/posts/swift-summit-boris-bugling-runtime-funtime/

http://buegling.com/blog/2015/5/3/swift-access-modifiers

http://www.globalnerdy.com/2014/06/03/swift-fun-fact-1-you-can-use-emoji-characters-in-variable-constant-function-and-class-names/

https://www.dzombak.com/blog/2017/01/Statically-Typechecked-Duck-Types-in-Swift.html

https://www.keithcirkel.co.uk/proposal-operator-overloading/

http://2ality.com/2016/01/classes-inner-names.html#the-inner-names-of-classes

http://amzn.github.io/ion-docs/guides/cookbook.html

https://www.sitepoint.com/symbol-gc-ruby-2-2/

https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/

https://dmitripavlutin.com/detailed-overview-of-well-known-symbols/

https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Internals/Functions

https://www.perlmonks.org/?node_id=94007

http://www.cs.virginia.edu/~cs415/scottcd/3a_impsc.pdf

https://docs.oracle.com/cd/E19205-01/819-5257/bladt/

http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a001072111.htm

http://bearcave.com/software/java/java_symtab.html

http://incrtcl.sourceforge.net/itcl/namesp.html

https://lucasfcosta.com/2016/12/01/Meta-Programming-in-JavaScript-Part-Four.html

https://itnext.io/straits-9ef2b9a563cd

https://www.cs.princeton.edu/courses/archive/fall05/cos217/reading/as.html

http://www.iitk.ac.in/LDP/LDP/Linux-Dictionary/html/Linux-Dictionary.html

http://web.cs.iastate.edu/~weile/cs440.540/5.SemanticAnalysis.scope.pdf

https://www.tutorialspoint.com/compiler_design/compiler_design_symbol_table.htm

https://www.tutorialspoint.com/lisp/lisp_quick_guide.htm

https://steemit.com/programming/@drifter1/writing-a-simple-compiler-on-my-own-symbol-table-basic-structure

https://www.brainkart.com/article/Symbol-Table-Per-Scope-and-Use-of-Symbol-Tables_8132/

https://www.kttpro.com/2017/02/09/six-phases-of-the-compilation-process/

http://turbopascal.org/turbo-pascal-internals

https://qlikcentral.com/2015/06/08/the-qlikview-engine/

http://flipcode.com/archives/Implementing_A_Scripting_Engine-Part_1_Overview.shtml

https://systemml.apache.org/docs/0.15.0/api/java/org/apache/sysml/api/mlcontext/MLContext.html

http://www.newlisp.org/newlisp_manual.html

https://en.wikibooks.org/wiki/Introduction_to_newLISP/Working_with_XML

http://www.gigamonkeys.com/book/programming-in-the-large-packages-and-symbols.html

https://xml.apache.org/xalan-j/xsltc/xsl_variable_design.html

https://developer.android.com/reference/android/icu/text/SymbolTable

https://xml.apache.org/xindice/dev/guide-internals.html

https://www.codeproject.com/Articles/1032231/What-is-the-Symbol-Table-and-What-is-the-Global-Of

https://psb.stanford.edu/psb-online/proceedings/psb97/dalke.pdf

https://rosettacode.org/wiki/Move-to-front_algorithm

https://www.cs.dartmouth.edu/~mckeeman/cs48/mxcom/doc/Symbols.html

http://types.bu.edu/Espresso/report/Espresso.html

https://ruslanspivak.com/lsbasi-part13/

https://wiki.visual-prolog.com/index.php?title=Language_Reference/Built-in_entities

https://picolisp.com/wiki/?symbolnamespaces

https://www.theiphonewiki.com/wiki/MobileDevice_Library

⚠️ **GitHub.com Fallback** ⚠️