# Rhombus how to make a macro defining macro

**URL:** https://racket.discourse.group/t/rhombus-how-to-make-a-macro-defining-macro/3315
**Category:** Questions & Answers
**Tags:** rhombus
**Created:** [November 13, 2024, 10:05pm UTC](https://racket.discourse.group/t/rhombus-how-to-make-a-macro-defining-macro/3315 "2024-11-13T22:05:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Hazematman](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Hazematman](https://racket.discourse.group/u/Hazematman)
#### Post date: [November 13, 2024, 10:05pm UTC](https://racket.discourse.group/t/rhombus-how-to-make-a-macro-defining-macro/3315/1 "2024-11-13T22:05:06Z")

</div>

I'm trying to figure out how I could write a macro `datatype` that creates an annotation macro so I could have code like:

```scheme
typedef FuncArg: (Number || String)

10 :: FuncArg
"Hi" :: FuncArg

```

I'm new to Rhombus so I don't really know what I'm doing but I tried to create a macro that defines a macro like this

```scheme
macro typedef '$name: $value':
  'annot.macro $name: $value'

typedef FuncArg: (Number || String)

```

but that didn't work and gives me the error `macro: misuse as an expression in: macro`

Also is there a good reference to learn macros in rhombus? I'm okay with scrolling through the code of project and using it as a references.

---

<div class="post-metadata">

### Author: ![Hazematman](https://avatars.discourse-cdn.com/v4/letter/h/977dab/32.png) [@Hazematman](https://racket.discourse.group/u/Hazematman)
#### Post date: [November 13, 2024, 10:13pm UTC](https://racket.discourse.group/t/rhombus-how-to-make-a-macro-defining-macro/3315/2 "2024-11-13T22:13:40Z")

</div>

I got help on the Racket discord. If anyone else is trying to do this the following code works

```scheme
#lang rhombus/static/and_meta

defn.macro 'typedef $name: $value':
  '«annot.macro '$name': '$value'»'

typedef NumStr: (Number || String)

fun test(a :: NumStr) :: NumStr:
  a

test(10)
test("b")

```
