* (error (format ...
@ 2005-06-16 13:32 Juanma Barranquero
2005-06-16 13:49 ` David Kastrup
0 siblings, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2005-06-16 13:32 UTC (permalink / raw)
Is there any reason for uses like this one from simple.el:
(error (format "No further undo information%s"
(if (and transient-mark-mode mark-active)
" for region" "")))
instead of simply:
(error "No further undo information%s"
(if (and transient-mark-mode mark-active)
" for region" ""))
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (error (format ...
2005-06-16 13:32 (error (format Juanma Barranquero
@ 2005-06-16 13:49 ` David Kastrup
2005-06-16 14:03 ` Lennart Borgman
2005-06-16 14:03 ` Juanma Barranquero
0 siblings, 2 replies; 5+ messages in thread
From: David Kastrup @ 2005-06-16 13:49 UTC (permalink / raw)
Cc: emacs-devel
Juanma Barranquero <lekktu@gmail.com> writes:
> Is there any reason for uses like this one from simple.el:
>
> (error (format "No further undo information%s"
> (if (and transient-mark-mode mark-active)
> " for region" "")))
>
> instead of simply:
>
> (error "No further undo information%s"
> (if (and transient-mark-mode mark-active)
> " for region" ""))
I'd probably be tempted to use
(error (concat "No further undo information"
(and transient-mark-mode mark-active
" for region")))
in this case. It shares the disadvantage of the original version
(when compared to yours) of being more likely to lead to accidental
format string vulnerabilities if a user takes this as starting code
for something with a variable string.
It is perhaps more educational to preferable follow (error ... with a
constant string.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (error (format ...
2005-06-16 13:49 ` David Kastrup
@ 2005-06-16 14:03 ` Lennart Borgman
2005-06-16 14:03 ` Juanma Barranquero
1 sibling, 0 replies; 5+ messages in thread
From: Lennart Borgman @ 2005-06-16 14:03 UTC (permalink / raw)
Cc: Juanma Barranquero, emacs-devel
David Kastrup wrote:
>It is perhaps more educational to preferable follow (error ... with a
>constant string.
>
>
Yes, in all cases where format is implicitly or explicitly used.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (error (format ...
2005-06-16 13:49 ` David Kastrup
2005-06-16 14:03 ` Lennart Borgman
@ 2005-06-16 14:03 ` Juanma Barranquero
2005-06-16 14:07 ` David Kastrup
1 sibling, 1 reply; 5+ messages in thread
From: Juanma Barranquero @ 2005-06-16 14:03 UTC (permalink / raw)
Cc: emacs-devel
> I'd probably be tempted to use
>
> (error (concat "No further undo information"
> (and transient-mark-mode mark-active
> " for region")))
Yes, in this case I think yours is better. But if the argument is a variable:
(lambda (arg) (error (format "This is the error: %s" arg)))
would be preferable to
(lambda (arg) (error "This is the error: %s" arg))
?
--
/L/e/k/t/u
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: (error (format ...
2005-06-16 14:03 ` Juanma Barranquero
@ 2005-06-16 14:07 ` David Kastrup
0 siblings, 0 replies; 5+ messages in thread
From: David Kastrup @ 2005-06-16 14:07 UTC (permalink / raw)
Cc: emacs-devel
Juanma Barranquero <lekktu@gmail.com> writes:
>> I'd probably be tempted to use
>>
>> (error (concat "No further undo information"
>> (and transient-mark-mode mark-active
>> " for region")))
>
> Yes, in this case I think yours is better. But if the argument is a variable:
>
> (lambda (arg) (error (format "This is the error: %s" arg)))
>
> would be preferable to
>
> (lambda (arg) (error "This is the error: %s" arg))
>
> ?
Not at all. The former is prone to bug out when "arg" contains "%"
somewhere. The latter works fine in this case.
--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-06-16 14:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-16 13:32 (error (format Juanma Barranquero
2005-06-16 13:49 ` David Kastrup
2005-06-16 14:03 ` Lennart Borgman
2005-06-16 14:03 ` Juanma Barranquero
2005-06-16 14:07 ` David Kastrup
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.