Me when Scheme records don’t support purely functional updaters
https://hacksrus.xyz/objects/f0787b7b-11fd-4688-92bb-d294cd56cd55
Me when Scheme records don’t support purely functional updaters 5 comments
@ramin_hal9001 In both R7 and R6, a field can be mutable, and if so the mutator will actually mutate the record. There’s no facility for functional updates in either. I want to change this, but the record system in R6 was already victim of too much feature piling, and record systems in general are a particularly bad place for such (https://codeberg.org/scheme/r7rs/wiki/Record-system-features) @dpk oh, sweet! Yeah, before I switched to Scheme I did most of my hobby projects in Haskell, and their immutable records are great! So easy to reason about. So I am definitely in favor of that feature. Also, I believe it is easier to optimize as the SSA pass of the compiler can more easily reason about immutable records, but I am not a compiler expert by any stretch of the imagination. @ramin_hal9001 Well, as things stand, you can already have immutable records – just don’t have any mutable fields. (This is actually the default in R6 define-record-type.) But there’s no automatic way to create functional field setting procedures like there is to create field mutator procedures. You can have them, but you have to define them yourself. I wrote a syntax-rules macro to define a record type with updaters instead of mutators: https://gitlab.com/dpk/presrfis/-/blob/master/define-value-type.scm |
@dpk correct me if I'm wrong (you being the chair of the R7RS working group and all) but a purely functional implementation of record mutators is just an implementation detail and not specified in the R7RS, right?