6.1.0310 2! two-store CORE

( x1 x2 a-addr -- )

Store the cell pair x1 x2 at a-addr, with x2 at a-addr and x1 at the next consecutive cell. It is equivalent to the sequence SWAP OVER ! CELL+ !.

See:

Testing:

ContributeContributions

ruvavatar of ruv [169] Cells numeration in a cell-pairComment2020-12-01 11:21:26

According to 3.1.4 Cell-pair types, when a cell pair is placed on a stack, the top cell is the first cell, and the cell immediately bellow the top is the second cell.

It can be slightly confusing that in this glossary entry (and some others) the indexes are reversed: ( x<sup>1 x<sup>2 )

Perhaps a better variant is to be in accordance with 3.1.4:

( x<sup>2 x<sup>1 a-addr -- )

AntonErtlavatar of AntonErtl

It is probably less work and especially more compatible with usage outside the standard to remove or swap the reference to "first" and "second" in 3.1.4, and in every other place where it occurs (I don't remember any other).

ruvavatar of ruv

Perhaps you are right. But numbering of stack items in such words like PICK, ROLL, CS-PICK, CS-ROLL is also from top to bottom (and the corresponding indexing is used in the stack notations).

So, I still think that numbering items in a cell pair (and in a tuple in the general case) from the top to the bottom would be more consistent.

Usage outside the standard (and also in the standard), when indexes are going from bottom to top, is just a result of practices from other languages, and common left-to-right writing, I think. Actually, it does matter only when the items are referred by their indexes (i.e., in the case of tuples). In such cases as the SEARCH word, it doesn't matter.

StephenPelcavatar of StephenPelc

The committee discussed this and decided to take no action.

Closed
Reply New Version