Discussion:
semantic for (str NIL) and (esc NIL)
Mac Chan
2007-05-05 02:26:30 UTC
Permalink
Hi all,

This happened to me a couple times where I have a form like this

(with-html
(:html
(:body
(str (get-error-messages)))))

Now if there's no error, (get-error-messages) returns NIL, otherwise
it returns a description of the problem.

This function also serve as a predicate for other code.

But (str (get-error-messages)) actually prints a "NIL" to the browser.

Of course I could replace (str (get-error-messages)) with

(let ((messages (get-error-messages))
(when messages (str messages))))

or

(str (or (get-error-messages) ""))

however it's getting rather verbose.


But the real issue is that the string "NIL" really doesn't make sense
in HTML, XML or JSON.

It's only something that a Lisp programmer would understand.

So I'm purposing to change the substitution of

(str form) => (princ form1 s)

to

(str form) => (let ((#:result form1)) (when #:result (princ #:result s)))


Attached is a diff for this change in case you guys agree that this makes sense.

Thanks,
-- Mac
Volkan YAZICI
2007-05-05 17:21:05 UTC
Permalink
Post by Mac Chan
But the real issue is that the string "NIL" really doesn't make sense
in HTML, XML or JSON.
It's only something that a Lisp programmer would understand.
Yes, therefore, IMHO, it's important for a programmer for debugging
purposes. I'm not against the change, but if it would be done, it
should better be controlled by a (yet another annoying) switch.


Regards.
Edi Weitz
2007-05-08 21:34:19 UTC
Permalink
Post by Mac Chan
Attached is a diff for this change in case you guys agree that this makes sense.
Yes, I think it makes sense. I've made a new release with your patch
incorporated.

Others, please note that this isn't fully backwards-compatible
although I doubt that serious applications so far relied on the fact
that (STR nil) would produce "NIL" in the output.

Thanks,
Edi.
Cyrus Harmon
2007-05-08 21:38:52 UTC
Permalink
My only complaint about this, which is a minor one, is that when I
see NIL in my HTML, it's a good sign that I've screwed something up.
Now I won't have that anymore, but that's ok I guess.

Cyrus
Post by Edi Weitz
Post by Mac Chan
Attached is a diff for this change in case you guys agree that this makes sense.
Yes, I think it makes sense. I've made a new release with your patch
incorporated.
Others, please note that this isn't fully backwards-compatible
although I doubt that serious applications so far relied on the fact
that (STR nil) would produce "NIL" in the output.
Thanks,
Edi.
_______________________________________________
cl-who-devel site list
http://common-lisp.net/mailman/listinfo/cl-who-devel
Loading...