Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json Lisp宏-如何正确输入类型_Json_Macros_Lisp - Fatal编程技术网

Json Lisp宏-如何正确输入类型

Json Lisp宏-如何正确输入类型,json,macros,lisp,Json,Macros,Lisp,我不熟悉宏,并且在JSON-RPC宏的需求中苦苦挣扎 它要求输入一个类型,我不知道如何正确输入 (defmacro defun-json-rpc (name type lambda-list &body body) "Defines a function and registers it as a json-rpc target." (unless (json-rpc-encoding-p type) (error "New version of defun

我不熟悉宏,并且在JSON-RPC宏的需求中苦苦挣扎

它要求输入一个类型,我不知道如何正确输入

(defmacro defun-json-rpc (name type lambda-list &body body)
  "Defines a function and registers it as a json-rpc target."   
   (unless (json-rpc-encoding-p type)    
   (error "New version of defun-json-rpc requires a TYPE argument"))   
  `(progn    
     (defun ,name ,lambda-list ,@body)   
     (export-as-json-rpc ',name (lisp-to-camel-case (symbol-name ',name)) ,type)))
下面是我找到的一段示例代码,但它不包含类型参数:

(json-rpc:defun-json-rpc add (x y)
  (+ x y))

如何输入类型?

找到了它。它是JSON-RPC特定的关键字,而不是lisp类型。我只需要查看json-rpc-encoding-p,看看只有3个关键字是有效的

(defgeneric json-rpc-encoding-p (keyword)
  (:documentation "Is KEYWORD a valid JSON-RPC value encoding?")
  (:method (keyword)
     "Default is no."
     (declare (ignore keyword))
      nil)
  ;;; built-in methods
  (:method ((keyword (eql :guessing)))
    t)
  (:method ((keyword (eql :streaming)))
    t)
  (:method ((keyword (eql :explicit)))
    t))

除非json-rpc-encoding-p类型错误…?纠正了这个问题。我使用的代码已经存在了。请确保将您的答案标记为已接受。如果你能详细说明一下,它可能会帮助其他用户。