help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [OT] What langauges have symbols?


From: Yuri Khan
Subject: Re: [OT] What langauges have symbols?
Date: Fri, 30 Jun 2017 12:15:09 +0700

On Fri, Jun 30, 2017 at 11:24 AM, Marcin Borkowski <mbork@mbork.pl> wrote:

> What langauges besides Lisps have "symbols"?  And I not only mean the
> name, of course, but also the properties.  For instance, ES6 seems to
> have something similar, but it seems to me that you can't have
> a variable containing a symbol and say something like
> (set var val)
> where val is assigned to a variable whose name is the value of var
> (i.e., that symbol).

You can, kind of.

In Javascript (also known as ECMAScript), there are no global
variables. They are emulated as properties of the global object. The
global object in web browsers is ‘window’.

All objects support setting properties by statically known name:

    window.bar = "baz";
    console.log(bar);  // prints “baz”

or dynamically:

    function foo() { return "bar"; }
    window[foo()] = "baz";
    console.log(bar);  // prints “baz”

So, in Javascript, for purposes of setting a variable by computed
name, the closest idea to Lisp’s symbols is a string.

I cannot recall any language other than Lisp that has symbols in the
sense of literal values which are distinct from every other value.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]