From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lars Brinkhoff Newsgroups: gmane.emacs.devel Subject: Re: RFC: User-defined pseudovectors Date: Thu, 10 Oct 2013 18:30:38 +0200 Organization: nocrew Message-ID: <8561t5cclt.fsf@junk.nocrew.org> References: <85k3hlcqvm.fsf@junk.nocrew.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1381422668 12872 80.91.229.3 (10 Oct 2013 16:31:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Oct 2013 16:31:08 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 10 18:31:12 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUJ8n-0003Np-81 for ged-emacs-devel@m.gmane.org; Thu, 10 Oct 2013 18:31:09 +0200 Original-Received: from localhost ([::1]:49336 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUJ8m-0002ZG-RI for ged-emacs-devel@m.gmane.org; Thu, 10 Oct 2013 12:31:08 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54622) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUJ8f-0002Yo-2K for emacs-devel@gnu.org; Thu, 10 Oct 2013 12:31:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUJ8W-0004Qc-JI for emacs-devel@gnu.org; Thu, 10 Oct 2013 12:31:00 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:34447) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUJ8W-0004QW-CU for emacs-devel@gnu.org; Thu, 10 Oct 2013 12:30:52 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VUJ8U-0003AW-Se for emacs-devel@gnu.org; Thu, 10 Oct 2013 18:30:50 +0200 Original-Received: from c-4957e555.012-14-67626717.cust.bredbandsbolaget.se ([85.229.87.73]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Oct 2013 18:30:50 +0200 Original-Received: from lars by c-4957e555.012-14-67626717.cust.bredbandsbolaget.se with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 10 Oct 2013 18:30:50 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 35 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: c-4957e555.012-14-67626717.cust.bredbandsbolaget.se User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) Cancel-Lock: sha1:bMh5TCzj2QvyrF1NvHmDOrkJ9ek= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164066 Archived-At: Stefan Monnier writes: > I'm not sure I understand the difference between your proposal and > cl-defstruct. The only difference I can see is that `vectorp' > returns nil on your new objects (well, type-of also changes, but > that is so rarely used that it's basically irrelevant). The difference in return value from functions like vectorp and type-of is the entire point, actually. > Oh, and there's a new print syntax for those objects. If it simplifies anything, that can be ignored for the moment. I just hacked something up on a whim. > What is the benefit? The benefit is that the types of these "typed pseudovectors" should be disjoint from all previously existing types. So e.g. this would be guaranteed to work, even if someone passes [foo] to frob. (cl-defstruct foo ...) (defun frob (x) (cond ((vectorp x) (frob-vector x)) ((foop x) (frob-foo x)))) In the case of an FFI, a wrapper may want to be able to pass a vector or a "struct" (something like a pseudovector) to Emacs, and have Lisp code be able to tell the difference. Or in my case, I have an implementation of Common Lisp written in Emacs Lisp, and it would be very nice if the Emacs Lisp vector type could also be the Common Lisp type vector. Instead I have to overload many Common Lisp types on top of the Emacs Lisp vector.