sasagawa888 / eisl

ISLisp interpreter/compiler
Other
272 stars 22 forks source link

More detailed documentation on calling C code from lisp #256

Closed gtnoble closed 1 year ago

gtnoble commented 1 year ago

I am trying to make bindings for a C library, but I'm not sure how to handle the transfer of data. I was wondering if there could be more documentation on the functions in fast.h which are used to transfer data to and from C and Lisp.

sasagawa888 commented 1 year ago

OK. I will try.

gtnoble commented 1 year ago

Thank you Mr. Sasagawa.

On Wed, Mar 15, 2023, 9:02 PM kenichi sasagawa @.***> wrote:

OK. I will try.

— Reply to this email directly, view it on GitHub https://github.com/sasagawa888/eisl/issues/256#issuecomment-1471165578, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQPYO4XXO552OUXDGUZ5EJDW4JYCPANCNFSM6AAAAAAV4ROK6U . You are receiving this because you authored the thread.Message ID: @.***>

sasagawa888 commented 1 year ago

I wrote a simple document. I am not a native English speaker. Please correct it to proper English. I would appreciate it if you could supplement the description.

documents)/INTERFACE-LISPtoC.md

gtnoble commented 1 year ago

I would be glad to. I'm starting on it now.

gtnoble commented 1 year ago

What is meant by "suppress the cell consumption of small integers"?

gtnoble commented 1 year ago

I put in a PR with the cleaned up documentation. Let me know if anything is incorrect.

sasagawa888 commented 1 year ago

Thank you for your clean up documentation.

Originally, all small integers in Easy-Lisp consisted of cells. For example, (+ 1 2) would create cells 1, 2, and 3. When doing a lot of recursive calculations, many cells are created. They are then reclaimed by garbage collection. This is inefficient. Therefore, I changed the method to create a small integer without using cells. It's called an immediate value. Integers in C are represented by 64 bits. The highest 1bit is 1 when the number is negative. If the second most significant bit is 1, it's a positive small integer in Lisp, and if it's a negative number, it's a negative small integer in Lisp. Since the cell area is 0 to 20,000,000, numbers outside that range mean small integers.

gtnoble commented 1 year ago

Thank you for your explanation. I plan to add more documentation later about accessing pointers, floating point numbers, long integers, and lists.