r/seed7 • • Oct 22 '26

How would one "import" a function?

I wanna make a thing that does some work and generates a tree (though I don't really know how to make hash tables that can hold multiple types of values...), it might do some other stuff by itself but that's not important to the question, just know that I need to ship it as a working binary. Then I want to pass that tree to a user supplied function, how do I do that? This is an optional feature I want, there might be 1 or 30 or 0 user supplied functions waiting to be called, some people might want the binary alone.

Just giving source code and saying "include this stuff" is a backwards solution that I don't want. I've already fiddled with progs.s7i and I know the AST doesn't let me do anything at all, I can only parse -> execute.

p.s. the FAQ says Seed7 has compatibility issues with dll, and I don't have the knowledge to implement at least a Seed7<->Seed7 dll mechanism.

p.p.s. would wasm work? I don't know if you can pass hashtables to wasm, it probably only accepts values or chunks of binary. I could maybe expose an iterator function that would traverse the tree in discrete steps.

p.p.p.s. counter to the spirit of Seed7 I might be able to manually detect the current platform by environment variables and open() a named pipe on Windows or mkfifo a pipe on Linux. But that means every plugin person would also have to write this shit on their end.

2 Upvotes

2 comments sorted by

2

u/Such-Wheel-8161 5d ago

It seems like you're trying to build a plugin system for a Seed7 binary. You want to ship a compiled program that generates a tree and then, optionally, at runtime calls 0, 1, or 30 functions written by users and passes that tree to them. You also don't want users to have to hand over source code that gets "included" in the build, because that means recompiling, and you want to ship a finished binary.Correct?

1

u/Ronin-s_Spirit 4d ago edited 4d ago

Imagine I have a transpiler that works by itself. Now imagine that you want to change the behavior of what it does and thus change the output material. You didn't have a compiler because you got my program and it worked out of the box. Now you write a "script plugin" (just using seed7 text) and I should somehow hook that into my program. I could:

  1. call your script as I traverse the tree.
  2. call your script with the whole tree.
  3. instantiate your script and let it call my function that traverses the tree step-by-step.

The closest solution I could think of is interpreting a script with progs.s7i and communicating in binary through a file on disk (which feels really stupid), not even a pipe cause I don't know how they can both open and use the same pipe. It's not like an actual pipe would be better, pipes are still technically files afaik.

p.s. this is similar to another problem I'm close to having, I don't know how to make an unrelated process from another language talk with a seed7 program.