Path: utzoo!attcan!uunet!samsung!uakari.primate.wisc.edu!ark1!nems!mimsy!chris From: chris@mimsy.umd.edu (Chris Torek) Newsgroups: comp.lang.c Subject: Re: binary constants (??) Keywords: macro, constant, binary Message-ID: <20830@mimsy.umd.edu> Date: 19 Nov 89 18:21:00 GMT References: <305@frf.omron.co.jp> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 One of my favourite silly ideas for C is now ruled out by X3J11's `#' `stringize' preprocessing operator (or at least, would require some other syntax), but it went like this: Instead of having hex, decimal, octal, binary, etc., constant syntaxes, why not have a single syntax for `based numbers'? The initial radix would always be decimal; the format would be something like #(base,expr) Numbers in the `expr' part would be interpreted in the base given by the `base' expression. Any value from 2 to 36 would be legal for the base. All `numbers' would be of the form [0-9][0-9a-zA-Z]* where ordinary digits represent themselves and letters represent digits >= 10 in the obvious manner. (Whether digits greater than the base would be legal is essentially irrelevant.) The sneaky (or silly) bit is that both `base' and `expr' would be arbitrary constant expressions. This would be useful for obfuscation such as #(3+#(2,#(6,13)-0010),#(5,11)/30) which is actually 1. (I think.) Whether the base is always decimal is an unresolved question. (Bases that are part of the base-forming expression are definitely decimal, but bases that are part of the based-expression---the stuff to the right of the comma---might start in the base determined by the thing to the left. This would probably be a bad idea, since macro expansion would yeild unpredictable results if the base part were multi-digit. Of course, this would be even better for obfuscatory purposes.) -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@cs.umd.edu Path: uunet!mimsy!chris