0

I want to use the function ignore but I want a more meaningful name when using its functionality of not doing anything.

Would like to make a function that takes the same argument possibilities as ignore and pass them to the ignare function. How can one set this thing up ?

I would like the ability to pass arguments that although they have meaning to the programmer, they do not do anything. The arguments are just there as informational indicators (annunciators) that are there for informational purposes only, rather than for executable command instructions.

1 Answer 1

0
  1. If you want a function like ignore that has a different name, and may or may not also do something different, just define it. Your question doesn't specify anything particular, so there's nothing else to be said about whether or how to do this.

    Note that ignore is a function, not a macro or special form. That means that it necessarily evaluates each of its arguments. I doesn't do anything with the results of such evaluation, that's all. So for example, if evaluating some argument is a long, expensive (or even infinite) computation, or performs side effects, then the name "ignore" is not really faithful. The function itself does nothing, but invoking the function call does evaluate the arguments.

  2. If you instead just want to have arguments that are ignored for some functions you write, all you have to do is ignore them!

  3. A stylistic convention, to tell human readers that an argument is ignored by its function, is to prefix the argument name with an underscore: _. E.g.

(defun my-fun (arg1 _arg2 &optional arg4 _arg5)
 ...
)

This indicates to readers that function my-fun ignores arguments _arg2 and _arg5. It doesn't make my-fun actually ignore them, but it lets human readers ignore those args. A typical use case is when the calling sequence of a function needs to accommodate some args because of some contexts where it's used, but in fact it doesn't do anything with those args.

7
  • OP: "rather than for executable command instructions" -- Perhaps a (defmacro your/ignore (&rest _)) is better than defining a function.
    – shynur
    Commented Aug 4, 2023 at 16:06
  • I would like that any number of arguments can be passed just like ignore. And in the same way, not expect them to actually perform some operation with them. They are just indicators describing some state at a particular line within the function. They are sort of higher level comments.
    – Dilna
    Commented Aug 4, 2023 at 16:07
  • 1
    @Curoca: Ah, I know what you want -- to ignore some text literally. But be aware that any S-exp that appears in ELisp code will return a object, which means you cannot completely ignore something unless you use comments. ||| "Why the preference for a macro." Macro your/ignore will prevent Emacs from executing your code and return a nil.
    – shynur
    Commented Aug 4, 2023 at 16:15
  • Please note that comments are not for conversations, for new questions, or for answers. Comments are only for clarifications that feed into edits to the message (question or answer) on which the comment exists. Stackoverflow network works best when a complete question is asked, such that users can provide a clear answer.
    – Trevoke
    Commented Aug 4, 2023 at 18:02
  • Added a paragraph explaining that since ignore is a function its arguments get evaluated. I say this because the OP question seems to want what ignore does.
    – Drew
    Commented Aug 4, 2023 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.