What is the difference between the brackets [] and () in the Racket (lisp) programming language?

It seems to me that both are technically interchangeable, but have different conditional meanings.

+5
source share
1 answer

According to the Racket documentation , there is no difference - there is only an agreement to use [ and ] for cond (and as far as I understand), use your judgment for the rest:

Using square brackets for cond conditions is an agreement. In Racket, brackets and square brackets are actually interchangeable as long as they match (and match). Using square brackets in several key places makes the Racket code even more readable.

Without any knowledge of the design of the Racket language, I assume that the square brackets were introduced as a response to complaints that many Lisp expressions are difficult to read due to the large number of parentheses of the same type, especially at the ends of deeply nested constructions. In other words, he probably used it so that your eye could easily set some reference points in the code to determine which bracket you are closing at any given point.

+10
source

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


All Articles