Merge a test for with-output-to-string with the one for
with-input-input-from-string to ensure both close their streams.
Remove check for stream-var being a stream outside of w-i-f-s &
w-o-t-s. According to the specification, the streams' extent ends with the
respective providing form. If the stream was indeed not acccessible anymore, the
test would not pass. In that case open-stream-p should signal a type-error,
causing the test to crash. However in ECL we can assume that the stream is still
intact.
Fix#576, Related to !197, 72560efa5a
with-output-to-string is required to close the output stream that it provides
for the extent of the body forms [1]. The current definition does not do that.
This change wraps the body forms in unwind-protect clauses to ensure the stream
is always closed on exit. Because declarations cannot appear at the beginning of
progn forms, any potential declarations are extracted from the body forms and
moved to the beginning of the surrounding let form's body.
element-type is no longer bound to a gensym, but evaluated inside the let body.
The uppercased names are downcased for a more coherent appearance.
[1]: http://www.lispworks.com/documentation/HyperSpec/Body/m_w_out_.htm
Announcement proposal. When this is merged to the develop branch, then
we should make a PR against master and merge. Then we shall publish
tarballs and the announcement on the website.
Slot definitions are no longer a signature, but they are still needed
to update obsolete instances. Reader function name is also changed to
SI:INSTANCE-SLOTDS. SI:INSTANCE-SIG-SET name does not change, because
it sets both SLOTDS and the STAMP.
We should call make-instances-obsolete from finalize-inheritance if we
want to be conforming, because user may have added their own auxiliary
methods.
This change while being last in a serie of commits was locally the
first change which solved problems. It will enable us to implement the
fast generic dispatch after the release.
It helps to determine whether the instance needs to be updated for a
class after redefinition. Currently it is done by comparing the
signature with the instance's class slots.
1. We've implemented SPECIALIZER-DIRECT-METHODS and
SPECIALIZER-DIRECT-GENERIC-FUNCTIONS as accessors to slots in the
specializer DIRECT-METHODS and DIRECT-GENERIC-FUNCTIONS.
2. As specified in MOP these collections are maintained by
ADD-DIRECT-METHOD and REMOVE-DIRECT-METHOD functions.
3. When we finalize standard-method, we remove old methods and among
them is a method for a function METHOD-GENERIC-FUNCTION, and that
function must be called from REMOVE-DIRECT-METHOD when we want to
update SPECIALIZER-DIRECT-GENERIC-FUNCTIONS, so we end up in a
debugger that there is no specialization for this function.
We adapt approach similar to one taken in SBCL (did they encounter a
similar issue?): specializer class has a SPECIALIZER-METHOD-HOLDER
accessor which stores a CONS cell. We add/remove methods to CAR and
take generic functions from CDR. The trick is that CDR is lazily
computed when SPECIALIZER-DIRECT-GENERIC-FUNCTIONS is called and
invalidated when we add and remove method.
Specification of M-I-O explicitly says that instances are not made
when "local slots" are compatible. This change is necessary to prevent
infinite recursion as reported in #568 without breaking the
finalization protocol, because currently class-slots are used as a
signature for its instances (and that's how being obsolete is
determined).
finalize-inheritance is expected to run regardless of the fact that
class has been already finalized. I suppose that it is in case when
compute-slot-* methods are specialized to return something else.
Local function REMOVE-OPTIONAL-SLOT-ACCESSORS removed generic
functions after removing methods while redefining the class if said
generic functions have no other methods. There is nothing in the spec
what would justify it, so we don't fmakunbound these functions
anymore.
As pointed out by Dr. Robert Strandth initargs argument may be passed
to allocate-instance only after the class has been already finalized,
and indeed we finalize it in make-instance. To be on a safe side,
unlike CLASP, we still check whether the class is already finalized in
case of someone calling allocate-instance outside the make-instance
method.
That was probably a typo, because finalize-unless-forward checked only
the class parents if they were forward-referenced classes, not the
class itself.
- extend tests for make-instances-obsolete
- add a metastability test for the standard-method finalization
- fix tests which assume that metaclasses are finalized eagerly
On linux, using AI_ADDRCONFIG causes getaddrinfo to return no ip
address for localhost when only the loopback connection is
active. Also, we only get ipv4 addresses anyway due to specifying
ai_family = AF_INET, therefore the AI_ADDRCONFIG flag in not necessary
anyway.
The Common Lisp Standard defines that with-input-from-string always closes the
input stream that it creates. But with the current definition it would only be
closed in the case of an index variable being provided.
This change wraps the code for both cases (index given or not) in a unified
unwind-protect form, updates the index if present, and always closes the
stream. It also unifies the processing of declarations.
Downcase code & fix indentation:
Set the uppercased code in lower case to harmonise appearance and increase
readability. Differentiated indentation for the first forms in unwind-protect
and multiple-value-prog1 helps to understand their special meaning.
Fix 49b244db78 assumed, that the class
itself is first in the CPL list, and this assumption while correct in
light of MOP specification may be broken by a non-conforming code.
Bringing back the check whether (eq x class) when we try to finalize
the "top-most class which is not yet finalized" does not break
conforming code whiel still enabling slihgtly broken code to work.
Fixes#572.
Lambda list congruency is described here:
- 7.6.4 Congruent Lambda-lists for all Methods of a Generic Function
- 7.6.5 Keyword Arguments in Generic Functions and Methods
Previously we have tested conformingly for the fourth point:
4. If the generic function lambda list mentions &key, each method
must accept all of the keyword names mentioned after &key, either by
accepting them explicitly, by specifying &allow-other-keys, or by
specifying &rest but not &key. Each method can accept additional
keyword arguments of its own. The checking of the validity of
keyword names is done in the generic function, not in each method. A
method is invoked as if the keyword argument pair whose name is
:allow-other-keys and whose value is true were supplied, though no
such argument pair will be passed.
The fifth point mentions that if either the generic function or any
applicable method has &allow-other-keys, then function may be called
with extra keyword arguments:
5. The use of &allow-other-keys need not be consistent across lambda
lists. If &allow-other-keys is mentioned in the lambda list of any
applicable method or of the generic function, any keyword arguments
may be mentioned in the call to the generic function.
This change makes the fourth point more consistent with the fifth,
however it is *not* conformant when it is read literally. Reasons for
this change:
- this behavior is exhibited at least by SBCL and CCL, so we'll be
more compatible with a non-conformant code tested on them
- the change won't impact results of a correct program unless it
depends on the defmethod signaling an error condition
Function is rewritten in C in compiler.d to remove a dependency
between the bytecodes compiler and the clos module. It may be more
performant thanks to more precise type handing, however we use a list
instead of a hashtable, so it may be slower with lookup. To assess
that we should run some benchmarks against real code -- rewriting C
code to work with a hash table should be trivial.
clos::need-to-make-load-form-p is now si::need-to-make-load-form-p and
may be called from C code as si_need_to_make_load_form_p.
We've reinitialized the class even when it was already finalized and
none of its parents has changed with the recomputed information.
That leads to replacing the class slots with a result of COMPUTE-SLOTS
and in effect changing the INSTANCE-SIG (see src/clos/change.lsp).
Next time when ENSURE-UP-TO-DATE-INSTANCE is called (i.e from the
STANDARD-INSTANCE-ACCESS), then the instance is reinitalized.
Behavior was the most notable when we had tried to re-finalize the
STANDARD-EFFECTIVE-SLOT-DEFINITION class, because then /its new/ slots
were by definition obsolete after calling setf on this class and
unbound, what leads to an infinite recursion when we try to signal
unbound-slot condition.
Fixes#568.
Now instead of a default printer #<a foo> we have the identity
information #<a foo 0x56123571d240>. That is certainly useful for
printing when we have lists of instances of the same class.
@"foo" will expand to ecl_make_constant_base_string("foo", -1) now.
That saves some typing during testing when we want to feed a string to
the cl_format and other CL functions opearting on strings.
Now:
cl_format(3, @"~a: ~s", obj1, obj2);
Then:
cl_object str = ecl_make_constant_base_string("~a: ~s", -1);
cl_format(3, str, obj1, obj2);
Init forms are deferred when possible. This change solves two problems:
- init forms using uninitialized constant boxes
- make forms not signaling an error when circular
Partial fix for #562 (we need to fix bytecodes compiler too).