Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I am fascinated to Lisp as it is simple yet powerful. I am just a beginner and I know there have been lots of discussions on removing parentheses from Lisp and its dialects. Yet I request Lisp ninja's to take few minutes answering this.

Will there be any side effects in Lisp/Clojure if they had followed 2 conventions below:

;; function declaration
defn function-name param-1 .... param-n
  ...
  function-body ;; not (function-body)
  ...

;; function call
function-name param-1 ... param-n ;; not (function-name param-1 ... param-n)

While still using () or [] for inline and nested expressions.

(println "hello, ") (println "world !!!") ;; inline    
= a (- 2 3) ;; nested
share|improve this question
2  
parsing would be more complicated, and you'd have the tab vs. space war happening –  ratchet freak Jan 17 at 11:36
    
will it have any problem implementing macros and other stuff? –  user115126 Jan 17 at 11:39
3  
Not to discourage the question, because you will get interesting answers that will help you. But FWIW, my advice is this: Don't bother. Lisp's simple, no-nonsense, use-everywhere, data=code syntax is your friend. Just get to know it better and you won't want or need to filter it through your previous glasses. Let it improve you; don't bother trying to improve it. –  Drew Jan 17 at 17:01
    
+1 to ur comment :) –  user115126 Jan 18 at 10:24

2 Answers 2

You can do that, and much more, using sweet-expressions. There is already a working implementation of sweet-expressions for Scheme, which I encourage you to study. The basic idea is that you replace the standard S-expression reader with a sweet-expression reader; everything else stays the same, and you retain homoiconicity and the ability to use macros.

The question is how to implement sweet-expressions in Clojure, since curly braces are already used as a notation for maps, sets, and metadata.

share|improve this answer

Lisps are very unique in how they are defined. Lisps are not defined in terms of text but in terms of Lisp data structures. E.g. in Python a function definition is defined like this:

the letter d followed by the letter e followed by the letter f followed by whitespace followed by an identifier denoting the name followed by the character ( followed by …

Whereas in a Lisp a function definition is defined like this:

a list with three elements, the first of which is the string "def", the second of which is a list of strings denoting the names of the parameters, and the third is the code of the function also represented as a list

Likewise, a function call is a list whose first element is a string denoting the name of the function to be called and the other elements are the arguments to the function.

How you write down those lists and strings is irrelevant. You could use the traditional Lisp syntax, you could use JSON, YAML, XML or whatever. The important thing is that code is just a data structure. How that data structure is represented is irrelevant.

share|improve this answer
    
Note: in reality, the identifiers would be symbols, not strings, I just wanted to avoid introducing a data type that not everybody is intimately familiar with. –  Jörg W Mittag Jan 17 at 16:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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