# What kind of \`with\`s have you come up with?

**URL:** <https://racket.discourse.group/t/what-kind-of-with-s-have-you-come-up-with/3360>\
**Category:** General\
**Created:** [November 27, 2024, 10:18am UTC](https://racket.discourse.group/t/what-kind-of-with-s-have-you-come-up-with/3360 "2024-11-27T10:18:55Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![shawnw](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/shawnw/32/1031_2.png) [@shawnw](https://racket.discourse.group/u/shawnw)\
**Post date:** [November 27, 2024, 10:30pm UTC](https://racket.discourse.group/t/what-kind-of-with-s-have-you-come-up-with/3360/8 "2024-11-27T22:30:05Z")

</div>

I made a version of the [Common Lisp `with-slots` macro](https://www.lispworks.com/documentation/HyperSpec/Body/m_w_slts.htm) for [Racket structs](https://docs.racket-lang.org/soup-lib/index.html#%28form._%28%28lib._soup-lib%2Fstruct..rkt%29._with-slots%29%29) recently that I'm proud of.

```scheme
(require soup-lib/struct)
(struct demo (a b c) #:transparent #:mutable)
(define x (demo 1 2 3))
(with-slots demo (a b) x
  (set! b (+ a b))
  (print x)) ; (demo 1 3 3)

```

Vital to the implementation are [`make-variable-like-transformer`](https://docs.racket-lang.org/syntax/transformer-helpers.html#%28def._%28%28lib._syntax%2Ftransformer..rkt%29._make-variable-like-transformer%29%29) and the [`struct-id` syntax class](https://docs.racket-lang.org/syntax-classes/index.html#%28form._%28%28lib._syntax%2Fparse%2Fclass%2Fstruct-id..rkt%29._struct-id%29%29).

---

_[View the full topic](https://racket.discourse.group/t/what-kind-of-with-s-have-you-come-up-with/3360)._
