4
$\begingroup$

All programming languages have globally defined symbols. While best practices invariably abjure their use as mutable entities the philosophy of what is mutable and what is not mutable is highly context dependent. Technologies like JIT compilation and type inference generate code on the fly based on the context in which symbols are dynamically referenced.

This makes me wonder exactly how far can this be taken. Have languages been researched that are oriented around embracing global references?

For an example of what I'm thinking of, in Perl there is a "local" command that allows you to save the value of a symbol that is global to the current dynamic scope, modify the symbol as though global within that scope, and automatically restore its prior global value upon return. This differs from ordinary concepts of local variables in that the nested dynamic scopes inherit the binding. It also means that all code references, as well as data references, would be potentially dynamic.

I'm sure features other than a Perl-like "local" would be necessary to make it more wieldy (or less unwieldy for programming in the large, as the case may be). An example of a more powerful dynamic scoping feature would be Javascript's "with" statement which allows unqualified references (without the object reference itself being repeatedly specified) to the properties of an object within the "with"'s dynamic scope.

The point here is that there are different ways of attacking the problem of programming in the large and some may be more conceptually clean than others in the sense of Ockham's Razor in that there is no escaping global symbols so we may as well make the best of them.

In more abstract terms, Quine suggested a similarly radical approach, at least in spirit, to applying Ockham's Razor in formal logic's use of the "name":

“Chief among the omitted frills is the name. This again is a mere convenience and is strictly redundant, for the following reasons. Think of ‘a’ as a name, and think of ‘F(a)’ as any sentence containing it. But clearly ‘F(a)’ is equivalent to ‘(∃x)( a = x & F(x))’. We see from this that ‘a’ need never occur except in the context ‘a =’. But we can as well render ‘a =’ always as a simple predicate ‘A’, thus abandoning the name ‘a’. ‘F(a)’ gives way thus to ‘(∃x)(A(x) & F(x))’, where the predicate ‘A’ is true solely of the object ‘a’.

“It may be objected that this paraphrase deprives us of an assurance of uniqueness that the name has afforded. It is understood that the name applies to only one object, whereas the predicate ‘A’ supposes no such condition. However, we lose nothing by this, since we can always stipulate by further sentences, when we wish, that ‘A’ is true of one and only one thing:

(∃x)A(x) & ~ (∃x,y)(A(x) & A(y) & ~(x=y) )”

“(This identity sign “=” here would either count as one of the simple predicates of the language or be paraphrased in terms of them.)”

PS: Part of the reason I ask this question is that I did a multitasking/multiuser OS on the 8088 back in the mid '80s that had a "push and set" macro that I used extensively to create very compact code that, it seemed to me, ran quite fast. This was a small system -- under 25,000 lines of code -- but it did work well in it specialized function as a 24 user instant messaging/bbs system.

$\endgroup$
9
  • 3
    $\begingroup$ Assembly language. And Perl's dynamic scoping used to be the default in Lisp. $\endgroup$ Nov 25, 2014 at 7:36
  • 1
    $\begingroup$ @Raphael I think the question needs some clarification but the phrase "... have languages been researched that..." suggests a more CS perspective to me. But if it's just a fancy way of saying "... are there languages that..." then I agree that Software Engineering looks more suitable. $\endgroup$ Nov 25, 2014 at 9:25
  • 1
    $\begingroup$ I don't understand what you mean by “embracing global references”. What you describe in your third paragraph is simply dynamic scoping, as opposed to the lexical scoping found in most languages (Perl offers both). I don't see the connection with OS design, a push-and-set macro, or performance. $\endgroup$ Nov 25, 2014 at 10:44
  • 1
    $\begingroup$ @DaveClarke Old Fortran allowed you to assign new values to literals, which was the source of very interesting programming bugs. Is there anything more gobal than literals. $\endgroup$
    – babou
    Nov 25, 2014 at 14:47
  • 1
    $\begingroup$ I am not sure what you are trying to prove with the Quine quote, but I would observe that it is using quantification that relies exclusively on static scoping. But maybe you should give one clear and simple pseudo-code example of a programming structure you would like to have, and cannot implement easily with current languages. $\endgroup$
    – babou
    Nov 26, 2014 at 11:17

1 Answer 1

4
$\begingroup$

This seems to me (as to some commenters) to be simply dynamic scoping. It was used often in Lisp to change the behavior of system functions to get some extra features, or perform hidden actions such as monitoring of programs. The cost is indeed that large programs may be difficult to manage and maintain. Since then, there was a long battle between static and dynamic scoping, I would guess that static scoping supporters provided techniques to do what was formerly done by dynamic scoping. The book I would look for such techniques is Abelson and Sussman: Structure and Interpretation of Computer Programs.

It is available on the web in different formats, including html and pdf

$\endgroup$
4
  • $\begingroup$ In λ calculus all names are local to definitions. I'm looking for something less kludgy than LISP's bastardization of the λ calculus in order to provide globals. $\endgroup$ Nov 25, 2014 at 22:34
  • $\begingroup$ @JamesBowery I did not suggest using Lisp, though I do have more respect for a language that was the cradle of so much innovation in programming. Actually Abelson and Sussman use Scheme, the statically scoped version of Lisp. You were asking for work on programming research, that might have the features you want, and I suggested looking in their excellent book. My idea is that you might find static scope solutions for the kind of programming style of programming techniques you may be interested in. $\endgroup$
    – babou
    Nov 25, 2014 at 23:19
  • $\begingroup$ I'll take a look at the Abelson and Sussman book to see if they provide the kind of insight I'm looking for. If so I'll mark yours as the correct answer and explain why I consider their text an adequate answer. $\endgroup$ Dec 4, 2014 at 4:12
  • $\begingroup$ @JamesBowery Good luck. This was just my best suggestion. The book is a classic, by two MIT professors who are experts on programming style and such pragmatic issues. $\endgroup$
    – babou
    Dec 4, 2014 at 10:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.