| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
|
|
|
|
|
|
| |
* hash.c (print_key_val): Static function removed.
(hash_print_op): Don't use maphash over print_key_val
to print hash tables. Use open-coded iteration and
printing with calls to obj_print_impl. This was
occassioned by a bug in circle printing. The use of
obj_print by hash_print_op resembles the actions of
a custom print method on a structure. A bug showed
up which is masked by refactoring to more direct
recursion via obj_print_impl. (The bug still has to be
fixed, though).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
No longer require the leftmost expression in a dwim place to
itself be a place, except when the expression evaluates to
a list, and the list is subject to an element deletion or
a range operation.
* eval.c (eval_init): Register dwim-set and dwim-del with
one additional argument that the C functions now take.
* lib.c (dwim_set, dwim_del): Take a new place_p argument
which informs these functions whether the object they
are operating on came from a syntactic place. The forbidden
situations are diagnosed based on this flag: modification
of the subrange of a list, or deletion of a list ref.
Some error messages reworded.
* lib.h (dwim_set, dwim_del): Declarations updated.
* share/txr/stdlib/place.tl (defplace dwim): Produce a
different update, clobber and delete expansion when
the obj-place form isn't a place. In the non-place case,
do not assign the result of the sys:dwim-set or
sys:dwim-del operation back obj-place. Furthermore,
pass a Boolean flag to sys:dwim-set and sys:dwim-del
indicating which situation is the case: did the object
argument come from a place or non-place.
* txr.1: Documentation updated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* eval.c (eval_init): Change registration of dwim-set to only
one required argument, with the rest variadic.
* lib.c (lambda_set_s): New symbol variable.
(dwim_set): Change to variadic function that takes all
arguments other than the object/sequence being operated on as
struct args *. Rewrite to do a test on the object type first,
handling hashes and structs specially.
(obj_init): Initialize lambda_set_s.
* share/txr/stdlib/place.tl (defplace dwim): Rewritten for
more generic syntax. The only argument required is obj-place;
the other arguments are treated as a variable argument list,
all treated uniformly. This eliminates the special handling
of the default value for hash lookups.
* args.h (args_count): New inline function.
* txr.1: Updated documentation for dwim operator, which neglects
to mention use over objects thanks to the lambda function.
Documented lambda-set.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
|
| |
* txr.1: Fix description under fun operator which
says that a macro expander is available via
symbol-function. This is outdated; the symbol-macro
function accesses macro bindings.
|
|
|
|
| |
* txr.1: Only first word of heading is capitalized.
|
|
|
|
| |
* txr.1: Under pprof, *std-output* corrected to *stdout*.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
New variable *trace-output*, and macros trace and untrace.
* lisplib.c (trace_set_entries, trace_instantiate): new static
functions.
(dlt_register): Register new functions to auto-load trace
module.
* share/txr/stdlib/trace.tl: New file.
* txr.1: Documented.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/awk.tl (sys:awk-state): New slot, streams.
Holds hash table of open streams. New :fini finalizer
which closes all streams.
(sys:awk-state ensure-stream, sys:awk-state close-or-flush):
New methods.
(sys:awk-redir): New macro.
(sys:awk-let): Bind new local macros ->, ->>, <-, !> and !<.
(awk): Call finalizers on awk state to get all streams
to close.
* txr.1: Document new awk macros.
|
|
|
|
|
|
| |
* txr.1: Listing last, butlast, nthlast, butlastn, ref, sub,
hash-userdata, slot, qref, slot access dot notation,
and sock peer. Redundant listing of rest removed.
|
|
|
|
| |
* txr.1: Around half a dozen toplevel -> top-level edits.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* share/txr/stdlib/place.tl (defplace dwim): In updater,
removing unused and redundant gensyms. Engaging unused
oldval-sym as a temporary to hold the result of invoking
(,ogetter-sym), the "getter" for the sequence object place we
are operating on. Both references then refer to this resut
instead of expanding the getter twice. Though getters should
not have side effects, they could be expensive. In simple
setter and deleter, setting up obj-sym similarly. We don't
make multiple accesses to the sequence, but we were evaluating
it in the wrong order w.r.t the index and new-val.
|
|
|
|
|
|
| |
* share/txr/stdlib/place.tl (defplace sub): Fix unbound
variable seq-setter in update expander. Wrong unquoting
level.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The alet macro should always convert bindings to constants
into symbol macros; the all-or-nothing logic should be applied
to any remaining bindings.
* share/txr/stdlib/place.tl (sys:r-s-let-expander): Generalize
this function somewhat more by passing in the fallback binding
symbol to use for bindings that can't be turned into symbol
macros, instead of hard-coding them to let.
(rlset, slet): Specify 'let when calling sys:r-s-let-expander.
(alet): If there are any bindings with constantp init
expressions, then recurse: produce an expansion which
separates constantp from non-constantp using
sys:r-s-let-expander. Pass 'alet as fallback binding symbol;
thus the expansion will recurse back to alet, but without
all the constantp bindings, if there are any.
We then deal with those using the existing all-or-nothing
logic (which simplifies slightly since it doesn't have
to check for constantp any more).
* txr.1: Revised description of alet.
|
|
|
|
|
|
|
|
| |
lib.c (tok_where) Implement new loop which suppresses
empty tokens immediately matching after non-empty
tokens. Old loop available under compatibility.
No documentation update needed since tok-where
is already documented as working like tok-str.
|
|
|
|
| |
* lib.c (tok_where): Just compare match_end == match_start.
|
|
|
|
|
|
| |
* lib.c (tok_where): Check that the regex match
succeeded before destructuring the result with
range_bind.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The problem is that when the regular expression
is capable of matching empty strings, tok-str
will extract an empty token immediately following
a non-empty token. For instance (tok-str "a,b" /[^,]*/)
extracts ("a" "" "b") instead of just ("a" "b").
This is a poor behavior and the way to fix it is to
impose a rule that an empty token must not be extracted
immediately at the ending position of a previous token.
Only a non-empty token can be consecutive to a token.
* lib.c (tok_str): Rewrite the logic of the loop,
using the prev_empty flag to suppress empty tokens
which immediately follow non-empty tokens. The
addition of 1 to the position when the token is empty
to skip a character is done at the bottom of the loop
and a new last_end variable keeps track of the end position
of the last extracted token for the purposes of extracting
the keep-between area if keep_sep is true. The old loop
is preserved intact and enabled by compatibility.
* tests/015/split.tl: Multiple empty-regex test cases for
tok-str updated.
* txr.1: Updated tok-str documentation and also added
a note between the conditions under which split-str and
tok-str, invoked with keep-sep true, produce equivalent
output. Added compatibility notes.
|
|
|
|
|
|
| |
* lib.c (obj_print): Only set up and tear down the
continuation-blocking unwind frame when doing circle
printing.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have a bug in that when an exception occurs in a context
called from obj_print, the guard for stopping continuation
captures across obj_print also unintentially blocks the
unwinding. Let's make the unwinding blockage optional
* unwind.c (uw_unwind_to_exit_point): If a UW_GUARD is
encountered, do not abort if the uw_ok flag is set;
keep unwinding.
(uw_push_guard): New uw_ok argument, initializes the
uw_ok member of a guard frame.
* unwind.h (struct uw_guard): New struct type.
(union uw_frame): New member gu of type struct uw_guard.
(uw_push_guard): Declaration updated.
* ftw.c (ftw_callback): Pass zero as new uw_push_guard
argument: no unwinding across the POSIX library function ftw.
* glob.c (errfunc_thunk): Likewise, no unwinding across
the library function glob.
* lib.c (obj_print): Pass 1 as new uw_push_guard argument:
continuations can't be captured, but unwinding is okay.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* share/txr/stdlib/place.tl (defplace sub): New place.
* txr.1: Document sub as accessor.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* 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.
|
|
|
|
|
|
| |
* share/txr/stdlib/place.tl (defplace nthcdr): In the case
when list is a place, the setter operation returns the
wrong value: the entire list, rather than the value assigned.
|
|
|
|
| |
* txr.1: Fix .code element in the middle of text.
|
|
|
|
|
|
| |
* txr.1: Description of ! hanging indent directive,
ironically, has wrong hanging indentation, due
to stray misplaced .RE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
* hash.c (hash_init): register hash-constrct using
symbol in hash_construct_s variable that was previously
interned rather than result of new call to intern.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
| |
* checkman.txr (check-func): Check for excess elements in singular
heading. Add exception for headings that have Operator and macro.
* txr.1: Missing plural in chr-ixdigit and chr-xdigit heading.
Same in hash-begin and hash-next, plus missing desc.
|
|
|
|
|
|
|
| |
* lib.c (epoch_time): New static function.
(time_parse): Default the struct tm to epoch.
* txr.1: Documented.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
* RELNOTES: Updated.
* configure, txr.1: Bumped version and date.
* share/txr/stdlib/ver.tl: Likewise.
* txr.vim, tl.vim: Regenerated.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The bug_unless statement was found to go off, indicating an
internal problem. Indeed, the store of inherited static slots
were being set to non-nil by incorrect copying in two places.
This is harmless in and of itself; it's just a way of being
tidy. If a slot's value is located elsewhere, then the local
store must be nil.
* struct.c (static_slot_home_fixup): After fetching a fresh
copy of the home type's stslot entry, clear the store to nil.
(make_struct_type): Likewise.
(struct_type_mark): Use assert for this rather than
bug_unless, because it happens in the middle of garbage
collection. Throwing an exception out of the middle of gc is a
nonstarter.
|
|
|
|
|
| |
* txr.1: Documenting circular notation and the *print-circle*
variable.
|
|
|
|
|
| |
* lib.c (obj_print): Applying a continuation guard
around the body of the function. This seems prudent.
|
|
|
|
|
|
|
| |
* parser.c (repl): Pass out_stream rather than std_error to
error_trace. I don't remember the original intent here. All it
does is create strange puzzling behavior when an error occurs
in the middle of a line of output that isn't flushed yet.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Continuing on the theme of the previous patch, we now properly
detect the situation when the recursive call is re-introducing
duplicate references to objects that have already been sent to
the stream without at #<num>= label. It's too late to print
those objects, so we throw an exception.
* lib.c (obj_print_impl): When we print an object that doesn't
have duplicates (its hash entry has a nil value), we replace
that value with the : symbol to indicate that the object has
already been printed. (obj_hash_merge): New function,
factoring out the hash merging logic from obj_print,
introduced in parent commit. Here, we detect the case that the
recursive print call has submitted to us an object which was
already printed without a label: because it is associated with
the : symbol in the parent hash. This situation is a
show-stopper so we throw. We cannot attempt to print the
object in any manner because we can get into runaway
recursion.
(obj_print): Hash merging logic replaced with call to new
static function.
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print): When invoked recursively in
circular printing mode, collect the nodes of the
new object into a separate hash table. Then
merge these entries into to the previous hash
table. If the newly visited object visits objects
we have already seen, suppress those entries.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
| |
* socket.c (dgram_get_byte_callback): nbytes must be volatile
because we assign to it after setting up the catch, and then
access it in the unwind code.
(sock_accept): Likewise.
* stream.c (generic_get_line): buf variable must be volatile.
(struct save_fds): The members of this structure must
be volatile; it's used as a local variable in a number of
functions in a way that requires volatile.
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print): The ret variable doesn't have to be
volatile qualified, because it is never modified after
setting an exception handler, and then accessed in the
cleanup. On the other hand, the ctx variable is
manipulated this way and must be volatile.
|
|
|
|
|
| |
* txr.1: Fixed grammar error and added clarification
that the init-val isn't filtered through key-function.
|
|
|
|
|
| |
* txr.1: describe from and to expressions of
range literals.
|
|
|
|
| |
* txr.1: describe key-value pairs of hash literals.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The circ_backpatch function could suffer runaway
recursion, so we must add a cycle check. This
could happen due to hitting cyclical objects
when traversing structs. Structs have static slots
that could contain cyclic objects, as well as
construction logic which can generate slots that
contain cycles and are not overridden by anything
in the literal.
* parser.c (circ_backpatch): Take struct circ_stack *
argument; extend the circ_stack in recursive calls.
Do circular check on entry.
(parser_resolve_circ): Pass null pointer as the
new stack argument to circ_backpatch.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The semantics of how struct literals come to life is poorly
designed: namely, the slot-value pairs in the struct literal
are used as the plist argument in a call to make-struct.
This is wrong because the implied initializations are then
clobbered by the structure type's :init and :postinit
handlers, resulting in an object with slot values that don't
match what is in the literal. When you add circular syntax
to the mix, things get worse. Slots may be initialized with
(sys:circ-ref ...) expressions corresponding to #<n># syntax.
These expressions then get clobbered by the constructor
actions before the circ_backpatch processes the syntax.
* parser.y (struct): Use make_struct_lit rather than
make_struct to instantiate struct object.
* struct.tl (sys:struct-lit): Expand to a form which calls
sys:make-struct-lit, rather than make-struct.
* struct.c (struct_init): Register new make_struct_lit
function as sys:make-struct-lit intrinsic.
(make_struct_lit): New function.
* struct.h (make_struct_lit): Declared.
* tests/012/struct.tl: struct literal expansion test case
updated.
* txr.1: Updated documentation of struct literals.
Added compat notes.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
* lib.c (obj_print_impl): On entry, ctx being non-null
indicates that cycle and substructure detecting is enabled via
*print-circle* for this print job. In this case, check
whether this is the first request to print a
multiply-referenced object, in which case we print the #<n>=
label definition, or whether it is a second or additional
reference, in which case we render the object as #<n>#.
Special handling must also be introduced into the loop which
prints list elements. At any point in a list, the rest of the
list could be shared substructure or a cyclic link that must
be rendered with the appropriate notation.
(populate_obj_hash): New static function. Enters all objects
in the substructure that are eligible for the circle notation
into the hash that is stored in the print context. Any object
that appears two or more times is associated with a t value.
(obj_print, obj_pprint): Unless circle printing is already in
effect, check *print-circle* and turn it on if necessary and
prepare the context, associating it with the stream. Either
way, if circle printing is enabled, call populate_obj_hash to
walk the object and add its components to the hash.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This is some infrastructure which will support *print-circle*.
* lib.h (struct strm_ctx): Forward declared.
(struct cobj_ops): Add context parameter to print function
pointer.
(cobj_print_op, obj_print_impl): Add context parameter to
declarations.
* hash.c (hash_print_op): Take context argument and
pass it down in obj_print_impl calls.
* lib.c (cobj_print_op, out_quasi_str): Likewise
(obj_print_impl): Likewise, and also pass to
COBJ print method.
(obj_print, obj_pprint): Pass null pointer
as context argument to obj_print_impl.
* regex.c (regex_print): Take context parameter and ignore it.
* socket.c (dgram_print): Likewise.
* stream.h (struct strm_ctx): New struct type.
(struct strm_base): New ctx member, pointer to struct
strm_ctx.
(stream_print_op): Add context parameter to declaration.
(get_set_ctx, get_ctx): Declared.
* stream.c (strm_base_init): Add null pointer to initializer.
(strm_base_cleanup): Add assertion against context pointer
being non-null: that indicates that some stream operation
installed a context pointer and neglected to restore it to
null before returning, which is bad because context will be
stack allocated.
(stream_print_op, stdio_stream_print, cat_stream_print): Take
context parameter and ignore it.
(get_set_ctx, get_ctx): New functions.
* struct.c (struct_type_print): Take context parameter and
ignore it.
(struct_inst_print): Take context parameter and pass
down to obj_print_impl.
|
|
|
|
|
|
|
|
| |
* stream.c (print_circle_s): New symbol variable.
(stream_init): Initialize print_circle_s as symbol
named *print-circle*; register as special var.
* stream.h (print_circle_s): Declared.
|