Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
with-contexts
with-contexts
Commits
38f0e4b6
Commit
38f0e4b6
authored
Dec 10, 2020
by
Marco Antoniotti
💬
Browse files
Fixed typos.
parent
3a336e18
Changes
3
Hide whitespace changes
Inline
Side-by-side
library/exit-stack-context.lisp
View file @
38f0e4b6
...
...
@@ -21,9 +21,9 @@ collected within a WITH macro body. The methods of this class provide
more control over what happens with errors that may happen within
ENTER calls in non-straightforward contexts.
Notes
;
Notes
:
This class provides much of the functionalities displayed in the Pythn
This class provides much of the functionalities displayed in the Pyth
o
n
examples.
"
)
)
...
...
library/managed-resource-context.lisp
View file @
38f0e4b6
...
...
@@ -12,7 +12,7 @@
;;;;
;;;; Solution one: we just build "state" objects.
;;;;
;;;; Other solutions are not feas
a
ble in Common Lisp given the lack of
;;;; Other solutions are not feas
i
ble in Common Lisp given the lack of
;;;; proper (delimited) continuations.
;;;;
;;;;
...
...
@@ -42,13 +42,13 @@ examples in Common Lisp.")
(
defgeneric
is-managed-resource-context
(
x
)
(
:method
((
x
managed-resource-context
))
t
)
(
:method
((
x
t
))
nil
)
(
:documentation
"Returns T if the argument X is a MANAGED-RESOURCE-CONTEXT."
))
(
:documentation
"Returns T if the argument X is a MANAGED-RESOURCE-CONTEXT."
))
(
defun
managed-resource-context-p
(
x
)
"Returns T if the argument X is a MANAGED-RESOURCE-CONTEXT.
Notes:
This function is a synonim of IS-MANAGED-RESOURCE-CONTEXT."
...
...
@@ -57,20 +57,33 @@ This function is a synonim of IS-MANAGED-RESOURCE-CONTEXT."
;;; Constructor.
(
defun
managed-resaouce
(
id
&key
&allow-other-keys
)
(
defun
managed-resource
(
id
&key
&allow-other-keys
)
"Constructs a MANAGED-RESOURCE.
The only declared parameter, ID, should be a unique identified for the
resource."
(
make-instance
'managed-resource-context
:resource
id
)
)
;;;; ACQUIRE/RELEASE protocol.
(
defgeneric
acquire
(
mr
&key
)
(
:method
((
mr
managed-resource-context
)
&key
)
mr
))
(
:method
((
mr
managed-resource-context
)
&key
)
mr
)
(
:documentation
"Acquires a MANAGED-RESOURCE.
This generic function is the 'entry' point of the ACQUIRE/RELEASE
protocol."
))
(
defgeneric
release
(
mr
&key
)
(
:method
((
mr
managed-resource-context
)
&key
)
mr
))
(
:method
((
mr
managed-resource-context
)
&key
)
mr
)
(
:documentation
"Releases a MANAGED-RESOURCE.
This generic function is the 'exit' point of the ACQUIRE/RELEASE
protocol."
))
;;;; ENTER/HANDLE/EXIT protocol.
...
...
@@ -83,7 +96,6 @@ This function is a synonim of IS-MANAGED-RESOURCE-CONTEXT."
(
call-next-method
)
; (error e)
)
(
defmethod
exit
((
mr
managed-resource-context
)
&key
)
(
release
mr
))
...
...
library/with-open-file.lisp
View file @
38f0e4b6
...
...
@@ -3,7 +3,7 @@
;;;; with-open-file.lisp
;;;; The WITH macro working as WITH-OPEN-FILE.
;;;;
;;;; Note that this implementation is "direct". An
d
"indirect" one
;;;; Note that this implementation is "direct". An "indirect" one
;;;; would wrap the stream in a NULL-CONTEXT; and this is what Python
;;;; appears to do with its decorator trick.
;;;; In Common Lisp we could to it either way; but the "direct" way
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment