<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,12 @@
 default: test
 
-test:
+test: skime
 	nosetests tests
+
+skime/iset.py: skime/iset.yml skime/iset_gen.py
+	(cd skime &amp;&amp; python iset_gen.py)
+
+skime/insns.py: skime/iset.yml skime/iset_gen.py
+	(cd skime &amp;&amp; python iset_gen.py)
+
+skime: skime/iset.py skime/insns.py
\ No newline at end of file</diff>
      <filename>Makefile</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ from types          import NoneType
 from ..types.symbol import Symbol as sym
 from ..types.cons   import Cons as cons
                      
-from ..errors       import UnboundVariable
 from ..errors       import CompileError
 from ..errors       import SyntaxError
 
@@ -139,6 +138,7 @@ class Compiler(object):
         &quot;(begin ...) is transformed to ((lambda () ...))&quot;
         gsub = g.push_proc(args=[], rest_arg=False)
         self.generate_body(gsub, body)
+        g.emit(&quot;make_lambda&quot;)
         g.emit(&quot;call&quot;, 0)
         if not keep:
             g.emit(&quot;pop&quot;)</diff>
      <filename>skime/compiler/compiler.py</filename>
    </modified>
    <modified>
      <diff>@@ -1,7 +1,9 @@
 from array  import array
 
-from ..iset import INSN_MAP
-from ..proc import Procedure
+from ..errors import UnboundVariable
+
+from ..iset   import INSN_MAP
+from ..proc   import Procedure
 
 class Generator(object):
     &quot;&quot;&quot;\</diff>
      <filename>skime/compiler/generator.py</filename>
    </modified>
    <modified>
      <diff>@@ -9,7 +9,7 @@ class Context(object):
         self.ip = 0
         self.bytecode = proc.bytecode
         self.stack = []
-        self.locals = map(lambda x: None, proc.locals)
+        self.locals = [None for x in proc.locals]
 
     def parent_get(self):
         return self.proc.lexical_parent
@@ -28,8 +28,10 @@ class Context(object):
         self.stack.append(val)
     def pop(self):
         return self.stack.pop()
-    def top(self):
-        return self.stack[-1]
+    def pop_n(self, n):
+        del self.stack[-n:]
+    def top(self, idx=1):
+        return self.stack[-idx]
 
 
 class TopLevelContext(Context):</diff>
      <filename>skime/ctx.py</filename>
    </modified>
    <modified>
      <diff>@@ -49,19 +49,24 @@ instructions:
       if isinstance(proc, Procedure):
           proc.check_arity(argc)
           nctx = Context(ctx.vm, proc)
-          while argc &gt; 0:
-              nctx.locals[argc-1] = ctx.pop()
-              argc -= 1
+
+          for i in range(proc.fixed_argc):
+              nctx.locals[i] = ctx.top(idx=argc-i)
+          if proc.fixed_argc != proc.argc:
+              rest = None
+              for i in range(argc-proc.fixed_argc):
+                  rest = Cons(ctx.top(idx=i+1), rest)
+              nctx.locals[proc.fixed_argc] = rest
+          ctx.pop_n(argc)
     
           ctx.vm.ctx = nctx
 
       elif isinstance(proc, Primitive):
           proc.check_arity(argc)
-          args = []
-          while argc &gt; 0:
-              args.append(ctx.pop())
-              argc -= 1
-          args.reverse()
+          args = range(argc)
+          for i in range(argc):
+              args[i] = ctx.top(idx=argc-i)
+          ctx.pop_n(argc)
           ctx.push(proc.call(*args))
 
       else:
@@ -70,6 +75,16 @@ instructions:
       ctx.ip += $(insn_len)
 
   -
+    name: pop
+    tags: []
+    desc: Pop the value off from the operand stack.
+    operands: []
+    stack_before: [value]
+    stack_after: []
+    code: |
+      ctx.pop()
+
+  -
     name: push_local
     tags: []
     desc: Push value of a local variable to operand stack.</diff>
      <filename>skime/iset.yml</filename>
    </modified>
    <modified>
      <diff>@@ -77,9 +77,10 @@ def process_tmpl(tmpl, env):
 TMPL_INSNS = &quot;&quot;&quot;\
 # Don't edit this file. This is generated by iset_gen.py
 
-from .ctx  import Context
-from .proc import Procedure
-from .prim import Primitive
+from .ctx        import Context
+from .proc       import Procedure
+from .prim       import Primitive
+from .types.cons import Cons
 
 $(tags)
 </diff>
      <filename>skime/iset_gen.py</filename>
    </modified>
    <modified>
      <diff>@@ -50,6 +50,9 @@ def load_primitives(ctx):
     ctx.add_local('*', PyPrimitive(mul, (-1, -1)))
     ctx.add_local('/', PyPrimitive(div, (1, -1)))
     ctx.add_local('=', PyPrimitive(equal, (2, -1)))
+    ctx.add_local('car', PyPrimitive(prim_car, (1, 1)))
+    ctx.add_local('cdr', PyPrimitive(prim_cdr, (1, 1)))
+    ctx.add_local('cons', PyPrimitive(prim_cons, (2, 2)))
 
 
 def plus(*args):
@@ -78,3 +81,10 @@ def equal(a, b, *args):
         if x != a:
             return False
     return True
+
+def prim_car(arg):
+    return arg.car
+def prim_cdr(arg):
+    return arg.cdr
+def prim_cons(a, b):
+    return cons(a, b)</diff>
      <filename>skime/prim.py</filename>
    </modified>
    <modified>
      <diff>@@ -39,6 +39,15 @@ class TestSyntax(object):
         assert self.eval(&quot;((lambda (x) x) 5)&quot;) == 5
         assert self.eval(&quot;((lambda (x) (+ x 1)) 5)&quot;) == 6
         assert self.eval(&quot;((lambda () 5))&quot;) == 5
+        assert self.eval(&quot;((lambda x (car x)) 1 2)&quot;) == 1
+        assert self.eval(&quot;((lambda x (car x)) 1 2 3 4 5)&quot;) == 1
+        assert self.eval(&quot;((lambda x (car x)) 1)&quot;) == 1
+        assert self.eval(&quot;((lambda (x . y) x) 1)&quot;) == 1
+        assert self.eval(&quot;((lambda (x . y) y) 1)&quot;) == None
+        assert self.eval(&quot;((lambda (x . y) (car y)) 1 2 3)&quot;) == 2
+
+    def test_call(self):
+        assert self.eval(&quot;(- 5 4)&quot;) == 1
 
     def test_define(self):
         assert self.eval(&quot;(begin (define foo 5) foo)&quot;) == 5
@@ -48,3 +57,6 @@ class TestSyntax(object):
 
         assert self.eval(&quot;(begin (define (foo x) x) (foo 5))&quot;) == 5
         assert self.eval(&quot;(begin (define (foo)) (foo))&quot;) == None
+
+        assert self.eval(&quot;(begin (define (foo . x) (car x)) (foo 1))&quot;) == 1
+        assert self.eval(&quot;(begin (define (foo . x) (car x)) (foo 1 2))&quot;) == 1</diff>
      <filename>tests/test_syntax.py</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f2be3f2eefb209ccad306d518d7a7720e924a6b0</id>
    </parent>
  </parents>
  <author>
    <name>pluskid</name>
    <email>pluskid@gmail.com</email>
  </author>
  <url>http://github.com/pluskid/skime/commit/58c1daea003e98ba34272e07787ef8afd74d24d4</url>
  <id>58c1daea003e98ba34272e07787ef8afd74d24d4</id>
  <committed-date>2008-07-14T16:05:14-07:00</committed-date>
  <authored-date>2008-07-14T16:05:14-07:00</authored-date>
  <message>Added support for variable arguments in lambda.</message>
  <tree>cafdbe37b8e950aec9e29f3961bd9ffaf6d56f8c</tree>
  <committer>
    <name>pluskid</name>
    <email>pluskid@gmail.com</email>
  </committer>
</commit>
