Need an example using Ypsilon

I started talking with Ypsilon , which is an implementation of Schema in C ++.

It complies with R6RS , contains a fast garbage collector, supports multi-core processors and Unicode, but has LACK documentation, C ++ code examples and comments in the code!

The authors provide it as a standalone console application. My goal is to use it as a scripting engine in an image processing application.

The source code is well structured, but the structure is unfamiliar. I spent two weeks, and here is what I found out:

  • All communication with the outside world is carried out through C ++ structures called ports, they correspond to the ports of the Scheme.
  • The virtual machine has 3 ports: IN, OUT and ERROR.
  • Ports can be STD ports (via the console), socket ports, bytevector-ports, named-file-ports, and user ports.
  • Each user port must provide a populated structure called handlers.
  • Handlers are a vector containing 6 elements: the first is Boolean (whether the port is text), and the other five are function pointers (onRead, onWrite, onSetPos, onGetPos, onClose).

As far as I understand, I need to implement 3 user ports (IN, OUT and ERROR). But so far I can’t understand what the input parameters of each function (onRead, onWrite, onSetPos, onGetPos, onClose) are in the handlers.

Unfortunately, there is no example implementation of a user port without an example of the following material:

  • Associations of C ++ and Scheme functions (provided that the examples are .scm files, it is still unclear what to do on the C ++ side).
  •    bytecode ( bytevector-ports?   ?).

, - ++ , . !

+5
2

, , , ( , ):

  • : (lambda (bv off len)): bytevector ( ), (fixnum) (fixnum). len , bv off. ( fixnum).
  • : (lambda (bv off len)): bytevector ( ), (fixnum) (fixnum). len bv, off . ( fixnum).
  • : (lambda (pos)) ( ): pos, pos reset . .
  • : (lambda (pos)): pos. .
  • : (lambda ()): . .
+2

, , "-":

  • , compile. .
  • . run-vmi, .
  • , , auto-compile-cache.

heap/boot/eval.scm . ( , , ​​ .)

+2

All Articles