Expanding Macro's

Home
Introduction
Tips and Techniques
Projects
Libraries
Links

With Functional Developer 2.0 it is now possible to see what code is generated when a macro is expanded. To do this, perform the following steps:

  1. Select the text that you want to macro expand in the text editor.
  2. Choose Project, Macroexpand Selection from the menu.

The code will be expanded and inserted after the selected text that you chose to expand. The expanded text will be highlighted allowing you to choose Macroexpand Selection again to further expand any macros in the current expansion.

For example, using the with-resource macro described in the tip 'Acquiring and Release Resources', highlighting and successive expanding a usage of the with-resource macro generates the following:

  1. with-resource(resource)
      do-something(resource);
    end;
    
  2. begin 
      let resource = obtain-resource ();
      block () 
        (begin 
          do-something(resource) 
        end)
      cleanup 
        release-resource (resource);
      end;
    end      
    

Sometimes when expanding a macro down multiple levels you'll get an error about being unable to parse the macro. This occurs when you try to expand a macro that is not exported from a module. You can only expand a macro that is exported and visible. This error message occurs when expanding some of the ole-automation macros for example.


Copyright © 2000, Chris ^M Double. All Rights Reserved.
^M All products and brand names are the registered trademarks or trademarks ^M of their respective owners.

^M