Nikita Karetnikov <[email protected]> skribis:

>> “Eval is evil”, as lispers love to say.
>
> Yeah, I've heard this one.
>
>> It should never be used, unless there’s a very good reason to do so.
>
> I've heard this too.  But people always fail to explain the "a very good
> reason" part.

There are many reasons, including: it’s hard to reason about code
generated at run time, it’s easy to generate invalid code, generated
code cannot be compiled & optimized, and evaluating code is much slower
than running compiled code.

>> In my unfinished binary substitute where a similar situation arises,
>> I’ve done this:
>
> [...]
>
>> And then, it is used like this:
>
>>          (alist->record properties
>>                         (cut %make-cache url <...>)
>>                         '("StoreDir" "WantMassQuery"))
>
> So, keys and values are strings here, right?

Keys are strings, and values can be anything.

> But I want to store setters as values.

The suggestion I made was in favor of using a single
‘make-gnu-record-descriptor’ call with all the field values (as opposed
to creating the record with all fields set to #f, and then using
‘setters’ to change them to their actual value.)

In the example above, the end result is a single call to the
constructor, equivalent to:

  (%make-cache url
               (assoc-ref properties "StoreDir")
               (assoc-ref properties "WantMassQuery"))

HTH,
Ludo’.

Reply via email to