For the next major release of uLisp, Release 4.9, I’m proposing to add a simplified version of the Common Lisp special form destructuring-bind, which lets you bind one or more variables to the values in a list returned by evaluating a function. I’m proposing to call the simpler version bind.
For example, suppose you have a function (lis3dh-xyz) that returns the x, y, and z values from a 3-axis accelerometer as a list of the three values:
> (lis3dh-g3d)
(0.0273438 0.0507813 1.02734)
Currently you might do something like:
(let* ((data (lis3dh-g3d))
(x (first data))
(y (second data))
(z (third data)))
(format t "x=~a, y=~a, z=~a~%" x y z))
With bind you will be able to replace this with:
(bind (x y z) (lis3dh-g3d)
(format t "x=~a, y=~a, z=~a~%" x y z))
Does this seem a useful addition?
I’m proposing to call it bind to make it clear that it is a simplified version of destructuring-bind, and because the latter is not one of my favourite Common Lisp names. I’m open to alternative suggestions, such as do-bind.