Skip to content

Racket Structures — Define New Data Types with struct

DodaTech Updated 2026-06-29 1 min read

In this tutorial, you will learn about Racket Structures. We cover key concepts, practical examples, and best practices to help you master this topic.

Structures in Racket let you define custom data types with named fields, constructors, predicates, and accessors — all generated automatically.

Basic Structs

(struct point (x y))

(define p (point 3 4))
(point-x p)  ; => 3
(point-y p)  ; => 4
(point? p)   ; => #t

; With type checking
(struct person (name age) #:transparent)
(define alice (person "Alice" 30))
alice  ; => (person "Alice" 30)

Inheritance

(struct employee person (role salary))
(struct manager employee (team-size))

(define m (manager "Bob" 45 "engineering" 150000 12))
(manager-name m)        ; => "Bob"
(manager-role m)        ; => "engineering"
(manager-team-size m)   ; => 12

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro