locals.definitions: add subwords support to locals/lambdas.

Fix unit test now that local syntax is in syntax by default.
locals-and-roots
Doug Coleman 2016-05-16 10:58:17 -07:00
parent 10f33905dd
commit e06d3e790a
2 changed files with 23 additions and 2 deletions

View File

@ -1,11 +1,32 @@
! Copyright (C) 2007, 2008 Slava Pestov, Eduardo Cavazos.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors definitions effects generic kernel locals
macros memoize prettyprint prettyprint.backend see words ;
macros memoize prettyprint prettyprint.backend see words
locals.types sequences make quotations ;
IN: locals.definitions
PREDICATE: lambda-word < word "lambda" word-prop >boolean ;
! Lambdas/locals need to expose their uninterned subwords in order
! to make a boot image.
GENERIC: lambda-subwords ( obj -- )
M: object lambda-subwords drop ;
M: lambda lambda-subwords [ vars>> % ] [ body>> [ lambda-subwords ] each ] bi ;
M: def lambda-subwords local>> , ;
M: callable lambda-subwords [ lambda-subwords ] each ;
M: lambda-word subwords
[
"lambda" word-prop
[ vars>> % ] [ body>> [ lambda-subwords ] each ] bi
] { } make ;
M: lambda-word definer drop \ :: \ ; ;
M: lambda-word definition

View File

@ -194,7 +194,7 @@ CONSTANT: new-definition "USING: math ;\nIN: locals.tests\n: a-word-with-locals
new-definition =
] unit-test
CONSTANT: method-definition "USING: locals locals.tests sequences ;\nM:: sequence method-with-locals ( a -- y ) a reverse ;\n"
CONSTANT: method-definition "USING: locals.tests sequences ;\nM:: sequence method-with-locals ( a -- y ) a reverse ;\n"
GENERIC: method-with-locals ( x -- y )