Skip to content
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

(Complex Single-Float) should have a repr CL::(COMPLEX SINGLE-FLOAT) #1008

Open
stylewarning opened this issue Oct 6, 2023 · 4 comments
Open
Labels
codegen Coalton -> Lisp enhancement New feature or request performance standard library

Comments

@stylewarning
Copy link
Member

The current implementation is not wrong, but the repr is (COMMON-LISP:OR COMMON-LISP:NUMBER C:COMPLEX), which means any sort of (Lisp) compiler optimization is hosed. This is basically the same issue as specialized arrays, but doesn't deserve as much ceremony as specialized arrays, and there are only two specialized types worth caring about: singles and doubles. We should work to make Coalton emit these specialized types.

@stylewarning stylewarning added enhancement New feature or request performance standard library codegen Coalton -> Lisp labels Oct 6, 2023
@digikar99
Copy link

How easy or difficult would it be to make specialize work for types? For example -

(in-package :coalton-user)

(coalton-toplevel
  (repr :native (or cl:number (cl:complex *)))
  (define-type (complx :a)))

(coalton-toplevel
  (repr :native (cl:complex single-float))
  (define-type complx/single-float)
  (specialize complx complx/single-float (complx single-float)))

Currently, the above results in an error that complx is an unknown function or variable. But if specialize also worked for types, then the case of complex as well as specialized-vectors/arrays seems solved (?).

@stylewarning
Copy link
Member Author

@digikar99 I think we can have something similar-ish, where at the definition of complx we can specify different ways :a substitutions can lead to optimized representations. See the draft PR for example details where a proof of concept of the mechanics were implemented, but the syntax is still TBD.

@digikar99
Copy link

Yup, this looks good!

On a sidenote, I wonder if coalton should have tagged versions, and/or separate main and dev branches to avoid breaking things for coalton users.

@stylewarning
Copy link
Member Author

Yup, this looks good!

On a sidenote, I wonder if coalton should have tagged versions, and/or separate main and dev branches to avoid breaking things for coalton users.

Eventually we'll tag versions when things sort of converge. We know we can't keep breaking things forever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Coalton -> Lisp enhancement New feature or request performance standard library
Projects
None yet
Development

No branches or pull requests

2 participants