[comp.windows.x] Endless Recursion?

battle@ALPHARD.CS.UTK.EDU (02/08/90)

In the R4 Intrinsics manual in section 1.6.4 there are some bits of code
which pretend to be an example of a possible Label widget.  Looking through
the code I see:

        /* Forward declarations of procedures */
                .
                .
                .
        static void SetText();
        static void GetText();
                .
                .
                .
        /* Class record constant */
        LabelClassRec labelClassRec = {
          {
            /* core class fields */
             /* superclass  */        (WidgetClass) &coreClassRec,
                .
                .
                .
             /* extension   */        NULL
          },
          {
            /* Label class fields     */
             /* get_text    */        GetText,
             /* set_text    */        SetText,
             /* extension   */        NULL
          }
        };
                .
                .
                .
        /* New method access routines */
        void Label SetText(w, text)
             Widget w;
             String text;
        {
             Label WidgetClass lwc = (Label WidgetClass)XtClass(w);
             XtCheckSubclass(w, labelWidgetClass, NULL);
             *(lwc->label_class.set_text)(w, text)
        }
                .
                .
                .

Hmm.  Isn't that cute.  You make a nice little interface for the user
to use which calls the class's set_text method.  But wait a minute.  This
*is* the class set_text method.  This call would recurse endlessly if it
would compile (there is also an omitted semicolon and what looks like a
space inside a typedef name "Label WidgetClass").  I suspect that this code
has never been compiled or tested.

                                        -David L. Battle
                                         battle@battle.esd.ornl.gov
                                         battle@utkux1.utk.edu

P.S. News is broken here.  Please send any followups to me by personal email
in addition to posting.  Thanks.