Skip to content

Commit

Permalink
Finish destructuring support for ikj
Browse files Browse the repository at this point in the history
  • Loading branch information
olabini committed Oct 22, 2009
1 parent f0490e5 commit a164125
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/ikj/main/ioke/lang/Base.java
Expand Up @@ -245,6 +245,12 @@ private Object recursiveDestructuring(List<Object> places, int numPlaces, IokeOb
} else if(name.equals("")) {
List<Object> newArgs = m1.getArguments();
recursiveDestructuring(newArgs, newArgs.size(), message, context, on, values[i]);
} else {
String newName = name + "=";
List<Object> arguments = new ArrayList<Object>(m1.getArguments());
arguments.add(context.runtime.createMessage(Message.wrap(IokeObject.as(values[i], context))));
IokeObject msg = context.runtime.newMessageFrom(message, newName, arguments);
((Message)IokeObject.data(msg)).sendTo(msg, context, on);
}
}
}
Expand Down
31 changes: 29 additions & 2 deletions test/assignment_spec.ik
Expand Up @@ -191,8 +191,35 @@ describe("assignment",
cval should == 35
)
it("should allow for places inside of the assignment specification")
it("should be possible to use places inside of a recursive assignment")
it("should allow for places inside of the assignment specification",
(cell(:a), b, cell(:c)) = (42, 45, 48)
a should == 42
b should == 45
c should == 48
x = [1,2,3]
x ([2], [1], [0]) = (42, 55, 77)
x should == [77, 55, 42]
)
it("should be possible to use places inside of a recursive assignment",
(a, (cell(:b), c), d) = (11, (21, 31), 41)
a should == 11
b should == 21
c should == 31
d should == 41
)
it("should do the assignment to places in parallell",
aval = 42
bval = 35
cval = 222
(cell(:aval), cell(:bval), cell(:cval)) = (cval, aval, bval)
aval should == 222
bval should == 42
cval should == 35
)
)
describe("+=",
Expand Down

0 comments on commit a164125

Please sign in to comment.