Skip to content

Latest commit

 

History

History
363 lines (294 loc) · 13.1 KB

ion.md

File metadata and controls

363 lines (294 loc) · 13.1 KB

ion

invoked object notation enables defining actions & information as observable & encapsulated software objects:

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

ion was discovered, defined & developed by michael lee in 2007, and exists & can be implemented within procedural operator overloading languages.

form

ion combines one or more objects with operators that invoke their action(s) and-or observation.

ion combines the ~ bitwise-not, +, and - unary operators, with operands that can be array, object, or regular expression literals in javascript, or references in javascript and other languages.

ion can be expressed as lion, literal ion:

~{ }      +{ }      -{ }     // 3 object lions
~[ ]      +[ ]      -[ ]     // 3 array  lions
~/ /      +/ /      -/ /     // 3 regular-expression lions

and orion, object reference ion:

~obj      +obj      -obj     // 3 prefixed orion

orion can also be expressed with the ++ and -- prefix operators, and the ++ and -- postfix operators:

         ++obj,    --obj     // 2 prefixed  orion
           obj++,    obj--   // 2 postfixed orion

punctuation

ions can be combined to form larger expressions via arithmetic, bitwise, relational & equality operator punctuation.

this example combines fifteen lions with seventeen ion-compatible bitwise, arithmetic, relational & equality punctuation operators:

~  /example/  -  /punctuation/
^  ["aesop"]  &  /  stories  /  >>  {are:"ions"}
*  ["these"]  +  /expressions/  <<  {are:"too" }
/  ["write"]  %  /them as you/  |   {see:"fit" }
>  ["using"]  >= /  any of   /  <=  [  "these" ]
<     17      == / compatible/  !=  "operators!"

as shown

  • arithmetic punctuation can be any of the +, -, *, /, or % operators,

  • bitwise punctuation can be any of the &, ~, |, ^, <<, or >> operators,

  • relational punctuation can be any of the >, >=, <, or <= operators,

  • and equality punctuation can be the == or != equality operators when comparing ions with basic values.

function

ion is enabled by operator overloading in multiple languages.

enables ion via hip-hop operator overloading of the valueOf() & toString() methods invoked during an object's conversion to a basic value.

hip: handled-in-place operator overloading implements the valueOf() method within an object, which enables observing that single object's type conversion whenever it's expressed with an operator:

~
{ valueOf:
    function hip ()
      { console.log ("hip: handled-in-place")
      }
}

hop: handled-on-prototype operator overloading implements the valueOf() method on a prototype object, which enables observing the type conversions of all objects sharing that prototype whenever they're expressed with an operator:

Object.prototype.valueOf
= function hop ()
    { console.log ('hop: handled-on-prototype')    /*\
    | enables observing all invoked objects except  |
    | BigInts, Booleans, Dates, Numbers, Strings,   |
    | Symbols & any others that implement their own |
    | valueOf() method.                            \*/
    }

~ { hello : "👋🏾👨🏾‍💻world"}

hip-hop operator overloading the valueOf() method enables expressing & punctuating ions with these arithmetic, bitwise, relational & equality operators:

~  /example/  -  /punctuation/
^  ["aesop"]  &  /  stories  /  >>  {are:"ions"}
*  ["these"]  +  /expressions/  <<  {are:"too" }
/  ["write"]  %  /them as you/  |   {see:"fit" }
>  ["using"]  >= /  any of   /  <=  [  "these" ]
<     17      == / compatible/  !=  "operators!"

hip-hop operator overloading the toString() method enables expressing sentences & phrases with ions punctuated by the + operator, but overloading the valueOf() method enables even more punctuation, and since it's less likely than toString() to be otherwise overloaded and-or invoked, overloading toString() is not recommended:

Object.prototype.valueOf // vs .toString
= function hop ()
    { console.log (this.say)         /*\
    | or do something more profound! \*/
    }

var   you = {say:'do you see all the things'}
  ,   can = {say:'we can do'   }
  , write = {say:'if we write' }
  ,  code = {say:'our code'    }
  ,    as = {say:'as groups of'}
  , prose = {say:'phrases & sentences?! 🤓'}

'with orion' - you - can - write + code - as -
 prose;

flow

during hip-hop operator overloading, an attempt is made to convert an ion's object operand to a number. that conversion attempts to invoke the object operand's valueOf() method. if the ion doesn't define that method, javascript searches for it along the ion's prototype path. for lions that search begins & ends at their prototype; i.e. Object.prototype, Array.prototype or RegExp.prototype. for orion the search may end similarly but begin with the ion's inherited object.

Object, Array & RegExp all define a prototype.valueOf() method, so for each ion of those types, their operator causes the ion's inherited prototype.valueOf() method to be invoked to obtain a basic value that's then converted to a number.

defining custom Object, Array & RegExp prototype.valueOf() methods enables interfacing with javascript objects' type conversion flow. that then enables interacting with all ions without needing access to any of their identifiers 🤓

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

~ {ion:"some data"}  // 1st ion
+ {ion:"more data"}  // 2nd ion
- {any:"data kind"}  // 3rd ion

javascript's hip-hop operator overloading is a simple & reliable pattern for enabling ion observation & notification. it can be implemented manually, as shown, or via ionify: invoked object notation implemented for you, a flexible & unobtrusive natural-language api that implements & provides vocabulary for: ion observation, notification & interaction, for you.

enables orion via hot: handled-on-type operator overloading by implementing an object type's toString() method, which enables overloading the + operation for objects of that type.

here's an in-depth proof-of-concept:

class AnION
  { public String
      ion = null,
      any = null;

    public AnION
      (String ion)
        { this.ion = ion;
        }

    public String
      toString ()
        { ion == "some data";  // true on invoke   ion!
          ion == "more data";  // true on these    ion!
          any == "data kind";  // true on ions     ion!
          return ion || any ;  // or do something else!
        }
  }

class ActIONs
  { public static void
      main (String [] args)
        { AnION invoke   = new AnION ("some data"),
                these    = new AnION ("more data"),
                ions     = new AnION (           ),
                now      = new AnION (           );
                ions.any =            "data kind" ;
          "let's" + invoke + these + ions + now ;
        }
  }

enables orion by applying hot: handled-on-type operator overloading via numeric type emulation.

here’s a proof-of-concept:

class Ion:
    def getName(self):
        return 'python.hip.ion!'

    def __repr__(self):
        return '<hip.ion>'

    def __str__(self):
        return 'hip.ion!'

    def __add__(self, other):
        print ('hip.ion + something!')
        return 'hip.ion + something!'

    def __neg__(self):
        print ('-hip.ion!')
        return '-hip.ion!'

    def __pos__(self):
        print ('+hip.ion!')
        return '+hip.ion!'

    def __invert__(self):
        print ('~' + self.getName())
        return '~hip.ion!'

ion = Ion()
~ ion
+ ion
- ion
ion + 777
repr (ion)
print (ion)

enable orion via procedural operator overloading of arithmetic, bitwise, relational & equality operators.

compatibility

orion & hip-hop operator overloading are compatible with all javascript environments. lion is compatible with all environments implementing any edition of the ecmascript specification since 1999.

javascript environments include all web browsers, web views & runtimes implementing any ecmascript specification.

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