Path: utzoo!utgpu!watmath!clyde!att!mtuxo!rolls!westmark!mole-end!mat From: mat@mole-end.UUCP (Mark A Terribile) Newsgroups: comp.lang.c Subject: Re: Why is switch (ptr) illegal (or how to pointers differ from scalers)? Summary: Constant expressions at compile time Message-ID: <121@mole-end.UUCP> Date: 17 Dec 88 18:20:15 GMT References: <4347@umd5.umd.edu> Organization: mole-end--private system. admin: mole-end!newtnews Lines: 25 | NOTE do, re, mi; | | and the pointer: | NOTE *scale; | | Why can I not do: | | switch (scale) { | | case &do: | do_something (scale); | break; The switch() requires *compile-time* constants, rather than link-time constants so that the compiler can determine which of several methods (table look-up, range-checked indexing, hashed back-checked lookup, if/then ...) it should use. Could it be changed to always do a linear search table lookup (worst case) on a link-time expression? Probably. Would it encourage bad style? Perhaps. Should it be done? I don't know. -- (This man's opinions are his own.) From mole-end Mark Terribile