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: RFC: User-defined pseudovectors Date: Thu, 10 Oct 2013 13:22:21 +0200 Organization: nocrew Message-ID: <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 1381404166 27102 80.91.229.3 (10 Oct 2013 11:22:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 10 Oct 2013 11:22:46 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 10 13:22:50 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 1VUEKP-0003eY-W3 for ged-emacs-devel@m.gmane.org; Thu, 10 Oct 2013 13:22:50 +0200 Original-Received: from localhost ([::1]:46379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUEKP-0000je-J1 for ged-emacs-devel@m.gmane.org; Thu, 10 Oct 2013 07:22:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42758) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUEKF-0000jY-K1 for emacs-devel@gnu.org; Thu, 10 Oct 2013 07:22:46 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUEK8-0003Fk-9M for emacs-devel@gnu.org; Thu, 10 Oct 2013 07:22:39 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:38081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUEK8-0003FX-1C for emacs-devel@gnu.org; Thu, 10 Oct 2013 07:22:32 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1VUEK7-0003Sj-7H for emacs-devel@gnu.org; Thu, 10 Oct 2013 13:22:31 +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 13:22:31 +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 13:22:31 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 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:iVFCgdbwMfGpn+5mVlN09O/lCFM= 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:164058 Archived-At: Hello, With the current FFI discussion, this may be a good time to ask for input on a Lisp extension I have lying around. Some FFI bindings may want to introduce new Lisp types. My idea is that this should be possible to do in Lisp, not just in C. This might also be useful in other situations, e.g. - Future new pseudovector types can be defined in Lisp. - Lisp code can potentially interoperate more easily with code in other languages. Existing languages for Emacs include JavaScript (Ejacs), Python (Pymacs), Ruby (El4r), Perl (EPL), Smalltalk (Eoops), Common Lisp (Emacs Common Lisp). - Possibly cl-defstruct can be extended to make new types if so requested. The gist of my patch is to add a new type of pseudovector which is like a normal vector, except the first element holds a symbol which is its Lisp type. So type-of returns whatever is in the first slot. This may sound slightly reckless, and probably is. It's just a first shot. Sample session: (let ((x (make-typed-pseudovector 3 'foo nil))) (aset x 1 1) (aset x 2 2) (aset x 3 3) (list (read-from-string (with-output-to-string (prin1 x))) (typed-pseudovector-p x) (type-of x) (aref x 0) (aref x 3) (length x))) => ((#%[foo 1 2 3] . 13) t foo foo 3 4)