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 Name | PHP constant
------- | ------------ ------- | ------------
dirsep | DIRECTORY_SEPARATOR DIRSEP | DIRECTORY_SEPARATOR
homedir | $_SERVER['HOME'] HOME | $_SERVER['HOME']
ln | PHP_EOL EOL | PHP_EOL
pi | M_PI PI | M_PI
## Extending ## Extending

View File

@ -41,14 +41,14 @@
((first cmd) args)))))) ((first cmd) args))))))
;; Define a file for readline and load it ;; Define a file for readline and load it
(def readlineFile (str homedir "calc_history")) (def readlineFile (str HOME "calc_history"))
(readlineLoad readlineFile) (readlineLoad readlineFile)
;; Main loop: Read input from user, add it to readline, and parse it ;; Main loop: Read input from user, add it to readline, and parse it
(def mainLoop (fn () (let (inp (readline "> ")) (def mainLoop (fn () (let (inp (readline "> "))
(do (readlineAdd inp) (do (readlineAdd inp)
(readlineSave readlineFile) (readlineSave readlineFile)
(print (str (parseInput inp) "\n")) (print (str (parseInput inp) EOL))
true)))) true))))
;; Run it ;; Run it

View File

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

View File

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

View File

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