unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* [modules] Possible return values of the env->type_of?
@ 2018-06-22 14:41 Kaushal Modi
  2018-06-22 17:10 ` Kaushal Modi
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Kaushal Modi @ 2018-06-22 14:41 UTC (permalink / raw)
  To: Help Gnu Emacs mailing list, Aurélien Aptel

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-12-25 16:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-22 14:41 [modules] Possible return values of the env->type_of? Kaushal Modi
2018-06-22 17:10 ` Kaushal Modi
2018-06-22 17:38 ` Aurélien Aptel
2018-06-22 17:52   ` Kaushal Modi
2018-06-22 18:16     ` Eli Zaretskii
2018-12-25 16:13     ` Philipp Stephani
2018-06-22 20:58   ` Drew Adams
2018-06-22 18:10 ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).