From owner-freebsd-hackers Thu Sep 30 2:49:43 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from mail1.atl.bellsouth.net (mail1.atl.bellsouth.net [205.152.0.28]) by hub.freebsd.org (Postfix) with ESMTP id 4551C15AA4 for ; Thu, 30 Sep 1999 02:49:38 -0700 (PDT) (envelope-from wghicks@bellsouth.net) Received: from wghicks.bellsouth.net (host-216-78-101-28.asm.bellsouth.net [216.78.101.28]) by mail1.atl.bellsouth.net (3.3.4alt/0.75.2) with ESMTP id FAA28249; Thu, 30 Sep 1999 05:45:24 -0400 (EDT) Received: from wghicks.bellsouth.net (IDENT:wghicks@localhost [127.0.0.1]) by wghicks.bellsouth.net (8.9.3/8.9.2) with ESMTP id FAA02650; Thu, 30 Sep 1999 05:54:49 -0400 (EDT) (envelope-from wghicks@wghicks.bellsouth.net) Message-Id: <199909300954.FAA02650@bellsouth.net> To: "Dennis" Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: A bug in the sppp driver? In-reply-to: Your message of "Wed, 29 Sep 1999 17:25:15 BST." <038d01bf0a97$3652f8d0$2e00a8c0@nt46daniel> Date: Thu, 30 Sep 1999 05:54:49 -0400 From: W Gerald Hicks Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > doing state machines with switch statements is a big mess. Still, you'll find a lot of them around. Do you have a favored technique for coding complex state machines? (I'm a collector :) One scheme I've been using for quite some time is to use a function pointer as a 'state variable', sometimes making a stack of them for a more flexible machine. Sometimes I use a transition matrix for selection of the 'state function' but more often the functions themselves perform 'next state' selection. To be honest though, most of the time the machinery I need for an application has from four to six states. Anything more than a simple switch on a state variable seems to be overkill for those. Cheers, Jerry Hicks wghicks@bellsouth.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message