Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!agate!labrea!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: register variable declaration question Message-ID: <981@goofy.megatest.UUCP> Date: 8 Nov 88 21:40:50 GMT References: <624@scotty.UUCP> Organization: Megatest Corporation, San Jose, Ca Lines: 36 From article <624@scotty.UUCP>, by jwr@scotty.UUCP (Dier Retlaw Semaj): > > A question: > > When should one declare a parameter to be a register variable? > I can't tell you when you "should" declare a register parameter, but I can give you an example of how I use them. I write lot's of C routines which are in the "object-oriented" mold. That is to say, they update only one kind of data-structure. I name the structures ("classes", in the current jargon) with typenames with capital letters. If a routine-name begins with a capitol letter, the reader knows theat it is tied to a class -- it is a "method" of that class. It's first parameter, named "obj", will invariably be a pointer to a structure of the given type. I usually declare that pointer to be "register", because it will be dereferenced many times within the procedure. typedef struct { type1 field1; type2 field2; /* etc. */ }Widget; int Widget_fiddle(obj, arg1, arg2) register Widget* obj; int arg1; int arg2; { /* Fiddle with the widget. */ }