Skip to content

Latest commit

 

History

History
114 lines (94 loc) · 4.28 KB

jems.md

File metadata and controls

114 lines (94 loc) · 4.28 KB

jems

json–expressed modules, are software-defined actions & information, expressed via json & ion: invoked object notation:

~ {  "log" : "👋🏾👨🏾‍💻"   } <= /do transcription/
+ { "json" : "data"  } <= /json information/
- ["natural language"] <= /text information/

why

jems can be used for

  • automatic & decoupled json observation,
  • event-driven programming,
  • defining domain-specific languages,
  • and more;

their full potential is up to you 🤲🏾

how

javascript runtimes interpret & evaluate jems as unary expressions composed of a +, -, or ~ unary operator prefix, and an object or array-literal operand:

;
~ {"jem":"one"} // a ~prefixed object-literal json
+ {"jem":"too"} // a +prefixed object-literal json
- ["jem three"] // a -prefixed  array-literal json
;

during jem evaluation, its +, -, or ~ unary operator attempts to convert its object or array operand to a number. during that conversion, an attempt is made to call the object or array's valueOf() method. since jems are json, and json have no methods, jems don't implement a valueOf() method. this causes javascript runtimes to traverse the jem's prototype inheritance path in search of one. that search begins & ends at Object.prototype & Array.prototype because:

  • jems are json,
  • json are object & array literals,
  • and object & array literals' prototypes are respectively, Object.prototype & Array.prototype

javascript runtimes implement both Object.prototype.valueOf() & Array.prototype.valueOf(), so each jem's +, -, or ~ unary operator, calls the jem’s prototype-inherited, Object or Array, valueOf() method to obtain a basic value that's then converted to a number.

defining custom Object.prototype.valueOf() & Array.prototype.valueOf() methods enables observing & interacting with all jems, with & without their identifiers, by interfacing with javascript's Object & Array implicit type conversion 🙏🏾

;
Object.prototype.valueOf
  = function onObject ()
      { this.jem == "some data" // true on 1st jem!
      ; this.jem == "more data" // true on 2nd jem!
      ; this.any == "json data" // true on 3rd jem!
      }

~ {"jem":"some data"} // 1st jem with no identifier
+ {"jem":"more data"} // 2nd jem with no identifier
- {"any":"json data"} // 3rd jem with no identifier
;

where

jems work everywhere javascript exists & can be used in all web browsers, web views & javascript runtimes implementing any version of the ecmascript specification published since 1999 👏🏾

to get started, try ionify: invoked object notation implemented for you, a flexible, unobtrusive & novel api that simplifies defining, observing & interacting with jems & other ions.

🙇🏾‍♂️ through * יהוה * impossible -is- nothing || 🇬🇾👨🏾‍💻🇺🇸 mike lee & team 🤲🏾