Article View: comp.windows.x
Article #36510Endless Recursion?
From: battle
Date: Wed, 07 Feb 1990 16:35
Date: Wed, 07 Feb 1990 16:35
60 lines
2466 bytes
2466 bytes
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.
Technical Details
Message-ID:
<9002071635.AA04174@alphard.cs.utk.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!ALPHARD.CS.UTK.EDU!battleShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!ALPHARD.CS.UTK.EDU!battle From: battle@ALPHARD.CS.UTK.EDU Newsgroups: comp.windows.x Subject: Endless Recursion? Message-ID: <9002071635.AA04174@alphard.cs.utk.edu> Date: 7 Feb 90 16:35:19 GMT Sender: daemon@athena.mit.edu (Mr Background) Organization: The Internet Lines: 60