Note
This is more or less an alias of use() except the object being adapted is cloned and the original left in tact. The adaptation is therefore temporary.
A simple trait thus looks like:
TFoo = Trait clone() do (
foo = method(
print("Foo!")
)
)
e.g:
TGreetable = Trait clone() do (
requires("name")
hello = method(
print("Hello ", self name)
)
)
World = Object clone() do (
name = "World!"
uses(TGreetable)
)
World hello()
Note
This is not context aware and build up a list of known objects from Root, Types, Core and builtins.
Warning
This does not work yet!
xs = [1, 2, 3, 4]
xs[0]
{"a": 1, "b": 2}
Note
This only works with keys as strings for the moment.
Note
Like Python this means any object whoose __hash__() method returns a non-None value.
1 in(1, 0)
Warning
This behavior may change as I’m not 100% happy with this.
Note
This is sort of a work-around to allow blocks to access the currently scoped object self inside the scope of a method or nested blocks within a method.
raise TypeError("foo")
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()
===> 4
A further iteration would result in:
mio> it next()
StopIteration:
--------------
next
ifFalse(
raise(StopIteration)
)
raise(StopIteration)
Note
Need to write lots of unit tests for this!
x = 1 .. 5 # a Range from 1 to 5
x = (1 .. 5) + 2 # a Range from 1 to 5 in increment of 2
$ mio
mio 0.0.6.dev
mio>
c = Continuation current()
print("foo")
c()
Example:
1 + 2 * 3
OLD:
1 +(2 *(3))
NEW:
1 +(2) *(3)
from foo import *
bar = from(foo) import(bar)