Ludovic Courtès <[email protected]> writes:

> Hello!
>
> Rutherther <[email protected]> skribis:
>
>> I am wondering, what are the disadvantages for making fields of records
>> thunked? I can come up with just one, that the error messages are harder
>> to read. Am I missing something?
>
> The disadvantages are:
>
>   1. code bloat (more code is generated for each site that builds a new
>      record and for each site that accesses the thunked field);
>
>   2. run-time overhead (a procedure call instead of a pointer
>      dereference when accessing the field);
>
>   3. delayed + repeated evaluation (the field’s thunk is called every
>      time the field is accessed).
>

One more I would add is that whether something is thunked or not is not
visible at the call site.  What does

  (define %param (make-parameter #f))
  (define foo (make-foo (param (%param))))
  (%param 42)
  (pk (foo-param foo))

print?  You cannot tell without inspecting how the record type is
defined.  And, more annoyingly, you need to re-check after every pull to
make sure the "thunked-ness" of the field did not change.  That is why
personally I am not a fan of the concept...

So the changes described are backwards incompatible and *could* break
someone's configuration.  Is that likely?  Probably no.

Tomas

-- 
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

Attachment: signature.asc
Description: PGP signature

Reply via email to