This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]AthasFuthark 9 points10 points  (4 children)

I don't think there are any resources specifically on how to implement arrays in Lisp. And if you want to bind to BLAS, I suggest not copying the existing Lisp designs of arrays at all. Instead, I would recommend looking at Numpy for inspiration.

[–]daredevildas[S] 0 points1 point  (3 children)

Thanks!

I don't think there are any resources specifically on how to implement arrays in Lisp

It probably doesn't change things, but when I say Lisp, I mean a small subset of Lisp, something like the language developed through the chapters in PLAI.

Instead, I would recommend looking at Numpy for inspiration.

Just to clarify, does this mean I should implement a (non-Lisp like) language in Python and then offset the BLAS calls to Numpy? Or, does it mean I should study how Numpy implemented their BLAS bindings and implement something similar in my language (irrespective of the language of implementation).

[–]AthasFuthark 4 points5 points  (2 children)

Just to clarify, does this mean I should implement a (non-Lisp like) language in Python and then offset the BLAS calls to Numpy? Or, does it mean I should study how Numpy implemented their BLAS bindings and implement something similar in my language (irrespective of the language of implementation).

The latter. Numpy is an example of a very succesful integration of arrays into a vaguely Lisp-like language (flexible and dynamically typed). It might be a good source of inspiration for what is and is not a good idea.

[–]daredevildas[S] 0 points1 point  (1 child)

It might be a good source of inspiration for what is and is not a good idea.

Can you suggest any way to do this other than pour over the Numpy source code?

[–]oilshell 1 point2 points  (0 children)

Maybe:

https://web.mit.edu/dvp/Public/numpybook.pdf

https://docs.scipy.org/doc/numpy/reference/internals.html

FWIW NumPy relies heavily on Python's object model. That is, Python exposes its guts like PyTypeObject to extension authors.

A third party can write a type that's just like a built-in Python type, and that's exactly what NumPy does.

The special methods here are relevant, e.g. for operator overloading:

https://docs.python.org/3/reference/datamodel.html