NOTE: Racket prop:custom-write
source link: https://dannypsnl.github.io/blog/2022/02/12/cs/racket-prop-write/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Control how to print an object is an important thing in any languages. in Racket, is one of many ways for structure, and it works for this…NOTE: Racket prop:custom-write
Email: [email protected]
GitHub: @dannypsnl
Twitter: @dannypsnl
Programming Language Theory • System Programming
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))))
author: Lîm Tsú-thuàn/林子篆/Danny
category:cs
tag:noterackettyped racketpretty print
Similar Articles
All works in this site is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK