vseloved / rutils

Radical Utilities for Common Lisp
Other
246 stars 36 forks source link

Feature request: (setf (rutil.lt X) Y) and similar for rutil.rt #63

Open mirkov opened 2 years ago

mirkov commented 2 years ago

When executing

(setf (rutil:lt (rutil:pair 0 1)) 1)

I get

The function (COMMON-LISP:SETF RUTILS.PAIR:LT) is undefined.

I can use car and cadr as workarounds.

jcguu95 commented 2 months ago

Pairs are defined using defstruct. While it is not very explicitly and clearly guaranteed in the standard, all conforming implementations should provide setfable reader functions. That means this is done automatically. What you want is to use pair-left instead of lt.

(setf (rutil:pair-left (rutil:pair 0 1)) 1)

You could use car or cadr to get around possibly because your lisp implementation chooses to implement the struct as a list anyway.

However, your point remains valid. As rutils defines abbreviated operator names in abbr.lisp as

(abbr lt pair-left)
(abbr rt pair-right)

it should transfer the setfability to the new names. To fix this issue, one has to support the macro definition of abbr.