Package: mio-lang
mio is a minimalistic IO programming language written in thePython Programming Languagebased on MIo (a port from Ruby to Python)
in the bookHow To Create Your Own Freaking Awesome Programming LanguagebyMarc-Andre Cournoye.This project is being developed for educational purposes only and should serve as
a teaching tool for others wanting to learn how to implement your own programming
language (albeit in the style of Smalltalk, Io, etc). Many thanks go toMarc-Andre Cournoyeand his wonderful book which was a great refresher and overview of the overall processing
and techniques involved in programming language design and implementation. Thanks also go to the
guys in the#iochannel on the FreeNode IRC Network specificallyjernadlocksfor their many valuable tips and help.The overall goal for this project is to create a fully useable and working programming language
implementation of a langauge quite similar toIowith heavy influence
fromPython(because Python is awesome!). This has already largely been
achived in the current version. See theRoadMapfor what might be coming up next.Warningmio is a new programming language in earlyPlanningandDevelopment.
DO NOT USE IN PRODUCTION! USE AT YOUR OWN RISK!Visit theProject WebsiteRead the DocsRead the TutorialDownload it from theDownloads PageExamplesFactorial:Number fact = method(reduce(block(a, x, a * x), range(1, self)))Hello World:print("Hello World!")FeaturesHomoiconicMessage PassingHigher Order MessagesHigher Order FunctionsFull support for TraitsObject Orienated LanguageWritten in an easy to understand languageSupports Imperative, Functional, Object Oriented and Behavior Driven Development styles.InstallationThe simplest and recommended way to install mio is with pip.
You may install the latest stable release from PyPI with pip:> pip install mio-langIf you do not have pip, you may use easy_install:> easy_install mio-langAlternatively, you may download the source package from thePyPI Pageor theDownloads pageon theProject Website;
extract it and install using:> python setup.py installYou can also install thelatest-development versionby usingpiporeasy_install:> pip install mio-lang==devor:> easy_install mio-lang==devFor further information see themio documentation.Changesmio 0.1.8 (2013-12-24)Implementedcaller()[functools]Fixed parser support for[1] + [2]–>[](1}+([](2))FixedList extend()to take another list, not*args.Implemented+List operator.Implementedminandmaxand added to the mio std. lib.mio 0.1.7 (2013-12-09)FixedObject evalArg()so it can take zero arguments and returnNone. e.g:() aImplementedidentity()andconstantly()infunctoolsstd. lib and added unit tests.Fixed typos inoperatorsmodule.Moved all trait related user methods toTAdaptablecore trait.Addedadapt()method toTAdaptable.NoteThis is more or less an alias ofuse()except the object
being adapted is cloned and the original left in tact. The
adaptation is therefore temporary.Added support for contextually aware tab completion.Test Coverage back up to 100%mio 0.1.6 (2013-12-04)Added support for packaging Pythonwheels.Define a defaultinit()method onObjectand just makeTCloneable init()just callinit().AddedString strip()method.MakeStringuseTIterable.Implementedinput()builtin.Implemented a special objectTraitwhich all traits are cloend from.This means traits now cannot contain state and aTypeErroris raised.Objects can only use or add traits that are inherited from theTraitobject.A simple trait thus looks like:TFoo = Trait clone() do (
    foo = method(
        print("Foo!")
    )
)ImplementedTrait requires()so that traits can declare the names of methods and attribute they depend on.e.g:TGreetable = Trait clone() do (
    requires("name")

    hello = method(
        print("Hello ", self name)
    )
)

World = Object clone() do (
    name = "World!"
    uses(TGreetable)
)

World hello()Added conflict resolution for traits.Remvoedusesin favor of singleuse(trait, resolution)whereresolutionis a dict of key->value pairs that rename
conflicting methods of the trait being used.MakeObject hasTrait()lookup the parent chain.Abuse theismethod ofTComparbleto be used as short-cut for:foo hasTrait(TFoo).mio 0.1.5 (2013-11-28)Don’t look intobuiltinsmodule for the tab-completer function of the REPL if there are no builtins. i.e:mio-SAdded a nice big shiny red warning about mio’s status.mio 0.1.4 (2013-11-27)Added “Functions” to the tutorial.Added “Objects” to the tutorial.Added “Traits” to the tutorial.Added the start of a smallfunctoolslibrary to the mio std. lib.Addedtest_builtinsto mio. std library as a tests package.Added operators module to mio std. lib.Rought cut of generators implemented in CPython and mio.ImplementedKeyErrorexception type and used this to guard non-existent key lookups on dicts.Somewhat improved the error handling and tracebacks.Improved the way generators work.Addedyieldto the mio std lib builtins.AddedTypeErrorguard around opening non-files with thePathobject.Rewrote the tutorial to utilizesphinxcontrib-autorunextension with custommiointerpreter.pymodule.Improved REPL continuation output of unclosed parens.Removed docs dependencies of unused sphinx extensions.Addedmio.state.State.runsource()which simplifiesmio.state.State.repl()a bit and allows our customsphinxcontrib-autorunext to work.Added API Docs.mio 0.1.3 (2013-11-19)Fixed tutorial by writing a bash script that generates it (Read the Docs forbids program-output extension).mio 0.1.2 (2013-11-19)MovedFilefrom types to core.Allow multiple-eexproptions to be given on the CLI.Implementedlenbuiltin.ImplementedList remove()method.ImplementedString split()method.ImplementedString __getitem__()andString __len__()methods.ImplementedBytes __getitem__()andBytes __len__()methods.Added[]syntactic sugar toBytesandStringobjects.Wrote a basicmio tutorialUpdated the factorial example to be a little clearer.Improved Test Coverage of new features and objects.mio 0.1.1  (2013-11-18)The beginnings of a testing framework.Implemented unit tests for mio builtins:abs,allandany.Added paren detection to the REPL so you start write long functions over multiple lines. (Borrowed from: https://bitbucket.org/pypy/lang-scheme/src/b1d5a1b8744f3c7c844775cb420c1a5d4c584592/scheme/interactive.py?at=default).Added basic tab completion support to the REPL.NoteThis is not context aware and build up a list of known objects fromRoot,Types,Coreandbuiltins.Many RPython compilation issues fixed.ImplementedPathobject.mio 0.1 (2013-11-14)Updated factorial examplesAdded support for and afab compiletask for compiling mio with RPythonWarningThis does not work yet!Changed the way results are printed on the REPL by implementing aformat_value(...)utility function.Addedassertas a special name (operator).Added optional message argument toassert.Improved repr ofCoreandTypesobjects.Fixed a bug in the parser so that we can use[]and{}as methods.xs = [1, 2, 3, 4]
xs[0]Implemented dict literals.{"a": 1, "b": 2}NoteThis only works with keys as strings for the moment.Added ahashbuiltin.Improved{}dict literal so that any hashable keys can be used.NoteLike Python this means any object whoose__hash__()method
returns a non-Nonevalue.Fixedanyandallbuiltins.IMplementedinmethod ofTComparable1 in(1, 0)Changed the semantics of closures.thisis a new attribute ofLocalsthat always references the
current block scope.selfis a reference to the current object in scope (if there is one).WarningThis behavior may change as I’m not 100% happy with this.NoteThis is sort of a work-around to allow blocks to access the
currently scoped objectselfinside the scope of a method
or nested blocks within a method.mio 0.0.9 (2013-11-10)Fixed[]syntax for creating lists.FixedTIterable foreacto work more like a for loop.Introduced properties for internal Python Functions exposed to mio.Adopted calling with(...)’s for all methods.Also format functions informat_object(...).Added__call__toErrorobjects. This allows:raise TypeError("foo")Added iterator support forRangeobject.Renamedstrandreprmethods ofObjectto__str__and__str__respectively and implemtnedstrandreprbuiltins.Optimized the tokenizerAddedifError,ifNonErrorandcatchto theObjectobject to deal with non-errors.Improved and fixed a lot of the builtins.Improved the way*argsis handled (still needs more work).Implementedassertbuiltin.mio 0.0.8 (2013-11-07)Removed operator precedence parsing.Operator precedence isHARDOperator precedence rules hareHARDto rememberOperator precedence is not the main goal of mio right now.Tidied up the builtins module.from foo import *works again (operator precedence parsing broke it).mio 0.0.7 (2013-11-06)Added rudamentary stack trace support to errors. A somewhat “okay” stack trace is displayed on error(s).AddedString formatmethod for performing string iterpolation. Only supports{0},{1}, etc.ImplementedListIteratoriterable object withiteradded to mio std. lib. This works similiarly to Python’s iterators:mio> xs = [1, 2, 3, 4]
===> list(1, 2, 3, 4)
mio> it = iter(xs)
===> ListIterator(list(1, 2, 3, 4))
mio> it next()
===> 1
mio> it next()
===> 2
mio> it next()
===> 3
mio> it next()
===> 4A further iteration would result in:mio> it next()

  StopIteration:
  --------------
  next
ifFalse(
 raise(StopIteration)
)

raise(StopIteration)Re-implementedreturnfunction as part of the mio std. lib.Don’t allowreturnto be called outside of aBlock(block/method) as this is illegal.Implementedwhilebuiltin as part of the mio std. lib.
(no break or continue support yet)Implementedloopbuiltin as part of the mio std. lib.
(no break or continue support yet)Implemented basic support for reshuffling messages before chaining to supportx is not None–>not(x is None).Finally implemented operator precedence support (which seems to cover most edge cases).NoteNeed to write lots of unit tests for this!Fixed all found edge cases with the new operator precedence lexer/parser.ImprovedErrorobject and addedError catchmethod for catching errors.Implementedreducebuiltin.Implemented TComparable traitImplemented TCloneable traitIterpretcall message argsto mean “pass all args to the callable”Imroved Dict and List objects.Implemented__call__calling semantics whereby an object can implement this as a method andFoo()will invokeFoo __call__if it exists.IMplemented the__get__part of the Data Descriptor protocol.mio 0.0.6 (2013-11-02)Allow an optional object to be passed to theObject idmethod.Implementedhexbuiltin.ImplementedBytesandTupleobjects.ImplementedStatecore object and sampleloopbuiltin (in testing).Refactored all of the context state management code (stopStatus) and exposed it to the end user.This means we can now write flow based constructs such as loops directly in mio.Fixed a minor bug in the parser wherenot(0)ifTrue(print("foo"))would parse asnot(0,ifTrue(print("foo")))Fixed a minor bug in the parser whereisErrorwould parse asis(Error). Parse identifiers before operators.Implemented basic excpetion handling and error object(s) (no stack traces yet).Movedexitto builtins.Moved the setting of.bindingattribute toObjectset/delmethods.Added support for..operator and added this toNumber. This allows you to write:x = 1 .. 5  # a Range from 1 to 5Added+and-operators to theRangeobject so you can do things like:x = (1 .. 5) + 2  # a Range from 1 to 5 in increment of 2Changed default REPL prompt to:$ mio
mio 0.0.6.dev
mio>Implementedsumbuiltin.Addedtryandraisebuiltins. (``raise`` is not implemented yet…).Added support for User level Error(s) and implementedException raiseReplacedContinuation callwith activatable object semantics. This means:c = Continuation current()
print("foo")
c()Object evalArgshould evaluate the argument with context as the receiver.AddedList __getitem__andList __len__methods.AddedTIterabletrait to the mio bootstrap library and added this toList.Removedforeach,whilte,continue,breakandreturnObjectmethods. These will be re-implemented as traits and builtins.Changed the way the parser parses and treats operators. They are no longer parsed in a deep right tree.Example:1 + 2 * 3OLD:1 +(2 *(3))NEW:1 +(2) *(3)This will probably make reshuffling and therefore implementing operator precedence a lot easier.This also makes the following expressions possible (used in the builtins module):from foo import *AddedTypeError,KeyErrorandAttributeErrorto the mio std. lib.Made it possible to import members from a module with:from foo import barmio 0.0.5 (2013-10-29)Split up core into core and types.Re-implementedTrue,FalseandNonein mio.Implementedbinbuiltin.Implementedboolbuiltin.Implementedcallablebuiltin.Implementedchabuiltin.IMplementedfromandimportbuiltins.Make theObject pimitive:foomethod return the internal Python data type.Fixed theabsbuiltin to return an newly cloned Number.Implemented support for packages ala Python.Restructured the mio std. libmio nwo bootstraps itself via an import of the “bootstrap” package.ReimplementedObject clonein the mio std. lib.mio 0.0.4 (2013-10-27)Moved the implementation ofsuperto the mio std. libOnly set_as the last result in the Root object (the Lobby)Added support for(),[]and{}special messages that can be used to define syntactic suguar for lists, dicts, etc.ImplementedDictobject type and{a=1, b=2}syntactic sugar to the builtint (mio std. lib)dict()method.Refactored theFileobject implementation and made it’s repr more consistent with other objects in mio.Fixed keyword argument support.Fixed a few minor bugs in theMessageobject and improved test coverage.Added?as a valid operator and an implementation ofObject?messagein the mio std. lib.Fixed a bug withRange’s internal iterator causingRange asListnot to work.Fixed a bug withObject foreachandcontinue.Achived 100% test coverage!Implemented*argsand**kwargssupport for methods and blocks.RemovedObjectmethodsprint,println,writeandwritelnin favor of the new builtinprintfunction in the mio std. libAdded an implemenation ofmapto the mio std. libFixed a bug with the parser where an argument’s previous attribute was not getting set correctly.Reimplementednotin the mio std. lib and added-=,*=and/=operators.Added aObject :foo(primitive) method using the:operator. This allows us to dig into the host object’s internal methods.Added an implementation ofabsbuiltin using the primitive method.Changed theimportfunction to return the imported module (instead of ``None``) so you can bind imported modules to explicitly bound names.Addedfroman alias toimportandModule importso you can do:bar = from(foo) import(bar)Fixed some minor bugs inObject foreachandObject whilewhere a ReturnState was not passed up to the callee.Added implementations ofallandanyto the mio std. lib.Added this.mio (The Zen of mio ala Zen of Python)Added List insert method and internal __len__.Moved the implementations of theImporterandModuleobjects to the host language (Python).Added support for modifying theImportersearch path.Restructured the mio std. library and moved all bootstrap modules into ./lib/bootstrapAdded (almost) Python-style string literal support. Triple Quote, Double, Quote, Single Quote, Short and Long StringsAdded support for exponents with number literals.Added internaltomioandfrommiotype converion function.Added anFFIimplementation that hooks directly into the host language (Python).Implemented theantigravitymodule in mio.Added support for exposing builtin functions as well in the FFI.Simplified the two examples used in the docs and readme and write a simple bash script to profile the factorial example.Changed the calling semantics so that calls to methods/blocks are explicitly made with().Added a new internal attribute toObjectcalledbindingused to show the binding of a bound object in repr(s).mio 0.0.3 (2013-10-20)Improved test coverageImproved theRangeobjectFixed the scoping ofblock(s).Fixed thewriteandwritelnmethods ofObjectto not join arguments by a single space.Don’t displayNoneresults in the REPL.Improved the__repr__of theFileobject.Addedopenandwithbuiltins to the mio standard library.Implemented a basic import system in the mio standard library.ImplementedDict itemsmethod.mio 0.0.2 (2013-10-19)Include lib as package dataAllow mio modules to be loaded from anywhere so mio can be more usefully run from anywhereAdded bool type converionImproved the documentation and added docs for the grammarChanged Lobby object to be called RootAdded an -S option (don’t load system libraries).Added unit test around testing for last value with returnRefactored Message.eval to be non-recursiveSet _ in the context as the last valeuImplemented Blocks and MethodsFixed return/state issue by implementing Object evalArg and Object evalArgAndReturnSelf in Python (not sure why this doesn’t work in mio itself)Implemented Object evalArgAndReturnNonemio 0.0.1 (2013-10-19)Initial Release