-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add (LispArray :t)
, add specialized representations of LispArray
and Complex
#1015
Conversation
I thought maybe something like
as syntax for specific parameter specializations. Maybe could be more flexible by binding lambda functions or something, but I'm not sure it needs to be that ostentatious. |
I would prefer to hard code these in |
Within the Common Lisp builtins, the number of cases is small. But the extensibility looks important in the wider lisp ecosystem, although you can achieve the same things with a typeclass (?). For example, one use case I imagine is defining a parametric coalton type with runtime representations given by magicl's tensor types. This way, a parametric coalton type |
In that case you should use a type class. The type isn't really parametric because it can't be instantiated with arbitrary types. |
I had a circularity issue: LISP-TYPE doesn't know about COMPLEX yet. Do you have any suggestions? (I also started to sketch a language feature, but I thought it was too cumbersome for just a couple specialized parametric types, like complexes and simple-arrays.) |
Use find-symbol. We do it in a couple places already. |
144528c
to
5ac9122
Compare
(Complex :t)
(LispArray :t)
, add specialized representations of LispArray
and Complex
The |
fcec26b
to
fc02ad5
Compare
fc02ad5
to
8262d52
Compare
f66e728
to
09fd6e4
Compare
09fd6e4
to
000803f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super cool! Just a few small nits
|
||
These arrays are represented as possibly specialized `(cl:simple-array <type> (cl:*))` and are meant to be used as a tool either to interface with Lisp code or to implement efficient data structures. One should consult `Vector` or `Seq` for more general sequential data structure needs. | ||
|
||
Whether or not the arrays are specialized depends on the underlying Lisp implementation. Consult `cl:upgraded-array-element-type` to determine whether `LispArray` may get specialized.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible/useful to add a specialized?
function which checks this within Coalton?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would this check, the array object itself? A type?
000803f
to
eb6cb51
Compare
@colescott I addressed everything except |
@@ -25,11 +25,18 @@ | |||
(cl:declaim #.coalton-impl/settings:*coalton-optimize-library*) | |||
|
|||
(coalton-toplevel | |||
(repr :native (cl:or cl:number complex)) | |||
;; The representation of (Complex :t) is specially dealt with by the | |||
;; compiler in lisp-type.lisp. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably change lisp-type.lisp
to src/typechecker/lisp-type.lisp
.
(coalton-toplevel
(define (make-u8-array size)
(the (LispArray U8) (make-uninitialized size)))) instead of requiring the user to write the slightly esoteric (coalton-toplevel
(define (make-u8-array size)
(make-uninitialized size (the (proxy u8) proxy))))
|
((member lisp-to | ||
*specialized-complex-part-types-considered* | ||
:test #'lisp-type=) | ||
`(cl:complex ,lisp-to)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the cl:
is unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i put it there since there's a coalton/whatever:complex, and this file deals with both lisp types and coalton tycons
b0720cc
to
667d133
Compare
This commit does two main things: 1. Adds (LispArray :t). There are presently no constructors for it, but there is logic to emit appropriately specialized (SIMPLE-ARRAY <t> (*)) declarations in many common monomorphic cases. 2. Handles the repr of (Complex :t) specially from LISP-TYPE so that more specific type declarations are emitted for floating point types.
667d133
to
79d087f
Compare
This PR does three things:
LispArray
type to match the semantics of(simple-array <t> (*))
. I think this is a good compromise between my concerns and @eliaslfox's suggestions. The nameLispArray
was chosen intentionally to emphasize this behavior, and not place itself as a "competitor" toVector
orSeq
.(Complex :t)
type.(LispArray :t)
type.Addresses #1008 in principle.