Revert "lists: Add list literal doc example."
[factor.git] / basis / alien / destructors / destructors.factor
blob27d7440454a4814b12426f82d383d6cd737ffaf0
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors destructors effects functors generalizations
4 kernel parser sequences ;
5 IN: alien.destructors
7 TUPLE: alien-destructor alien ;
9 <FUNCTOR: define-destructor ( F -- )
11 F-destructor DEFINES-CLASS ${F}-destructor
12 <F-destructor> DEFINES <${F}-destructor>
13 &F DEFINES &${F}
14 |F DEFINES |${F}
15 N [ F stack-effect out>> length ]
17 WHERE
19 TUPLE: F-destructor < alien-destructor ;
21 : <F-destructor> ( alien -- destructor )
22     F-destructor boa ; inline
24 M: F-destructor dispose alien>> F N ndrop ;
26 : &F ( alien -- alien ) dup <F-destructor> &dispose drop ; inline
28 : |F ( alien -- alien ) dup <F-destructor> |dispose drop ; inline
30 ;FUNCTOR>
32 SYNTAX: DESTRUCTOR: scan-word define-destructor ;