# Macros generating phase-0 parametric units

**URL:** <https://racket.discourse.group/t/macros-generating-phase-0-parametric-units/316>\
**Category:** Questions & Answers\
**Tags:** macro\
**Created:** [November 30, 2021, 12:36pm UTC](https://racket.discourse.group/t/macros-generating-phase-0-parametric-units/316 "2021-11-30T12:36:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cperivol](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/cperivol/32/205_2.png) [@cperivol](https://racket.discourse.group/u/cperivol)\
**Post date:** [November 30, 2021, 12:36pm UTC](https://racket.discourse.group/t/macros-generating-phase-0-parametric-units/316/1 "2021-11-30T12:36:43Z")

</div>

A few days ago I first found out about [units](https://docs.racket-lang.org/guide/units.html) and it seemed kind of nice. If I understand the motivation for units correctly I have been solving the same problem so far using closures

```scheme
(define (pseudo-unit param1 param2) 
  (define (a-funtion) ...)
  (define (another-function param) ...)
  (define internal-state ...)
  (values a-function another-function))

```

And this has been working ok but to be honest I would prefer it if my `pseudo-unit` were a macro so that I could access `param1` and `param2` at phase 0 if they are available at the call-site. I found, however, that is a bit too much bookkeeping using `define-syntax` and `syntax-parse` (which is the only part of racket macrology that I half-way understand).

I was looking for advice on what might be a good way to approach this. Maybe this is a good time to get out of my comfort zone with respect to macros trying to get a better solution this?

---

<div class="post-metadata">

**Author:** ![samth](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/samth/32/3_2.png) [@samth](https://racket.discourse.group/u/samth)\
**Post date:** [November 30, 2021, 4:24pm UTC](https://racket.discourse.group/t/macros-generating-phase-0-parametric-units/316/2 "2021-11-30T16:24:19Z")

</div>

I'm not totally sure what you mean by "access param1 at the call site". Can you give an example?
