Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #3605

Re: macro expansion ?

From Chris Hinsley <chris.hinsley@gmail.com>
Newsgroups comp.lang.forth
Date 2011-06-28 18:34 +0100
Message-ID <2011062818340635857-chrishinsley@gmailcom> (permalink)
References <2011062814435882049-chrishinsley@gmailcom> <DLadnaa9famEZ5TTnZ2dnUVZ8v2dnZ2d@supernews.com>
Subject Re: macro expansion ?

Show all headers | View raw


>> But this led me on to thinking how would I do a more Lisp like macro ?
>> Somthing that would be expanded and then that expantion expanded till
>> there was no more expantions.
> 
> I think that's going to happen anyway.  When EVALUATE comes across a
> MACRO it'll expand it recursively.
> 
> Perhaps you could show us an example of something like this not
> working.
> 
> Andrew.

A simple example that does work as intended.

macro ma * +"
macro mp1 1 -rot ma"
: t1 1 -rot * + ;
: t2 mp1 ;

Both t1 and t2 dissesemble to exactly the same code. Good that's as I 
intended. And show the expansion of macros is recursive. :)

However now I'm thinking how would a do a macro that can use itself ? 
Part of this is no problem, the EVALUATE call will be able to find the 
named macro and recurse in no problem.

macro bert bert"

Would just recurse till it crashed. But there's no problem with defineing it.

So how would I exit a macro expansion ? I'd presumably have to have 
interpret time, rather than runtime conditions used in the macro ?

Forgive me if I'm rambling a bit, I'm making this up on the fly here, 
trying to see if I can spot a problem. Would I hit a problem that IF, 
ELSE, ENDIF are only available as compile time words (well they are for 
my Forth, I know others have made them work at interpret time). Maybe 
you just stick to useing [IF], [ELSE], [THEN] in macro definitions and 
it will all just work (tm).

I'll try a few more experiments.

Chris

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 14:43 +0100
  Re: macro expansion ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-06-28 10:58 -0500
    Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 18:34 +0100
      Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 18:51 +0100
        Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 19:02 +0100
          Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 19:11 +0100
            Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 19:17 +0100
              Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 19:47 +0100
                Re: macro expansion ? Josh Grams <josh@qualdan.com> - 2011-06-29 15:34 +0000
                Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-29 19:21 +0100
            Re: macro expansion ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-06-29 03:15 -0500
              Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-29 13:11 +0100
            Re: macro expansion ? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-06-29 17:17 +0100
              Re: macro expansion ? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-06-29 18:09 +0100
                Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-29 19:32 +0100
                Re: macro expansion ? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-07-02 08:48 +0100
    Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-29 00:44 +0100
    Re: macro expansion ? Gerry Jackson <gerry@jackson9000.fsnet.co.uk> - 2011-06-29 20:39 +0100
  Re: macro expansion ? Elizabeth D Rather <erather@forth.com> - 2011-06-28 08:59 -1000
    Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 20:39 +0100
      Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-28 21:34 +0100
        Re: macro expansion ? Andrew Haley <andrew29@littlepinkcloud.invalid> - 2011-06-29 03:26 -0500
  Re: macro expansion ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-06-29 11:25 +0000
    Re: macro expansion ? Chris Hinsley <chris.hinsley@gmail.com> - 2011-06-29 13:24 +0100
      Re: macro expansion ? anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2011-07-03 14:02 +0000
    Re: macro expansion ? Albert van der Horst <albert@spenarnc.xs4all.nl> - 2011-06-29 18:48 +0000
  Re: macro expansion ? BruceMcF <agila61@netscape.net> - 2011-06-30 11:11 -0700
  Re: macro expansion ? Ian Osgood <iano@quirkster.com> - 2011-07-02 16:22 -0700
  Re: macro expansion ? Hugh Aguilar <hughaguilar96@yahoo.com> - 2011-07-05 17:35 -0700

csiph-web