unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Beginner questions
@ 2018-10-29 22:00 swedebugia
  2018-10-29 22:35 ` Tk
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: swedebugia @ 2018-10-29 22:00 UTC (permalink / raw)
  To: guile-user

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




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-10-29 22:00 Beginner questions swedebugia
@ 2018-10-29 22:35 ` Tk
  2018-10-30 13:15 ` Alex Sassmannshausen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Tk @ 2018-10-29 22:35 UTC (permalink / raw)
  To: swedebugia; +Cc: guile-user@gnu.org

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 examples.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-10-29 22:00 Beginner questions swedebugia
  2018-10-29 22:35 ` Tk
@ 2018-10-30 13:15 ` Alex Sassmannshausen
  2018-10-30 13:27 ` Mark H Weaver
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Alex Sassmannshausen @ 2018-10-30 13:15 UTC (permalink / raw)
  To: swedebugia; +Cc: guile-user


Hello!

swedebugia writes:

> 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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-10-29 22:00 Beginner questions swedebugia
  2018-10-29 22:35 ` Tk
  2018-10-30 13:15 ` Alex Sassmannshausen
@ 2018-10-30 13:27 ` Mark H Weaver
  2018-10-30 19:22 ` Alex Vong
  2018-11-18 19:33 ` Catonano
  4 siblings, 0 replies; 9+ messages in thread
From: Mark H Weaver @ 2018-10-30 13:27 UTC (permalink / raw)
  To: swedebugia; +Cc: guile-user

Hi,

swedebugia <swedebugia@riseup.net> writes:

> 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?

> Is that possible with guile? In the REPL?

Yes and yes.

> 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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-10-29 22:00 Beginner questions swedebugia
                   ` (2 preceding siblings ...)
  2018-10-30 13:27 ` Mark H Weaver
@ 2018-10-30 19:22 ` Alex Vong
  2018-11-18 19:33 ` Catonano
  4 siblings, 0 replies; 9+ messages in thread
From: Alex Vong @ 2018-10-30 19:22 UTC (permalink / raw)
  To: swedebugia; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 1056 bytes --]

swedebugia <swedebugia@riseup.net> writes:

> Hi
>
Hello,

> 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!

> 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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-10-29 22:00 Beginner questions swedebugia
                   ` (3 preceding siblings ...)
  2018-10-30 19:22 ` Alex Vong
@ 2018-11-18 19:33 ` Catonano
  2018-11-19  9:02   ` Neil Jerram
  4 siblings, 1 reply; 9+ messages in thread
From: Catonano @ 2018-11-18 19:33 UTC (permalink / raw)
  To: swedebugia; +Cc: Guile User

Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia <swedebugia@riseup.net>
ha scritto:

> 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 ?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-11-18 19:33 ` Catonano
@ 2018-11-19  9:02   ` Neil Jerram
  2018-11-27 19:59     ` Catonano
  0 siblings, 1 reply; 9+ messages in thread
From: Neil Jerram @ 2018-11-19  9:02 UTC (permalink / raw)
  To: guile-user, Catonano, swedebugia; +Cc: Guile User



On 18 November 2018 19:33:31 GMT, Catonano <catonano@gmail.com> wrote:
>Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia
><swedebugia@riseup.net>
>ha scritto:
>
>> 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 ?

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



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-11-19  9:02   ` Neil Jerram
@ 2018-11-27 19:59     ` Catonano
  2018-11-28 16:45       ` Neil Jerram
  0 siblings, 1 reply; 9+ messages in thread
From: Catonano @ 2018-11-27 19:59 UTC (permalink / raw)
  To: neil; +Cc: Guile User

Neil,

Il giorno lun 19 nov 2018 alle ore 10:02 Neil Jerram <
neil@ossau.homelinux.net> ha scritto:

>
>
> On 18 November 2018 19:33:31 GMT, Catonano <catonano@gmail.com> wrote:
> >Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia
> ><swedebugia@riseup.net>
> >ha scritto:
> >
> >> 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 ?
>
> 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
>

thank you

But I'm a bit overwhelmed by so much code

a tiny example of reading a short string that a user could type at a prompt
would be more useful to a beginner, I think

I came up with this short example

(use-modules (ice-9 rdelim))

(let ((str (read-line (current-input-port))))
    (display (string-append str "\n")))

it's extremely essential but it demonstrates the usage of the current input
port in association with delimited text reading

This is a very basic use case, intended as an example, a step 0 for further
developments

Guile could use some more examples, in its manual

Thanks !


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Beginner questions
  2018-11-27 19:59     ` Catonano
@ 2018-11-28 16:45       ` Neil Jerram
  0 siblings, 0 replies; 9+ messages in thread
From: Neil Jerram @ 2018-11-28 16:45 UTC (permalink / raw)
  To: Catonano; +Cc: Guile User

Catonano <catonano@gmail.com> writes:

> Neil,
>
> Il giorno lun 19 nov 2018 alle ore 10:02 Neil Jerram <
> neil@ossau.homelinux.net> ha scritto:
>
>>
>>
>> On 18 November 2018 19:33:31 GMT, Catonano <catonano@gmail.com> wrote:
>> >Il giorno lun 29 ott 2018 alle ore 22:58 swedebugia
>> ><swedebugia@riseup.net>
>> >ha scritto:
>> >
>> >> 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 ?
>>
>> 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
>>
>
> thank you
>
> But I'm a bit overwhelmed by so much code

Thanks for taking a look.  It is a _lot_ of code, so I can understand it
being overwhelming.

> a tiny example of reading a short string that a user could type at a prompt
> would be more useful to a beginner, I think
>
> I came up with this short example
>
> (use-modules (ice-9 rdelim))
>
> (let ((str (read-line (current-input-port))))
>     (display (string-append str "\n")))
>
> it's extremely essential but it demonstrates the usage of the current input
> port in association with delimited text reading
>
> This is a very basic use case, intended as an example, a step 0 for further
> developments

I started with that (or something very like it), but then gradually
added more structure for the specific applications that I had in
mind... and surprisingly quickly we can end up with the amount of code
that I have in ossaulib.

Best wishes,
   Neil



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-11-28 16:45 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-29 22:00 Beginner questions swedebugia
2018-10-29 22:35 ` Tk
2018-10-30 13:15 ` Alex Sassmannshausen
2018-10-30 13:27 ` Mark H Weaver
2018-10-30 19:22 ` Alex Vong
2018-11-18 19:33 ` Catonano
2018-11-19  9:02   ` Neil Jerram
2018-11-27 19:59     ` Catonano
2018-11-28 16:45       ` Neil Jerram

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).