Thursday, March 22, 2018

[dhipnjdq] Multi word identifiers in Lisp

We consider a programming language that allows identifiers with spaces in them, eliminating the need for camelCase, underscores, or dashes in identifiers.  We consider building on Lisp syntax, which is the most challenging because of Lisp's limited syntactical elements.

Easiest is for multi-word identifiers to have a parenthesized special form, preceded by a reserved word signifying a multi-word identifier:(sine x) ((mwi inverse sine) x)

Making mwi a reserved word does subtract that word from the user's available namespace; however, things like (mwi my mwi) are available.  Alternative words: "id", some symbol, and... "multiWordIdentifier".  The irony is that "multi-word identifier" is itself a multi-word identifier, but we can't use it to signify itself, or else we fall into a recursive rabbit hole like (((mwi multi word identifier) inverse sine) x).

Intriguingly, multi-word identifiers in Lisp allow parentheses within identifiers: ((mwi sine (implemented by Bob)) x), ((mwi (multi word) identifier (avoiding a dash)) x)

Another way to do it is to let multi-word identifiers be simply parenthesized: (inverse sine).  This interferes with function call syntax, so we modify function call syntax with a reserved word "do": (do sine x) (do (inverse sine) x).

Using up "do" as a reserved word prevents any multi-word identifier from starting with the word "do".  We could use some other word or symbol, perhaps period: (. (inverse sine) x).  This steals syntax from Lisp dotted pairs, so use another symbol for dotted pairs, assuming one wants to keep that feature.

Period to signify function invocation could be made more unobtrusive by making it postfix, radically departing from Lisp's normal prefix convention: (sine x .) ((inverse sine) x .)

Explicitly invoking functions is reminiscent of Haskell's $ operator.  It also suggests providing many different options on how to invoke a function, e.g., lazy evaluation, concurrency.

No comments:

Post a Comment