欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  资讯频道

SymbolicWeb: 用Lisp写AJAX和Comet程序

程序员文章站 2022-03-08 14:57:39
...
Lisp 长久以来一直被视为伟大的编程语言之一。其漫长的发展过程(接近五十年)中引发的追随狂潮表明:这是一门非同凡响的语言。但是用Lisp写的web应用很少,现在出现了SymbolicWeb,希望改变这种情况。SymbolicWeb目标是用Lisp来创建一个GUI框架,类似GTK+ 和 QT,不同点是SymbolicWeb使用浏览器来渲染UI元素。

下面是一个简单的Echo Chat例子:

;;;; http://nostdal.org/ ;;;;
	(in-package #:sw)
	(defparameter *max-chat-pane-size* 100)
	(defapp chat-app (empty-page-app)
  ((input (mk-text-input))
   (chat-pane :allocation :class (mk-container nil))))
	(defuri chat-app "chat")
	(defmethod main ((chat-app chat-app))
  (with-slots (input chat-pane) chat-app
    (setf (on-enterpress-of input
                          :callback-data `((:input-value . ,(js-code-of (value-of input)))) ;; Include some data when the event fires.
                          :js-after (js-code-of (setf (value-of input) "")))                ;; Clear the input field after the event has been fired and sent.
          (lambda (&key input-value)
            (prepend (mk-span (escape-for-html input-value) :display "block")
                     chat-pane)
            ;; Don't let it grow too big; delete some chat history.
            (when (> (length (children-of chat-pane)) *max-chat-pane-size*)
              (dolist (span (subseq (children-of chat-pane) *max-chat-pane-size*))
                (remove span)))))
    (add-to *root*
            (mk-span (who (:p "Type something in and press enter. New content is added at the top.")))
            input
            chat-pane)))


	



相关标签: Comet LISP Ajax