view tests/tooltalk/simple.el @ 5356:5dd1ba5e0113

Be better about eliminating `block's that are not `return-from'd, bytecomp.el 2011-02-12 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el: * bytecomp.el (byte-compile-initial-macro-environment): * bytecomp.el (unwind-protect): * bytecomp.el (byte-compile-active-blocks): * bytecomp.el (byte-compile-catch): * bytecomp.el ('return-from-1): Removed. * bytecomp.el ('block-1): Removed. * bytecomp.el (byte-compile-block-1): Removed. * bytecomp.el (byte-compile-return-from-1): Removed. * bytecomp.el (byte-compile-throw): * cl-macs.el (block): * cl-macs.el (return-from): In my last change, the elimination of `block's that were never `return-from'd didn't work if `cl-macroexpand-all' was called explicitly, something much code in cl-macs.el does. Change the implementation to something that doesn't require shadowing of the macros in `byte-compile-initial-macro-environment', putting a `cl-block-name' property on the gensym'd symbol argument to `catch' instead.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 12 Feb 2011 14:07:38 +0000
parents 131b0175ea99
children 9fc91aa3a927
line wrap: on
line source

;;; Example of Sending Messages

(defun tooltalk-random-query-handler (msg pat)
  (let ((state (get-tooltalk-message-attribute msg 'state)))
    (cond
      ((eq state 'TT_HANDLED)
       (message (get-tooltalk-message-attribute msg arg_val 0)))
      ((memq state '(TT_FAILED TT_REJECTED))
       (message "Random query turns up nothing")))))

(setq random-query-message
  '(   class TT_REQUEST
       scope TT_SESSION
     address TT_PROCEDURE
	  op "random-query"
        args ((TT_INOUT "?" "string"))
    callback tooltalk-random-query-handler))

(let ((m (make-tooltalk-message random-query-message)))
      (send-tooltalk-message m))

;;; Example of Receiving Messaegs

(defun tooltalk-display-string-handler (msg pat)
  (return-tooltalk-message msg 'reply)
  (describe-tooltalk-message msg)
  (message (get-tooltalk-message-attribute msg 'arg_val 0)))

(setq display-string-pattern
  '(category TT_HANDLE
       scope TT_SESSION
	  op "emacs-eval"
	args ((TT_IN "filename" "string"))
    callback tooltalk-display-string-handler))

(let ((p (make-tooltalk-pattern display-string-pattern)))
  (register-tooltalk-pattern p))