# Macros question

**URL:** <https://forum.crystal-lang.org/t/macros-question/1247>\
**Category:** Help & Support\
**Created:** [October 16, 2019, 2:21pm UTC](https://forum.crystal-lang.org/t/macros-question/1247 "2019-10-16T14:21:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![igor-alexandrov](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/igor-alexandrov/32/587_2.png) [@igor-alexandrov](https://forum.crystal-lang.org/u/igor-alexandrov)\
**Post date:** [October 16, 2019, 2:21pm UTC](https://forum.crystal-lang.org/t/macros-question/1247/1 "2019-10-16T14:21:37Z")

</div>

Hello, I am working on Shrine implementation for Crystal ([https://github.com/jetrockets/shrine.cr](https://github.com/jetrockets/shrine.cr)).

Currently my biggest problem is a plugin system. I tried to implement it with macros and everything was good until I tried to inherit plugins list from a superclass.

Here is an example [https://play.crystal-lang.org/#/r/7tfe](https://play.crystal-lang.org/#/r/7tfe).

As far as I understand `{{@type.superclass.constant(:PLUGINS)}}` should return Array of plugins for C class, but it is blank…

---

<div class="post-metadata">

**Author:** ![girng\_github](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/girng_github/32/571_2.png) [@girng\_github](https://forum.crystal-lang.org/u/girng_github)\
**Post date:** [October 16, 2019, 8:27pm UTC](https://forum.crystal-lang.org/t/macros-question/1247/2 "2019-10-16T20:27:06Z")

</div>

/cc @Blacksmoke16

---

<div class="post-metadata">

**Author:** ![asterite](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/asterite/32/60_2.png) [@asterite](https://forum.crystal-lang.org/u/asterite)\
**Post date:** [October 16, 2019, 8:52pm UTC](https://forum.crystal-lang.org/t/macros-question/1247/3 "2019-10-16T20:52:49Z")

</div>

You do:

```auto
PLUGINS << plugin

```

and that happens at **runtime**.

You need to do:

```auto
{% PLUGINS << plugin %}

```

(without the resolve bit)

and then it will work.

I also recommend removing everything unnecessary to demostrante a problem or question. There’s `InstanceMethods` and many other things that are not relevant to the question, and at least in me it caused an effect of “this is too much code, I’ll skip helping” (well, then I did it anyway, but with less code there’s more change to get help).

---

<div class="post-metadata">

**Author:** ![igor-alexandrov](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.crystal-lang.org/igor-alexandrov/32/587_2.png) [@igor-alexandrov](https://forum.crystal-lang.org/u/igor-alexandrov)\
**Post date:** [October 17, 2019, 2:56pm UTC](https://forum.crystal-lang.org/t/macros-question/1247/4 "2019-10-17T14:56:08Z")

</div>

Finally, I get it to work!

[https://play.crystal-lang.org/#/r/7tqz](https://play.crystal-lang.org/#/r/7tqz)

Features:

- Inheritance of plugins from base class
- Protection from loading same plugin several times
