Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
..
Failed to load latest commit information.
DifferencesFromIo.txt
IonGrammar.ion
IonGrammar.js
IonVM.js
IonVMTest.js
JSONGrammar.ion
JSONGrammar.js
OOP.js
Parcer.ion
Parser.js
README
TODO
Test.js
TestGrammar.js
UnitTest.js
Util.js
notes.js
testparser.js

README


import flash.utils.*

eval for arbitrary code execution
getDefinitionByName for class retrieval
new for creating instances
[] for getting properties
hasOwnProperty for checking properties
for in for enumerating properties


Packaging:
1. Place Io code in EXML literal inside *.as file[s]
2. Compile SWF from the AST


Deviations from the mainline Io:

1. Square brackets instead fo parentheses
2. Method name may have "=", "?" or "!" in the end
3. Only one type of assignment: A = B
4. Assignment invokes "A=[B]" method instead of "setSlot['A', B]"
5. Slot is marked as activatable, rather than value. This allows to pass methods as first class objects without using "getSlot" to avoid activation.

Basically, object does not have slots anymore. It is just a collection of methods.

callMethod["name"]           #=> ""
callMethod["name=", "Oleg"]  #=> "Oleg"
getMethod == getSlot
getMethod["name"]            #=> method[getSlot["_name"]]
getMethod["name="]           #=> method[x, setSlot["_name", x]]
setMethod["name",  method[_name]]
setMethod["name=", method[n, _name = n]]

Note: when "name=" method is called, the argument is always returned. Even if callMethod["name="] was used.
      For consistency it is recommended to explicitely return value from the "a="-kind method

syntactic sugar:

def[name, arg1, arg2, arg1 + arg2]: creates and assigns the method
Object setMethod["def", 
  method[
    setMethod[name, 
      call locals doMessage[
        message[method] setArguments[call arguments tail]
      ]
    ]
  ]
]


    JavaScript            Ion                       Ion internals
    
    obj.prop         =>   obj getSlot["prop"]
    obj.prop = x     =>   obj setSlot["prop"]
    obj.prop()       =>   obj prop             =>   callMethod["prop"]
    obj.setProp(x)   =>   obj prop = x         =>   callMethod["prop=", x]



setMethod["init", method[
  self ivar = 1
  lvar = 2
]]

def initialize[
  self ivar = 1
  lvar = 2
]

def initialize[
  @ivar = 1
  lvar = 2
]


Named arguments:
- optional => you can't change arguments order later
- should be mergeable with dictionaries

method[options,
  options = options or[{"a": 1, "b": 2}]
]

list map[x, x + 2]
list mapWithBlock[block[x, x + 2]]