Hacker News new | past | comments | ask | show | jobs | submit login

The key for me is that a REPL reads, then evaluates (generally involving printing), then starts over (looping). Bash for example fits this criteria. I'm as much of a fan of lisp as anyone, but it doesn't need to be literally printing the result of `eval` to be a REPL in my eyes.



bash doesn't print the result of an evaluation, the commands print if the want

it's more a PEL: Parse Execute Loop


In that case, most lisp 'repls' don't satisfy your definition either.


Most Lisp REPLS print a result somewhere.


The P stands for print. A REPL prints by definition.


Then what is this?

    (defun add (a b)
           (+ a b))


This is Lisp code defining a function ADD.

If you enter it at a Lisp REPL, the REPL will read the expression, evaluate it and store it as a function. The result value is the name of the defined function. The REPL will then print the result, here the name of the function: ADD.

  CL-USER 13 > (defun add (a b)
                 (+ a b))
  ADD
As you can see, the function does not print the Lisp symbol 'ADD', it's printed by the REPL. That's the P-component of R E P L, REPL. P stands for PRINT. This means that the REPL will always print a result - unless a Lisp function does not have a result - which is rare.

If we execute the function, the REPL prints the result of the function:

  CL-USER 14 > (add 17 25)
  42
Here the result is the number 42.


That's some Lisp code; if you enter it at a REPL, it prints the result of evaluating it:

    CL-USER> (defun add (a b) (+ a b))
    ADD


That is an expression which evaluates to the symbol add. It also has an important side-effect of defining a function.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: