summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog15
-rw-r--r--lib.c33
-rw-r--r--lib.h1
-rw-r--r--txr.155
-rw-r--r--txr.c1
5 files changed, 85 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index a0be3ea0..eb578f74 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2014-09-03 Kaz Kylheku <kaz@kylheku.com>
+
+ * lib.c (symbol_setname): New static function.
+ (obj_init): Change exception symbol names with underscores
+ to use friendly dashes instead.
+ (compat_fixup): New function.
+
+ * lib.h (compat_fixup): Declared.
+
+ * txr.1: Change occurrences of exception symbols from
+ underscores to dashes.
+
+ * txr.c (txr_main): Call compat_fixup when -C option
+ is processed.
+
2014-09-02 Kaz Kylheku <kaz@kylheku.com>
* txr.1: Document -C option.
diff --git a/lib.c b/lib.c
index 7baa35d2..da3ccf35 100644
--- a/lib.c
+++ b/lib.c
@@ -3064,6 +3064,12 @@ val symbol_name(val sym)
return sym ? sym->s.name : nil_string;
}
+static void symbol_setname(val sym, val name)
+{
+ type_check(sym, SYM);
+ sym->s.name = name;
+}
+
val symbol_package(val sym)
{
if (sym == nil)
@@ -6040,13 +6046,13 @@ static void obj_init(void)
eof_s = intern(lit("eof"), user_package);
eol_s = intern(lit("eol"), user_package);
error_s = intern(lit("error"), user_package);
- type_error_s = intern(lit("type_error"), user_package);
- internal_error_s = intern(lit("internal_error"), user_package);
- numeric_error_s = intern(lit("numeric_error"), user_package);
- range_error_s = intern(lit("range_error"), user_package);
- query_error_s = intern(lit("query_error"), user_package);
- file_error_s = intern(lit("file_error"), user_package);
- process_error_s = intern(lit("process_error"), user_package);
+ type_error_s = intern(lit("type-error"), user_package);
+ internal_error_s = intern(lit("internal-error"), user_package);
+ numeric_error_s = intern(lit("numeric-error"), user_package);
+ range_error_s = intern(lit("range-error"), user_package);
+ query_error_s = intern(lit("query-error"), user_package);
+ file_error_s = intern(lit("file-error"), user_package);
+ process_error_s = intern(lit("process-error"), user_package);
syntax_error_s = intern(lit("syntax-error"), user_package);
assert_s = intern(lit("assert"), user_package);
@@ -6639,6 +6645,19 @@ void init(const wchar_t *pn, mem_t *(*oom)(mem_t *, size_t),
gc_state(gc_save);
}
+void compat_fixup(int compat_ver)
+{
+ if (compat_ver <= 97) {
+ symbol_setname(type_error_s, lit("type_error"));
+ symbol_setname(internal_error_s, lit("internal_error"));
+ symbol_setname(numeric_error_s, lit("numeric_error"));
+ symbol_setname(range_error_s, lit("range_error"));
+ symbol_setname(query_error_s, lit("query_error"));
+ symbol_setname(file_error_s, lit("file_error"));
+ symbol_setname(process_error_s, lit("process_error"));
+ }
+}
+
void dump(val obj, val out)
{
obj_print(obj, out);
diff --git a/lib.h b/lib.h
index 8ec7ddb9..ae173621 100644
--- a/lib.h
+++ b/lib.h
@@ -795,6 +795,7 @@ val make_time_utc(val year, val month, val day,
void init(const wchar_t *progname, mem_t *(*oom_realloc)(mem_t *, size_t),
val *stack_bottom);
+void compat_fixup(int compat_ver);
void dump(val obj, val stream);
void d(val obj);
void breakpt(void);
diff --git a/txr.1 b/txr.1
index daf9a3a2..c856165a 100644
--- a/txr.1
+++ b/txr.1
@@ -196,12 +196,16 @@ Requests TXR to behave in a manner that is compatible with the specified
version of TXR. This makes a difference in situations when a release of
TXR breaks backward compatibility. If some version N+1 deliberately introduces
a change which is backward incompatible, then -C N can be used to request
-the old behavior. The requested value of N can be too low, in which case TXR
+the old behavior.
+
+The requested value of N can be too low, in which case TXR
will complain and exit with an unsuccessful termination status. This indicates
that TXR refuses to be compatible with such an old version. Users requiring
the behavior of that version will have to install an older version of TXR which
supports that behavior, or even that exact version.
+For more information, see the COMPATIBILITY section.
+
.IP --help
Prints usage summary on standard output, and terminates successfully.
@@ -2633,7 +2637,7 @@ variables do not propagate.
Furthermore, for any variable which is not specified with a default value, the
collect body, whenever it matches successfully, must bind that variable. If it
-neglects to bind the variable, an exception of type query_error is thrown.
+neglects to bind the variable, an exception of type query-error is thrown.
(If a collect body matches successfully, but produces no new bindings, then
this error is suppressed.)
@@ -4622,12 +4626,12 @@ of whose applications is error handling.
An exception control transfer (simply called an exception) is always identified
by a symbol, which is its type. Types are organized in a subtype-supertype
-hierarchy. For instance, the file_error exception type is a subtype of the
+hierarchy. For instance, the file-error exception type is a subtype of the
error type. This means that a file error is a kind of error. An exception
handling block which catches exceptions of type error will catch exceptions of
-type file_error, but a block which catches file_error will not catch all
-exceptions of type error. A query_error is a kind of error, but not a kind of
-file_error. The symbol t is the supertype of every type: every exception type
+type file-error, but a block which catches file-error will not catch all
+exceptions of type error. A query-error is a kind of error, but not a kind of
+file-error. The symbol t is the supertype of every type: every exception type
is considered to be a kind of t. (Mnemonic: t stands for type, as in any
type).
@@ -4801,18 +4805,18 @@ Example:
@ (finally)
@ (accept)
@ (end)
- @(catch file_error)
+ @(catch file-error)
@ (output)
file error caught
@ (end)
@(end)
-In this example, the @(next) directive throws an exception of type file_error,
+In this example, the @(next) directive throws an exception of type file-error,
because the given file does not exist. The exit point for this exception is the
-@(catch file_error) clause in the outer-most try block. The inner block is
+@(catch file-error) clause in the outer-most try block. The inner block is
not eligible because it contains no catch clauses at all. However, the inner
try block has a finally clause, and so during the processing of this
-exception which is headed for the @(catch file_error), the finally
+exception which is headed for the @(catch file-error), the finally
clause performs an anonymous accept. The exit point for the accept
is the anonymous block surrounding the inner try. So the original
transfer to the catch clause is forgotten. The inner try terminates
@@ -4856,7 +4860,7 @@ Example:
Query: @(try)
@ (next "nonexistent-file")
@ x
- @ (catch file_error)
+ @ (catch file-error)
@a
@(finally)
@b
@@ -4871,7 +4875,7 @@ Example:
b="2"
c="3"
-Here, the try block's main clause is terminated abruptly by a file_error
+Here, the try block's main clause is terminated abruptly by a file-error
exception from the @(next) directive. This is handled by the
catch clause, which binds variable a to the input line "1".
Then the finally clause executes, binding b to "2". The try block
@@ -14339,7 +14343,7 @@ Syntax:
Description:
Try to create the directory named <path> using the POSIX mkdir function.
-An exception of type file_error is thrown if the function fails. Returns
+An exception of type file-error is thrown if the function fails. Returns
t on success.
The <mode> argument specifies the request numeric permissions
@@ -16030,6 +16034,31 @@ Then a continue command, which finishes the program, whose output appears:
Mar-30 03:22:52 PM AKDT
Mar-30 01:22:52 PM HAST
+.SH COMPATIBILITY
+
+New TXR versions are usually intended to be backward-compatible with prior
+releases in the sense that documented features will continue to work in
+the same way. Due to new features, new versions of TXR will supply new
+behaviors where old versions of TXR would have produced an error, such as a
+syntax error. Though, strictly speaking, this means that something is working
+differently in a new version, replacing an error situation with functionality
+is usually not considered a deviation from backward-compatibility.
+
+When a change is introduced which is not backward compatible, TXR's
+-C option can be used to request emulation of old behavior.
+
+The option was introduced in TXR 98, and so the oldest TXR version which
+can be emulated is TXR 97.
+
+Here are values which have a special meaning as arguments to -C:
+the -C option, along with a description of what behaviors are affected:
+
+.IP 97
+Up to TXR 97, the error exception symbols such as "file-error" were named with
+underscores, as in "file-error". These error symbols existed: type_error,
+internal_error, numeric_error, range_error, query_error, file_error and
+process_error.
+
.SH APPENDIX A: NOTES ON EXOTIC REGULAR EXPRESSIONS
Users familiar with regular expressions may not be familiar with the complement
diff --git a/txr.c b/txr.c
index 16a2cbe7..a2bb9dd2 100644
--- a/txr.c
+++ b/txr.c
@@ -407,6 +407,7 @@ int txr_main(int argc, char **argv)
prog_string, auto_str(version), nao);
return EXIT_FAILURE;
}
+ compat_fixup(opt_compat);
}
}
break;