| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (looup_fun): Handle (meth ...) syntax.
* share/txr/stdlib/place.tl (sys:get-fb): Function
removed.
(sys:get-fun-getter-setter): New function.
(defplace symbol-function): Rework getter and
setter using new function which works for method
as well as regular function bindings.
* txr.1: Documentation updated in several places.
The mention of symbol-function in the list of place
forms altered so it doesn't insinuate that the argument
must be a symbol. Description of symbol-function
updated. Also under the trace and untrace macros,
a note added that tracing methods is possible.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (optimize_qquote_form): Pass nil to default
new argument of butlast.
(me_whilet, me_iflet_whenlet): Likewise for last.
(eval_init): Add optional argument to registration
of last and butlast intrinsics.
* lib.c (last, butlast): Support optional numeric
argument, like in Common Lisp.
* lib.h (last, butlast): Declarations updated.
* share/txr/stdlib/place.tl (last, butlast): New
place macros.
* txr.1: Updated documentation. The description of
last is now moved into the sequence functions
section.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): register nthlast and butlastn
intrinsicis.
* lib.c (nthlast, butlastn): New function.
* lib.h (nthlast, butlastn): Declared.
* share/txr/stdlib/place.tl (defplace nthlast,
defplace butlastn): New places.
* txr.1: Documented nthlast and butlastn.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The quasiquote expander does something very odd: it passes the
macro-time environment through its recursion and calls expand
on some forms. Why was this done? Perhaps it helps promote
certain optimizations. In any case, it gets in the way of
being able to expand quasiquotes in a non-macro context.
* eval.c (expand_qquote_rec): Lose menv argument,
and eliminate all expand calls.
(expand_qquote): Lose menv argument, and don't pass it
down to expand_qquote_rec.
(me_qquote): Ignore menv argument; don't pass it down
to expand_qquote.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Turns out that there is missing support for quasiquoting
over structs. Code analogous to the way vector and hash
literals are handled is missing for structs.
* eval.c (expand_qquote_rec): Handle struct_lit_s forms
specially, like hash_lit_s and vector_lit_s.
commit 1e5bc5708d5763f20a7774f9348e825304a51adc
* struct.c (make_struct_lit_s): New symbol variable.
(struct_init): Store interned sys:make-struct-lit symbol
into make_struct_lit_s, and use that to register the
function.
* struct.h (make_struct_lit_s): Declared.
* tests/012/struct.tl: Update struct literal quasiquote
test cases to reflect fixed behavior.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The print function now takes an optional boolean
for pretty printing.
The print method is also called with a third argument;
hence structures can customize both standard printing
and pretty printing.
* lib.c (obj_print): Take pretty argument, and pass it down
to obj_print_impl. This makes obj_pprint redundant.
(obj_pprint): Function removed: it was identical to obj_print
except for passing t down to obj_print_impl for the
pretty argument. These two wrappers had started small and
got bigger with identical changes done in parallel.
(pprint): New function.
(tostring, dump): Pass nil for pretty argument of obj_print.
(tostringp): Use pprint instead of obj_pprint.
* lib.h (obj_print): Declaration updated.
(obj_pprint): Declaration removed.
(print, pprint): Declared.
* eval.c (prinl): Pass nil for pretty_p argument of obj_print.
Do the stream defaulting here; obj_print doesn't do it.
(pprinl): Pass t for pretty_p argument of obj_print,
and do stream argument defaulting.
(eval_init): Register print to new print function rather
than directly to obj_print.
Register pprint to new pprint function rather than obj_pprint.
* hash.c (hash_print_op): Call obj_print_impl to print
the :equal-based keyword, rather than obj_print. Pass
down the pretty flag. All the other keywords are treated
this way; this fixes an inconsistency.
* match.c (dump_var): Call pprint instead of obj_pprint.
* stream.c (formatv): Call obj_print, with a calculated
pretty argument instead of switching between obj_pprint
and obj_print.
* struct.c (struct_inst_print): Except when in backward
compatibility mode, call the object's print method in both
pretty and regular printing mode, passing the mode as a third
argument.
* tests/012/oop.tl (defstruct animal): Support third argument
in print method. Make it optional because there are some
explicit calls which don't pass the argument.
* txr.1: Documentation updated for print method and the
print function. Revised text for some of the related
functions. Added compat notes.
|
|
|
|
|
|
|
|
| |
* eval.c (env_fbind, env_vbind): Allow env to be
nil, indicating that the binding is to take
place in the global environment.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* Makefile, args.c, args.h, arith.c, arith.h, cadr.c, cadr.h, combi.c,
combi.h, configure, debug.c, debug.h, eval.c, eval.h, filter.c,
filter.h, ftw.c, ftw.h, gc.c, gc.h, glob.c, glob.h, hash.c, hash.h,
jmp.S, lib.c, lib.h, lisplib.c, lisplib.h, match.c, match.h, parser.c,
parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h,
share/txr/stdlib/awk.tl, share/txr/stdlib/build.tl,
share/txr/stdlib/cadr.tl, share/txr/stdlib/conv.tl,
share/txr/stdlib/except.tl, share/txr/stdlib/hash.tl,
share/txr/stdlib/ifa.tl, share/txr/stdlib/path-test.tl,
share/txr/stdlib/place.tl, share/txr/stdlib/socket.tl,
share/txr/stdlib/struct.tl, share/txr/stdlib/termios.tl,
share/txr/stdlib/txr-case.tl, share/txr/stdlib/type.tl,
share/txr/stdlib/with-resources.tl, share/txr/stdlib/with-stream.tl,
share/txr/stdlib/yield.tl, signal.c, signal.h, socket.c, socket.h,
stream.c, stream.h, struct.c, struct.h, sysif.c, sysif.h, syslog.c,
syslog.h, termios.c, termios.h, txr.1, txr.c, txr.h, unwind.c,
unwind.h, utf8.c, utf8.h: Revert to verbatim 2-Clause BSD.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (load): Do not resolve all relative paths
relative to the current *load-path*, only pure
relative ones.
* match.c (v_load): Likewise.
* txr.1: Update doc for @(load)/@(include) and load function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (sys_load_s): Variable removed.
(sys_load): Function removed.
(load): Body of function taken from sys_load.
There is no sloc argument; the *load-path*
variable is sampled via new load_path macro.
(me_load): Static function removed.
(eval_init): Remove initialization of sys_load_s
Remove registration of load macro and
sys:load function. Register load function.
* eval.h (load_path): New macro.
* txr.1: Change documentation of load from macro
to function.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The self-load-path symbol macro is as of now
deprecated. It simply expands to *load-path*.
*load-path* is a new special variable which is
dynamically bound to the path of a file
being loaded.
* eval.c (self_load_path_s): Global variable renamed
to load_path_s.
(sys_load): Bind *load-path* around processing of loaded file.
(me_load): Expand (load x) simply to (sys:load x *load-path*).
(set_get_symacro): Function removed.
(reg_symacro): New static function.
(eval_init): Initialize renamed load_path_s with interned
symbol having the name *load-path*. Register the *load-path*
special variable. Set up the sel-load-path symbol macro
aliasing for *load-path*.
* eval.h (self_load_path_s): Declaration renamed.
* match.c (v_load): Bind *load-path* around loading
or inclusion.
* parser.c (load_rcfile): Bind *load-path* around loading
of .txr_profile file.
* txr.c (txr_main): Bind *load-path* instead of
self-load-path symbol macro.
* txr.1: Updated documentation for @(load) directive
and load macro. Replaced documentation of self-load-path
with *load-path*.
|
|
|
|
|
|
|
|
|
|
| |
* arith.c (tofloatz, tointz): New functions.
* arith.h (tofloatz, tointz): Declared.
* eval.c (eval_init): Register tofloatz and tointz intrinsics.
* txr.1: Documented new functions.
|
|
|
|
|
|
|
| |
* eval.c (do_eval): The no such function or operator message
is replaced with one which makes it clear that this means
that the first element of the form doesn't name an operator
or function.
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Remove all regex-related function
registrations from here.
* regex.c (regex_init): Move regex-related function
registrations here.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register split-str to split_str_keep,
with optional argument.
* lib.c (split_str_keep): New function, formed from
split_str, with third argument.
(split_str): Reduced to wrapper around split_str_keep.
Thus we don't have to update umpteen existing calls
with an extra nil parameter.
* lib.h (split_str_keep): Declared.
* txr.1: Documented new optional argument of split-str.
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (me_while, me_until, me_while_star, me_until_star):
Functions removed.
(me_while_until, me_while_until_star): New functions.
Here we just check the form symbol and add the negation
to the test. Also: use of (zap flag) in the while* and until*
expansion has been replaced with (set flag nil), because
zap wastefully arranges to yield the prior value, which
is not used at all.
|
|
|
|
|
| |
eval.c (me_while_star, me_until_star): for loop test must be a
sequence of forms, not a single form.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (weave_while): Pass third arg to remq as nil.
(eval_init): Update registrations of remq, remql and
remqual.
* lib.c (remq, remql, remqual): Implement key function
argument.
* lib.h (remq, remql, remqual): Declarations updated.
* sysif.c (at_exit_call): Pass third arg to remq as nil.
* debug.c (debug): Pass third argument to remqual as nil.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Register keepq, keepql and keepqual
intrinsic functions.
* lib.c (keepq, keepql, keepqual): New functions.
* lib.h (keepq, keepql, keepqual): Declared.
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (qquote_init): Stricter quote_form_p_f test
function: reject the quote form if it isn't a proper
list of two elements.
(optimize_qquote_form): Extract all arguments of list
forms and catenate them with mapcan, rather than
assuming that they have one argument. This wrong
assumption breaks ,,*(list ...) interpolation,
for instance.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (consp_f, second_f, list_form_p_f, quote_form_p_f,
xform_listed_quote_f): New static variables.
(qquote_init): New function.
(optimize_qquote_form): Use list_form_p_f, quote_form_p_f, and
second_f instead of constructing functions locally.
(optimize_qquote_args): Use xform_listed_quote_f instead
of locally constructed function.
(eval_init): Call qquote_init.
Register second function to second_f.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The surface motive here is to get better code than
forms like (append (list 'a) (list 'b) ...).
The ulterior motive is to suppress the memory
explosion when heavily nested forms like ^^^^^^^^^^^x
are expanded. This problem was uncovered by
AFL (fast).
* eval.c (optimize_qquote_form, optimize_qquote_args,
optimize_qquote): New static functions.
(expand_qquote_rec): New function.
(expand_qquote): Contents moved into expand_qquote_rec.
This function now optimizes the results of calling
expand_qquote_rec.
|
|
|
|
|
|
| |
* eval.c (list_star_s): New symbol variable.
(eval_init): Initialize list_star_s and use it for the
list* function registration.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The op transformer generates a lambda which has
as many arguments as the highest-valued metanumber
(@<digits> syntax) occurring in the form.
If this is a huge integer, it obligingly tries to
construct the argument list, running out of memory.
In this commit, we cap the value to 1024.
This issue was uncovered by the fuzzing utility
AFL (fast) 2.30b.
* eval.c (me_op): Throw error if max exceeds 1024,
preventing the call to supplement_op_syms to actually
generate an a formal parameter list of max symbols.
|
|
|
|
|
|
| |
* eval.c (me_def_variable): Check for sym not
being a bindable symbol. Otherwise we might call
mark_special on nil, which triggers an assertion.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Variables defined with defvarl or defparml are being marked
special, due to a mark_special call in the macro expander
which existed before they were introduced.
* eval.c (me_def_variable): We have to call mark_special
at macro-expansion-time for defparm and defvar, rather than
arrange for it to be called later, for the same reasons
that the (now incorrect) mark_special call had been introduced
in do_expand function for handling defvar.
(do_expand): Do not call mark_special, because the symbol
being handled here is defvarl: define lexical variable.
|
|
|
|
|
|
| |
* eval.c (do_expand): Throw error if defsymacro form
isn't a list of three elements, just like defparm
and defparml do.
|
|
|
|
|
|
| |
* eval.c (op_defvarl, op_defsymacro): Report correct
symbol in not-bindable-symbol error message rather
than reporting as let.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* configure: Test for strptime.
* eval.c (eval_init): register time-parse intrinsic.
* lib.c (time_parse): New function.
* lib.h (time_parse): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (op_defsymacro): Remove sym from the special
hash, unless compatibility 143 or lower is requested.
* txr.1: Document effects of evaluating defsymacro
if a global variable of the same name exists, and the
behavior in lexical scopes where sym is bound.
Added compatibility notes covering the code change.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (unbound_s): New symbol variable.
(lookup_var): If a dynamic binding has the special sys:unbound
symbol as its value, then return nil, so the behavior
is as if there is no binding.
(makunbound): If the symbol exists in a dynamic environment,
then replace its value with sys:unbound, making it look
unbound.
(eval_init): Initialize unbound_s.
* lib.h (us_car, us_cdr): New inline functions.
* txr.1: New dialect notes under boundp.
Updated the makunbound documentation. Separated
makunbound documentation from fmakunbound and
mmakunbound. Added compatibility notes.
|
|
|
|
|
|
| |
* eval.c (format_field): Improve error messages; streamline
some code, report expression value rather than expression
itself for bad modifier.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (gethash_s): Global symbol variable removed,
due to being used only in one place.
(eval_init): Remove registration of make-hash, make-similar-hash,
copy-hash, hash, hash-construct, hash-from-pairs, hash-list, inhash,
sethash, pushhash, remhash, hash-count, get-hash-userdata,
set-hash-userdata, hashp, maphash, hash-eql, hash-equal, hash-keys,
hash-values, hash-pairs, hash-alist, hash-uni, hash-diff, hash-isec,
hash-subset, hash-proper-subset, group-by, group-reduce, hash-update,
hash-update-1, hash-revget, hash-begin, hash-next.
* hash.c (hash_init): Registrations removed from eval_init
moved here.
|
|
|
|
|
|
|
|
| |
* eval.c (me_op): We tell a little lie here, by indicating
that the "dwim body" is an expansion of the op operator.
Of course, the entire lambda containing that body
is that expansion. But in error messages, we need something
useful for the user.
|
|
|
|
|
|
| |
* eval.c (eval_init): Use sys_load_s variable
set up earlier in the function instead of redundant call to
intern.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (self_load_path_s): New symbol variable.
(sys_load): Save, set-up and restore self-load-path
around load.
(set_get_symacro): New function.
(eval_init): Register load function using sys_load_s instead
of redundant intern.
* eval.h (set_get_symacro): Declared.
* match.c (v_load): Save, set-up and restore self-load-path
macro.
* parser.c (load_rcfile): Likewise.
* txr.c (txr_main: Set up self-load-path when opening
file.
* txr.1: Documented self-load-path.
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Remove registration of
make-random-state, random-state-get-vec, random-state-p,
random-fixnup, random, and rand.
* rand.c (rand_init): Move registrations removed from
eval_init here.
|
|
|
|
|
|
|
|
| |
* eval.c (mapcarv, mappendv, mapdov): When done, we can
recycle the conses used for the temporary copy of the
list-of-lists, whose car-s are used for iterating over the
lists in paralle. This is safe because the temporary
list's conses aren't shared with any other function.
|
|
|
|
|
|
|
| |
* eval.c (sys_load): Use ~a format specifier rather than ~s
for the load path (if already known to be a string).
* match.c (v_load): Likewise.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (sys_load): close stream in all cases.
* match.c (v_load): Likewise.
* parser.c (load_rcfile): Close stream in unwind
block, if open.
* txr.c (txr_main): Close stream after parsing
in all cases. If stream is std_input, or a string stream,
close_stream does nothing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is really a gratuitous incompatibility with Common Lisp
and other dialects. Let's fix it internally also, but keep the
proper-listp function binding for backwards compatibility.
* eval.c (dot_to_apply, me_op): Update proper_listp
call to proper_list_p.
(eval_init): Register proper-list-p to the same C function as
proper-listp, and that C function is now called proper_list_p.
* lib.c (proper_listp): Renamed to proper_list_p.
* lib.h (proper_listp): Declaration updated.
* parser.y (define_transform): Update proper_listp call.
* txr.1: Replace all occurrences of proper-listp with
proper-list-p. Add note explaining the rename situation.
|
|
|
|
|
|
| |
* eval.c (error_trace): If an error occurs during the
expansion of a form, that form may be the result of
expansions. Dump those expansions.
|
|
|
|
|
|
|
|
|
|
|
| |
This fix is no longer that important, since due to the
previous commit, expand now tracks expansion origins
thoroughly, which hides this bug. However, expand_macro is
directly called from a few other functions, like macroexpand,
which don't benefit from that fix.
* eval.c (expand_macro): Add forgotten set_origin call
in the case when the native C expander is called.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This promotes better diagnostics. Simple test
case: [(ret @5) 1].
* eval.c (do_expand): Manual tail recursion via backwards goto
is removed; the function recurses now, and it recurses through
the expand wrapper rather than by calling itself. That is
needed in order to properly install the origin tracking for
each expansion.
(expand): Record origin for each expansion that already
doesn't have one.
|
|
|
|
|
|
|
|
|
| |
* eval.c (expand_symacrolet, do_expand): Don't expand the
replacement form of a global or lexical symbol macro at the
time it is bound to its symbol. This is almost certainly
wrong in situations where it makes a difference.
* txr.1: Noted in compatibility section.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The expander now actually produces apply forms for dot
position function call and dwim forms. This allows symbol
macros to work naturally.
* eval.c (sys_apply_s): New symbol variable.
(imp_list_to_list, dot_to_apply): New static functions.
(expand_forms, expand_forms_lisp1): We now throw an error if a
non-nil atom terminates a form, Except in compatibility mode
with TXR 137 or less, whereby we emulate the old behavior of
not expanding this atom.
(do_expand): Perform the dot_to_apply transformation
on the arguments of the dwim form.
Perform the dot_to_apply transformation on an
entire function call form.
(eval_init): Initialize sys_apply_s and register
sys:apply function (using the same function object that
is registered under apply).
* txr.1: Documented that both DWIM forms and regular
function call forms work as if by a transformation to apply form,
removing verbiage which separately described the DWIM
handling. Documented that symbol macros work properly in
dot position.
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (expand_forms): If the forms list is an atom, then
don't just return it. Try to expand it as a macro.
If the macro produces a compound form, diagnose with
an exception, otherwise return the expansion.
* txr.1: Document the treatment of symbol macros in
function call dot position.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Registered intrinsics rmemq, rmemql,
rmemqual, rmember, rmember-if, rposqual, rposql, rposq,
rpos, rpos-if, rfind, rfind-if and rsearch.
* lib.c (rmemq, rmemql, rmemqual, rmember, rmember-if,
rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if,
rsearch): New functions.
(rsearch_list): New static function.
(search): Omit unreachable return statement.
* lib.h (rmemq, rmemql, rmemqual, rmember, rmember-if,
rposqual, rposql, rposq, rpos, rpos-if, rfind, rfind-if,
rsearch): Declared.
* txr.1: Documented.
|
|
|
|
|
|
|
| |
* eval.c (do_expand, macroexpand_1): The original form
must have priority in providing source location info,
over the macro. Otherwise macro bodies may get reported as
locations of errors that occur in substituted code.
|
|
|
|
|
| |
* eval.c (op_each): Use list_collect_append not
list_collect_nconc. Ouch!
|