[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[modules] Possible return values of the env->type_of?
From: |
Kaushal Modi |
Subject: |
[modules] Possible return values of the env->type_of? |
Date: |
Fri, 22 Jun 2018 10:41:35 -0400 |
Hello,
What are all the possible return values of the type_of function in the
Dynamic Modules API?
I am playing with Nim Emacs Modules[1], and interestingly the symbol
returned by type_of for lists is 'cons too.
>From [2]:
(ert-deftest modtest-get-type ()
(should (eq 'string (modtest-get-type "abc")))
(should (eq 'integer (modtest-get-type 42)))
(should (eq 'float (modtest-get-type 42.0)))
(should (eq 'symbol (modtest-get-type nil)))
(should (eq 'symbol (modtest-get-type t)))
(should (eq 'symbol (modtest-get-type '())))
(should (eq 'cons (modtest-get-type (cons 1 2))))
(should (eq 'cons (modtest-get-type '(1 . 2))))
(should (eq 'cons (modtest-get-type '(1 2 3)))) ;Interestingly, this is a
"cons" too.
(should (eq 'cons (modtest-get-type (list 1 2 3))))) ;.. and this too!
Below code[3] is in Nim that creates that Elisp modtest-get-type function;
it's a light wrapper that calls the type_of Modules API function:
emacs.defun(get_type, 1):
## Returns the Emacs-Lisp symbol of the argument type.
env.type_of(env, args[0])
Is this expected? I was expecting the type symbol returned for the last two
tests above to be 'list.
[1]: https://github.com/kaushalmodi/nim-emacs-module
[2]:
https://github.com/yuutayamada/nim-emacs-module/blob/f7ee0c886c67707612c6b2a62f17025b083e2aca/test/test-modtest.el#L30-L40
[3]:
https://github.com/yuutayamada/nim-emacs-module/blob/f7ee0c886c67707612c6b2a62f17025b083e2aca/test/modtest.nim#L161-L163
--
Kaushal Modi
- [modules] Possible return values of the env->type_of?,
Kaushal Modi <=