diff options
-rw-r--r-- | ChangeLog | 50 | ||||
-rw-r--r-- | arith.c | 18 | ||||
-rw-r--r-- | eval.c | 43 | ||||
-rw-r--r-- | eval.h | 3 | ||||
-rw-r--r-- | genvim.txr | 8 | ||||
-rw-r--r-- | glob.c | 24 | ||||
-rw-r--r-- | lib.c | 6 | ||||
-rw-r--r-- | share/txr/stdlib/ver.tl | 3 | ||||
-rw-r--r-- | signal.c | 74 | ||||
-rw-r--r-- | sysif.c | 68 | ||||
-rw-r--r-- | syslog.c | 36 | ||||
-rw-r--r-- | txr.1 | 54 | ||||
-rw-r--r-- | txr.c | 11 |
13 files changed, 240 insertions, 158 deletions
@@ -1,5 +1,55 @@ 2015-08-03 Kaz Kylheku <kaz@kylheku.com> + Switching some globals to lexical and changing some names. + + * arith.c (arith-init): Changing *flo-...* from special to + lexical, and adding un-earmuffed variants. The earmuffed + versions are obsolescent. + Adding %pi% and %e% global lexicals. Earmuffed versions are + also made global lexical, and obsolescent. + + * eval.c (lookup_global_var, lookup_global_var_l): New functions. + (lookup_var): Uses lookup_global_var. + (reg_varl): New function. + (reg_var): Uses reg_var. + (eval_init): Register global lexicals user-package, system-package + and keyword-package. Old symbols with earmuffs are obsoleted, + and also turned into global lexicals. + (top-vb, top-fb): Changed to lexical. + + * eval.h (lookup_global_var, lookup_global_var_l, reg_varl): + Declared. + + * genvim.txr: Scan ver.tl so that the lib-version variable + is included. Extract reg_varl calls. + + * glob.c (glob_init): glob-err and other variables made lexical. + + * lib.c (get_user_package, get_system_package, get_keyword_package): + Use lookup_global_var_l to avoid searching dynamic scope for + lexicals which cannot be dynamically rebound. + + * share/txr/stdlib/ver.tl (lib-version): New global lexical variable. + (*lib-version*): Turned lexical. Obsolescent. + + * signal.c (sig-init): sig-* variables turned lexical. + + * sysif.c (sysif-init): s-*, poll-* and w-* variables turned lexical. + + * syslog.c (syslog-init): log-* variables turned lexical. + + * txr.c (sysroot-init): stdlib and *txr-version* variables turned + lexical. txr-version variable added, and *txr-version* is + obsolescent. + (txr-main): self-path variable added. *self-path* turns lexical + and is obsolescent. + + * txr.1: Documentation updated. Lexical variables not referred + to as special. Special variables referred to as special. + + +2015-08-03 Kaz Kylheku <kaz@kylheku.com> + * txr.c (txr_main): Bugfix: register *args-full*, the variable described in the documentation! We keep *full-args* for backward compatibility, as an obsolescent feature. @@ -2276,16 +2276,22 @@ void arith_init(void) mp_set_intptr(&INT_PTR_MAX_MP, INT_PTR_MAX); log2_init(); - reg_var(intern(lit("*flo-dig*"), user_package), num_fast(DBL_DIG)); - reg_var(intern(lit("*flo-max*"), user_package), flo(DBL_MAX)); - reg_var(intern(lit("*flo-min*"), user_package), flo(DBL_MIN)); - reg_var(intern(lit("*flo-epsilon*"), user_package), flo(DBL_EPSILON)); + reg_varl(intern(lit("*flo-dig*"), user_package), num_fast(DBL_DIG)); + reg_varl(intern(lit("*flo-max*"), user_package), flo(DBL_MAX)); + reg_varl(intern(lit("*flo-min*"), user_package), flo(DBL_MIN)); + reg_varl(intern(lit("*flo-epsilon*"), user_package), flo(DBL_EPSILON)); + reg_varl(intern(lit("flo-dig"), user_package), num_fast(DBL_DIG)); + reg_varl(intern(lit("flo-max"), user_package), flo(DBL_MAX)); + reg_varl(intern(lit("flo-min"), user_package), flo(DBL_MIN)); + reg_varl(intern(lit("flo-epsilon"), user_package), flo(DBL_EPSILON)); #ifndef M_PI #define M_PI 3.14159265358979323846 #endif - reg_var(intern(lit("*pi*"), user_package), flo(M_PI)); + reg_varl(intern(lit("*pi*"), user_package), flo(M_PI)); + reg_varl(intern(lit("%pi%"), user_package), flo(M_PI)); #ifndef M_E #define M_E 2.71828182845904523536 #endif - reg_var(intern(lit("*e*"), user_package), flo(M_E)); + reg_varl(intern(lit("*e*"), user_package), flo(M_E)); + reg_varl(intern(lit("%e%"), user_package), flo(M_E)); } @@ -168,10 +168,15 @@ noreturn static val eval_error(val form, val fmt, ...) abort(); } -val lookup_var(val env, val sym) +val lookup_global_var(val sym) { uses_or2; + return or2(gethash(top_vb, sym), + if2(lisplib_try_load(sym), gethash(top_vb, sym))); +} +val lookup_var(val env, val sym) +{ if (env) { type_check(env, ENV); @@ -188,8 +193,7 @@ val lookup_var(val env, val sym) return binding; } - return or2(gethash(top_vb, sym), - if2(lisplib_try_load(sym), gethash(top_vb, sym))); + return lookup_global_var(sym); } static val lookup_sym_lisp1(val env, val sym) @@ -226,6 +230,12 @@ loc lookup_var_l(val env, val sym) return if3(binding, cdr_l(binding), nulloc); } +loc lookup_global_var_l(val sym) +{ + val binding = lookup_global_var(sym); + return if3(binding, cdr_l(binding), nulloc); +} + val lookup_fun(val env, val sym) { uses_or2; @@ -3761,10 +3771,15 @@ static void reg_mac(val sym, mefun_t fun) sethash(builtin, sym, defmacro_s); } -void reg_var(val sym, val val) +void reg_varl(val sym, val val) { assert (sym != nil); sethash(top_vb, sym, cons(sym, val)); +} + +void reg_var(val sym, val val) +{ + reg_varl(sym, val); mark_special(sym); } @@ -4406,12 +4421,16 @@ void eval_init(void) reg_fun(intern(lit("pprinl"), user_package), func_n2o(pprinl, 1)); reg_fun(intern(lit("tprint"), user_package), func_n2o(tprint, 1)); - reg_var(user_package_s = intern(lit("*user-package*"), user_package_var), - user_package_var); - reg_var(system_package_s = intern(lit("*system-package*"), user_package_var), - system_package_var); - reg_var(keyword_package_s = intern(lit("*keyword-package*"), user_package_var), - keyword_package_var); + reg_varl(user_package_s = intern(lit("user-package"), user_package_var), + user_package_var); + reg_varl(system_package_s = intern(lit("system-package"), user_package_var), + system_package_var); + reg_varl(keyword_package_s = intern(lit("keyword-package"), user_package_var), + keyword_package_var); + + reg_varl(intern(lit("*user-package*"), user_package), user_package_var); + reg_varl(intern(lit("*system-package*"), user_package), system_package_var); + reg_varl(intern(lit("*keyword-package*"), user_package), keyword_package_var); reg_fun(intern(lit("make-sym"), user_package), func_n1(make_sym)); reg_fun(intern(lit("gensym"), user_package), func_n1o(gensym, 0)); @@ -4555,8 +4574,8 @@ void eval_init(void) reg_fun(intern(lit("make-like"), user_package), func_n2(make_like)); reg_fun(intern(lit("nullify"), user_package), func_n1(nullify)); - reg_var(intern(lit("top-vb"), system_package), top_vb); - reg_var(intern(lit("top-fb"), system_package), top_fb); + reg_varl(intern(lit("top-vb"), system_package), top_vb); + reg_varl(intern(lit("top-fb"), system_package), top_fb); reg_fun(intern(lit("symbol-value"), user_package), func_n1(symbol_value)); reg_fun(intern(lit("symbol-function"), user_package), func_n1(symbol_function)); reg_fun(intern(lit("boundp"), user_package), func_n1(boundp)); @@ -33,12 +33,15 @@ val make_env(val fbindings, val vbindings, val up_env); val env_fbind(val env, val sym, val fun); val env_vbind(val env, val sym, val obj); val lookup_var(val env, val sym); +val lookup_global_var(val sym); loc lookup_var_l(val env, val sym); +loc lookup_global_var_l(val sym); val lookup_fun(val env, val sym); val interp_fun(val env, val fun, val args); val fboundp(val sym); val special_operator_p(val sym); val macro_form_p(val form, val menv); +void reg_varl(val sym, val val); void reg_var(val sym, val val); void reg_fun(val sym, val fun); val apply(val fun, val arglist, val ctx_form); @@ -10,7 +10,7 @@ static void dir_tables_init(void) @(bind lib "share/txr/stdlib") @(next @(open-files ^(#*"eval.c rand.c signal.c stream.c gc.c glob.c" #*"syslog.c filter.c txr.c arith.c unwind.c cadr.c" - ,*#`sysif.c @lib/place.tl @lib/ifa.tl` + ,*#`sysif.c @lib/place.tl @lib/ifa.tl @lib/ver.tl` ,*#`@lib/cadr.tl @lib/with-resources.tl` ,*#`@lib/txr-case.tl`))) @(collect) @@ -28,12 +28,12 @@ static void dir_tables_init(void) @ (or) reg_fun(@{txl-sym}_s,@(skip) @ (or) - reg_var(@{txl-sym-special}_s,@(skip) + reg_var@/l?/(@{txl-sym-special}_s,@(skip) @ (bind txl-sym `*@{txl-sym-special}*`) @ (or) - @/ */reg_var(@(skip)intern(lit("@{txl-sym}")@(skip) + @/ *reg_varl?/(@(skip)intern(lit("@{txl-sym}")@(skip) @ (or) -@/ *\((defun|defvar|defmacro)/ @{txl-sym} @(skip) +@/ *\((defun|defvarl?|defmacro)/ @{txl-sym} @(skip) @ (end) @ (set txl-sym @(regsub #/_/ #\- txl-sym)) @ (end) @@ -75,30 +75,30 @@ void glob_init(void) { prot1(&s_errfunc); reg_fun(intern(lit("glob"), user_package), func_n3o(glob_wrap, 1)); - reg_var(intern(lit("glob-err"), user_package), num_fast(GLOB_ERR)); - reg_var(intern(lit("glob-mark"), user_package), num_fast(GLOB_MARK)); - reg_var(intern(lit("glob-nosort"), user_package), num_fast(GLOB_NOSORT)); - reg_var(intern(lit("glob-nocheck"), user_package), num_fast(GLOB_NOCHECK)); - reg_var(intern(lit("glob-noescape"), user_package), num_fast(GLOB_NOESCAPE)); + reg_varl(intern(lit("glob-err"), user_package), num_fast(GLOB_ERR)); + reg_varl(intern(lit("glob-mark"), user_package), num_fast(GLOB_MARK)); + reg_varl(intern(lit("glob-nosort"), user_package), num_fast(GLOB_NOSORT)); + reg_varl(intern(lit("glob-nocheck"), user_package), num_fast(GLOB_NOCHECK)); + reg_varl(intern(lit("glob-noescape"), user_package), num_fast(GLOB_NOESCAPE)); #ifdef GLOB_PERIOD - reg_var(intern(lit("glob-period"), user_package), num_fast(GLOB_PERIOD)); + reg_varl(intern(lit("glob-period"), user_package), num_fast(GLOB_PERIOD)); #endif #ifdef GLOB_ALTDIRFUNC - reg_var(intern(lit("glob-altdirfunc"), user_package), num_fast(GLOB_ALTDIRFUNC)); + reg_varl(intern(lit("glob-altdirfunc"), user_package), num_fast(GLOB_ALTDIRFUNC)); #endif #ifdef GLOB_BRACE - reg_var(intern(lit("glob-brace"), user_package), num_fast(GLOB_BRACE)); + reg_varl(intern(lit("glob-brace"), user_package), num_fast(GLOB_BRACE)); #endif #ifdef GLOB_NOMAGIC - reg_var(intern(lit("glob-nomagic"), user_package), num_fast(GLOB_NOMAGIC)); + reg_varl(intern(lit("glob-nomagic"), user_package), num_fast(GLOB_NOMAGIC)); #endif #ifdef GLOB_TILDE - reg_var(intern(lit("glob-tilde"), user_package), num_fast(GLOB_TILDE)); + reg_varl(intern(lit("glob-tilde"), user_package), num_fast(GLOB_TILDE)); #endif #ifdef GLOB_TILDE_CHECK - reg_var(intern(lit("glob-tilde-check"), user_package), num_fast(GLOB_TILDE_CHECK)); + reg_varl(intern(lit("glob-tilde-check"), user_package), num_fast(GLOB_TILDE_CHECK)); #endif #ifdef GLOB_ONLYDIR - reg_var(intern(lit("glob-onlydir"), user_package), num_fast(GLOB_ONLYDIR)); + reg_varl(intern(lit("glob-onlydir"), user_package), num_fast(GLOB_ONLYDIR)); #endif } @@ -3810,21 +3810,21 @@ loc get_user_package(void) { if (nilp(user_package_s)) return mkcloc(user_package_var); - return lookup_var_l(nil, user_package_s); + return lookup_global_var_l(user_package_s); } loc get_system_package(void) { if (nilp(system_package_s)) return mkcloc(system_package_var); - return lookup_var_l(nil, system_package_s); + return lookup_global_var_l(system_package_s); } loc get_keyword_package(void) { if (nilp(keyword_package_s)) return mkcloc(keyword_package_var); - return lookup_var_l(nil, keyword_package_s); + return lookup_global_var_l(keyword_package_s); } val func_f0(val env, val (*fun)(val)) diff --git a/share/txr/stdlib/ver.tl b/share/txr/stdlib/ver.tl index c4daa06e..a721092f 100644 --- a/share/txr/stdlib/ver.tl +++ b/share/txr/stdlib/ver.tl @@ -1 +1,2 @@ -(defvar *lib-version* 110) +(defvarl lib-version 110) +(defvarl *lib-version* lib-version) @@ -114,59 +114,59 @@ void sig_init(void) prot1(&sig_lambda[i]); } - reg_var(intern(lit("sig-hup"), user_package), num_fast(SIGHUP)); - reg_var(intern(lit("sig-int"), user_package), num_fast(SIGINT)); - reg_var(intern(lit("sig-quit"), user_package), num_fast(SIGQUIT)); - reg_var(intern(lit("sig-ill"), user_package), num_fast(SIGILL)); - reg_var(intern(lit("sig-trap"), user_package), num_fast(SIGTRAP)); - reg_var(intern(lit("sig-abrt"), user_package), num_fast(SIGABRT)); - reg_var(intern(lit("sig-bus"), user_package), num_fast(SIGBUS)); - reg_var(intern(lit("sig-fpe"), user_package), num_fast(SIGFPE)); - reg_var(intern(lit("sig-kill"), user_package), num_fast(SIGKILL)); - reg_var(intern(lit("sig-usr1"), user_package), num_fast(SIGUSR1)); - reg_var(intern(lit("sig-segv"), user_package), num_fast(SIGSEGV)); - reg_var(intern(lit("sig-usr2"), user_package), num_fast(SIGUSR2)); - reg_var(intern(lit("sig-pipe"), user_package), num_fast(SIGPIPE)); - reg_var(intern(lit("sig-alrm"), user_package), num_fast(SIGALRM)); - reg_var(intern(lit("sig-term"), user_package), num_fast(SIGTERM)); - reg_var(intern(lit("sig-chld"), user_package), num_fast(SIGCHLD)); - reg_var(intern(lit("sig-cont"), user_package), num_fast(SIGCONT)); - reg_var(intern(lit("sig-stop"), user_package), num_fast(SIGSTOP)); - reg_var(intern(lit("sig-tstp"), user_package), num_fast(SIGTSTP)); - reg_var(intern(lit("sig-ttin"), user_package), num_fast(SIGTTIN)); - reg_var(intern(lit("sig-ttou"), user_package), num_fast(SIGTTOU)); - reg_var(intern(lit("sig-urg"), user_package), num_fast(SIGURG)); - reg_var(intern(lit("sig-xcpu"), user_package), num_fast(SIGXCPU)); - reg_var(intern(lit("sig-xfsz"), user_package), num_fast(SIGXFSZ)); - reg_var(intern(lit("sig-vtalrm"), user_package), num_fast(SIGVTALRM)); - reg_var(intern(lit("sig-prof"), user_package), num_fast(SIGPROF)); + reg_varl(intern(lit("sig-hup"), user_package), num_fast(SIGHUP)); + reg_varl(intern(lit("sig-int"), user_package), num_fast(SIGINT)); + reg_varl(intern(lit("sig-quit"), user_package), num_fast(SIGQUIT)); + reg_varl(intern(lit("sig-ill"), user_package), num_fast(SIGILL)); + reg_varl(intern(lit("sig-trap"), user_package), num_fast(SIGTRAP)); + reg_varl(intern(lit("sig-abrt"), user_package), num_fast(SIGABRT)); + reg_varl(intern(lit("sig-bus"), user_package), num_fast(SIGBUS)); + reg_varl(intern(lit("sig-fpe"), user_package), num_fast(SIGFPE)); + reg_varl(intern(lit("sig-kill"), user_package), num_fast(SIGKILL)); + reg_varl(intern(lit("sig-usr1"), user_package), num_fast(SIGUSR1)); + reg_varl(intern(lit("sig-segv"), user_package), num_fast(SIGSEGV)); + reg_varl(intern(lit("sig-usr2"), user_package), num_fast(SIGUSR2)); + reg_varl(intern(lit("sig-pipe"), user_package), num_fast(SIGPIPE)); + reg_varl(intern(lit("sig-alrm"), user_package), num_fast(SIGALRM)); + reg_varl(intern(lit("sig-term"), user_package), num_fast(SIGTERM)); + reg_varl(intern(lit("sig-chld"), user_package), num_fast(SIGCHLD)); + reg_varl(intern(lit("sig-cont"), user_package), num_fast(SIGCONT)); + reg_varl(intern(lit("sig-stop"), user_package), num_fast(SIGSTOP)); + reg_varl(intern(lit("sig-tstp"), user_package), num_fast(SIGTSTP)); + reg_varl(intern(lit("sig-ttin"), user_package), num_fast(SIGTTIN)); + reg_varl(intern(lit("sig-ttou"), user_package), num_fast(SIGTTOU)); + reg_varl(intern(lit("sig-urg"), user_package), num_fast(SIGURG)); + reg_varl(intern(lit("sig-xcpu"), user_package), num_fast(SIGXCPU)); + reg_varl(intern(lit("sig-xfsz"), user_package), num_fast(SIGXFSZ)); + reg_varl(intern(lit("sig-vtalrm"), user_package), num_fast(SIGVTALRM)); + reg_varl(intern(lit("sig-prof"), user_package), num_fast(SIGPROF)); #ifdef SIGPOLL - reg_var(intern(lit("sig-poll"), user_package), num_fast(SIGPOLL)); + reg_varl(intern(lit("sig-poll"), user_package), num_fast(SIGPOLL)); #endif - reg_var(intern(lit("sig-sys"), user_package), num_fast(SIGSYS)); + reg_varl(intern(lit("sig-sys"), user_package), num_fast(SIGSYS)); #ifdef SIGWINCH - reg_var(intern(lit("sig-winch"), user_package), num_fast(SIGWINCH)); + reg_varl(intern(lit("sig-winch"), user_package), num_fast(SIGWINCH)); #endif #ifdef SIGIOT - reg_var(intern(lit("sig-iot"), user_package), num_fast(SIGIOT)); + reg_varl(intern(lit("sig-iot"), user_package), num_fast(SIGIOT)); #endif #ifdef SIGSTKFLT - reg_var(intern(lit("sig-stkflt"), user_package), num_fast(SIGSTKFLT)); + reg_varl(intern(lit("sig-stkflt"), user_package), num_fast(SIGSTKFLT)); #endif #ifdef SIGIO - reg_var(intern(lit("sig-io"), user_package), num_fast(SIGIO)); + reg_varl(intern(lit("sig-io"), user_package), num_fast(SIGIO)); #endif #ifdef SIGLOST - reg_var(intern(lit("sig-lost"), user_package), num_fast(SIGLOST)); + reg_varl(intern(lit("sig-lost"), user_package), num_fast(SIGLOST)); #endif #ifdef SIGPWR - reg_var(intern(lit("sig-pwr"), user_package), num_fast(SIGPWR)); + reg_varl(intern(lit("sig-pwr"), user_package), num_fast(SIGPWR)); #endif #if HAVE_ITIMER - reg_var(intern(lit("itimer-real"), user_package), num_fast(ITIMER_REAL)); - reg_var(intern(lit("itimer-virtual"), user_package), num_fast(ITIMER_VIRTUAL)); - reg_var(intern(lit("itimer-prov"), user_package), num_fast(ITIMER_PROF)); + reg_varl(intern(lit("itimer-real"), user_package), num_fast(ITIMER_REAL)); + reg_varl(intern(lit("itimer-virtual"), user_package), num_fast(ITIMER_VIRTUAL)); + reg_varl(intern(lit("itimer-prov"), user_package), num_fast(ITIMER_PROF)); reg_fun(intern(lit("getitimer"), user_package), func_n1(getitimer_wrap)); reg_fun(intern(lit("setitimer"), user_package), func_n3(setitimer_wrap)); #endif @@ -826,48 +826,48 @@ void sysif_init(void) #define S_IXOTH 0 #endif - reg_var(intern(lit("s-ifmt"), user_package), num_fast(S_IFMT)); - reg_var(intern(lit("s-ifsock"), user_package), num_fast(S_IFSOCK)); - reg_var(intern(lit("s-iflnk"), user_package), num_fast(S_IFLNK)); - reg_var(intern(lit("s-ifreg"), user_package), num_fast(S_IFREG)); - reg_var(intern(lit("s-ifblk"), user_package), num_fast(S_IFBLK)); - reg_var(intern(lit("s-ifdir"), user_package), num_fast(S_IFDIR)); - reg_var(intern(lit("s-ifchr"), user_package), num_fast(S_IFCHR)); - reg_var(intern(lit("s-ififo"), user_package), num_fast(S_IFIFO)); - reg_var(intern(lit("s-isuid"), user_package), num_fast(S_ISUID)); - reg_var(intern(lit("s-isgid"), user_package), num_fast(S_ISGID)); - reg_var(intern(lit("s-isvtx"), user_package), num_fast(S_ISVTX)); - reg_var(intern(lit("s-irwxu"), user_package), num_fast(S_IRWXU)); - reg_var(intern(lit("s-irusr"), user_package), num_fast(S_IRUSR)); - reg_var(intern(lit("s-iwusr"), user_package), num_fast(S_IWUSR)); - reg_var(intern(lit("s-ixusr"), user_package), num_fast(S_IXUSR)); - reg_var(intern(lit("s-irwxg"), user_package), num_fast(S_IRWXG)); - reg_var(intern(lit("s-irgrp"), user_package), num_fast(S_IRGRP)); - reg_var(intern(lit("s-iwgrp"), user_package), num_fast(S_IWGRP)); - reg_var(intern(lit("s-ixgrp"), user_package), num_fast(S_IXGRP)); - reg_var(intern(lit("s-irwxo"), user_package), num_fast(S_IRWXO)); - reg_var(intern(lit("s-iroth"), user_package), num_fast(S_IROTH)); - reg_var(intern(lit("s-iwoth"), user_package), num_fast(S_IWOTH)); - reg_var(intern(lit("s-ixoth"), user_package), num_fast(S_IXOTH)); + reg_varl(intern(lit("s-ifmt"), user_package), num_fast(S_IFMT)); + reg_varl(intern(lit("s-ifsock"), user_package), num_fast(S_IFSOCK)); + reg_varl(intern(lit("s-iflnk"), user_package), num_fast(S_IFLNK)); + reg_varl(intern(lit("s-ifreg"), user_package), num_fast(S_IFREG)); + reg_varl(intern(lit("s-ifblk"), user_package), num_fast(S_IFBLK)); + reg_varl(intern(lit("s-ifdir"), user_package), num_fast(S_IFDIR)); + reg_varl(intern(lit("s-ifchr"), user_package), num_fast(S_IFCHR)); + reg_varl(intern(lit("s-ififo"), user_package), num_fast(S_IFIFO)); + reg_varl(intern(lit("s-isuid"), user_package), num_fast(S_ISUID)); + reg_varl(intern(lit("s-isgid"), user_package), num_fast(S_ISGID)); + reg_varl(intern(lit("s-isvtx"), user_package), num_fast(S_ISVTX)); + reg_varl(intern(lit("s-irwxu"), user_package), num_fast(S_IRWXU)); + reg_varl(intern(lit("s-irusr"), user_package), num_fast(S_IRUSR)); + reg_varl(intern(lit("s-iwusr"), user_package), num_fast(S_IWUSR)); + reg_varl(intern(lit("s-ixusr"), user_package), num_fast(S_IXUSR)); + reg_varl(intern(lit("s-irwxg"), user_package), num_fast(S_IRWXG)); + reg_varl(intern(lit("s-irgrp"), user_package), num_fast(S_IRGRP)); + reg_varl(intern(lit("s-iwgrp"), user_package), num_fast(S_IWGRP)); + reg_varl(intern(lit("s-ixgrp"), user_package), num_fast(S_IXGRP)); + reg_varl(intern(lit("s-irwxo"), user_package), num_fast(S_IRWXO)); + reg_varl(intern(lit("s-iroth"), user_package), num_fast(S_IROTH)); + reg_varl(intern(lit("s-iwoth"), user_package), num_fast(S_IWOTH)); + reg_varl(intern(lit("s-ixoth"), user_package), num_fast(S_IXOTH)); #endif #if HAVE_POLL - reg_var(intern(lit("poll-in"), user_package), num_fast(POLLIN)); - reg_var(intern(lit("poll-out"), user_package), num_fast(POLLOUT)); - reg_var(intern(lit("poll-err"), user_package), num_fast(POLLERR)); + reg_varl(intern(lit("poll-in"), user_package), num_fast(POLLIN)); + reg_varl(intern(lit("poll-out"), user_package), num_fast(POLLOUT)); + reg_varl(intern(lit("poll-err"), user_package), num_fast(POLLERR)); #ifdef POLLPRI - reg_var(intern(lit("poll-pri"), user_package), num_fast(POLLPRI)); + reg_varl(intern(lit("poll-pri"), user_package), num_fast(POLLPRI)); #endif #ifdef POLLRDHUP - reg_var(intern(lit("poll-rdhup"), user_package), num_fast(POLLRDHUP)); + reg_varl(intern(lit("poll-rdhup"), user_package), num_fast(POLLRDHUP)); #endif #ifdef POLLNVAL - reg_var(intern(lit("poll-nval"), user_package), num_fast(POLLNVAL)); + reg_varl(intern(lit("poll-nval"), user_package), num_fast(POLLNVAL)); #endif #ifdef POLLRDBAND - reg_var(intern(lit("poll-rdband"), user_package), num_fast(POLLRDBAND)); + reg_varl(intern(lit("poll-rdband"), user_package), num_fast(POLLRDBAND)); #endif #ifdef POLLWRBAND - reg_var(intern(lit("poll-wrband"), user_package), num_fast(POLLWRBAND)); + reg_varl(intern(lit("poll-wrband"), user_package), num_fast(POLLWRBAND)); #endif #endif @@ -889,13 +889,13 @@ void sysif_init(void) reg_fun(intern(lit("w-ifcontinued"), user_package), func_n1(wifcontinued)); #endif #ifdef WNOHANG - reg_var(intern(lit("w-nohang"), user_package), num_fast(WNOHANG)); + reg_varl(intern(lit("w-nohang"), user_package), num_fast(WNOHANG)); #endif #ifdef WUNTRACED - reg_var(intern(lit("w-untraced"), user_package), num_fast(WUNTRACED)); + reg_varl(intern(lit("w-untraced"), user_package), num_fast(WUNTRACED)); #endif #ifdef WCONTINUED - reg_var(intern(lit("w-continued"), user_package), num_fast(WCONTINUED)); + reg_varl(intern(lit("w-continued"), user_package), num_fast(WCONTINUED)); #endif reg_fun(intern(lit("dupfd"), user_package), func_n2o(dup_wrap, 1)); #endif @@ -55,28 +55,28 @@ static struct strm_ops syslog_strm_ops; void syslog_init(void) { - reg_var(intern(lit("log-pid"), user_package), num_fast(LOG_PID)); - reg_var(intern(lit("log-cons"), user_package), num_fast(LOG_CONS)); - reg_var(intern(lit("log-ndelay"), user_package), num_fast(LOG_NDELAY)); - reg_var(intern(lit("log-odelay"), user_package), num_fast(LOG_ODELAY)); - reg_var(intern(lit("log-nowait"), user_package), num_fast(LOG_NOWAIT)); + reg_varl(intern(lit("log-pid"), user_package), num_fast(LOG_PID)); + reg_varl(intern(lit("log-cons"), user_package), num_fast(LOG_CONS)); + reg_varl(intern(lit("log-ndelay"), user_package), num_fast(LOG_NDELAY)); + reg_varl(intern(lit("log-odelay"), user_package), num_fast(LOG_ODELAY)); + reg_varl(intern(lit("log-nowait"), user_package), num_fast(LOG_NOWAIT)); #ifdef LOG_PERROR - reg_var(intern(lit("log-perror"), user_package), num_fast(LOG_PERROR)); + reg_varl(intern(lit("log-perror"), user_package), num_fast(LOG_PERROR)); #endif - reg_var(intern(lit("log-user"), user_package), num_fast(LOG_USER)); - reg_var(intern(lit("log-daemon"), user_package), num_fast(LOG_DAEMON)); - reg_var(intern(lit("log-auth"), user_package), num_fast(LOG_AUTH)); + reg_varl(intern(lit("log-user"), user_package), num_fast(LOG_USER)); + reg_varl(intern(lit("log-daemon"), user_package), num_fast(LOG_DAEMON)); + reg_varl(intern(lit("log-auth"), user_package), num_fast(LOG_AUTH)); #ifdef LOG_AUTHPRIV - reg_var(intern(lit("log-authpriv"), user_package), num_fast(LOG_AUTHPRIV)); + reg_varl(intern(lit("log-authpriv"), user_package), num_fast(LOG_AUTHPRIV)); #endif - reg_var(intern(lit("log-emerg"), user_package), num_fast(LOG_EMERG)); - reg_var(intern(lit("log-alert"), user_package), num_fast(LOG_ALERT)); - reg_var(intern(lit("log-crit"), user_package), num_fast(LOG_CRIT)); - reg_var(intern(lit("log-err"), user_package), num_fast(LOG_ERR)); - reg_var(intern(lit("log-warning"), user_package), num_fast(LOG_WARNING)); - reg_var(intern(lit("log-notice"), user_package), num_fast(LOG_NOTICE)); - reg_var(intern(lit("log-info"), user_package), num_fast(LOG_INFO)); - reg_var(intern(lit("log-debug"), user_package), num_fast(LOG_DEBUG)); + reg_varl(intern(lit("log-emerg"), user_package), num_fast(LOG_EMERG)); + reg_varl(intern(lit("log-alert"), user_package), num_fast(LOG_ALERT)); + reg_varl(intern(lit("log-crit"), user_package), num_fast(LOG_CRIT)); + reg_varl(intern(lit("log-err"), user_package), num_fast(LOG_ERR)); + reg_varl(intern(lit("log-warning"), user_package), num_fast(LOG_WARNING)); + reg_varl(intern(lit("log-notice"), user_package), num_fast(LOG_NOTICE)); + reg_varl(intern(lit("log-info"), user_package), num_fast(LOG_INFO)); + reg_varl(intern(lit("log-debug"), user_package), num_fast(LOG_DEBUG)); reg_fun(intern(lit("openlog"), user_package), func_n3o(openlog_wrap, 1)); reg_fun(intern(lit("closelog"), user_package), func_n0(closelog_wrap)); reg_fun(intern(lit("setlogmask"), user_package), func_n1(setlogmask_wrap)); @@ -6853,7 +6853,7 @@ takes place prior to evaluation time, whereas doesn't execute until evaluation time. See also: the -.code *self-path* +.code self-path and .code stdlib variables in \*(TL. @@ -23735,26 +23735,26 @@ is a floating-point number, then it is converted by as if by the function .codn int-flo . -.coNP Variables @, *flo-min* @, *flo-max* and @ *flo-epsilon* +.coNP Variables @, flo-min @, flo-max and @ flo-epsilon .desc These variables hold, respectively: the smallest positive floating-point value; the largest positive floating-point value; and the difference between 1.0 and the smallest representable value greater than 1.0. -.code *flo-min* +.code flo-min and -.code *flo-max* +.code flo-max define the floating-point range, which consists of three regions: values from -.code (- *flo-max*) +.code (- flo-max) to -.codn (- *flo-min*) ; +.codn (- flo-min) ; the value 0.0, and values from -.code *flo-min* +.code flo-min to -.codn *flo-max* . +.codn flo-max . -.coNP Variable @ *flo-dig* +.coNP Variable @ flo-dig .desc This variable holds an integer representing the number of decimal digits in a decimal floating-point number such that this number can be converted @@ -23762,15 +23762,15 @@ to a \*(TX floating-point number, and back to decimal, without a change in any o the digits. This holds regardless of the value of the number, provided that it does not exceed the floating-point range. -.coNP Variables @ *pi* and @ *e* +.coNP Variables @ %pi% and @ %e% .desc These variables hold an approximation of the mathematical constants \(*p and e. To four digits of precision, \(*p is 3.142 and e is 2.718. The -.code *pi* +.code %pi% and -.code *e* +.code %e% approximations are accurate to -.code *flo-dig* +.code flo-dig decimal digits. .SS* Bit Operations @@ -24397,7 +24397,7 @@ while ensuring that the stream is closed immediately: -.coNP Variable @ *unhandled-hook* +.coNP Special variable @ *unhandled-hook* The .code *unhandled-hook* variable is initialized with @@ -28272,17 +28272,17 @@ deleted from the list with the function, but it continues to exist until the program loses the last reference to that package. -.coNP Special variables @, *user-package* @, *keyword-package* and @ *system-package* +.coNP Variables @, user-package @, keyword-package and @ system-package .desc These variables hold predefined packages. The -.code *user-package* +.code user-package is the one in which symbols are read when a \*(TX program is being scanned. The -.code *keyword-package* +.code keyword-package holds keyword symbols, which are printed with a leading colon. The -.code *system-package* +.code system-package is for internal symbols, helping the implementation avoid name clashes with user code in some situations. @@ -29175,7 +29175,7 @@ function can retrieve a file descriptor, otherwise an exception of type .code file-error is thrown. -.coNP Special variables @, s-ifmt @, s-iflnk @, s-ifreg @, s-ifblk ... , @ s-ixoth +.coNP Variables @, s-ifmt @, s-iflnk @, s-ifreg @, s-ifblk ... , @ s-ixoth The following variables exist, having integer values. These are bitmasks which can be applied against the value given by the @@ -29410,7 +29410,7 @@ signals. These handlers are then safely called if they were subroutines of .codn sig-check , and not asynchronous interrupts. -.coNP Special variables @, sig-hup @, sig-int @, sig-quit @, sig-ill @, sig-trap @, sig-abrt @, sig-bus @, sig-fpe @, sig-kill @, sig-usr1 @, sig-segv @, sig-usr2 @, sig-pipe @, sig-alrm @, sig-term @, sig-chld @, sig-cont @, sig-stop @, sig-tstp @, sig-ttin @, sig-ttou @, sig-urg @, sig-xcpu @, sig-xfsz @, sig-vtalrm @, sig-prof @, sig-poll @, sig-sys @, sig-winch @, sig-iot @, sig-stkflt @, sig-io @ sig-lost and @ sig-pwr +.coNP Variables @, sig-hup @, sig-int @, sig-quit @, sig-ill @, sig-trap @, sig-abrt @, sig-bus @, sig-fpe @, sig-kill @, sig-usr1 @, sig-segv @, sig-usr2 @, sig-pipe @, sig-alrm @, sig-term @, sig-chld @, sig-cont @, sig-stop @, sig-tstp @, sig-ttin @, sig-ttou @, sig-urg @, sig-xcpu @, sig-xfsz @, sig-vtalrm @, sig-prof @, sig-poll @, sig-sys @, sig-winch @, sig-iot @, sig-stkflt @, sig-io @ sig-lost and @ sig-pwr .desc These variables correspond to the C signal constants .codn SIGHUP , @@ -29634,7 +29634,7 @@ The argument defaults to zero. If it is specified as nonzero, it should be a bitwise combination (via the .code logior -function) of the constants +function) of the variables .codn w-nohang , .codn w-untraced and @@ -29960,7 +29960,7 @@ and generate logs via .codn syslog , or using special syslog streams. -.coNP Special variables @, log-pid @, log-cons @, log-ndelay @, log-odelay @ log-nowait and @ log-perror +.coNP Variables @, log-pid @, log-cons @, log-ndelay @, log-odelay @ log-nowait and @ log-perror .desc These variables take on the values of the corresponding C preprocessor constants from the @@ -31193,11 +31193,11 @@ finalization execution are not eligible for the current phase of finalization processing; they will be processed in a later garbage collection pass. .SS* Modularization -.coNP Special variable @ *self-path* +.coNP Variable @ self-path .desc This variable holds the invocation path name of the \*(TX program. -.coNP Special variable @ stdlib +.coNP Variable @ stdlib The .code stdlib variable expands to the directory where the \*(TX standard library @@ -31632,15 +31632,15 @@ These error symbols existed: and .codn process_error . -.coNP Variables @ *txr-version* and @ *lib-version* +.coNP Variables @ txr-version and @ lib-version .desc The -.code *txr-version* +.code txr-version variable gives the version of the \*(TX executable. Programs can express conditional variable based on detecting the version. The -.code *lib-version* +.code lib-version variable gives the version of the installed library of \*(TX code accompanying the executable. @@ -258,9 +258,11 @@ static void sysroot_init(void) #endif stdlib_path = sysroot(lit("share/txr/stdlib")); - reg_var(intern(lit("stdlib"), user_package), stdlib_path); - reg_var(intern(lit("*txr-version*"), user_package), - toint(lit(TXR_VER), nil)); + reg_varl(intern(lit("stdlib"), user_package), stdlib_path); + reg_varl(intern(lit("*txr-version*"), user_package), + toint(lit(TXR_VER), nil)); + reg_varl(intern(lit("txr-version"), user_package), + toint(lit(TXR_VER), nil)); } static int license(void) @@ -682,7 +684,8 @@ int txr_main(int argc, char **argv) format(std_error, lit("bindings:\n~s\n"), bindings, nao); } - reg_var(intern(lit("*self-path*"), user_package), spec_file_str); + reg_varl(intern(lit("*self-path*"), user_package), spec_file_str); + reg_var(intern(lit("self-path"), user_package), spec_file_str); { int retval = extract(spec, arg_list, bindings); |