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

Class with LIPS types as props #411

Open
jcubic opened this issue Nov 10, 2024 · 1 comment
Open

Class with LIPS types as props #411

jcubic opened this issue Nov 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@jcubic
Copy link
Collaborator

jcubic commented Nov 10, 2024

Investigate this problem:

(define Person (class Object (constructor (lambda (self name age)
                                            (set! self.name name)
                                            (set! self.age age)))))

(define jack (new Person 'Jack 27))
jack.name
;; ==> "Jack"
(define jack (new Person 'Jack 27+i))
jack.age
;; ==> #(27 1)

The same problems is with records

(define-record-type <point>
  (make-point x y)
  point?
  (x get-x set-x!)
  (y get-y set-y!))

(define p (make-point +10i +20i))
(get-x p)
;; ==> #(0 10)

LIPS types are unboxed, but the should not. If the user wants to share a class with JavaScript it's his responsibility to not use native types.

@jcubic jcubic added the bug Something isn't working label Nov 10, 2024
@jcubic
Copy link
Collaborator Author

jcubic commented Nov 10, 2024

The problem is with new operator that unbox the arguments:

lips> (new (lambda (x) (print x)) 10+10i)
#(10 10)

I think that it's ok for the class to do this, but it should not happen with records.

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