0

In Emacs Calc I use <TAB> to swap the last two elements on the stack. The command for this is called calc-roll-down. What does "roll down" mean in this context?

When rolling the stack I would expect the whole stack rolls, but the default operation is just to swap the last two elements. (I know I can roll the stack with the same command (via C-u 0 <TAB>), but it is not the default operation of the command.)

Do I miss something here?

3
  • Why that name was given I don't know, and maybe no one knows. Is that really what you're asking?
    – Drew
    Commented Jun 6, 2022 at 1:22
  • Or are you really asking what "roll down" might mean in this context? If the latter, I'd guess it means to roll the top element down one, so it becomes second instead of first. If that's what it does, and that's what that name is meant to indicate, then perhaps it's not the best name. But it's shorter than explicitly saying which two are being swapped.
    – Drew
    Commented Jun 6, 2022 at 1:23
  • @Drew Yes, that’s what I’m asking!
    – halloleo
    Commented Jun 6, 2022 at 2:25

1 Answer 1

1

You can look at the implementation of calc-roll-down: it takes an argument n, but when called interactively with TAB that argument is nil. In that case, the function calls the subordinate function calc-roll-down-stack with an argument of 2, thereby exchanging the top two elements. But if you call it with a different argument n (e.g. C-u TAB would call it with a prefix argument of '(4) which the function interprets as 4), then the top n elements of the stack are indeed rolled.

1
  • 1
    Aha, so the default operation is “roll 2”, which sort-off, kind-off makes sense…
    – halloleo
    Commented Jun 6, 2022 at 2:28

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.