# Macros as functions

**URL:** <https://bnd.discourse.group/t/macros-as-functions/50>\
**Category:** TIPS\
**Created:** [December 14, 2020, 11:28am UTC](https://bnd.discourse.group/t/macros-as-functions/50 "2020-12-14T11:28:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [December 14, 2020, 11:28am UTC](https://bnd.discourse.group/t/macros-as-functions/50/1 "2020-12-14T11:28:20Z")

</div>

It is hard to think there are bnd users that never used a macro. After all, every property in a bnd file can be used as a macro, including all the instructions. For example, you can use a very foundational instruction as `-buildpath` as macro.

```
 ${-buildpath}

```

However, few users seem to know that you can also create your own macros with parameters. For each macro invocation, there are {0} to {9} available as the arguments.

```
service = osgi.service;objectClass="${1}";resolution:=active

Provide-Capability: \
   ${service;my.wonderful.Service}, \
   ${service;another.wonderful.Service}  

```

And don’t forget, you can hover over a selection in the bnd editors and then a tooltip will show you the expansion:

![image](https://global.discourse-cdn.com/free1/uploads/bnd/original/1X/23c20bf6e81a40e37c4b0571fd00cef770943bc7.png)

---

<div class="post-metadata">

**Author:** ![rotty3000](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/rotty3000/32/16_2.png) [@rotty3000](https://bnd.discourse.group/u/rotty3000)\
**Post date:** [December 16, 2020, 3:04pm UTC](https://bnd.discourse.group/t/macros-as-functions/50/2 "2020-12-16T15:04:01Z")

</div>

Wow, why didn’t I know about this?

Thx @pkriens

---

<div class="post-metadata">

**Author:** ![pkriens](https://yyz2.discourse-cdn.com/free1/user_avatar/bnd.discourse.group/pkriens/32/3_2.png) [@pkriens](https://bnd.discourse.group/u/pkriens)\
**Post date:** [December 16, 2020, 4:06pm UTC](https://bnd.discourse.group/t/macros-as-functions/50/3 "2020-12-16T16:06:59Z")

</div>

[RTFM](https://bnd.bndtools.org/chapters/850-macros.html#arguments)? 🕶

There so many cool things in bnd, we even have an implementation of the Trajan algorithm in there! 🙂
