Re: Advises and feedback

Kristian Lein-Mathisen <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <CAAGQtHyfSUusQ42=etOeCKVCAMEuwiH1kE10WoPnCFgSKp_j5A@mail.gmail.com>
Hi Miguel,

and welcome to the Chicken community! Your project looks very thourogh and
the Scheme code looks good.

There are a couple of issues related to building that I thought I'd point
out.

Like Felix points out, load and load-relative open files at runtime. So sdb
fails when run outside of its repo directory because of these:

> make
> ./sdb -h
> cd ~
~> ~/opt/simple_db/sdb
Error: (load) cannot open file: "./db-utils.scm"

====

In the same manner, the help-file is opened and read at runtime here:
https://github.com/MigAP/simple_db/blob/main/cli.scm#L31. This results in a
similar problem when sdb is used outside its repo directory:

> ~/opt/simple_db/sdb -h
Error: (open-input-file) cannot open file - No such file or directory:
"./cli-interface.txt"

In Scheme, the ordinary string syntax can have multiple lines. So if you
wanted to, you could wrap the content of cli-interface.txt in double-qoutes
and embed it directly into your sources. That'll eliminate these kinds of
runtime issues. You could also use include or read cli-interface.txt at
compile time using define-syntax or let-syntax.

====

There are also egg dependencies in use which don't seem to be mentioned
anywhere. Without these, I get this error message.

> ./sdb -h
Error: (import) during expansion of (import ...) - cannot import from
undefined module: list-utils.basic

I'm guessing I need to install list-utils, but that olso fails because of
transitive dependencies. So I need to run `chicken-install check-errors`,
then `chicken-install list-utils`. Then another `chicken-install
gnuplot-pipe`.

Manual dependency management like quickly gets out of hand. You can use
egg-files, which you've probably come across. Here's a bare minimum to get
dependencies and transitive dependencies installed:

~/o/simple_db (main)> cat sdb.egg
((dependencies list-utils gnuplot-pipe))
~/o/simple_db (main)> chicken-install
...
building gnuplot-pipe
installing gnuplot-pipe
building sdb
installing sdb

chicken-install runs for the current directory if nothing is specified, so
it picks up sdb.egg. I often use egg files even for small toy project that
I don't tend to release because of this, amongst other things. You can also
use egg files to install programs like sdb if you wish.

If you run chicken-install with -test, it'll run test/run.scm, where you
can put your unit tests. This is all chicken-specific stuff, other Schemes
do it their way. A Makefile like you have is a pretty global mechanism so
it has its advantages.

===
I hope none of this is discouraging! Looking forward to seeing what else
you produce.

Hoppy holidays,
K.


On Fri, Mar 22, 2024, 19:54 <[email protected]> wrote:

> > Hello everyone!
> >
> > My name is Miguel, and I am interested in developing in Chicken Scheme.
> >
> > I just created a toy project to put in practice what I have been
> > learning in the Little Schemer and SICP books, you can find it here:
> >
> > https://github.com/MigAP/simple_db
> >
> > It is a simple database to store urls. I am not a developer, so I would
> > appreciate any feedback from you. In particular, it is the first time I
> > write unit tests, and I am not sure if this is the correct way of
> doing-it.
> >
> > I thank you in advance for any feedback. I am looking forward to start
> > building stuff using Chicken Scheme!
> >
> > I wish you all a good day.
>
> Hi!
>
> Your code looks good to me. I haven't examined it in detail, but
> the overall impression is fine. Also, the unit-tests seem to be similar
> to what I've seen in other code by more experienced Schemers.
>
> Note that you compile your program but load additional files via
> "load-relative". This technically works, but if you want all code to
> be compiled, I recommend to use "include" instead: that way,
> the parts are inserted into your main program and fully compiled,
> which is of course more efficient and also makes it easier to
> move the compiled program around or call it from a different
> location.
>
> > PS: Is there any small/medium project that I could study to learn the
> > "good practices" for Chicken Scheme? One of my goals is to use Chicken
> > Scheme for scientific computing and embedded applications.
>
> The egg sources are usually good examples for how to structure
> libraries. Some of these have example programs that you might
> want to study. Also, you can look at
>
>         http://wiki.call-cc.org/Software
>
> which lists a couple of larger projects that use CHICKEN.
>
>
> cheers,
> felix
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.