News for hackers. Stuff that matters.
Re:History of T (2001) by pvg on Friday August 17, 2018 @06:09PM (#17785804)
I wonder how people made working software at all in the '80s

It seems to me a lot of the debate and handwringing about dynamic scoping happened in Lisp-world. I was a kid learning to program in the mid 80s and the high level languages I encountered - Pascal and C did not have dynamic scoping. I first heard of it in a Lisp context. It's not quite that exotic, though - lots of people have been exposed to Emacs Lisp and the Javascript 'this' weirdness, among others.

Re:History of T (2001) by lispm on Saturday August 18, 2018 @01:59AM (#17787104)
> Pascal and C did not have dynamic scoping

They also did not have first-class functions.

The Lisp community investigated dynamic scope, because functions can take functions as arguments and can return functions as values. In this context dynamic scope showed its problems and closures were wanted. It took some time to find out what the problems are and what solutions were: closures (first Lisp implementors tried to add closures as an additional programming construct) and then lexical scope by default. During some time there was also a difference between the Lisp interpreter (using dynamic scope) and the same language implemented with a compiler (using lexical scope). Scheme and then Common Lisp required that both use the same technique: lexical scope.

Since neither C nor PASCAL had first class functions, they never had the problems of implementing closures, implementing garbage collection, etc... This also means that users never were programming with closures in these languages.

Re:History of T (2001) by pvg on Saturday August 18, 2018 @02:34AM (#17787195)
They also did not have first-class functions.

Sure, for some values of 'did not'. What I'm getting at is (and I think, if I'm reading you right, so are you) this debate existed in a fairly specialized universe. There wasn't a time in the 80s where statistically anybody was grappling with the choice of lexical over dynamic scoping, at least, not for programs most people wrote or used. Block-structured languages were already the norm by then.

Re:History of T (2001) by lispm on Saturday August 18, 2018 @04:26AM (#17787481)
The dynamic binding 'debate' began in the Lisp community in the 60s. Some functional programming language designers and people thinking about implementing them also explored it then.

See: The Funarg problem, 1968 http://www.softwarepreservation.org/projects/LISP/MIT/Weizen...

Mid 70s Scheme then was the first dialect to use lexical binding as a default. From then on new dialects of Lisp or new versions of of it switched over time to lexical binding by default. Scheme names block-structured Algol as one of its influences. 1982 Common Lisp was initially described amd it was then also using lexical binding.

The primitive block structured languages like PASCAL had it from Algol, too. But it was not a big deal, because they had no Closures, were not using Interpreters, had first class functions, no higher-order functions, etc. Lisp users were looking to implement higher-order functions in a 'right' way.

But most Lisps never gave up to provide dynamic binding as a feature, since it is used in a lot of programs...

Re:History of T (2001) by nils-m-holm on Saturday August 18, 2018 @07:06AM (#17787949)
And even in the LISPs that did give up dynamic binding, you can still emulate it to some degree. E.g. in Scheme:

  (define-syntax fluid-let
    (syntax-rules ()
      ((_ () x . xs)
        (begin x . xs))
      ((_ ((v1 a1) (v2 a2) ...) x . xs)
        (let ((tmp v1))
          (set! v1 a1)
          (fluid-let ((v2 a2) ...)
            (let ((r (begin x . xs)))
              (set! v1 tmp)
              r))))))

  (define x 'foo)
  (define (f) x)

  (f) ==> foo

  (fluid-let ((x 'bar))
    (f))                ==>  bar