Closed soc closed 2 years ago
The proposed design is based on lessons learned and problems experienced with various languages, including Java, Haskell, Rust and Scala:
toString
is supposed to only ever be used for debugging, and no common interface/method exists for user-facing display/printing of values.toString
implementation. Due to the lack of runtime-facilities, it had to laboriously implement an almost-reliable REPL printing mechanism in user-code as a workaround.IO
type. This is largely due to being able to write arbitrary user code to log in Haskell. The proposed design avoids this issue by not allowing arbitrary user-code to run to create a debug string, but deferring to a single runtime-internal implementation that can be built/verified to provide the desired safety guarantees.Stringable
) exists, except the derivation of a toString
implementation by the compiler via an annotation. This is not a blocker and may happen independently of the next point.debugString
) does no exist and I propose implementing it.
Brought up in https://github.com/dinfuehr/dora/pull/254#issuecomment-907566068 by @dinfuehr, my plan as promised in https://github.com/dinfuehr/dora/pull/254#issuecomment-907648809.
Plan
Stringable#toString()
focuses on general-purpose output:capacity
for collections, the structure of binary trees, the occupancy ratio of hash maps etc.).Stringable
traits, and putting that constraint on parameters/values when calling the method.runtime.debugString(value)
provides debugging-oriented output:@internal
static method implemented by the runtime.debugString
is""
except in release builds.