Email or username:

Password:

Forgot your password?
Top-level
Ramin Honary

@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?

4 comments
Daphne Preston-Kendal

@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 (codeberg.org/scheme/r7rs/wiki/)

Ramin Honary

@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.

Daphne Preston-Kendal

@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.

Daphne Preston-Kendal

I wrote a syntax-rules macro to define a record type with updaters instead of mutators: gitlab.com/dpk/presrfis/-/blob

Go Up