Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

"Bite off, dirtball." Richard Sexton, richard@gryphon.COM


devel / comp.lang.lisp / Re: the debug macro

SubjectAuthor
* the debug macroMadhu
`- Re: the debug macroMadhu

1
the debug macro

<m335512mos.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17375&group=comp.lang.lisp#17375

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: the debug macro
Date: Sat, 15 Apr 2023 20:54:19 +0530
Organization: Motzarella
Lines: 38
Message-ID: <m335512mos.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="08095a51ddb907b2fb6c79cc4cb2f1ef";
logging-data="2197330"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dop9vRRfvzsD9RUNqDuXFx22Vl+X3X1w="
Cancel-Lock: sha1:6AJYWHdkpXUpkKarCv7YduOrzmA=
sha1:X5rXtwV8S3xQEi0TiwkSznqk0kM=
 by: Madhu - Sat, 15 Apr 2023 15:24 UTC

I recently had to reinvent this, but I'm sure I've seen a version of it
on cll decades ago. Anyone remember which poster or post? I'm
interested to see how it was described.

```
(defmacro debug (&rest syms)
(let ((leader (if (stringp (car syms)) (pop syms) "DEBUG")))
(let ((format-string (format nil "~A: ~{~A=~~S~^, ~}~~&" leader syms)))
`(format t ,format-string ,@syms))))
```

The best docstring I could come up with is:

"\(DEBUG [\"DEBUG-MSG\"] [ITEMS...] \) prints DEBUG-MSG: [ITEM=VAL ...]
on standard output"

A slight advantage may be gleaned if the string and arguments to DEBUG
are treated as such:

```
(defmacro debug (&rest syms-and-strings)
(let* ((args nil)
(fmt-string
(with-output-to-string (stream)
(loop for (c . rest) on syms-and-strings do
(typecase c
(string (princ c stream))
((or (and symbol (not keyword)) (not atom))
(push c args)
(princ c stream)
(princ "=~S" stream))
(otherwise (prin1 c stream)))
(princ (if (endp rest) #\Newline #\Space) stream)))))
`(format t ,fmt-string ,@(nreverse args))))
```

But then it loses some of the declarative conciseness

Re: the debug macro

<m3353kd890.fsf@leonis4.robolove.meer.net>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=17403&group=comp.lang.lisp#17403

  copy link   Newsgroups: comp.lang.lisp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: enometh@meer.net (Madhu)
Newsgroups: comp.lang.lisp
Subject: Re: the debug macro
Date: Thu, 25 May 2023 15:48:35 +0530
Organization: Motzarella
Lines: 46
Message-ID: <m3353kd890.fsf@leonis4.robolove.meer.net>
References: <m335512mos.fsf@leonis4.robolove.meer.net>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="e31902155e383b7b139d74f3297a1a08";
logging-data="3617272"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SgA/tl6UuiWEKdZbQLJjxnWJBqxUf2xw="
Cancel-Lock: sha1:SVCq2TU8SeQ8lSSjPBW4tfpd+Tg=
sha1:dG8RLmQTXvjWp+aXUQYYFDFyhO0=
 by: Madhu - Thu, 25 May 2023 10:18 UTC

* In <m335512mos.fsf@leonis4.robolove.meer.net> :
I Wrote on Sat, 15 Apr 2023 20:54:19 +0530:

> I recently had to reinvent this, but I'm sure I've seen a version of it
> on cll decades ago. Anyone remember which poster or post? I'm
> interested to see how it was described.

I found this one now, https://github.com/danlentz/printv

>
> ```
> (defmacro debug (&rest syms)
> (let ((leader (if (stringp (car syms)) (pop syms) "DEBUG")))
> (let ((format-string (format nil "~A: ~{~A=~~S~^, ~}~~&" leader syms)))
> `(format t ,format-string ,@syms))))
> ```
>
>
> The best docstring I could come up with is:
>
> "\(DEBUG [\"DEBUG-MSG\"] [ITEMS...] \) prints DEBUG-MSG: [ITEM=VAL ...]
> on standard output"
>
>
> A slight advantage may be gleaned if the string and arguments to DEBUG
> are treated as such:
>
> ```
> (defmacro debug (&rest syms-and-strings)
> (let* ((args nil)
> (fmt-string
> (with-output-to-string (stream)
> (loop for (c . rest) on syms-and-strings do
> (typecase c
> (string (princ c stream))
> ((or (and symbol (not keyword)) (not atom))
> (push c args)
> (princ c stream)
> (princ "=~S" stream))
> (otherwise (prin1 c stream)))
> (princ (if (endp rest) #\Newline #\Space) stream)))))
> `(format t ,fmt-string ,@(nreverse args))))
> ```
>
> But then it loses some of the declarative conciseness

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor