Discussion:
Beginner questions
swedebugia
2018-10-29 22:00:33 UTC
Permalink
Hi

I would like to learn more scheme and I would like to make a small CLI
program that runs in the terminal and prompts the user for input and
evaluates it.

Is that possible with guile? In the REPL?

Can someone point me in the right direction for succeding with that?
--
---
Swedebugia
Tk
2018-10-29 22:35:23 UTC
Permalink
Sent from ProtonMail mobile

-------- Original Message --------
On 29 Oct 2018, 22:58, swedebugia wrote:

Hi

I would like to learn more scheme and I would like to make a small CLI
program that runs in the terminal and prompts the user for input and
evaluates it.

Is that possible with guile? In the REPL?

Can someone point me in the right direction for succeding with that?

--
---
Swedebugia

Look through documentation that comes with guile, it's excellent. It's in info format. Also, check out Dybvig's book on Scheme r6rs standard. It also contains a lot of examp
Alex Sassmannshausen
2018-10-30 13:15:06 UTC
Permalink
Hello!
Post by swedebugia
Hi
I would like to learn more scheme and I would like to make a small CLI
program that runs in the terminal and prompts the user for input and
evaluates it.
Is that possible with guile? In the REPL?
Can someone point me in the right direction for succeding with that?
In addition to what Tk recommends, here some pointers:

- For commandline argument parsing & organization, you could
specifically look at (ice-9 getopt-long). I think there's a srfi for
some form of arg-fold, but I have not used that yet. In addition, you
may want to look at guile-config (it's something that I wrote) which
provides a more comprehensive way of structuring your entire CLI into
different sub-commands and providing a nice structure for documenting
your CLI. It's particularly easy to install through Guix.

- For reading and writing interactively, you may want to look at the
(read) and (write) procedures if you're intending to read & write
s-expressions. Otherwise you may want to look at (ice-9 rdelim),
which provides line based, or other delimiter based reading rather
than s-expression reading.

- You could also look at the readline library to be able to implement
nice command line features if you decide to go down the full
commandline path.

Hope this helps. As Tk suggested, the documentation for Guile is great,
if at points a little light on examples.

Best wishes,

Alex
Mark H Weaver
2018-10-30 13:27:19 UTC
Permalink
Hi,
Post by swedebugia
I would like to learn more scheme and I would like to make a small CLI
program that runs in the terminal and prompts the user for input and
evaluates it.
This sounds like a description of Guile's REPL itself. Are you looking
to implement your own simple REPL for educational purposes?
Post by swedebugia
Is that possible with guile? In the REPL?
Yes and yes.
Post by swedebugia
Can someone point me in the right direction for succeding with that?
Here are some relevant sections of the Guile manual to get started:

https://www.gnu.org/software/guile/manual/html_node/Scripting-Examples.html
https://www.gnu.org/software/guile/manual/html_node/Read_002fLoad_002fEval_002fCompile.html
https://www.gnu.org/software/guile/manual/html_node/Line_002fDelimited.html
https://www.gnu.org/software/guile/manual/html_node/Strings.html

The first link gives several small examples of Guile scripts. The
second documents procedures to read, evaluate, and print S-expressions,
and in particular the 'read', 'eval', and 'write' procedures, which are
the three main components of a REPL. The third link documents
procedures to read a single line of input as a string, and the fourth
documents the string operations.

Would you like to start by looking over these sections of the manual,
and then asking more questions as they arise?

Mark
Alex Vong
2018-10-30 19:22:19 UTC
Permalink
Post by swedebugia
Hi
Hello,
Post by swedebugia
I would like to learn more scheme and I would like to make a small CLI
If you have time, I suggest you to watch the Structure and
Interpretation of Computer Programs (SICP) lecture series[0][1]. It is a
classic. The videos were recorded in 1986. However, the topics it
covered are still very relevant today: high-order procedures
(functionals), pattern matching, state & side effects, stream (lazy
list), metacircular evaluator, logic programming, garbage collection.

Have a look at the first lecture and see if you like it!
Post by swedebugia
program that runs in the terminal and prompts the user for input and
evaluates it.
Is that possible with guile? In the REPL?
Can someone point me in the right direction for succeding with that?
Cheers,
Alex

[0]: https://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-001-structure-and-interpretation-of-computer-programs-spring-2005/video-lectures/
[1]: https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs
Catonano
2018-11-18 19:33:31 UTC
Permalink
Post by swedebugia
Hi
I would like to learn more scheme and I would like to make a small CLI
program that runs in the terminal and prompts the user for input and
evaluates it.
Is that possible with guile? In the REPL?
Can someone point me in the right direction for succeding with that?
Hi

I am curious: did you manage to put together a prototype of this thing
prompting a user in the terminal ?
Neil Jerram
2018-11-19 09:02:23 UTC
Permalink
Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia
Post by swedebugia
Hi
I would like to learn more scheme and I would like to make a small
CLI
Post by swedebugia
program that runs in the terminal and prompts the user for input and
evaluates it.
Is that possible with guile? In the REPL?
Can someone point me in the right direction for succeding with that?
Hi
I am curious: did you manage to put together a prototype of this thing
prompting a user in the terminal ?
In case it's of interest, I wrote this kind of thing a few years ago: a command loop for Guile where you can register possible commands, and each command has a spec like the Emacs 'interactive' form that says what the args are and how to prompt for them.

The command loop entry point is at http://git.savannah.nongnu.org/cgit/ossaulib.git/tree/ossau/command-loop.scm and the dependency modules are all included in that git repo.

Best wishes,
Neil

Continue reading on narkive:
Loading...