5

Which programming system first introduced "destructuring" denoting accessing various parts of an object using some sort of pattern, and binding those parts to variables, like Common Lisp's destructuring-bind, either as an the name of an operator in the actual implementation, or perhaps as a term in its documentation?

Now it's a bit of a buzzword, what with new versions of JavaScript and other languages supporting "destructuring assignment", but I suspect it might have arisen in Lisp development circles, first appearing in some Lisp system.

13
  • 1
    You might want to try HSM.SE, as this is a quite exotic condition.
    – Raffzahn
    Commented Aug 11, 2019 at 18:07
  • You're specifically asking about the terminology rather than the mechanism?
    – dave
    Commented Aug 11, 2019 at 20:37
  • Not the term "destructuring" but you might want to look into Scheme, a Lisp vaariant by Gerald Sussman and Guy Steele. Commented Aug 11, 2019 at 22:14
  • 2
    As @Raffzahn said, such questions seem to be on-topic over on History of Science and Mathematics. As this is more computer-science related than retrocomputing, I'm happy to migrate it there for you if you want. (It's almost certainly perfectly on-topic here too, but those people might be more likely to be able to help.)
    – wizzwizz4
    Commented Aug 11, 2019 at 22:53
  • 4
    Does MOVE CORRESPONDING In COBOL count, as a combined destructuring and partial restructuring? ;-)
    – dave
    Commented Aug 12, 2019 at 12:08

1 Answer 1

5

As far as I have been able to find, the earliest use of the word “destructuring” in its current meaning is in the release notes for Maclisp 1742, from September 1978:

[1] New autoloadable interpreter macros: backquote ("`") and LET.
    The "backquote" macro and the LET macro will be autoloaded when used.  
        The backquote macro allows generation of quoted structure with
    evaluated inserts, and is compatible with the LISP Machine's version.  
    A "," within a backquote indicates evaluation of the next s-expression, 
    and ",@" indicates not only evaluation but also that the resultant form is 
    "spliced" into the surrounding list.
    For example:
        `(A B ,(+ 1 2)) reads in like (CONS 'A (CONS 'B (CONS (+ 1 2) 'NIL)))
          which when evaluated  generates  (A B 3)
        `(A B ,@(LIST 1 2)) read in like 
         (CONS 'A (CONS 'B (APPEND (LIST 1 2) 'NIL)))
          which when evaluated  generates  (A B 1 2)
    One can imagine how especially helpful this will be in writing definitions
    of MACROs.
        The LET macro provides a convenient way to lambda-bind variables to 
    values.  Its usages is as follows:
        (LET ((var1 val1) (var2 val2) . . . (varn valn))
             <form1>
             . . . 
             <formn>)
    One may substitute merely "var"  in place of "(var NIL)"
    For example:
        (LET ((A 1) (B 2) C)
             <forms>)
    Binds A to 1, B to 2, and C to NIL and then evaluates <forms>.
    An extension to the binding of one variable, is a "pattern" of
    variables, which are bound to the corresponding subparts of the 
    "val";  e.g., (LET ( ((A . B) '(CONS 1 2)) ((C () D) (LIST 1 2 3)))
                       <forms>)
    would bind A to "CONS", B to "(1 2)", C to "1", and D to "3".
    There is an attempt by the LET macro code to optimize the destructuring
    operations of CAR and CDR over the original value.

If that's too informal, the term also occurs in 1980, in MIT Laboratory for Computer Science TM-169 (“LOOP Iteration Macro”), section 5:

Destructuring provides one with the ability to “simultaneously” assign or bind multiple variables to components of some data structure.

A 1972 thesis about APL program verification (Susan Lucille Gerhart, “Verification of APL Programs”) uses “destructuring” to mean something unrelated, though still related to programming.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .