class example_record does Compact is finalized { has Str $.name is rw should serialize (:length_prefix(2), :encoding(UTF16), padding => {:char("\0", :strip} ); has int16 $.val is rw; has Str $!presentation_cache; # private, not included in compact struct I/O method presentation () returns Str { unless defined $!presentation_cache { ... # compute it } return $!presentation_cache; } }