capitalize constants

This commit is contained in:
Pekka Laiho 2020-10-18 13:32:20 +07:00
parent be9ffae2e8
commit c0fb53742a
5 changed files with 10 additions and 10 deletions

View File

@ -338,10 +338,10 @@ The following constants are defined by default:
Name | PHP constant
------- | ------------
dirsep | DIRECTORY_SEPARATOR
homedir | $_SERVER['HOME']
ln | PHP_EOL
pi | M_PI
DIRSEP | DIRECTORY_SEPARATOR
HOME | $_SERVER['HOME']
EOL | PHP_EOL
PI | M_PI
## Extending

View File

@ -41,14 +41,14 @@
((first cmd) args))))))
;; Define a file for readline and load it
(def readlineFile (str homedir "calc_history"))
(def readlineFile (str HOME "calc_history"))
(readlineLoad 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)
(print (str (parseInput inp) "\n"))
(print (str (parseInput inp) EOL))
true))))
;; Run it

View File

@ -8,8 +8,8 @@ class IO implements ILib
{
public function register(Env $env): void
{
$env->set('dirsep', \DIRECTORY_SEPARATOR);
$env->set('homedir', $_SERVER['HOME'] . \DIRECTORY_SEPARATOR);
$env->set('DIRSEP', \DIRECTORY_SEPARATOR);
$env->set('HOME', $_SERVER['HOME'] . \DIRECTORY_SEPARATOR);
$env->set('wd', new CoreFunc('wd', 'Get the current working directory.', 0, 0,
fn () => getcwd() . \DIRECTORY_SEPARATOR

View File

@ -10,7 +10,7 @@ class Math implements ILib
{
// Constants
$env->set('pi', \M_PI);
$env->set('PI', \M_PI);
// Basic arithmetic

View File

@ -9,7 +9,7 @@ class Strings implements ILib
{
public function register(Env $env): void
{
$env->set('ln', \PHP_EOL);
$env->set('EOL', \PHP_EOL);
$env->set('trim', new CoreFunc('trim', 'Remove whitespace from beginning and end of string.', 1, 1,
fn (string $a) => trim($a)