Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't use set-obj! on functions #18

Closed
jcubic opened this issue May 27, 2019 · 1 comment
Closed

Can't use set-obj! on functions #18

jcubic opened this issue May 27, 2019 · 1 comment
Labels
bug Something isn't working resolved
Milestone

Comments

@jcubic
Copy link
Owner

jcubic commented May 27, 2019

You can set prototype of a function when constructing class.

My attempt to create class macro:

(define-macro (define-class spec . body)
   (let* ((class (gensym))
          (constructor-s (string->symbol "constructor"))
          (constructor (find-first (lambda (x) (eq? (car x) constructor-s)) body)))
    `(let ((,class (lambda ,@(cdr constructor))))
        (set-obj! ,class 'prototype (--> Object (create ,(cadr spec))))
        (define-global ,(car spec) ,class))))

code:

 (set-obj! ,class 'prototype (--> Object (create ,(cadr spec))))

don't work you get error that function is not an object.

@jcubic
Copy link
Owner Author

jcubic commented May 27, 2019

it should use typecheck('set-obj!', obj, ['function', 'object']) Pair is also object according to object same as Macros.

@jcubic jcubic added the bug Something isn't working label May 27, 2019
@jcubic jcubic changed the title set-obj! should not test type of argument Can't use set-obj! on functions May 27, 2019
@jcubic jcubic closed this as completed Dec 1, 2019
@jcubic jcubic added this to the 1.0 milestone Dec 22, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working resolved
Projects
None yet
Development

No branches or pull requests

1 participant