HOLDS

( c-addr u -- )

Adds the string represented by c-addr u to the pictured numeric output string. An ambiguous condition exists if HOLDS executes outside of a <# #> delimited number conversion.

See:

Implementation:

: HOLDS ( addr u -- )
   BEGIN DUP WHILE 1- 2DUP + C@ HOLD REPEAT 2DROP ;

Testing:

T{ 0. <# S" Test" HOLDS #> S" Test" COMPARE -> 0 }T

ContributeContributions

GerryJacksonavatar of GerryJackson Specification of HOLDS is ambiguousComment2018-06-27 15:59:05

The description doesn't make it clear that the string is prepended to the existing contents of the pictured output buffer. That can be deduced from the reference implementation but a user shouldn't have to do that.

Also the test does not make it clear. Suggest adding a test along the lines:

T{ <# 123 0 #S S" Number: " HOLDS #> " Number: 123" COMPARE -> 0  }T

GerryJacksonavatar of GerryJackson 2018-06-27 16:02:07

Sorry the test should read:

T{ <# 123 0 #S S" Number: " HOLDS #> S" Number: 123" COMPARE -> 0  }T

BerndPaysanavatar of BerndPaysan 2018-06-28 11:07:34

Yes, same issue with XHOLD; apparently everybody assumed that adding to the pictured numeric output buffer always means “before”, not after. That's why the language felt clear enough.

Reply