Boo

Nested macros extensions

Details

  • Type: New Feature New Feature
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 0.9
  • Fix Version/s: 0.9.1
  • Component/s: Compiler
  • Labels:
    None
  • Testcase included:
    yes
  • Number of attachments :
    0

Description

Nested macros (BOO-1120) are very nice, however having to declare them 'inline' in the macro block can quickly become a mess (all nested macros defined in the same file) and does not permit extending an existing macro from an external assembly.

The following syntax would allow defining nested macros within parent macro block as well as outside (or even an external assembly) :

"""
base
nested
nestedNestedExtension
extensionNested < base
nestedExtension
nestedExtensionExtension < base
"""

macro base:
	macro nested:
		yield [| print "nested" |]
		yield
	yield [| print "base" |]
	yield

macro base.nestedExtension:
	yield [| print "nestedExtension" |]
	yield

macro base.nested.nestedNestedExtension:
	assert base.Name == "base"
	assert nested.Name == "nested"

	macro extensionNested:
		assert base.Name == "base"
		assert nested.Name == "nested"
		assert nestedNestedExtension.Name == "nestedNestedExtension"
		yield [| print "extensionNested ${$(base.Arguments[0])}" |]

	yield [| print "nestedNestedExtension" |]
	yield

macro base.nestedExtension.nestedExtensionExtension:
	assert base.Name == "base"
	assert nestedExtension.Name == "nestedExtension"
	yield [| print "nestedExtensionExtension ${$(base.Arguments[0])}" |]


base "< base":
	nested:
		nestedNestedExtension:
			extensionNested
	nestedExtension:
		nestedExtensionExtension

Activity

Hide
Cedric Vivier added a comment -

Initial support landed in rev. 3208 (extending internal macros with "macro grandParent.parent.me:" syntax works)

Show
Cedric Vivier added a comment - Initial support landed in rev. 3208 (extending internal macros with "macro grandParent.parent.me:" syntax works)
Hide
Cedric Vivier added a comment -

External nested macro extension support just landed in rev. 3211.
One issue pending, usage of an external nested macro extension within an already external nested macro (ignored nested-macros-7 testcase).

Show
Cedric Vivier added a comment - External nested macro extension support just landed in rev. 3211. One issue pending, usage of an external nested macro extension within an already external nested macro (ignored nested-macros-7 testcase).
Hide
Cedric Vivier added a comment -

Mark resolved.
Opening new issue about ignored nested-macros-7 testcase.

Show
Cedric Vivier added a comment - Mark resolved. Opening new issue about ignored nested-macros-7 testcase.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: