Using variables in the values-form in multiple-value-bind

Viewed 261

I am trying to implement a function read-from-whole-string in lisp, where it uses the inbuilt function read-from-string.


About read-from-string

read-from-string is used to read an object from a string which can be specified using the keywords :start,:end etc. It returns two values, the object and the position of the next element, which wasn't read. I plan to use this value.


The plan

The plan is to use the second value returned from the read-from-string function, again on itself to insert the value of the keyword :start. But the problem comes with the function multiple-value-bind. We can't:

  1. Initialize a variable in multiple-value-bind.
  2. Use a variable just defined into the values-form.

To be specific, I want to:

(multiple-value-bind (x (y 0))
         (read-from-string str :Start y)
         y)

Any other clean method is appreciated.

3 Answers
Related