Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!boring!lambert From: lambert@boring.uucp (Lambert Meertens) Newsgroups: net.lang Subject: Re: and if you put this in your language ... Message-ID: <6843@boring.UUCP> Date: Mon, 24-Mar-86 10:52:15 EST Article-I.D.: boring.6843 Posted: Mon Mar 24 10:52:15 1986 Date-Received: Fri, 11-Apr-86 06:49:14 EST References: <1187@mmintl.UUCP> <800009@ccvaxa> Reply-To: lambert@boring.UUCP (Lambert Meertens) Organization: CWI, Amsterdam Lines: 65 Keywords: Refinement Apparently-To: rnews@mcvax In article <800009@ccvaxa> aglew@ccvaxa.UUCP writes: > Finally, something I'm not sure whether > it's my idea, or Knuth's, or somebody else's, there is the concept of an > ASIDE. An ASIDE is a labelled block of code that can only be entered via > a goto to the label at the top of the aside (and can only be exited in one of > the normal ways to exit a block). Code that would seemm to fall through to > an aside branches around it. So above you really have > goto END > AB: begin Z; goto END end > END: ... > The aside has saved you a goto and a label - it makes it seem just a bit less > like spaghetti. > [...] > but if Z is not simply a function call then you have to make sure that two > copies of code get updated. That's what macros are for [...] > A big #define in line looks ugly, and is really just like an aside, except > that it hides a bit of the concept of doing work to get simpler cases. Some languages have "refinements", which are somewhat like macros but they really are part of the language and do not get expanded by a preprocessor. Mainly useful for programming in a relaxed top-down style, but also good to prevent code duplication. The languages I know of that support refinements are (in the chronological order in which the refinements entered the design) ELAN, ABC (the upcoming revision of our B) and SETL. In ABC, a possible way of expressing the program is SELECT: a: X SELECT: b: Y ELSE: Z ELSE: Z ... X: Y: Z: X and Y may be expanded in place, but for Z this gives code duplication. Tests may also be refined, so if the evaluation of a and b is fast enough, you can also write SELECT: a AND b: X Y a AND NOT b: X Z NOT a: Z I wrote an article to make propaganda for refinements: Program Text and Program Structure, in: Constructing Quality Software (P.G. Hibbard and S.A. Schuman, eds), 271-281, North-Holland, 1978. If any other languages than the three mentioned above sport refinements, I would like to hear about them. -- Lambert Meertens ...!{seismo,okstate,garfield,decvax,philabs}!lambert@mcvax.UUCP CWI (Centre for Mathematics and Computer Science), Amsterdam