Are there any good alternative schema syntaxes?

I suggest that the circuit (and possibly Lisp) might be more user friendly using a different syntax. For example, instead of nested S-expressions with ugly brackets, you can come up with some kind of syntax closer to some more widely used languages ​​(for example, Java-like ones, without requiring class definitions).

This is not necessarily a bad thing in more detail. For example, syntax may require line breaks and commas in places where many expect them, and expect explicit return statements. In addition, it seems that it is difficult to allow some operators to use the infix style (just obey the generally accepted rules of operator preference).

And if that doesn't make things too messy, the syntax can even be backward compatible, so that wherever an expression is expected, a normal S-expression between parentheses can be used.

What are your opinions and ideas about this? And is there anything like that? (I expect this to happen, but "Schema" is a useless google term, I can't find anything!)

+4
source share
6 answers

I think that “sweet expressions” may be one of the most thoughtful approaches to getting rid of parentheses in Lisp. It seems to support macros.

http://www.dwheeler.com/readable/sweet-expressions.html

However, I think that most people end up over parentheses or use a different language.

+7
source

Initially, Lisp planned to use a syntax called M-Expressions, with S-Expressions being just a transitional solution to simplify compiler construction. When M-Expressions were ready for implementation, programmers who had already taken over Lisp simply remained with what they were used to, and M-Expressions never came across.

Guile has infix notation, but it is rarely used. A good Lisp programmer no longer sees partners, and prefix notation has its merits ...

+6
source

Take a look at “sweet expressions,” which provides a set of additional abbreviations for traditional s-expressions. They add syntactically meaningful indentation, a way to make infix, and traditional function calls like f (x). Unlike almost all past efforts to make Lisp readable, sweet expressions are compatible with feedback (you can freely mix well formatted s-expressions and sweets), generic and homoiconic.

Sweet expressions were developed at http://readable.sourceforge.net and there is an example implementation.

For the schema, there is an SRFI for sweet expressions: http://srfi.schemers.org/srfi-110/

+6
source

Try SRFI 49 for size. :-P

(Seriously, however, as Rafe remarked, “I don't think anyone wants this.”)

+2
source

Some consider Python a kind of infix notation for operators, algebraic notation for functions, and which uses a more "java-like" syntax to represent the language. I do not agree with this assessment, but I see where this idea comes from.

The big problem with changing the notation for Scheme is that macros become very difficult to write (to see how difficult it is, take a look at the Nimrod or Boo language). Instead of working directly with the code in the form of lists, you first need to parse the input language. This is usually due to the construction of an AST (abstract syntax tree) for the input language. When working directly with Scheme, this is optional.

However, you can check the syntax of the SIX expression in the Gambit Scheme. There is a nice set of slides here that contains a discussion of this:

http://www.iro.umontreal.ca/~gambit/Gambit-inside-out.pdf

But don't tell anyone about it! (An internal joke is that someone suggests writing Lisp without parentheses and with infix notation once a day, and someone announces the implementation about once a month.)

+2
source

There are several languages ​​that do just that. For example: Dylan .

+1
source

Source: https://habr.com/ru/post/1334402/


All Articles