class Array[E]
fun sort
- with cmp(a, b: E): Int
+ !cmp(a, b: E): Int
do
var e1 = _e1
var e2 = _e2
end
fun iterate
- with each(e: E)
+ !each(e: E)
do
each(_e1)
each(_e2)
end
class Map[K, V]
- fun get(k: K): V
- with def: V do abort
+ fun [](k: K): V
+ !def: V do abort
do
if _k == k then return _v
var n = _next
- if n != null then return n.get(k) with do continue def
+ if n != null then return n[k] !def do continue def
var v = def
_next = new Map[K, V](k, v)
return v
if n != null then return n.has_key(k) else return false
end
fun iterate
- with each2(k: K, v: V)
+ !each2(k: K, v: V)
do
var n: nullable Map[K, V] = self
while n != null do
end
fun file_open(i: Int)
- with work(f: File)
- with break error(i: Int) do abort
+ !work(f: File)
+ break !error(j: Int) do abort
do
var f = new File(i)
if not f.is_open then error(404)
- work(f) with do f.close
+ work(f) !break do f.close
f.close
end
do
var a = new Array[Char]('2', '1')
a.output
- a.sort with x, y do continue x <=> y
+ a.sort !cmp(x, y) = x <=> y
a.output
- a.sort with x, y do continue y <=> x
+ a.sort !cmp(x, y) = y <=> x
a.output
- a.iterate with i do i.output
+ a.iterate !each i do i.output
'\n'.output
end
if not m.has_key('I') then (-1).output
'I'.output
'='.output
- var i = m.get('I')
+ var i = m['I']
i.output
'\n'.output
if m.has_key('V') then (-2).output
'V'.output
'='.output
- i = m.get('V') with do continue '5'
+ i = m['V'] !def = '5'
i.output
'\n'.output
if not m.has_key('V') then (-3).output
'V'.output
'='.output
- i = m.get('V') with do continue '6'
+ i = m['V'] !def = '6'
i.output
'\n'.output
if m.has_key('X') then (-4).output
'X'.output
'='.output
- i = m.get('X') with do break '0'
+ i = m['X'] !def do break '0'
i.output
'\n'.output
if m.has_key('X') then (-5).output
- m.iterate with k, v do
+ m.iterate !each2(k,v) do
k.output
'='.output
v.output
fun test_file(i: Int)
do
var f_escape: nullable File = null
- file_open(i) with f do
+ file_open(i) !work(f) do
'O'.output
'?'.output
f.is_open.output
f_escape = f
- with e do
+ !error(e) do
'E'.output
e.output
- break
end
if f_escape != null then
'O'.output