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

In repl coalton:Coalton macro: Single-Float automatically converts to Double-Float #1073

Open
Izaakwltn opened this issue Mar 22, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Izaakwltn
Copy link
Collaborator

When using coalton:coalton in the repl, single floats are automatically converted to Double-Floats.

This behavior doesn't happen with coalton-codegen or coalton-toplevel.

Most likely a reader error.

COALTON-USER> (coalton 1.0d0)
1.0d0
COALTON-USER> (coalton 1.0)
1.0d0
COALTON-USER> (coalton 1.0f0)
1.0d0
COALTON-USER> (coalton-toplevel (define x 1.0f0)) ;; this works correctly
; No value
COALTON-USER> (type-of 'x)
SINGLE-FLOAT
COALTON-USER> cl:*read-default-float-format*
COMMON-LISP:SINGLE-FLOAT

Here is the behavior after changing cl:*read-default-float-format* to other floating-point types:

;; setting to long-float
COALTON-USER> (cl:setq  cl:*read-default-float-format* 'cl:long-float)
COMMON-LISP:LONG-FLOAT
COALTON-USER> (coalton:coalton 1.0f0)
1.0f0
COALTON-USER> (coalton:coalton 1.0d0)
1.0
COALTON-USER> (coalton:coalton 1.0l0)
1.0
;; setting to double-float
COALTON-USER> (cl:setq  cl:*read-default-float-format* 'cl:double-float)
COMMON-LISP:DOUBLE-FLOAT
COALTON-USER> (coalton:coalton 1.0f0)
1.0f0
COALTON-USER> (coalton:coalton 1.0d0)
1.0
COALTON-USER> (coalton:coalton 1.0l0)
1.0

(development mode on SBCL)

@Izaakwltn Izaakwltn added the bug Something isn't working label Mar 22, 2024
@Izaakwltn
Copy link
Collaborator Author

One other case:

COALTON-USER> (coalton (the single-float 1.0))
error: Type mismatch
  --> COALTON (NIL):1:9
   |
 1 |  (COALTON (THE SINGLE-FLOAT 1.0))
   |           ^^^^^^^^^^^^^^^^^^^^^^ Declared type 'SINGLE-FLOAT' does not match inferred type 'DOUBLE-FLOAT'
   [Condition of type COALTON-IMPL/TYPECHECKER/BASE:TC-ERROR]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant