Skip to content

Instantly share code, notes, and snippets.

@Bike
Created July 12, 2021 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bike/43cf08b0d4788904b169180d013ead6b to your computer and use it in GitHub Desktop.
Save Bike/43cf08b0d4788904b169180d013ead6b to your computer and use it in GitHub Desktop.

Operators that could have condition behavior more specifically defined

"Should signal an error of type-error" (or stronger?)

  1. N/A
  2. N/A
  3. compile, compiler-macro-function, macro-function, proclaim
  4. typep, type-error-datum, type-error-expected-type
  5. apply, funcall, function-lambda-expression, complement, multiple-value-call, get-setf-expansion
  6. various loop clauses?, dolist
  7. skipped because specialization and MOP might make this require more thought
  8. copy-structure
  9. cell-error-name, cerror (depending on how strict "effectively invokes" is taken to be), check-type, invalid-method-error, method-combination-error, signal, simple-condition-format-control, simple-condition-format-arguments, warn (sorta), break, handler-bind, make-condition, compute-restarts, find-restart, invoke-restart (says control-error should be signaled if the restart is "not valid", but I think that's more about dynamic extent?), invoke-restart-interactively (ditto), restart-bind, restart-name, with-condition-restarts, with-simple-restart, abort, continue, muffle-warning, store-value, use-value
  10. set
  11. export, find-symbol, find-package, find-all-symbols, import, rename-package, shadow, shadowing-import, delete-package, make-package, with-package-iterator, unexport, unintern, in-package (but doesn't evaluate), unuse-package, use-package, do-symbols, do-external-symbols, intern, package-used-by-list (has typo: args and values says package designator, exceptional situations says package), package-error-package
  12. = etc, floor etc, *, +, -, /, 1+, 1-, abs, exp, expt, incf, decf, log, mod, rem, signum, random (for random-state parameter), cis, complex, conjugate, upgraded-complex-part-type, numerator, denominator, parse-integer, byte, byte-size, byte-position, deposit-field, dpb, ldb, ldb-test, mask-field, decode-float etc (should signal an error, but not specced as a type error), float, arithmetic-error-operands, arithmetic-error-operation. NOTE: Many are specced as "might signal" already
  13. char= etc, digit-char, digit-char-p, char-int, code-char
  14. rplaca, rplacd (self-contradictory), sublis, nsublis, subst etc, tree-equal, copy-list, pop, first etc, nth, nconc, append, revappend, nreconc, last, nthcdr, rest, member etc (e.g. test parameter), mapc etc (function parameter), assoc etc, copy-alist, pairlis ("should be prepared"), rassoc etc, get-properties, getf, remf, intersection, nintersection, adjoin, pushnew, set-difference, nset-difference, set-exclusive-or, nset-exclusive-or, subsetp, union, nunion
  15. make-array, adjust-array, aref, array-dimension, array-in-bounds-p, array-row-major-index, row-major-aref, upgraded-array-element-type, svref, vector-pop, vector-push, vector-push-extend, bit, sbit, bit-and etc
  16. char, schar, string (could be more specific about what extensions are allowed?), string-upcase etc, string-trim etc, string= etc, make-string
  17. make-sequence (for the initial element), map (for the function), map-into (ditto), reduce (ditto & test functions), count etc, sort, find etc, position etc, search, mismatch, replace, substitute etc, merge, remove etc, remove-duplicates etc
  18. make-hash-table, hash-table-count, gethash, remhash, maphash, with-hash-table-iterator, clrhash
  19. pathname, make-pathname, load-logical-pathname-translations (?), namestring etc, parse-namestring, merge-pathnames. NOTE: Wording is kind of weird on some that do specify (e.g. logical-pathname-translations "If host is incorrectly supplied")
  20. directory, probe-file, ensure-directories-exist, truename, file-author, file-write-date, rename-file, delete-file, file-error-pathname
  21. peek-char, read-char, read-char-no-hang, terpri etc, unread-char, write-char, read-line, write-string etc, file-position, file-string-length, open, stream-external-format, with-open-file, close, with-open-stream, listen, y-or-n-p etc, synonym-stream-symbol, broadcast-stream-streams, two-way-strema-input-stream etc, echo-stream-input-stream etc, make-echo-stream, concatenated-stream-streams, get-output-stream-string, make-string-input-stream, make-string-output-stream, with-input-from-string, with-output-to-string
  22. formatter (?), pprint-fill etc, pprint-indent, pprint-newline, pprint-tab, print-unreadable-object, set-pprint-dispatch, write etc, write-to-string etc, print-not-readable-object, format
  23. copy-readtable, make-dispatch-macro-character, read etc, read-delimited-list, read-from-string, set-dispatch-macro-character etc, set-macro-character etc, set-syntax-from-char
  24. compile-file, compile-file-pathname, load, require (pathname-list parameter)
  25. decode-universal-time, encode-universal-time, apropos etc, describe, describe-object (?), trace etc (? does not evaluate), room (? could have implementation extensions), ed (ditto), dribble, user-homedir-pathname

Proposed organization: One issue for test functions (for sequences and some cons functions), since the concerns are basically identical for dozens of functions. One issue for arithmetic functions since implementation behavior may vary and there should be sufficient latitude to make things fast. Issues for special cases I've marked with parentheticals above not counted in the last two issues, and also special cases I've probably missed. One issue for miscellany, which could include dozens/hundreds of operators but basically uncontroversially (e.g. rest), or possibly break these down by chapter. The cases involving format controls might also be a good grouping?

This problem is pervasive enough that it may be simpler to redefine the meta parts to say that if "Arguments and values" restrictions are not met an error should be signaled (currently it's UB), but this could be too blunt an instrument. For example many functions operating on sequences only "should be prepared" to allow them to not have to traverse all lists unless they have to, and some operators could be stricter (mandated to signal errors even in unsafe code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment