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.

Kaz
  • 1,660
  • 1
  • 7
  • 14
  • 1
    You might want to try HSM.SE, as this is a quite exotic condition. – Raffzahn Aug 11 '19 at 18:07
  • You're specifically asking about the terminology rather than the mechanism? – dave Aug 11 '19 at 20:37
  • Not the term "destructuring" but you might want to look into Scheme, a Lisp vaariant by Gerald Sussman and Guy Steele. – Walter Mitty Aug 11 '19 at 22:14
  • 2
    As @Raffzahn said, such questions seem to be on-topic over on [hsm.se]. 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 Aug 11 '19 at 22:53
  • @wizzwizz4 I don't care who used that word in science or mathematics or other academics: only systems implementation. – Kaz Aug 12 '19 at 04:29
  • @Kaz "Lisp development circles" is pretty much academics and GNU IMP users nowadays, and was originally (iirc) pretty much just AI developers, but I see your point. – wizzwizz4 Aug 12 '19 at 05:53
  • My guess would also be Lisp, if that helps in any way. Typed functional programming languages (ML etc.) also had this early on, but it wasn't called "destructuring". Tracking the origin of words is hard. – dirkt Aug 12 '19 at 06:26
  • 4
    Does MOVE CORRESPONDING In COBOL count, as a combined destructuring and partial restructuring? ;-) – dave Aug 12 '19 at 12:08
  • My best guess is that the Javascript community came up with this term "destructuring" because they needed to describe this old feature of many languages (mathematics of sets, really) with a new term, since it was new to Javascript. – Brian H Aug 12 '19 at 14:36
  • I changed the question to clarify the systems perspective. I don't care if "destructuring" appeared in some paper whose author didn't implement anything; just where was this is used in an implemented system. – Kaz Aug 12 '19 at 16:50
  • Your last comment adds abiguity to the whole question. It is almost certain that some systems in the 1950s implemented what we would call "destructuring" today, without calling it that. Are you interested in such cases? – Walter Mitty Aug 12 '19 at 21:24
  • @WalterMitty: no, only if they actually had words in the programming language incorporating the term "destructuring", like exemplified by Lisp's destructuring-bind, or at least in the documentation. E.g. "the dollar sign operator performs destructuring, which means ...". – Kaz Aug 12 '19 at 21:51
  • @BrianH: "My best guess is that the Javascript community came up with this term "destructuring"" – That would be quite a feat, considering that Common Lisp the Language, 2nd edition which is the specification where DESTRUCTURING-BIND (the macro that sparked this question) was added to Common Lisp, was published in 1989. – Jörg W Mittag Aug 15 '19 at 19:54

1 Answers1

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.

texdr.aft
  • 3,495
  • 1
  • 19
  • 42