Re: The ?PAIRS word



Montesquiou wrote:
Bonjour to all,

In the archive of the group, I found the word "?PAIRS"
as in

: ENDCASE 4 ?PAIRS COMPILE DROP
BEGIN SP@ CSP @ = 0=
WHILE 2 [COMPILE ENDIF REPEAT
CSP ! ; IMMEDIATE

According the FAQ, the ?PAIRS word was FIG-Forth's way of implementing a
small amount of syntax checking.

Is "Number ?PAIRS" similar to ... over <> if (error message) then ...;

More or less, yes. If you can get the fig-FORTH source, it's in Block
40:

: ?ERROR ( BOOLEAN-2 ERROR TYPE-1, WARN FOR TRUE *)
SWAP IF ERROR ELSE DROP ENDIF ;

: ?PAIRS - 13 ?ERROR ; ( VERIFY STACK VALUES ARE PAIRED *)

Andrew.


.



Relevant Pages

  • Re: The ?PAIRS word
    ... WHILE 2 [COMPILE ENDIF REPEAT ... CSP! ... Evidently CASE in this implementation leaves 4 on the stack at compile ...
    (comp.lang.forth)
  • Re: A replacement for lambda
    ... It looks sort of like CSP. ... > with native parallelism, mmmmm. ... The syntax was inspired by OCamls pattern matching syntax: ... But for Python we have to look for an expression not a statement ...
    (comp.lang.python)
  • Call a Java Script Function from CSP
    ... Does anyone have the syntax for running a Javascript function from a ... So far I have only done this via html within csp. ...
    (comp.lang.mumps)