Skip to content

Cannot override the __str__ for a records or deftypes #1237

Closed
@chrisrink10

Description

@chrisrink10

It is either not possible or not easy to customize the str output for a type or record right now:

(definterface Shape
  (area []))

(defrecord Circle [radius]
  Shape
  (area [self]
    (* 3.14 radius radius))

  (__str__ [self]
    (str "radius: " radius)))

(str (->Circle 1))  ;; => "#basilisp.user.Circle{:radius 1}"

This is likely due to the messy and convoluted relationship between basilisp.lang.obj.lrepr and basillisp.core/str.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions