Re: csm static build fails on yaml egg

2022-06-11 Thread Matt Welland
Ok. csm is helpful but not a magic bullet. I assumed that because "csm
-program yamltest" worked without additional switches etc I could merely
add -static to get a static build. Adding all.options and yamltest.options
with the needed info works:

cat all.options
-program yamltest -C -I/usr/include

cat yamltest.options
L -L/usr/lib/x86_64-linux-gnu -L -lyaml -static -L -static -L -lm -L
-ldl> ldd yamltest

$ file yamltest
yamltest: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux),
statically linked, for GNU/Linux 3.2.0,
BuildID[sha1]=642844535ad617a9378ce2ff7a7616e74dcdd940, not stripped

Thanks Felix.

On Sat, Jun 11, 2022 at 4:32 PM  wrote:

> > This is on ubuntu, chicken 5.3:
> >
> > Test code:
> > (module yamltest *
> > (import scheme
> > chicken.string
> > yaml)
> > (write (yaml-load "test.yaml")))
> >
> > > csm -static -program yamltest
> >   '/home/ubuntu/data/buildall/w23-0-ck5.3/bin/csc' '-o' 'yamltest' '-I'
> > '/home/ubuntu/data/opensrc/testsnips/yaml_static' '-C' '-I' '-C'
> > '/home/ubuntu/data/opensrc/testsnips/yaml_static' '-static'
> > '/home/ubuntu/data/opensrc/testsnips/yaml_static/yamltest.scm'
> > /home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
> > `f_3911':
> > yaml.static.c:(.text+0xae1c): undefined reference to `yaml_parser_delete'
> > yaml.static.c:(.text+0xae48): undefined reference to `yaml_parser_delete'
>
> Does this egg require an external library to be linked? It looks like it
> does. You need to add that.
>
>
> felix
>
>

-- 
--
Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.


Re: csm static build fails on yaml egg

2022-06-11 Thread felix . winkelmann
> This is on ubuntu, chicken 5.3:
>
> Test code:
> (module yamltest *
> (import scheme
> chicken.string
> yaml)
> (write (yaml-load "test.yaml")))
>
> > csm -static -program yamltest
>   '/home/ubuntu/data/buildall/w23-0-ck5.3/bin/csc' '-o' 'yamltest' '-I'
> '/home/ubuntu/data/opensrc/testsnips/yaml_static' '-C' '-I' '-C'
> '/home/ubuntu/data/opensrc/testsnips/yaml_static' '-static'
> '/home/ubuntu/data/opensrc/testsnips/yaml_static/yamltest.scm'
> /home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
> `f_3911':
> yaml.static.c:(.text+0xae1c): undefined reference to `yaml_parser_delete'
> yaml.static.c:(.text+0xae48): undefined reference to `yaml_parser_delete'

Does this egg require an external library to be linked? It looks like it
does. You need to add that.


felix




Re: How best to get a default result from sqlite3, or to use or not use first-result?

2022-06-11 Thread Matt Welland
Thanks all for the perspectives. Clearly I misinterpreted the intent of the
design of first-result. I'll use one of the provided options. Thomas, an
enhancement to the sqlite3 egg would be great if you get a chance.

Matt
-=-

On Thu, Jun 9, 2022 at 2:34 AM Thomas Chust  wrote:

> Hello Matt,
>
> it may be a bit of an oversight that no such procedure exists in the
> SQLite3 egg, but you could define something like this:
>
> (define (one-result/default default db sql . parameters)
>   (call-with-temporary-statements
> (lambda (stmt)
>   (apply bind-parameters! stmt parameters)
>   (if (step! stmt)
> (column-data stmt 0)
> default))
> db sql))
>
> [untested, and leaving the usual "overloads" for statement objects vs. SQL
> source as an exercise to the reader ]
>
> Ciao,
> Thomas
>
>
> Am Mi., 8. Juni 2022 um 20:10 Uhr schrieb Matt Welland :
>
>> The problem: retrieve one value from a query, if there is no matching
>> row return a default.
>>
>> Method 1: use for-each-row, overwrite the default with found values
>> Method 2: use first-result, on exception return the default
>> Method 3: use fold-row (wasn't an option when I first wrote the code)
>>
>> My question is, which of these is the "right" way to do what I want? Is
>> there another, better, way? Note that method #2 has problems in my
>> program but it might be due to my using chicken 4.10 (for now).
>>
>> ==additional details==
>>
>> Method 1, for-each-row, was my original approach and seemed to work
>> fine.
>>
>> Then, in the midst of a major rewrite I tried to use first-result. It
>> seemed odd to me to use an exception this way but I assumed (wrongly?)
>> it was a fancy software engineery way to do things since the sqlite3
>> egg did not provide any direct way to do what I want.
>>
>> However I hit a strange scalability issue with database locks happening
>> only a few hours into a run. After a lot of fruitless debug and on a
>> hunch, I replaced the first-result with a for-each-row and now am able
>> to run ten of thousands of tests over many hours (still not perfect,
>> work progresses).
>>
>> I plan to replace use of for-each-row with something like:
>>
>> (define (get-id db name default)
>>   (fold-row (lambda (row)
>>   (car row))
>> #f
>> db "SELECT id FROM tests WHERE testname=?" name))
>>
>> Thanks.
>>
>>
>>

-- 
--
Complexity is your enemy. Any fool can make something complicated.
It is hard to keep things simple. - Richard Branson.


csm static build fails on yaml egg

2022-06-11 Thread Matt Welland
This is on ubuntu, chicken 5.3:

Test code:
(module yamltest *
(import scheme
chicken.string
yaml)
(write (yaml-load "test.yaml")))

> csm -static -program yamltest
  '/home/ubuntu/data/buildall/w23-0-ck5.3/bin/csc' '-o' 'yamltest' '-I'
'/home/ubuntu/data/opensrc/testsnips/yaml_static' '-C' '-I' '-C'
'/home/ubuntu/data/opensrc/testsnips/yaml_static' '-static'
'/home/ubuntu/data/opensrc/testsnips/yaml_static/yamltest.scm'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3911':
yaml.static.c:(.text+0xae1c): undefined reference to `yaml_parser_delete'
yaml.static.c:(.text+0xae48): undefined reference to `yaml_parser_delete'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3542':
yaml.static.c:(.text+0xb15c): undefined reference to `yaml_event_delete'
yaml.static.c:(.text+0xb188): undefined reference to `yaml_event_delete'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3758':
yaml.static.c:(.text+0xb597): undefined reference to
`yaml_mapping_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3708':
yaml.static.c:(.text+0xb884): undefined reference to
`yaml_sequence_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3664':
yaml.static.c:(.text+0xbb12): undefined reference to
`yaml_scalar_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2045':
yaml.static.c:(.text+0xbedb): undefined reference to `yaml_emitter_delete'
yaml.static.c:(.text+0xbf07): undefined reference to `yaml_emitter_delete'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3905':
yaml.static.c:(.text+0xd9d5): undefined reference to
`yaml_parser_initialize'
yaml.static.c:(.text+0xd9e1): undefined reference to
`yaml_parser_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3561':
yaml.static.c:(.text+0xda7f): undefined reference to `yaml_emitter_emit'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2100':
yaml.static.c:(.text+0xdc02): undefined reference to
`yaml_document_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2256':
yaml.static.c:(.text+0xe1b1): undefined reference to
`yaml_mapping_end_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2075':
yaml.static.c:(.text+0xe274): undefined reference to
`yaml_stream_end_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2228':
yaml.static.c:(.text+0xe337): undefined reference to
`yaml_sequence_end_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2268':
yaml.static.c:(.text+0xe5d6): undefined reference to
`yaml_alias_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3762':
yaml.static.c:(.text+0xe6ca): undefined reference to
`yaml_mapping_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3712':
yaml.static.c:(.text+0xe7be): undefined reference to
`yaml_sequence_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2172':
yaml.static.c:(.text+0xe8a4): undefined reference to
`yaml_document_end_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_2063':
yaml.static.c:(.text+0xe98b): undefined reference to
`yaml_stream_start_event_initialize'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_1969':
yaml.static.c:(.text+0xea5c): undefined reference to
`yaml_emitter_initialize'
yaml.static.c:(.text+0xea79): undefined reference to
`yaml_emitter_initialize'
yaml.static.c:(.text+0xea85): undefined reference to
`yaml_emitter_set_unicode'
yaml.static.c:(.text+0xea91): undefined reference to
`yaml_emitter_set_indent'
yaml.static.c:(.text+0xeaa2): undefined reference to
`yaml_emitter_set_unicode'
yaml.static.c:(.text+0xeac0): undefined reference to
`yaml_emitter_set_indent'
yaml.static.c:(.text+0xeb04): undefined reference to
`yaml_emitter_set_output_file'
yaml.static.c:(.text+0xeb53): undefined reference to
`yaml_emitter_set_output_file'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3006':
yaml.static.c:(.text+0xece4): undefined reference to
`yaml_parser_set_input_file'
yaml.static.c:(.text+0xedda): undefined reference to
`yaml_parser_set_input_string'
/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o: In function
`f_3302':
yaml.static.c:(.text+0xfaa0): undefined reference to `yaml_parser_parse'
collect2: error: ld returned 1 exit status

Error: shell command terminated with non-zero exit status 256: 'gcc'
'yamltest.o' '/home/ubuntu/data/buildall/w23-0-ck5.3/lib/chicken/11/yaml.o'

Re: LSP Server for CHICKEN (and more ...)

2022-06-11 Thread Mario Domenech Goulart
Hi Ricardo,

On Sat, 11 Jun 2022 12:09:05 + "Ricardo G. Herdt"  wrote:

> I mentioned my work on an LSP server for Scheme a while ago. For those
> that don't know the Language Server Protocol (LSP), it is meant for 
> adding programming language support for IDEs and editors that
> implement the protocol (nowadays most of them support it). After a
> long pause period due to private reasons, I finally managed to get it
> into a working state, so here my results:
>
> 1) You can find the server here:
> https://codeberg.org/rgherdt/scheme-lsp-server
>
> For now I am focusing on Guile 3 and CHICKEN 5. The idea is to write
> as much R7RS for common code as possible (like representing documents, 
> fetching word under cursor etc.) and leave implementation specific
> code to dedicated files. So far I managed to implement
> auto-completion, fetch signature, fetch documentation and jump to
> definition. "Jump to definition" has some particularities in the
> CHICKEN case (I basically scan some paths for scheme files and keep
> track of changes) see
> https://codeberg.org/rgherdt/emacs-lsp-scheme#chicken.
>
> note: salmonella's Testing is failing, although chicken-install -test
> works. I'm investigating it.

Maybe
http://wiki.call-cc.org/eggref/5/salmonella#testing-executable-files-installed-by-eggs
can help.

> 2) An LSP server without a client is quite useless, so I'm also
> sharing an emacs-lsp client:
>
> Repo: https://codeberg.org/rgherdt/emacs-lsp-scheme
>
> I will create a PR to melpa for this. Until it is merged, you can
> clone the repo somewhere, 'load' it and follow the instructions in the
> README to activate it.
>
> 3) The whole idea behind LSP is to improve language support across
> multiple IDEs/editors. So I started a proof of concept in VS Code:
>
> https://codeberg.org/rgherdt/vscode-scheme-lsp
>
> Since I don't use VS Code, I don't know how similar extensions
> typically work and don't have a clear idea how a lispy LSP client
> should/could look like in it. If you have ideas, or want to
> contribute, feel free to contact me. It is not documented nor
> published yet, but already works for the functionality mentioned
> (there are a couple of commands to launch a REPL and load files on
> it). I will investigate how to automate installation of the LSP server
> before publishing it and let you know.
>
> Everything is on an early stage of development, and APIs may change. I
> tested it using following software:
> - CHICKEN 5.3.0
> - Guile 3.0.8
> - Emacs 27.1 and 28.1
> - Debian Bullseye and Ubuntu 18.04
>
> Any questions, suggestions, critics and contributions are welcome. You
> can also reach me on @libera's #chicken, #scheme channels (rgherdt).
>
> Have a nice weekend!

Many thanks for the update!

All the best.
Mario
-- 
http://parenteses.org/mario



LSP Server for CHICKEN (and more ...)

2022-06-11 Thread Ricardo G. Herdt

Hi folks!

I mentioned my work on an LSP server for Scheme a while ago. For those 
that don't know the Language Server Protocol (LSP), it is meant for 
adding programming language support for IDEs and editors that implement 
the protocol (nowadays most of them support it). After a long pause 
period due to private reasons, I finally managed to get it into a 
working state, so here my results:


1) You can find the server here:
https://codeberg.org/rgherdt/scheme-lsp-server

For now I am focusing on Guile 3 and CHICKEN 5. The idea is to write as 
much R7RS for common code as possible (like representing documents, 
fetching word under cursor etc.) and leave implementation specific code 
to dedicated files. So far I managed to implement auto-completion, fetch 
signature, fetch documentation and jump to definition. "Jump to 
definition" has some particularities in the CHICKEN case (I basically 
scan some paths for scheme files and keep track of changes) see 
https://codeberg.org/rgherdt/emacs-lsp-scheme#chicken.


note: salmonella's Testing is failing, although chicken-install -test 
works. I'm investigating it.


2) An LSP server without a client is quite useless, so I'm also sharing 
an emacs-lsp client:


Repo: https://codeberg.org/rgherdt/emacs-lsp-scheme

I will create a PR to melpa for this. Until it is merged, you can clone 
the repo somewhere, 'load' it and follow the instructions in the README 
to activate it.


3) The whole idea behind LSP is to improve language support across 
multiple IDEs/editors. So I started a proof of concept in VS Code:


https://codeberg.org/rgherdt/vscode-scheme-lsp

Since I don't use VS Code, I don't know how similar extensions typically 
work and don't have a clear idea how a lispy LSP client should/could 
look like in it. If you have ideas, or want to contribute, feel free to 
contact me. It is not documented nor published yet, but already works 
for the functionality mentioned (there are a couple of commands to 
launch a REPL and load files on it). I will investigate how to automate 
installation of the LSP server before publishing it and let you know.


Everything is on an early stage of development, and APIs may change. I 
tested it using following software:

- CHICKEN 5.3.0
- Guile 3.0.8
- Emacs 27.1 and 28.1
- Debian Bullseye and Ubuntu 18.04

Any questions, suggestions, critics and contributions are welcome. You 
can also reach me on @libera's #chicken, #scheme channels (rgherdt).


Have a nice weekend!

Ricardo