delorie.com/archives/browse.cgi   search  
Mail Archives: opendos/1997/04/19/15:49:36

Comments: Authenticated sender is <alaric+abwillms AT sdps DOT demon DOT co DOT uk>
From: "Alaric B. Williams" <alaric AT abwillms DOT demon DOT co DOT uk>
To: Lorier <lorier AT ihug DOT co DOT nz>
Date: Sat, 19 Apr 1997 20:33:32 +0000
MIME-Version: 1.0
Subject: Re: Usage of directory entries
Reply-to: alaric AT abwillms DOT demon DOT co DOT uk
CC: Mark Habersack <grendel AT hoth DOT amu DOT edu DOT pl>, opendos-developer AT delorie DOT com
In-reply-to: <m0wIPwn-000FlqC@hn.planet.gen.nz>
Message-ID: <861478226.1014430.0@abwillms.demon.co.uk>

On 19 Apr 97 at 14:32, Lorier wrote:

> >It'd be interesting to see if one can make Scheme-like hygenic macros
> >for assembly language, rather than just simple substitution devices!
> 
> Sounds great! Now, can you explain what it is? ;)
 
Oh, all right...

Hygeinic macros are macros guaranteed not to cause name space collisions.

Eg, if we have a C macro like so:

#define PRINT_SUM(x,y) {int temp; temp = x + y; cout << temp << endl;} 

It works by simply substituting the text of the macro in where it is
invoked.

However, this soon brings up problems. The x and y parameters may not
be references to variables called temp, cout, or endl, since that will
collide with the definitions in the macro.

The definition of a hygenic macro is that any global identifiers accessed in
the macro have the meaning they did at the point the macro was defined, eg
if we use PRINT_SUM inside a block with a local variable called "cout",
PRINT_SUM will still use the cout that was declared when /it/ was declared.

Saves on bugs and confusion...


ABW
--
Alaric B. Williams (alaric AT abwillms DOT demon DOT co DOT uk)

   ---<## OpenDOS FAQ ##>---

Plain HTML: http://www.delorie.com/opendos/faq/
            http://www.deltasoft.com/faq.html

Fancy HTML: http://www.deltasoft.com/faq0000.html

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019