RSS Feed

Lisp Project of the Day


You can support this project by donating at:

Donate using PatreonDonate using Liberapay

Or see the list of project sponsors.


Tests 🥺
CI 🥺

This is library by @Shinmera. It implements a message-passing protocol.

With deeds you are sending events of some class to the handlers.

Handlers are much like methods, but with additional abilities. For example, here is the handler which filters and process only messages containing "Hello":

POFTHEDAY> (deeds:define-handler (foo deeds:info-event) (event message)
             :filter '(search "Hello" message)
             (format t "GREETING: ~A~%" message))

POFTHEDAY> (deeds:do-issue deeds:info-event :message "Blah")
#<DEEDS:INFO-EVENT 2020.08.04 21:36:08 :ORIGIN #<PACKAGE "POFTHEDAY"> {1006D0A7E3}>

POFTHEDAY> (deeds:do-issue deeds:info-event :message "Hello Bob!")
#<DEEDS:INFO-EVENT 2020.08.04 21:36:14 :ORIGIN #<PACKAGE "POFTHEDAY"> {1006D3F833}>
GREETING: Hello Bob!

Pay attention, we see output only after the second do-issue call. And it goes after the information about DEEDS:INFO-EVENT, which is the result of the do-issue form.

All events are handled in a separate thread.

You also can define your own classes for events. They should inherit from deeds:event because they carry "origin" slot. This slot is filled by the Lisp package where the event was fired.

POFTHEDAY> (defclass my-message (deeds:event)

POFTHEDAY> (defclass special-message (my-message)

POFTHEDAY> (deeds:define-handler (foo my-message) (event)
             (format t "My message handled!~%"))

POFTHEDAY> (deeds:define-handler (bar special-message) (event)
             (format t "Special message handled!~%"))

POFTHEDAY> (deeds:do-issue my-message)
My message handled!

;; Both handlers will match because of class inheritance:
POFTHEDAY> (deeds:do-issue special-message)
Special message handled!
My message handled!

There are also other cool features, covered by the documentation.

If you are interested in Common Lisp library for message passing, read about two other systems, reviewed in the #poftheday series:

Brought to you by 40Ants under Creative Commons License