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

Support for cl-vector->clj-vector conversions #13

Open
carkat opened this issue Apr 15, 2023 · 2 comments
Open

Support for cl-vector->clj-vector conversions #13

carkat opened this issue Apr 15, 2023 · 2 comments

Comments

@carkat
Copy link

carkat commented Apr 15, 2023

Is there a way presently to convert Common Lisp vectors to Clojure vectors? Especially the higher dimensional variety?

For instance

(require '[abclj.quicklisp :refer [quickload]])
(quickload :april)
(-> (with-cl `(april:april-c "1 2 3 + 1 2 3") .coptyToVec vec) 

Or something of the sort. I guess this method is only expecting list results from lisp, rather than the native CL vector type. Does there need to be some additional conversion functions written to handle vector types, or is there already something that supports this conversion?

Further, round tripping of values doesn't seem to be supported for CL vectors either.

CL-USER> (setq x (april:april-c "1 2 3 + 1 2 3"))
#(2 4 6)
CL-USER> x
#(2 4 6)
CL-USER> (april:april-c "{⍵+⍵}" x) ;; add vector x to itself using an april function
#(4 8 12)

In the above example, x is store, then passed into the next expression. but using clj, x is said to be an org.armedbear.lisp.SimpleVector and yet I can't pass it back into an expression expecting a lisp vector

abclj.core> (def x (with-cl '(april:april-c "1 2 3 + 1 2 3")))
;; => #'abclj.core/x
abclj.core> (with-cl `(april:april-c "{⍵+⍵}" ~x))
Execution error (UnhandledCondition) at abclj.java.AbcljUtils$2/execute (AbcljUtils.java:70).
Unhandled lisp condition: #<ERROR {1D4DD0A0}>
@cptjimkirk
Copy link

Don't know how to create ISeq from: org.armedbear.lisp.SimpleArray_ByteBuffer
Don't know how to create ISeq from: org.armedbear.lisp.SimpleVector

What I'm looking to find out is if there is something that can do a conversion on these types, or how I might do that on my end

@lsevero
Copy link
Owner

lsevero commented Apr 24, 2023

@carkat The easiest way to save the result in a variable and pass it to a CL context is actually to define a CL var and save it there.
example:

(abclj.core/setvar 'x (abclj.core/with-cl '(april:april-c "1 2 3 + 1 2 3")))
(abclj.core/with-cl `(april:april-c "{⍵+⍵}" x)) 

works just fine.

defining an 'x' variable on clj and passing it CL will return a JVM address to the function on CL and april absolutely will not be able to work on that.

But I think the request does make a lot of sense and it is worth to try to add support for org.armedbear.lisp.SimpleVector on the cl->clj conversion. I'll try to do it this week.

Repository owner deleted a comment from cyny39 Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants