quicklisp-projects icon indicating copy to clipboard operation
quicklisp-projects copied to clipboard

Please update `defclass-std` source

Open vindarel opened this issue 1 year ago • 4 comments

defclass-std provides a shorter defclass macro, and now a define-print-object/std macro.

  • old source: https://github.com/EuAndreh/defclass-std but they archived the repository. So I didn't ping them.
  • new source: https://github.com/lisp-maintainers/defclass-std where I added the short PRINT-OBJECT macro. The lisp-maintainers org isn't tied to one person.
(defclass/std example ()
  ((slot1 slot2 slot3)))

;; even shorter:
;; (class/std classname slot1 slot2 slot3)

(define-print-object/std example)

expands to

(DEFCLASS EXAMPLE ()
  ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL)
   (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL)
   (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))

(defmethod print-object ((obj example) stream)
    (print-unreadable-object (obj stream :type t :identity t)
        (format stream \"~{~a~^ ~}\" (collect-object-slots obj))))

result:

(make-instance 'example)
;; #<EXAMPLE (SLOT1 NIL) (SLOT2 NIL) (SLOT3 NIL) {100ADFFF73}>

While certainly a rite of passage, having such a quick macro is nice for prototyping and the upcoming AOC :p

Comparison to other libraries: this one is very light on dependencies and doesn't go too far.

vindarel avatar Nov 29 '24 11:11 vindarel

Please ping them first.

On Fri, Nov 29, 2024 at 6:49 AM vindarel @.***> wrote:

defclass-std provides a shorter defclass macro, and now a define-print-object/std macro.

  • old source: https://github.com/EuAndreh/defclass-std but they archived the repository. So I didn't ping them.
  • new source: https://github.com/lisp-maintainers/defclass-std where I added the short PRINT-OBJECT macro. The lisp-maintainers org isn't tied to one person.

(defclass/std example () ((slot1 slot2 slot3))) ;; even shorter:;; (class/std classname slot1 slot2 slot3)

(define-print-object/std example)

expands to

(DEFCLASS EXAMPLE () ((SLOT1 :ACCESSOR SLOT1 :INITARG :SLOT1 :INITFORM NIL) (SLOT2 :ACCESSOR SLOT2 :INITARG :SLOT2 :INITFORM NIL) (SLOT3 :ACCESSOR SLOT3 :INITARG :SLOT3 :INITFORM NIL)))

(defmethod print-object ((obj example) stream) (print-unreadable-object (obj stream :type t :identity t) (format stream "~{~a~^ ~}" (collect-object-slots obj))))

result:

(make-instance 'example);; #<EXAMPLE (SLOT1 NIL) (SLOT2 NIL) (SLOT3 NIL) {100ADFFF73}>

While certainly a rite of passage, having such a quick macro is nice for prototyping and the upcoming AOC :p

Comparison to other libraries: this one is very light on dependencies and doesn't go too far.

— Reply to this email directly, view it on GitHub https://github.com/quicklisp/quicklisp-projects/issues/2454, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACPNLJMN5XFWDAW7HUPZ5L2DBIC3AVCNFSM6AAAAABSW6PANOVHI2DSMVQWIX3LMV43ASLTON2WKOZSG4YDIOJRGEYTOOA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

quicklisp avatar Dec 02 '24 13:12 quicklisp

:shipit:

EuAndreh avatar Dec 04 '24 06:12 EuAndreh

And here I was, trying to figure out which damn Unicode character that is... 🤦

Hexstream avatar Dec 04 '24 11:12 Hexstream

:shipit:

thanks.

the image is called shipit ^^

vindarel avatar Dec 05 '24 13:12 vindarel