P4_SYNONYM(3)

NAME
p4_synonym - SYNONYM ( "newname" "oldname" -- )

SYNOPSIS

#include <pfe/header-ext.h>

FCode p4_synonym(---);

DESCRIPTION

make an name-alias for a word - this is very different from a DEFER since a DEFER will resolve at runtime. Changing the target of a DEFER via IS will result in changing the BEHAVIOR of all words defined earlier and containing the name of the DEFER.

A SYNONYM however does not have any data field (theoretically not even an execution token), instead it gets resolved at compile time. In theory, you can try to FIND the name of the SYNONYM but as soon as you apply NAME> the execution token of the end-point is returned. This has also the effect that using the inverse >NAME operation will result in the name-token of the other name.

        SYNONYM CREATE &lt;BUILDS ( like it is in ANS Forth )
        : FOO CREATE DOES&gt; @ ;
        SEE FOO
        : foo &lt;builds
          does&gt; @ ;
        SYNONYM CREATE CREATE:
        : BAR CREATE 10 ALLOT ;
        SEE BAR
        : bar create: 10 allot ;

(only LINK> does not care about SYNONYMs)

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>