# Proposal: [307] Fix stack comments for N>R and NR>

Informal

This page is dedicated to discussing this specific proposal

Leon Wagner

## Change Log

2023-09-13 Initial proposal

## Problem:

The stack comments for N>R and NR> don't make it clear that n items are moved between the data and return stacks.

## Solution:

The stack comments should more clearly indicate that n data stack items are moved to or from the return stack.

## Proposal:

Change the stack comments for 15.6.2.1908 N>R to ( n*x +n -- ) ( R: -- n*x +n ) and 15.6.2.1940 NR> to ( -- n*x +n ) ( R: n*x +n -- )

### AntonErtl[r1045] 2023-09-14 05:35:33

Actually, reading through the discussion of the request, Jim Peterson wants to implement N>R as copying to a separate buffer, and leaving the address of the return stack. This kind of implementation is suggested by the rationale of N>R.

## Author:

Anton Ertl Leon Wagner

## Change Log

2023-09-14 Revision after discussion (AE) 2023-09-13 Initial proposal

## Problem:

The stack comments for N>R and NR> don't make it clear that n items are moved between the data and return stacks.

## Solution:

The stack comments should more clearly indicate that n data stack items are moved to or from the return stack.

## Proposal:

In the definition of N>R, replace

( i * n +n -- ) ( R: -- j * x +n )

with

( x_n ... x_1 n -- ) ( R: -- j * x +n )

In the definition of NR>, replace

( -- i * x +n ) ( R: j * x +n -- )

with

( -- x_n ... x_1 +n ) ( R: j * x +n -- )

## Discussion

On the return stack, j*x +n because the data may be in a separate buffer and only the address and +n on the return stack. +n on the return stack because the original specified that, and changing that would be a substantial change.

On the data stack x_n ... x_1 +n because that is the way we usually specify a numbered number of cells (even for +n=0). See, e.g., get-order.

## ruv[310] Why do we use +n and not u in the stack diagram for n>r and nr>Request for clarification2023-09-23 01:06:43

A citation from the Discussion section (in r1079):

On the data stack x_n ... x_1 +n because that is the way we usually specify a numbered number of cells (even for +n=0). See, e.g., get-order.

Well, in get-order n (the signed number data type) is probably incorrectly used after set-order, where n can be -1.

But in other words: pick, roll, cs-pick, cs-roll, — the unsigned number data type (identified by u) is used to indicate the number of items.

So the question is: why is +n used in the stack diagrams for n>r and nr> instead of u?