[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RFC: User-defined pseudovectors
From: |
Lars Brinkhoff |
Subject: |
Re: RFC: User-defined pseudovectors |
Date: |
Thu, 10 Oct 2013 18:30:38 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) |
Stefan Monnier <address@hidden> 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.
- RFC: User-defined pseudovectors, Lars Brinkhoff, 2013/10/10
- Re: RFC: User-defined pseudovectors, Lars Brinkhoff, 2013/10/10
- Re: RFC: User-defined pseudovectors, Dmitry Antipov, 2013/10/10
- Re: RFC: User-defined pseudovectors, Stefan Monnier, 2013/10/10
- Re: RFC: User-defined pseudovectors,
Lars Brinkhoff <=
- Re: RFC: User-defined pseudovectors, Stefan Monnier, 2013/10/10
- Re: RFC: User-defined pseudovectors, Lars Brinkhoff, 2013/10/11
- Re: RFC: User-defined pseudovectors, Stefan Monnier, 2013/10/11
- User-defined record types, Lars Brinkhoff, 2013/10/12
- Re: User-defined record types, Stefan Monnier, 2013/10/15
- Re: User-defined record types, Ted Zlatanov, 2013/10/18
- Re: User-defined record types, Stefan Monnier, 2013/10/18
- Re: User-defined record types, Ted Zlatanov, 2013/10/18
- Re: User-defined record types, Stefan Monnier, 2013/10/18
- RE: User-defined record types, Drew Adams, 2013/10/18