Boo

nestable macros (context sensitive macros)

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.8.2
  • Fix Version/s: 0.9
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

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

Activity

Hide
Cedric Vivier added a comment -

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

Show
Cedric Vivier added a comment - Superb. Would it be possible to have nice error reporting that displays the possible 'parents' for the macro?
Hide
Rodrigo B. de Oliveira added a comment -

Fixed in rev. 3124

Show
Rodrigo B. de Oliveira added a comment - Fixed in rev. 3124
Hide
Cedric Vivier added a comment -

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.

Show
Cedric Vivier added a comment - 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.
Hide
Cedric Vivier added a comment -

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)

Show
Cedric Vivier added a comment - 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)
Hide
Cedric Vivier added a comment -

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

Show
Cedric Vivier added a comment - Ability to reference to parent macro(s) added in rev. 3135

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: