all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Kaushal Modi <kaushal.modi@gmail.com>
To: "Help Gnu Emacs mailing list" <help-gnu-emacs@gnu.org>,
	"Aurélien Aptel" <aurelien.aptel@gmail.com>
Subject: [modules] Possible return values of the env->type_of?
Date: Fri, 22 Jun 2018 10:41:35 -0400	[thread overview]
Message-ID: <CAFyQvY2coP24Od7Kvop_67JPNzRDtkAfAUCX4sxbnjapFYpzTw@mail.gmail.com> (raw)

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


             reply	other threads:[~2018-06-22 14:41 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 14:41 Kaushal Modi [this message]
2018-06-22 17:10 ` [modules] Possible return values of the env->type_of? 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFyQvY2coP24Od7Kvop_67JPNzRDtkAfAUCX4sxbnjapFYpzTw@mail.gmail.com \
    --to=kaushal.modi@gmail.com \
    --cc=aurelien.aptel@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.