Is a lisp with only functional parentheses possible?

Started by newdep, August 18, 2009, 03:13:35 PM

Previous topic - Next topic

Elica

#30
Try to code this:  "if a is integer and b is integer then print 'yes'."

cormullion

#31
The problem with this suggestion is partly that if you make functions smarter, they become less general-purpose. There's the trade-off between having simple small tools that combine well, and complex tools with more intricate syntax.



Also, one of the ideas behind Lisp is that you develop your own language for solving your own problems. If you find yourself writing this sort of thing a lot, you extend the language to meet your needs, rather than burden the base language with every possible application.


(define-macro (integer??)
   (if (integer? (eval (args 0)))
       (eval (args 1))
       (eval (args 2))))

(integer?? 3 (println "yes it is") (println "no it isn't"))
;-> yes it is

(set 'a 1.2)
(integer?? a (println "yes it is") (println "no it isn't"))
;-> no it isn't



more complicated to check for all integers:


(define-macro (integers??)
   (if (for-all integer? (0 -2 (args)))
       (eval (args -2))
       (eval (args -1))))
       
(integers?? 3 4 5 6 (println "yes they are") (println "no they aren't "))
;-> yes they are

(set 'a 1.2)

(integers?? a 2 3 (println "yes they are") (println "no they aren't "))
;-> no they aren't

hilti

#32
I just found this site via twitter. Have a look at it:



http://www.genyris.com/">//http://www.genyris.com/



Cheers

Hilti
--()o Dragonfly web framework for newLISP

http://dragonfly.apptruck.de\">http://dragonfly.apptruck.de

Elica

#33
Six years ago I presented a paper about how Elica displays source code to help users find errors. The paper is available http://elica.net/download/papers/ErrorReportingInElica.pdf">here. You may have a look at figures:



Fig.4 - a summary of supported representations of source code

Fig.5 - fully parenthesised original Logo source

Fig.6 - graphical non-ASCII brace notation

Fig.7 - graphical non-ASCII box notation

Fig.8 - prefix-only Lisp-like indented notation



Of course, the paper is about Logo, but all results are immediately applicable to Lisp.





PS. There are other representations, but they are not related to the discussion, like assembler representation or natural language representation.