summaryrefslogtreecommitdiffstats
path: root/ChangeLog
Commit message (Collapse)AuthorAgeFilesLines
...
* Change in the design of how special variables work, to fix the brokenKaz Kylheku2014-02-281-0/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | re-binding. C code now has to go through the dynamic environment lookup to access things like *random-state*, or *stdout*. As part of this, I'm moving some intrinsic variable and function initializations out of eval.c and into their respective modules. Macros are are used to make global variables look like ordinary C variables. This is very similar to the errno trick in POSIX threads implementations. * eval.c (looup_var, lookup_var_l): Restructured to eliminate silly goto, the cobjp handling is gone. (reg_fun, reg_var): Internal function becomes external. reg_var registers a simple cons cell binding now, without any C pointer tricks to real C global variables. (c_var_mark): Static function removed. (c_var_ops): Static struct removed. (eval_init): Numerous initializations for streams, syslog, rand, signals and others moved to their respective modules. The new symbol variables user_package_s, keyword_package_s and system_package_s are interned here, and the variables are created in a special way. * eval.h (reg_var, reg_fun): Declared. * gc.c (prot1): Added assert that the loc pointer isn't null. This happened, and blew up during garbage collection. * lib.c (system_package, keyword_package, user_package): Variables removed these become macros. (system_package_var, keyword_package_var, user_package_var): New global variables. (system_package_s, keyword_package_s, user_package_s): New symbol globals. (get_user_package, get_system_package, get_keyword_package): New functions. (obj_init): Protect new variables. Initialization order of modules tweaked: the modules sig_init, stream_init, and rand_init are moved after eval_init because they register variables. * lib.h (keyword_package, system_pckage, user_package): Variables turned into macros. (system_package_var, keyword_package_var, user_package_var): Declared. (system_package_s, keyword_package_s, user_package_s): Declared. (get_user_package, get_system_package, get_keyword_package): Declared. * rand.c (struct random_state): Renamed to struct rand_state to avoid clash with new random_state macro. (random_state): Global variable removed. (random_state_s): New symbol global. (make_state, rand32, make_random_state, random_fixnum, random): Follow rename of struct random_state.
* * eval.c (op_defvar): Remove the same-named symbol macro when aKaz Kylheku2014-02-281-0/+13
| | | | | | | | | | | | variable is defined. (op_defsymacro): Remove the same-named variable when a symbol macro is defined. (op_defun): Throw excpetion if an attempt is made to define a special operator as a function. Remove the same-named macro when a function is defined. (op_defmacro): Throw excpetion if an attempt is made to define a special operator as a macro. REmove the same-named function when a macro is defined.
* * eval.c (expand_qquote): Fix broken '(,x . ,y) case, whichKaz Kylheku2014-02-281-0/+9
| | | | | | | | is generating (append (list x) . y) instead of (append (list x) y). Also, added a nil case which is now necessary to prevent '(,x) from generating (append (list x) nil), though this is effectively an optimization, which is pointless, since the expander isn't optimizing overall.
* * tests/010/output-clauses.expected: New file.Kaz Kylheku2014-02-281-0/+6
| | | | * tests/010/output-clauses.txr: New file.
* About time for some new regression tests.Kaz Kylheku2014-02-281-0/+16
| | | | | | | | | | | | | | * tests/011/macros-1.expected: New file. * tests/011/macros-1.txr: New file. * tests/011/macros-2.expected: New file. * tests/011/macros-2.txr: New file. * tests/011/special-1.expected: New file. * tests/011/special-1.txr: New file.
* Bugfixing semantics of symbol macro hiding by variable bindings.Kaz Kylheku2014-02-281-0/+15
| | | | | | | | | | | | | * eval.c (expand_vars): Expand vars needs to know whether it's handling a sequential (let*-like) or parallel (let-like) binding. The init form of a variable sees the previous macro environment, but that variable must, for the remaining variables, shadow any previous symbol macro. (expand): In expand we must inform expand_vars whether we have a sequential or parallel binding construct. Moreover, there was a huge bug here: the new_menv (with the shadows) was passed to expand_vars, so that all the variables were hiding same-named symbol macros from all their initforms.
* * eval.c (delay_s): Global variable removed.Kaz Kylheku2014-02-271-0/+9
| | | | | | | | (eval_init): Initialiation of delay_s removed. Symbol now interned in reg_mac call for registering me_delay . * genvim.txr: Updated to recognize a reg_mac call with intern.
* * txr.1: Improved documentation for the dwim operator.Kaz Kylheku2014-02-271-0/+4
|
* Version 82.txr-82Kaz Kylheku2014-02-271-0/+14
|
* * txr.1: Typos, grammar and formatting fixes mailed inKaz Kylheku2014-02-271-0/+5
| | | | by Roman Mishin.
* * parser.l: Regression: valid floating-point literals taggedKaz Kylheku2014-02-271-0/+6
| | | | | as having trailing junk. The fix is to put the junk-matching rule after the valid rules.
* * lib.c (copy): New function.Kaz Kylheku2014-02-271-0/+10
| | | | | | | | * lib.h (copy): Declared. * eval.c (eval_init): Registered copy function as intrinsic. * txr.1: Added missing documentation for length. Documented copy.
* * genvim.txr: Updated with regard to how operators are registered inKaz Kylheku2014-02-271-0/+8
| | | | | | | in eval_init. Also, scans reg_mac registrations now. * txr.vim: Refreshed. The previously missed "delay" operator is now listed, thanks to reg_mac.
* * eval.c (maybe_progn): New function.Kaz Kylheku2014-02-271-0/+6
| | | | | (expand_macrolet, expand_symacrolet): Use maybe_progn to eliminate unnecessary progn wrapping.
* * eval.c (gun_s): New global variable.Kaz Kylheku2014-02-261-0/+9
| | | | | | | | (me_gun): New static function. (eval_init): New gun symbol interened, me_gun registered as intrinsic macro. * txr.1: Documented gun.
* Converting expander special case code transformations intoKaz Kylheku2014-02-261-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | formal macros that are in the top_mb table, make their symbols fboundp and can be expanded with macroexpand. * eval.c (mefun_t): New typedef name. (expand_macro): If the expander is a cobj, then pull out the C function and call it, otherwise realize the interpreted macro as before. (me_gen, me_delay): New static functions, replace expand_gen and expand_delay. (expand_qquote): Renamed to me_quote. (expand_gen, expand_delay): Renamed to me_gen and me_delay, with an interface adjustment and moved. (expand_op): Renamed to me_op. (expand): Removed qquote, gen, delay, op, and do handling, since these operators are now macros. Removed the unnecessary expansion of with-saved-vars. (reg_op, reg_fun): Assert that the symbol is not nil, to catch initialization order issues. One just showed up: op_do was interned in match.c, which is initialized later. (reg_mac): New static function (eval_init): Intern do_s, because match.c hasn't done it yet at this point. Register me_gen, me_delay, me_op (twice) and me_qquote as intrinsic macros. * txr.1: Documented those operators as macros.
* * eval.c (reg_op): New static function.Kaz Kylheku2014-02-261-0/+6
| | | | | (eval_init): Register operators with reg_op instead of direct sethash calls.
* * lib.c (make_like): If the first element of list isn'tKaz Kylheku2014-02-261-0/+7
| | | | | | a character, then don't try to make it into a string; keep it as a list. This allows [mapcar list "abc" "def"] to work intuitively rather than blow up.
* * lib.c (lit_s): New symbol.Kaz Kylheku2014-02-261-0/+8
| | | | | | | (code2type): Return lit_s for LIT type. (typeof): Return lit_s for TAG_LIT. (replace_str): Error message wording. (obj_init): lit_s interned.
* * eval.c (do_eval): Set last_form_evaled just beforeKaz Kylheku2014-02-261-0/+5
| | | | dispatching function, so it is not clobbered by argument evaluations.
* * eval.c (expand_op): Use rlcp_tree when constructing theKaz Kylheku2014-02-261-0/+13
| | | | | | | | | | | | dwim_body, since the append2 copies list structure. * parser.y (n_exprs): propagate source loc info from both constituents, giving precedence to the left one, rather than just taking it from the left one and ignoring the second constituent. This fixes cases of missing location info. The left constituent n_expr is often a symbol, and those do not have location info. We want a case like like ((x) y) to take from (x), and (x (y)) to take it from (y), and so on.
* * parser.y (list): For @n_expr, get the source location infoKaz Kylheku2014-02-261-0/+8
| | | | | | | from the @ token. (n_expr): Bugfix: do not attribute a symbol with location info. (quasilit): Obtain location info from quasi_items, and only if that is unavailable, then from lineno.
* Version 81txr-81Kaz Kylheku2014-02-261-0/+12
| | | | | | | | | | * txr.c (version): Bumped. * txr.1: Bumped version and set date. * configure (txr_ver): Bumped. * RELNOTES, txr.vim: Updated.
* * parser.l (regex_parse, lisp_parse): Better formattingKaz Kylheku2014-02-261-0/+5
| | | | for the context string that serves in place of a filename.
* * eval.c (expand_place): Unnecessary, buggy function removed.Kaz Kylheku2014-02-261-0/+13
| | | | | | | | | | | | It was handling silly special cases with the net effect of being nearly equivalent to just expand, while failing to expand places which are compound macro calls. It did diagnose nonexistent place types at expansion time, which isn't worth much. (expand): All the expansions for the mutating operator sset, inc, dec, push, pop and flip were also pointless and have been removed. they did the precise equivalent of doing expand(rest(form)), and consing the symbol to the front, which is the fallback case for function call forms.
* * configure: Make it an error to have implicit function declarations byKaz Kylheku2014-02-251-0/+12
| | | | | | | | | | | means of -Werror=implicit-function-declarations. Fix broken mkdir and mknod tests. Regenerate config.make if we add -U__STRICT_ANSI__ to the compiler options, so that later tests benefit from this. Regenerate config.make right away if adding -D_DARWIN_C_SOURCE. This allows the makedev test to pass. * stream.c: Include <sys/types.h> for makedev. (mknod_wrap): Don't rely on makedev wrappers to be there; test.
* * parser.y (spec): Bugfix: SECRET_ESCAPE_E should use n_exprKaz Kylheku2014-02-251-0/+13
| | | | | | | | | | | | not expr. expr is subject to expand_meta. (n_expr): Do not associate source info with character literals. (expand_meta): Bugfix: when walking forms in a collecting loop, propagate the source info to them. Bugfix: attach source info to var and expr expansions. (rl): Rewritten in terms of rlset. (rlset): Only set source info for an object that doesn't already have it.
* * lib.c (obj_init): Revert qquote, unquote and spliceKaz Kylheku2014-02-251-0/+7
| | | | | | to the system namespace, for hygiene. * txr.1: Updated.
* * eval.c (eval_init): HAVE_MAKEDEV not HAVE_MKDEV.Kaz Kylheku2014-02-251-0/+4
|
* * stream.c (getcwd_wrap): Implement correct test of getcwd'sKaz Kylheku2014-02-251-0/+5
| | | | return value.
* * configure: Use -Werror= on the missing prototypes andKaz Kylheku2014-02-251-0/+5
| | | | strict prototypes warnings; these should be errors.
* * configure: Added feature tests for makedev, link/symlink/readlink,Kaz Kylheku2014-02-251-0/+15
| | | | | | | | | | | | | | mkdir and mknod. * eval.c (eval_init): Wrap #ifdefs around the registrations of the wrappers for these functions. * stream.c (mkdir_wrap): Wrap in #ifdef HAVE_MKDIR, and provide a Windows version if HAVE_MKDIR is missing, but HAVE_WINDOWS_H is true. (makedev_wrap, major_wrap, minor_wrap): Wrap with #if HAVE_MAKEDEV. (mknod): Use #if HAVE_MKNOD. (symlink_wrap, link_wrap, readlink_wrap): Wrap with #if HAVE_SYMLINK.
* * debug.c (debug): Fix 2013-12-02 regression, which leaves theKaz Kylheku2014-02-241-0/+5
| | | | debugger not printing the current line of data.
* * eval.c (eval_init): Intern symlink_wrap, link_wrap, readlink_wrap.Kaz Kylheku2014-02-241-0/+10
| | | | | | | | * stream.c (symlink_wrap, link_wrap, readlink_wrap): New functions. * stream.h (symlink_wrap, link_wrap, readlink_wrap): Declared. * txr.1: Documented.
* * eval.c (eval_init): Register forgotten s_ifsock variable.Kaz Kylheku2014-02-241-0/+17
| | | | | | | | | | | | | | | | Register mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap and mknod_wrap. * stream.c (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): New functions. (stream_init): Initialize forgotten variable s-ifsock. * stream.h (s_ifsock): Declared. (mkdir_wrap, chdir_wrap, getcwd_wrap, makedev_wrap, minor_wrap, major_wrap, mknod_wrap): Declared. * txr.1: Forgotten documentation for remove-path and rename-path added. Forgotten mention of s-ifsock. Documented new Unix functions.
* * parser.l: Support octal and binary numbers.Kaz Kylheku2014-02-241-0/+8
| | | | | | * txr.1: Documented. * genvim.txr, txr.vim: Updated.
* * parser.y (modifiers): Bugfix: list element not subject to expansionKaz Kylheku2014-02-241-0/+7
| | | | | | of Lisp forms denoted by @. (expand_meta): Bugfix: failure to expand vars, which can be symbol macros now.
* * lib.c (obj_print, obj_pprint): Render quasi-quote hash andKaz Kylheku2014-02-241-0/+13
| | | | | | | | | | | | vector literals using their original notation. * parser.y (unquotes_occur): Takes new argument, level. Only finds quotes which are at the given quasiquoting level. Finally, this is the right semantics. In the first version of this function, we were not eager enough: we neglected to find unquotes that were wrapped in nested quasiquotes. Then we were too eager: finding any unquotes, even ones belonging to the inner backquotes. (vector, hash, choose_quote): Pass zero to unquotes_occur function.
* * eval.c (expand_qquote): Bugfix. Was not handling an unquoteKaz Kylheku2014-02-241-0/+10
| | | | | | | | | in the dotted position: (qquote x1 .. xn . (unquote form)), which looks like the structure (qquote x1 .. xn unquote form). Fixed by a hack: after recursively expanding the (unquote form) part (rest of the form), we check whether the unexpanded version has unquote at the front. If so, we know the expansion is just form, and use it to emit the suitable expansion.
* Symbol macros.Kaz Kylheku2014-02-241-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | * eval.c (top_smb, defsymacro_s, symacrolet_s): New global variables. (lookup_symac, get_opt_param_syms, get_param_syms, op_defsymacro, expand_symacrolet, make_var_shadowing_env): New static functions. (expand_tree_cases, expand_catch_clause): Install shadowing environment so lexical bindings hide any symbol macrolets. (expand_place): Fix neglect to expand an atomic form, which breaks symbol macros used as places. (expand): Expand symbol macros, expand symacrolet binding forms. Make sure symbol macros are shadowed in the lexical binding constructs. Take advantage of return value of rlcp_tree in a few places. (macro_form_p): Support for symbol macros; bugfix: not handling default argument. (macroexpand_1): Streamlined, and support added for symbol macros. (eval_init): Protect top_smb from gc. Create new hash, stored in top_smb. Initialize defsymacro_s and symacrolet_s. Register op_defsymacro. * parser.y (rlcp_tree): Return the to form instead of useless t and nil. * txr.1: Documented.
* * txr.1: Document quasiquote operator syntax.Kaz Kylheku2014-02-231-0/+4
|
* * eval.c (env_fbind, env_vbind): Use acons_new_c, and provideKaz Kylheku2014-02-231-0/+19
| | | | | | | | | | | | | | | | | | a much more useful return value: the binding cell itself, rather than the symbol. (bind_args): Bugfix: env_vbind was still being called in one case, leading to a neglect to bind a special variable properly. (bindings_helper): Changed interface. Bugfix: in sequential binding, actually bind the successive environments so closures will behave 100% correctly. Returns a list of the actual bindings, in which special variables are not distinguished in any way. (op_let, op_for): Conform to new bindings_helper interface. Use the lexical environment that it returns instead of making a new one. (op_each): Use the environment and list of bindings out of bindings_helper. The bindings are used for stepping the lists, and that includes stepping any special vars. The lexical environment is used for evaluating the body. Thus, we need no special processing for special vars here any more.
* * eval.c (bindings_helper): This must now bind dynamic valuesKaz Kylheku2014-02-231-0/+16
| | | | | | | | | | | | | | | rather than just assign to them. Got rid of the superfluous variable saving array. Fixed the problem in recognizing the special_s symbol (it is bindable). (op_with_saved_vars): This simplifies, since it no longer needs to save individual variables in an array, only to set up and tear down a new dynamic environment frame. (expand_vars): No longer returns two values with a cons. Takes a form argument for error reporting and a pointer to a boolean just to report whether there are special vars without listing them. (expand_save_specials): The with-saved-specials form doesn't need a var list any more, so the expander is updated not to stick them in. (expand): Update calls to expand_vars to new interface.
* * stream.c (get_string_from_stream): Bugfix: do not abort ifKaz Kylheku2014-02-231-0/+5
| | | | stream is not a string stream, but throw a proper error exception.
* Get special variable overriding working in function and macroKaz Kylheku2014-02-231-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | parameter lists. There is a bugfix here too (see eval_init below). * eval.c (special_s): New global variable. This symbol is used as a marker in parameter lists denoting expander-generating syntax that gives information about specials. (lookup_var, looup_var_l): Bugfix: walk the dynamic chain properly. Fallback from the lexical chain to the dynamic. (env_vbind_special): New static function. (bind_args, bind_macro_params): Detect special list in params. Use env_vbind_special to bind variables either in the dynamic environment or the lexical one. (expand_opt_params, expand_params): Renamed to expand_opt_params_rec and expand_params_rec, respectively. Now take extra argument for accumulating list of special variables found in the param list. (expand_params): New static function. (set_dyn_env): New static function. (interp_fun, expand_macro): Set up and tear down new dynamic environment around parameter list evaluation and body evaluation. This will take any new dynamic bindings. (bindings_helper, op_each): The special_s symbol is now used instead of colon_k for marking specials. (op_defun): Recognize the specials added to the parameter list so as not to t report that as not a bindable symbol. (op_catch): Set up an tear down new dynamic environment around the evaluation of the catch clause param binding and body. (expand_vars): use colon_s symbol instead of colon_k for marking special var. (eval_init): Bugfix: gc-protect recently added dyn_env variable. Intern special symbol into special_s variable.
* Introducing some changes for improved handling of special variables.Kaz Kylheku2014-02-231-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saving and restoring of individual variables is very silly and it's making it difficult to implement function parameters that are rebindings of special variables. Let's have a global pointer to a dynamic environment called dyn_env. Let's make it part of the extended_jmp_buf structure, so that it's implicitly saved and restored across exception handling. Special variable lookups go through the dyn_env chain, and fall back on the global bindings. To override some specials, we just push a new dynamic environment and stick them there. (As a bonus, the bindings can even be repeated in the lexical environment (i.e. the same objects), so they can be found faster. We have to make sure we remove that environment when we leave the scope in the normal way. If we unwind out, it is done automatically by extended_longjmp mechanism. * eval.c (dyn_env): New global variable. (lookup_var, lookup_var_l): If env is nil, look in the dyn_env first, and only if that fails, look in the global bindings top_vb. * signal.h (extended_jmp_buf): New member, de, for saving/restoring dyn_env. This structure is now used whether or not we have signals. (extended_setjmp, extended_longjmp): Updated to save and restore dyn_env, and to do it regardless of whether there is POSIX signal support. (dyn_env): Declared here.
* * eval.c (symbol_function): Retrieve the global macro binding if theKaz Kylheku2014-02-221-0/+12
| | | | | | | | | | | function lookup fails, and if that fails, retrieve the special operator binding. (fboundp): Report t if there is a global macro binding. * txr.1: Use "global" rather than "toplevel". Added note that the fun operator doesn't see macro bindings. Documented that symbol-function and fboundp see global macro bindings, and that symbol-function can retrieve a special operator binding.
* * eval.c (prinl, pprinl): New functions.Kaz Kylheku2014-02-221-0/+7
| | | | | | (eval_init): Registered as intrinsics. * txr.1: Documented.
* * lib.c (obj_init): changing the quote, qquote, unquoteKaz Kylheku2014-02-221-0/+6
| | | | | and splice symbols to be in the regular user package, rather than the system package.
* * parser.y: Allow the (. expr) syntax to denote expr.Kaz Kylheku2014-02-221-0/+11
| | | | | | | | | * eval.h: Declare existing lambda_s extern variable. * lib.c (obj_print, obj_pprint): print (lambda sym ...) as (lambda (. sym) ...) and (lambda sym) as (lambda (. sym)). * txr.1: document it.