emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: describe-variable with string arg


From: Drew Adams
Subject: RE: describe-variable with string arg
Date: Fri, 23 Mar 2007 15:57:44 -0700

I said:

> describe-variable expects a symbol, not a symbol-name (string).
>
> In Emacs 20, passing it a symbol name leads to an error message. Starting
> with Emacs 21, the message is displayed via `message', not
> `error'. AFAICT, no Emacs code depends on this use of `message' instead
> of `error'. The latter makes more sense to me.

Let me be clearer. This is a type error, and it should be treated as an
error. To inform the user via a message is fine, but code that calls
`describe-variable' should be able to use `condition-case' to detect and
handle a `wrong-type-argument' error.

Yes, such code could also check the arg type itself, but that assumes that
it knows that it is dealing with `describe-variable' and that that function
expects a symbol arg.

If there were some important reason why `describe-variable' should not raise
an error in this context, I would understand why `error' was changed to
`message'.

For example, if a return value were tested in code that calls
`describe-variable'. But I don't see that happening anywhere in the Emacs
code. What's more, the return value is a string in either case (`message'
returns the message; otherwise, the help string is returned), so the return
type cannot be tested. I see no reason that an error shouldn't be raised.

> Beyond that, why not let `describe-variable' try a little harder, to use
> `intern' applied to its arg, if that is a string?
>
> That would be friendlier to possible 3rd-party code that might generically
> apply a function such as `describe-variable' to an arg that might be a
> symbol name instead of a symbol.

In sum, I'd like to see the treatment of an arg that is not a bound symbol
be:

. If an unbound symbol, raise an error saying so.
. If a string, intern it and try again using the resulting symbol.
. If any other type, raise a type error.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]