UP | HOME

NOTE: Racket prop:custom-write

Control how to print an object is an important thing in any languages. in Racket, prop:custom-write is one of many ways for structure, and it works for typed/racket this variant.

#lang racket
(struct vec3
  (x y z)
  #:property prop:custom-write
  (λ (v port mode)
    (fprintf port "~a ~a ~a" (vec3-x v) (vec3-y v) (vec3-z v))))

Date: 2022-02-12 Sat 00:00

Author: Lîm Tsú-thuàn