From 1e33e4d14677695b54851e9f4872f5d62a6872f4 Mon Sep 17 00:00:00 2001 From: Pekka Laiho Date: Sun, 18 Oct 2020 14:45:49 +0700 Subject: [PATCH] change syntax of readline functions --- README.md | 6 +++--- mad/calc.mad | 6 +++--- src/Lib/IO.php | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 1d83194..cdca7c1 100644 --- a/README.md +++ b/README.md @@ -236,9 +236,9 @@ fflush | `(fflush f)` | `true` | Persist buffered writes to disk for a file res fread | `(fread f 16)` | `"abc"` | Read from a file resource. feof? | `(feof? f)` | `true` | Return true if end of file has been reached for a file resource. readline | `(readline "What is your name? ")` | `What is your name? ` | Read line of user input using [readline](https://www.php.net/manual/en/function.readline.php). -readlineAdd | `(readlineAdd "What is your name? ")` | `true` | Add line of user input to readline history using [readline_add_history](https://www.php.net/manual/en/function.readline-add-history.php). -readlineLoad | `(readlineLoad "historyfile")` | `true` | Read readline history from file using [readline_read_history](https://www.php.net/manual/en/function.readline-read-history.php). -readlineSave | `(readlineSave "historyfile")` | `true` | Write readline history into file using [readline_write_history](https://www.php.net/manual/en/function.readline-write-history.php). +readline-add | `(readline-add "What is your name? ")` | `true` | Add line of user input to readline history using [readline_add_history](https://www.php.net/manual/en/function.readline-add-history.php). +readline-load | `(readline-load "historyfile")` | `true` | Read readline history from file using [readline_read_history](https://www.php.net/manual/en/function.readline-read-history.php). +readline-save | `(readline-save "historyfile")` | `true` | Write readline history into file using [readline_write_history](https://www.php.net/manual/en/function.readline-write-history.php). ### Json functions diff --git a/mad/calc.mad b/mad/calc.mad index 4ddd44a..8fd8bea 100644 --- a/mad/calc.mad +++ b/mad/calc.mad @@ -42,12 +42,12 @@ ;; Define a file for readline and load it (def readlineFile (str HOME "calc_history")) -(readlineLoad readlineFile) +(readline-load readlineFile) ;; Main loop: Read input from user, add it to readline, and parse it (def mainLoop (fn () (let (inp (readline "> ")) - (do (readlineAdd inp) - (readlineSave readlineFile) + (do (readline-add inp) + (readline-save readlineFile) (print (str (parseInput inp) EOL)) true)))) diff --git a/src/Lib/IO.php b/src/Lib/IO.php index 146fb67..a7842dd 100644 --- a/src/Lib/IO.php +++ b/src/Lib/IO.php @@ -72,15 +72,15 @@ class IO implements ILib fn ($prompt = null) => readline($prompt) )); - $env->set('readlineAdd', new CoreFunc('readlineAdd', 'Add new line of input to history.', 1, 1, + $env->set('readline-add', new CoreFunc('readline-add', 'Add new line of input to history.', 1, 1, fn (string $line) => readline_add_history($line) )); - $env->set('readlineLoad', new CoreFunc('readlineLoad', 'Load the history for readline from a file.', 1, 1, + $env->set('readline-load', new CoreFunc('readline-load', 'Load the history for readline from a file.', 1, 1, fn (string $file) => readline_read_history($file) )); - $env->set('readlineSave', new CoreFunc('readlineSave', 'Save the readline history into a file.', 1, 1, + $env->set('readline-save', new CoreFunc('readline-save', 'Save the readline history into a file.', 1, 1, fn (string $file) => readline_write_history($file) )); }