egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
68 stars 17 forks source link

Add `,version`, `,date` and other commands to the REPL #559

Closed jpellegrini closed 8 months ago

jpellegrini commented 1 year ago

Hi @egallesio ! What do you think of this one?

jpellegrini commented 1 year ago

Maybe some others would be interesting?

- ,apropos      Search for symbol in documentation
- ,describe ,d  Describe an object
- ,time         Run the next expression while evaluating the time to do so
- ,require ,r   Require a feature
- ,expand ,e    Macroexpand a form

Those are things I usually do and would be nice to have quick access to, but maybe they're redundant, since one can also type them as Scheme forms?

jpellegrini commented 1 year ago

By the way... It seems that the shell command ,! stklos can be nested an arbitrarily large number of times. Quite nice! :) And when comparing output with other Schemes, we can do things like

stklos> (+ 2 3)
5
stklos> ,! gosh
gosh$ (+ 2 3)
5
gosh$ ^D
stklos> 

:grin:

jpellegrini commented 10 months ago

I added more commands, including ,+ and ,* (inspired by CL's + and *).

I only thing the time command is not actually good, since it discards the result of the expression.

jpellegrini commented 10 months ago

Hmm, @egallesio -- the REPL uses an output port and an error port:

(define (repl :key (in  default-in)
                   (out default-out)
                   (err default-err))
  .
  .
  .
                           (for-each (lambda (x) (write-shared x out) (newline out))
                                     v))

But the REPL commands don't:

(define (do-repl-command l)
  .
  .
  .
    ((pwd)              (printf "~S\n" (getcwd)))

Shouldn't the REPL commands also be accepting error and output ports as arguments?

jpellegrini commented 10 months ago

If #598 is accepted in the future, we could also include a ,manual command... :)

jpellegrini commented 10 months ago
stklos> (define x 20)
;; x
stklos> ,d x
x is a symbol, with mutable binding.

Not sure what do do here... eval it, maybe? Would that be ok?

egallesio commented 8 months ago

I have mostly applied all your propositions, but in a different manner as explained in PR #598. Thanks for all your ideas.

jpellegrini commented 8 months ago

It looks like this PR is also not needed! :)