3 ms·
That's in many cases what a LET with a dynamic binding does in Lisp. Set origin draw Reset Origin is (let ((origin (move 50 50))) (draw something))
by lispm 15y ago
That's in many cases what a LET with a dynamic binding does in Lisp.
Set origin
draw
Reset Origin
is
(let ((origin (move 50 50)))
(draw something))
Similar in the Common Lisp object system we use :before, :after and :around methods.
(defmethod draw :before () (move 50 50))
(defmethod draw () (draw-something))
(defmethod draw :after () (move -50 -50))
- draegtun 15y ago> Similar in the Common Lisp object system we use :before, :after and :around methods Ditto for Moose (in Perl)... before draw => sub { shift->move( 50, 50 )}; sub draw { shift->draw_something } after draw => sub { shift->move( -50, -50 )}; Also you can package up these method modifiers into a role which not only can be composed into a class but can also be applied just to an object... { package DrawRole; use Moose::Role; before draw => sub { shift->move( 50, 50 )}; after draw => sub { shift->move( -50, -50 )}; } my $d = Draw->new; DrawRole->meta->apply( $d );
- Shorel 15y agoI think you mean Special Operator UNWIND-PROTECT.