How do we implement Ratio
and Complex
?
#155
Replies: 5 comments
-
See also |
Beta Was this translation helpful? Give feedback.
-
I don't think Ratio is an issue once #51 is solved due to the reduction of those to integers being the first thing that happens, which would then have something like ((Num :a) => :a) for their type, and ratios must have an instance of Num to implement Fractional. |
Beta Was this translation helpful? Give feedback.
-
I think @stylewarning is referring to the fact that SBCL will convert |
Beta Was this translation helpful? Give feedback.
-
Yes: CL-USER> 4/3
4/3
CL-USER> (type-of *)
RATIO
CL-USER> 4/2
2
CL-USER> (type-of *)
(INTEGER 0 4611686018427387903)
CL-USER> #C(2 1)
#C(2 1)
CL-USER> (type-of *)
(COMPLEX (INTEGER 1 2))
CL-USER> #C(2 0)
2
CL-USER> (type-of *)
(INTEGER 0 4611686018427387903) |
Beta Was this translation helpful? Give feedback.
-
Ah, sorry, I misunderstood the issue. It might just be best to represent these as a datatype like in Haskell, and handle this in the codegen? |
Beta Was this translation helpful? Give feedback.
-
There is difficulty in implementing these as native Lisp objects, because:
Problem 1: reduction of
#C(k 0)
tok
; ork/1
tok
Problem 2: Lisp doesn't allow arbitrary field elements as components (
Complex :a
cannot use Lisp's complex numbers)How do we implement
Complex Single-Float
as specialized on(COMPLEX SINGLE-FLOAT)
, but also allowNum :a => Complex :a
to exist?Beta Was this translation helpful? Give feedback.
All reactions