dido/arcueid — Issue #33: Destructuring bind fails for argument named o
Author: dido
Created: 2012-02-05 05:21:31+00:00
State: open

```arc
arc> ((fn ((n o p)) n) '(1 2 3))
1
arc> ((fn ((n o p)) o) '(1 2 3))
Error: Unbound symbol: _o
arc> ((fn ((n o p)) p) '(1 2 3))
(2 3)
```
The 'o' should be treated special only if it is the first argument of a pair with two or three elements, denoting an optional argument. The disassembly for
```arc
(fn ((n o p)) o)
```
is
00000000 env	02	00
00000003 pop
00000004 push
00000005 car
00000006 push
00000007 mvarg	00
00000009 pop
0000000a cdr
0000000b push
0000000c mvoarg	01
0000000e ldg	[o]	(01)
00000010 ret
Note that mvoarg is used for the p argument, and o is treated as though it were a *global symbol*. The same code for
```arc
(fn ((p q r)) q)
```
is in contrast:
00000000 env	03	00
00000003 pop
00000004 push
00000005 car
00000006 push
00000007 mvarg	00
00000009 pop
0000000a cdr
0000000b push
0000000c car
0000000d push
0000000e mvarg	01
00000010 pop
00000011 cdr
00000012 car
00000013 push
00000014 mvarg	02
00000016 lde	00	01
00000019 ret
The destructuring bind was properly handled here.