named-tuples: use ?offset-of-slot in M\ named-tuple at*.

windows-high-dpi
John Benediktsson 2018-02-17 12:56:43 -08:00
parent edc1b3f65d
commit 8cfeab92f3
2 changed files with 4 additions and 1 deletions

View File

@ -24,6 +24,8 @@ INSTANCE: foo named-tuple
{ f } [ T{ foo } "y" of ] unit-test
{ f } [ T{ foo } "z" of ] unit-test
{ f f } [ "not found" T{ foo f 1 2 3 } at* ] unit-test
{ 1 } [ T{ foo f 1 2 3 } "x" of ] unit-test
{ 2 } [ T{ foo f 1 2 3 } "y" of ] unit-test
{ 3 } [ T{ foo f 1 2 3 } "z" of ] unit-test

View File

@ -11,7 +11,8 @@ MIXIN: named-tuple
M: named-tuple assoc-size tuple-size ;
M: named-tuple at* get-slot-named t ;
M: named-tuple at*
[ nip ] [ ?offset-of-slot ] 2bi [ slot t ] [ drop f f ] if* ;
M: named-tuple set-at set-slot-named ;