RE: using guile like a awk filter in a C program.

2024-06-10 Thread Maxime Devos via General Guile related discussions
>it looks ugly. Currently the user just define the 'filter' part and then I >include this string in a larger code. Ant how should I design this if I want >to include modules, custom functions,...  ? I propose replacing the interface for filter part by (lambda (record) [more code here]) and

Re: using guile like a awk filter in a C program.

2024-05-30 Thread Pjotr Prins
Note that the scheme shell (scsh) has an awk implementation using macros. Maybe the code helps: https://carlstrom.com/publications/scsh-manual.pdf On Fri, May 10, 2024 at 03:55:58PM +0200, Pierre LINDENBAUM wrote: > > Hi all, > > I tried to learn guile a few years ago with a side project that

Re: using guile like a awk filter in a C program.

2024-05-28 Thread Zelphir Kaltstahl
Hello Pierre, To me it looks like the easiest way could be to think of a declarative description of your filters and put that into a JSON file and read that as input (or similar file format), rather than using a whole programming language. Is there a specific requirement, that makes a JSON

Re: using guile like a awk filter in a C program.

2024-05-24 Thread Pierre Lindenbaum
I want to call scheme from C. The C loop scans the binary data and a scheme script would be used to accept/reject a record. Something like     ./my-c-program --filter '(and (is-male?) (is-german?) )' persons.data > male_from_germany.data - furthermore, what's the best practice to

Re: using guile like a awk filter in a C program.

2024-05-22 Thread Simon Tournier
Hi Pierre, > I want to call scheme from C. Well, I would start with: https://www.gnu.org/software/guile/manual/html_node/A-Sample-Guile-Main-Program.html Then maybe: https://www.gnu.org/software/guile/manual/html_node/General-Libguile-Concepts.html Personally, I have never done that. The

Re: using guile like a awk filter in a C program.

2024-05-21 Thread Basile Starynkevitch
Hello Pierre, (if you reply privately, feel free to reply in French, we both are French) You definitely could use libguile in your C program. Since Guile has a conservative garbage collector, and assuming your program is single-threaded, this should be reasonably easy. If your C program needs

Re: using guile like a awk filter in a C program.

2024-05-21 Thread Pierre Lindenbaum
Thanks for your answer - is it possible to use guile for such task ? More precisely, can I compile the guile script just once in `my_initialize_guile` and use it in the while loop without having to recompile it. I am not sure to well understand. Since, it could be read two ways: + Call

Re: using guile like a awk filter in a C program.

2024-05-21 Thread Simon Tournier
Hi, On Fri, 10 May 2024 at 15:55, Pierre LINDENBAUM wrote: > ``` > header = read_header(input); > guile_context = my_initialize_guile(header, argc_argv_user_script) > variant = new_variant(); > while(read_variant(input,header,variant)) { >