Issue Details (XML | Word | Printable)

Key: BOO-1120
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Rodrigo B. de Oliveira
Reporter: Rodrigo B. de Oliveira
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

nestable macros (context sensitive macros)

Created: 17/Jan/09 06:23 PM   Updated: 19/Jan/09 07:29 AM   Resolved: 18/Jan/09 01:25 AM
Component/s: None
Affects Version/s: 0.8.2
Fix Version/s: 0.9

Time Tracking:
Not Specified


 Description  « Hide

Ability to define macros inside other macros with context sensitive name resolution:

macro foo:
   macro bar:
      yield [| print "foo.bar" |]
   yield foo.Block

macro choco:
    macro bar:
       yield [| print "yummy" |]
    yield choco.Block

foo:
    bar # foo.bar
choco:
    bar # yummy


Cedric Vivier added a comment - 18/Jan/09 12:36 AM

Superb.
Would it be possible to have nice error reporting that displays the possible 'parents' for the macro?


Rodrigo B. de Oliveira added a comment - 18/Jan/09 01:25 AM

Fixed in rev. 3124


Cedric Vivier added a comment - 19/Jan/09 03:24 AM

I think it would be real nice if a child macro could access the parent macro (and its variables) as if it was a nested class, ie:

macro choco:
     isYummy = [| $(choco.Arguments[0]) |]

     macro bar:
            yield [|
                   if choco.isYummy:
                        print "yummy chocolate bar"
                   else:
                        print "average chocolate bar"
           |]

It avoids code duplication to handle/process/inspect state of the parent macro from within each child macro.


Cedric Vivier added a comment - 19/Jan/09 04:11 AM

Well, it might now be possible in the depthFirst scenario... but at least getting 'choco' from 'bar' would be handy (instead of doing something like choco = bar.ParentNode.ParentNode as MacroStatement etc)


Cedric Vivier added a comment - 19/Jan/09 07:29 AM

Ability to reference to parent macro(s) added in rev. 3135