Commit graph

593 commits

Author SHA1 Message Date
Marius Gerbershagen
1a0aa0a52e gray streams: add missing default method for stream-interactive-p
According to the documentation we should always return nil.
2024-05-18 13:30:49 +02:00
Tarn W. Burton
bc6e31f926
Add generic pathname/truename 2024-01-25 14:05:27 -05:00
Daniel Kochmański
3850dcf5d7 Merge branch 'gray-string-length' into 'develop'
Add Gray extension for file-string-length

See merge request embeddable-common-lisp/ecl!318
2024-01-24 12:47:38 +00:00
Daniel Kochmański
3e37843a33 cleanup: update license to lgpl-2.1+ in both headers and text 2024-01-14 12:22:27 +01:00
Tarn W. Burton
e554673006
Add support for gray:stream-file-string-length 2024-01-13 10:26:35 -05:00
Tarn W. Burton
4ede355c26
Allow empty string for EOF in read-line 2023-12-04 13:01:40 -05:00
Tarn W. Burton
0abaa78feb
Add gray:stream-line-length 2023-11-20 15:21:35 -05:00
Tarn W. Burton
a597fc07b1
Return NIL from stream-terpri 2023-11-19 14:27:35 -05:00
Tarn W. Burton
dda901a394
Fix generic definition of stream-file-length 2023-11-16 12:26:40 -05:00
Daniel Kochmański
9c7c62ed7f Merge branch 'gray-file-length' into 'develop'
Add gray:stream-file-length

See merge request embeddable-common-lisp/ecl!307
2023-11-16 16:00:33 +00:00
Tarn W. Burton
edd88aac45
Add gray-streams module to avoid use of redefine-cl-functions 2023-11-15 12:30:08 -05:00
Tarn W. Burton
b9a7d06635
Add gray:stream-file-length 2023-11-12 16:14:34 -05:00
Daniel Kochmański
faebc7b266 cmp: enforce valid shape of si:function-block-name delcaration
Also fix a declaration in clos::make-raw-lambda function.
2023-09-25 13:13:27 +02:00
Daniel Kochmański
63d9f41f19 predlib: define clos constants used by 'predlib' in 'symbols_table'
predlib.lsp is loaded before the clos module, but constants used by predlib were
defined in the latter. That worked because the C compiler inlines constants that
are fixnums, although it is a bit shaky to rely on particular optimizations.

To avoid this dependency we hardcode relevant constants in symbols_list.h and
later we assert in the clos module ethat their values are correct.
2023-09-11 16:54:21 +02:00
Marius Gerbershagen
064f1426ba clos: change metaclass of funcallable-standard-object to funcallable-standard-class
This makes more sense in general and is in accord with other
implementations.
2023-07-13 18:38:20 +02:00
Daniel Kochmański
23428b8af9 cosmetic: clos: declare unused variables as ignored 2023-02-21 14:34:11 +01:00
Marius Gerbershagen
a5cb93d311 clos: fix computation of instance size
For empty structs, the size was off by one. While this did not affect
structs that were created directly with the structure constructor, for
structs that were externalized with MAKE-LOAD-FORM-SAVING-SLOTS
instances which were one element too large were created.
2023-02-16 20:00:12 +01:00
Daniel Kochmański
7db7e0545f clos: defcombin: fix regressions 2023-01-28 22:15:54 +01:00
Daniel Kochmański
2ba8228366 clos: move define-method-combination to a separate file 2023-01-22 20:36:09 +01:00
Daniel Kochmański
dea75e6bb5 clos: refactor define-complex-method-combination
Factor out a macro WITH-METHOD-GROUPS. The function PARSE-QUALIFIER-PATTERN is
put as a local function in this new macro.
2023-01-22 20:36:09 +01:00
Daniel Kochmański
78abe40fb9 clos: handle correctly the pattern * in define-method-combination
The pattern in the long form of the define-method-combination may contain * as
a list element meaning "any" qualifier. For example:

(define-method-combination foo ()
    ((bar (:xxx * :yyy)))
  ...)

In this case qualifiers `:xxx 3 :yyy' and `:xxx :zzz :yyy' will match.
2023-01-22 20:36:09 +01:00
Marius Gerbershagen
84db9e7a3f clos: implement the :arguments option for define-method-combination 2023-01-21 17:18:10 +01:00
Daniel Kochmański
285c12a2c6 cosmetic: indentation, s/if/when/ 2022-11-25 13:49:43 +01:00
Marius Gerbershagen
de15a85420 cosmetic: fix some compiler warnings 2022-10-22 19:58:24 +02:00
Daniel Kochmański
2307259fcd clos: sort-applicable-methods: be specific regarding arguments
The function SORT-APPLICABLE-METHODS accepts as the third argument called
ARGS-SPECIALIZERS however this function assumed that the argument was a list
of argument's classes (i.e not EQL specializers) - see COMPARE-SPECIALIZERS.
This commit doesn't change the function signature but conses a new list that
is ensured to be a list of classes and passes them to COMPARE-METHODS.

(Local) functions COMPARE-METHODS, COMPARE-SPECIALIZERS-LISTS and
COMPARE-SPECIALIZERS have the argument name changed to reflect their true
expectations.

The function COMPARE-SPECIALIZERS takes the CLASS-PRECEDENCE-LIST of the class
of the argument to break ties when there is no direct relationship between
method specializers.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
f37fe9533c clos: compute-applicable-methods: small refactor
Pull a function APPLICABLE-METHOD-LIST into its sole consumer
STD-COMPUTE-APPLICABLE-METHODS.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
86e71d7eb9 clos: add a reference implementation of the legacy discriminator
This implementation is included for the reference and benchmarks.
2022-02-05 16:21:23 +01:00
Daniel Kochmański
74c08fa072 clos: c-a-m-using-classes: don't give up eagerly on EQL specializer
Previously a local function APPLICABLE-METHOD-P returned (values nil nil) when
it found an EQL-specializer where the object was of a matching class. This is
premature because some later specializer may make the method not applicable
based on one of the argument classes, so there is no need to resort to
COMPUTE-APPLICABLE-METHODS in such case.
2022-02-05 16:20:13 +01:00
Daniel Kochmański
9ff049c969 clos: rewrite compute-g-f-spec-list
Previously this function stored a list of elements

  (cons list-or-random-atom argument-position)

ARGUMENT-POSITION was preasumbly stored because authors anticipated denoting
unspecialized arguments, however all positions were always filled because
unspecializer argument had non-nil specializer #<BUILTIN-CLASS T>.

LIST-OR-RANDOM-ATOM contained either a list of EQL specializers or a random
specializer from all method specializers. The second value was not clear.

This change simplifies the code and the interface, we additionally maintain
additional information. From now on the list stores elements:

  (cons class-specializer-p eql-specializers)

CLASS-SPECIALIZER-P is either NIL or T denoting whether the generic function
has a method specialized on this argument on a class other than T.

EQL-SPECIALIZERS without change, is a list of all EQL specializers.
2022-02-05 16:10:33 +01:00
Daniel Kochmański
84200fd315 clos: rework slightly the dispatch mechanism
- improve set-generic-function-dispatch comments
- add a new file that contains "lisp-defined" dispatchers
- remove unused code
2022-02-05 15:03:52 +01:00
Daniel Kochmański
5cb67471fd clos: finalize-inheritance conformance fix
According to "Reinitialization of Class Metaobjects" reinitialize-instance
must call finalize-inheritance if the class was already finalized.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
2d5da9e8bf clos: add a missing method finalize-inheritance for forward classes
MOP specifies that FINALIZE-INHERITANCE should have a method specialized on
the FORWARD-REFERENCED-CLASS that signals an error.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
acc5162680 clos: add-method: call add-direct-method for specializers
Previously we didn't call it due to bootstrapping issues, but now we convert
functions to methods after early methods are fixed up and their classes are
also updated, so we can. This fix improves conformance.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
653cba539f clos: various bootstrap improvements
The most notable change applies to the file fixup.lsp. Functions destined to
be generic are converted to their final version.

Previously this conversion was done in a few steps in order to avoid issues
with infinite recursion in dispatch. We achieve this by assigning to these new
generic function a simplified discriminating function:

    (lamda (&rest args)
      (unless (or (null *clos-booted*)
                  (specializers-match-p args specializers))
        (apply #'no-applicable-method generic-function args))
      (apply old-function args))

The old function is also seeded as a primary method for the generic
function. This works correctly because functions have only one method so we
may directly call it (it is also a fine optimization strategy we do not
incorporate generally yet), and because the discriminating function will be
recomputed when other methods are added etc.

This way we may use these generic functions without issues directly with newly
redefined versions and the file is now ordered as follows:

- fixup early methods
- redefine functions to their final version
- convert functions to generics
- define missing methods
- implement the dependant maintenance protocol

After this file is loaded it is possible to use generic functions as usual.
2022-02-05 15:03:52 +01:00
Daniel Kochmański
ea92cba4ce defstruct: fix incorrect compatibility checks
Previously we've checked whether the new defstruct is compatible with the old
one like this:

(let ((old-desc (old-descriptions struct)))
  (when (and old-desc (null (compat old-desc new-desc)))
    (error "incompatible")))

This was to allow new definitions. This is incorrect, because allows first
defining a structure without slots and then adding some, like

(defstruct foo)
(defstruct foo xxx)

The new check verifies whether the structure is a structure and then compares
slot, so the verification is not inhibited when the first definition doesn't
have slots.

Moreover we now test for slot names being string= because:
a) initargs and functions ignore the package (so functions will be redefined)
b) we want to match gensymed slot names
This is compatible with what sbcl does.

On top of that check for duplicated names and signal an error if there are
such.
2022-02-05 15:03:22 +01:00
Daniel Kochmański
cc27aadf5f clos: ensure correct class stamps
- we did not distinguish between classes that had no slots and classes that
  had no been iniutialized - that led to incorrect class stamps

- structures had no initial class stamp matching their structure

- structures when slot names chagned had their stamp increased despite not
  really changing
2022-02-04 21:31:53 +01:00
Daniel Kochmański
e82d002f90 restart-case: conformance fix: more precise keyword parsing
- don't assume that any keyword is an option
- don't process the same keyword twice

New behavior could be summarized in these two cases:

(restart-case t
  (retry ()
    :retired ; <- form
))

(restart-case t
  (retry ()
    :report report  ; <- expression
    :report "foo"   ; <- form
    :test test      ; <- form
))

Fixes #666.
2022-01-06 09:51:40 +01:00
Tarn W. Burton
d778112a34 Allow real-valued columns in Gray methods 2021-12-21 10:04:56 -05:00
Tarn W. Burton
bc0e2dbf99 Add reader type errors for WSCL conformance 2021-10-05 05:46:29 -04:00
Daniel Kochmański
0e5174c040 direct-superclasses: the default value of the slot is nil per AMOP
http://metamodular.com/CLOS-MOP/class-direct-superclasses.html
2021-05-10 13:23:56 +02:00
Daniel Kochmański
086ec59ab8 check-direct-superclasses: handle forward-referenced-class
The forward-referenced-class metaclass has no superclasses.

Moreover:

- check superclasses after they are added (removes one fixme)
- don't map validate-superclass during clos booting
2021-05-10 13:23:56 +02:00
Marius Gerbershagen
9e204464ea clos: replace macros by functions in with-early-accessors
Accessors are fuctions not macros. While using macros is fine in most
cases, we can't use them for example in higher-order functions. The
only reason this worked in the first place is due to our compiler
allowing expressions such as

`(macrolet ((x (...) ...)) (funcall #'x ...))

even though this is invalid.
2021-03-31 21:09:18 +02:00
Marius Gerbershagen
788b9b4cd0 clos: FUNCTION-KEYWORDS must be a generic function 2021-03-03 22:14:28 +01:00
Marius Gerbershagen
4e1847f775 clos: don't call make-load-form in the code walker for defmethod
Fixes #594.
2020-09-18 21:22:32 +02:00
Daniel Kochmański
0ab85fc9d5 conditions: add an ext:timeout serious condition 2020-06-15 12:34:10 +02:00
Daniel Kochmański
0158e14dea clos: stream-read-sequence: fix the order of arguments
Function si:do-read-sequence was called with the stream and the
sequence arguments reversed. Spotted by Christian Schafmeister.
2020-06-11 08:24:30 +02:00
Daniel Kochmański
4da8ca54b6 slot-definitions-compatible-p: check for the slot class too
The spec says:

    The generic function make-instances-obsolete is invoked
    automatically by the system when defclass has been used to
    redefine an existing standard class and the set of local slots
    accessible in an instance is changed or the order of slots in
    storage is changed. It can also be explicitly invoked by the user.

If the local slot's class is changed then indeed the set has
changed. We also check whether the slot class is S-D-S-D or S-E-S-D
and in both cases we also decide that layouts are not compatible.

Fixes #586.
2020-05-16 19:55:19 +02:00
Marius Gerbershagen
c6b4296bb8 cosmetic: fix some compiler warnings 2020-04-29 20:35:37 +02:00
Daniel Kochmański
b9d54d6be7 internals: rename instance.sig to instance.slotds
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.
2020-04-19 17:04:42 +02:00
Daniel Kochmański
f1bc883ed6 clos: introduce class stamps for marking instances obsolete
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.
2020-04-19 17:04:41 +02:00