# Conditional define-syntax

**URL:** https://racket.discourse.group/t/conditional-define-syntax/4181
**Category:** Questions & Answers
**Created:** [April 5, 2026, 7:41pm UTC](https://racket.discourse.group/t/conditional-define-syntax/4181 "2026-04-05T19:41:41Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![hnmdijkema](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hnmdijkema/32/2629_2.png) [@hnmdijkema](https://racket.discourse.group/u/hnmdijkema)
#### Post date: [April 5, 2026, 7:41pm UTC](https://racket.discourse.group/t/conditional-define-syntax/4181/1 "2026-04-05T19:41:41Z")

</div>

I'm trying to not load an FFI and define all functions when it's not available, defining the functions to be something like 'error' on call.

Is it possible to do a define-syntax based on the value of a variable? e.g., something like this:

```scheme
(define-ffi-definer def-rktwebview webview-lib)

(define-syntax def-rktwebiew-dummy
  (syntax-rules ()
    ((_ f def)
     (λ args (error "Not implemented")))))

(define define-rktwebview #f)

(if (eq? do-ffi #t)
    (set! define-rktwebview def-rktwebview)
    (set! define-rktwebview def-rktwebview-dummy))

```

---

<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: [April 5, 2026, 9:37pm UTC](https://racket.discourse.group/t/conditional-define-syntax/4181/2 "2026-04-05T21:37:04Z")

</div>

You can use `#:default-make-fail make-not-available` in `define-ffi-definer` and it will do what I think you want.

---

<div class="post-metadata">

### Author: ![hnmdijkema](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/hnmdijkema/32/2629_2.png) [@hnmdijkema](https://racket.discourse.group/u/hnmdijkema)
#### Post date: [April 5, 2026, 9:41pm UTC](https://racket.discourse.group/t/conditional-define-syntax/4181/3 "2026-04-05T21:41:57Z")

</div>

Thanks, I just created this (read the manual of ffi-definer).

```scheme
(define (make-ffi-repl id err . ret)
  (let ((warned #f)
        (msg (if (eq? do-ffi #t)
                 (string-append
                  "'~a' could not be loaded from "
                  (format "~a" webview-lib-file))
                 (string-append
                  "'~a' could not be loaded.\n"
                  reason)))
        )
    (λ () (λ args
            (if err
                (error (format msg id))
                (begin
                  (unless warned
                    (displayln (format msg id))
                    (set! warned #t))
                  (car ret)))))))

(define-ffi-definer define-rktwebview
                    webview-lib
                    #:default-make-fail (λ (id)
                                          (if (eq? do-ffi #f)
                                              (cond
                                                ((eq? id 'rkt_webview_env)
                                                 (make-ffi-repl id #f #t))
                                                ((eq? id 'rkt_webview_events_waiting)
                                                 (make-ffi-repl id #f 0))
                                                ((eq? id 'rkt_webview_init)
                                                 (make-ffi-repl id #f #t))
                                                ((eq? id 'rkt_webview_cleanup)
                                                 (make-ffi-repl id #f #t))
                                                (else
                                                 (make-ffi-repl id #t))
                                                )
                                              (make-ffi-repl id #t)))
  )

```
