rudolph-miller / jonathan

JSON encoder and decoder.
http://rudolph-miller.github.io/jonathan/overview.html
164 stars 24 forks source link

Proposal to remove the dependency on cl-annot #63

Open vindarel opened 4 years ago

vindarel commented 4 years ago

Hello,

I see that cl-annot is only used for the @doc annotation, for the usual defmacro, defgeneric and defvar forms, which all accept a docstring.

This prevents me from quickloading Jonathan in a project that uses pythonic-string-reader.

If there is no good reason to keep cl-annot, I'd like to remove them. Shall I?

Best,

svetlyak40wt commented 3 years ago

Byt the way, also seems annotations breaks code navigation. When I press v on the first stackframe:

Unexpected EOF found:
{"foo": 123.5.6}
   [Condition of type JONATHAN.ERROR:<JONATHAN-UNEXPECTED-EOF-ERROR>]

Restarts:
 0: [RETRY] Retry SLY mREPL evaluation request.
 1: [*ABORT] Return to SLY's top level.
 2: [ABORT] abort thread (#<THREAD "sly-channel-1-mrepl-remote-1" RUNNING {1002CB0503}>)

Backtrace:
 0: ((LABELS JONATHAN.DECODE::DISPATCH :IN JONATHAN.DECODE:PARSE) #<unavailable argument> #<unavailable argument>)
 1: (JONATHAN.DECODE:PARSE #<unavailable argument> :AS #<unavailable argument> :JUNK-ALLOWED #<unavailable argument> :KEYWORDS-TO-READ #<unavailable argument> :KEYWORD-NORMALIZER #<unavailable argument> :..
 2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (JONATHAN.DECODE:PARSE "{\"foo\": 123.5.6}") #<NULL-LEXENV>)
 3: (EVAL (JONATHAN.DECODE:PARSE "{\"foo\": 123.5.6}"))

SLY opens this form:

@doc
"LISP value of {}."
(defvar *empty-object-value* nil)
vindarel commented 3 years ago

I had a try here: https://github.com/ciel-lang/jonathan/commit/f7c971fc286bd5f8aeb970c26b11712ab6937f80

cl-annot is still required for progn-form-last and progn-form-replace-last (but without the reader syntax).

I stopped because of the use of cl-annot-prove in circle.yaml

    - run-annot-prove -p *-test.asd

(although it is actually not used in tests ?)

svetlyak40wt commented 3 years ago

BTW, @vindarel seem the problem you have is caused by inproper use of read table. Each package should use named-readtables to prevent such conflicts.

vindarel commented 3 years ago

mmh. pythonic-string-reader uses named-readtables. In my stacktrace I see a call to (CL-SYNTAX::%USE-SYNTAX (:CL-ANNOT)) which wants to (merge-readtables-into *readtable* syntax) ). I wonder if this expected behavior from cl-syntax, because here I didn't ask to use both syntaxes at the same time. cl-annot is used internally only to Jonathan.

svetlyak40wt commented 3 years ago

I see, cl-syntax copies the readtable before changing it:

(defun %use-syntax (names)
  (declare (type (or syntax-designator
                     (proper-list syntax-designator))
                 names))
  (unless (listp names)
    (setq names (list names)))
  (setq *readtable* (copy-readtable))
  (loop for name in names
        for syntax = (find-syntax name)
        for options = (get-options name)
        if (assoc :fuze (if (consp (car options)) options (cdr options))) do
          (handler-bind ((named-readtables:reader-macro-conflict
                            (lambda (_) (declare (ignore _))
                              (invoke-restart 'continue))))
             (merge-readtables-into *readtable* syntax) )
        else do
          (merge-readtables-into *readtable* syntax) )
  (when (find-package :swank)
    (named-readtables::%frob-swank-readtable-alist *package* *readtable*)))

Don't understand what problem do you have.

It would be nice if you create a minimal example to reproduce the problem.

vindarel commented 3 years ago

Sure, here it is: https://github.com/smithzvk/pythonic-string-reader/issues/3 if not the correct place, it should be a better place than jonathan's issue tracker.