P4_Q_DUP(3)

NAME
p4_Q_dup - ?DUP ( 0 -- 0 | value! -- value! value! | value -- 0 | value! value! ) [ANS]

SYNOPSIS

#include <pfe/core-ext.h>

FCode p4_Q_dup(---);

DESCRIPTION

one of the rare words whose stack-change is condition-dependet. This word will duplicate the value only if it is not zero. The usual place to use it is directly before a control-word that can go to different places where we can spare an extra DROP on the is-null-part. This makes the code faster and often a little easier to read.

      example:
        : XX BEGIN ?DUP WHILE DUP . 2/ REPEAT ; instead of
        : XX BEGIN DUP WHILE DUP . 2/ REPEAT DROP ;

AUTHOR

    • Guido U. Draheim (modified by $Author: guidod $)

COPYRIGHT

Copyright (C) Tektronix, Inc. 1998 - 2001. Copyright (C) 2005 - 2008 Guido U. Draheim <guidod@gmx.de>