fix rename-in bug, and try to provide a better error message for attempting to use a run-time definition in a transformer expression

svn: r9819
This commit is contained in:
Matthew Flatt 2008-05-12 23:13:47 +00:00
parent b44c20d3c3
commit a932a75708
8 changed files with 107 additions and 86 deletions

View File

@ -32,8 +32,8 @@
((beginner-* *) (num num num ... -> num)
"to compute the product of all of the input numbers")
((beginner-/ /) (num num num ... -> num)
"to divide the first by the second (and all following) number(s)"
"None but the first number can be zero.")
"to divide the first by the second (and all following) number(s);"
" only the first number can be zero.")
(max (real real ... -> real)
"to determine the largest number")
(min (real real ... -> real)
@ -52,7 +52,7 @@
"to compute the power of the first to the second number")
(abs (real -> real)
"to compute the absolute value of a real number")
(sgn (real -> (union 1 |#i1.0| 0 |#i0.0| -1 |#i-1.0|))
(sgn (real -> (union 1 #i1.0 0 #i0.0 -1 #i-1.0))
"to compute the sign of a real number")
;; fancy numeric
@ -80,21 +80,21 @@
(cosh (num -> num)
"to compute the hyperbolic cosine of a number")
(exact? (num -> bool)
(exact? (num -> boolean)
"to determine whether some number is exact")
(integer? (any -> bool)
(integer? (any -> boolean)
"to determine whether some value is an integer (exact or inexact)")
(zero? (number -> bool)
(zero? (number -> boolean)
"to determine if some value is zero or not")
(positive? (number -> bool)
(positive? (number -> boolean)
"to determine if some value is strictly larger than zero")
(negative? (number -> bool)
(negative? (number -> boolean)
"to determine if some value is strictly smaller than zero")
(odd? (integer -> bool)
(odd? (integer -> boolean)
"to determine if some value is odd or not")
(even? (integer -> bool)
(even? (integer -> boolean)
"to determine if some value is even or not")
(add1 (number -> number)
@ -108,8 +108,8 @@
(gcd (int int ... -> int)
"to compute the greatest common divisior")
(rational? (any -> bool)
"to determine whether some value is rational number")
(rational? (any -> boolean)
"to determine whether some value is a rational number")
(numerator (rat -> int)
"to compute the numerator of a rational")
@ -117,10 +117,10 @@
(denominator (rat -> int)
"to compute the denominator of a rational")
(inexact? (num -> bool)
(inexact? (num -> boolean)
"to determine whether some number is inexact")
(real? (any -> bool)
(real? (any -> boolean)
"to determine whether some value is a real number")
(floor (real -> int)
@ -132,7 +132,7 @@
(round (real -> int)
"to round a real number to an integer (rounds to even to break ties)")
(complex? (any -> bool)
(complex? (any -> boolean)
"to determine whether some value is complex")
(make-polar (real real -> num)
@ -172,7 +172,7 @@
(current-seconds (-> int)
"to compute the current time in seconds elapsed"
"(since a platform-specific starting date)")
" (since a platform-specific starting date)")
(e real
"Euler's number")
@ -279,18 +279,18 @@
"to compute the number of items on a list")
(memq (any list -> (union false list))
"to determine whether some value is on some list"
"(comparing values with eq?)")
" (comparing values with eq?)")
(memv (any list -> (union false list))
"to determine whether some value is on the list"
"(comparing values with eqv?)")
" (comparing values with eqv?)")
((beginner-member member) (any list -> (union false list))
"to determine whether some value is on the list"
"(comparing values with equal?)")
" (comparing values with equal?)")
(reverse (list -> list)
"to create a reversed version of a list")
(assq (X (listof (cons X Y)) -> (union false (cons X Y)))
"to determine whether some item is the first item of a pair"
"in a list of pairs"))
" in a list of pairs"))
("Posns"
(make-posn (number number -> posn) "to construct a posn")
@ -300,7 +300,7 @@
("Characters"
(char? (any -> boolean)
" ")
"to determine whether a value is a character")
(char=? (char char ... -> boolean)
"to determine whether two characters are equal")
(char<? (char char ... -> boolean)
@ -309,26 +309,26 @@
"to determine whether a character succeeds another")
(char<=? (char char ... -> boolean)
"to determine whether a character precedes another"
"(or is equal to it)")
" (or is equal to it)")
(char>=? (char char ... -> boolean)
"to determine whether a character succeeds another"
"(or is equal to it)")
" (or is equal to it)")
(char-ci=? (char char ... -> boolean)
"to determine whether two characters are equal"
"in a case-insensitive manner")
" in a case-insensitive manner")
(char-ci<? (char char ... -> boolean)
"to determine whether a character precedes another"
"in a case-insensitive manner")
" in a case-insensitive manner")
(char-ci>? (char char ... -> boolean)
"to determine whether a character succeeds another"
"in a case-insensitive manner")
" in a case-insensitive manner")
(char-ci<=? (char char ... -> boolean)
"to determine whether a character precedes another"
"(or is equal to it) in a case-insensitive manner")
" (or is equal to it) in a case-insensitive manner")
(char-ci>=? (char char ... -> boolean)
"to determine whether a character succeeds another"
"(or is equal to it) in a case-insensitive manner")
" (or is equal to it) in a case-insensitive manner")
(char-numeric? (char -> boolean)
"to determine whether a character represents a digit")
@ -339,17 +339,17 @@
"to determine whether a character represents space")
(char-upper-case? (char -> boolean)
"to determine whether a character is an"
"upper-case character")
" upper-case character")
(char-lower-case? (char -> boolean)
"to determine whether a character is a"
"lower-case character")
" lower-case character")
(char-upcase (char -> char)
"to determine the equivalent upper-case character")
(char-downcase (char -> char)
"to determine the equivalent lower-case character")
(char->integer (char -> integer)
"to lookup the number that corresponds to the"
"given character in the ASCII table (if any)"))
" given character in the ASCII table (if any)"))
("Strings"
(string? (any -> boolean)
"to determine whether a value is a string")
@ -359,7 +359,7 @@
"(string c1 c2 ...) builds a string")
(make-string (nat char -> string)
"to produce a string of given length"
"from a single given character")
" from a single given character")
(string-ref (string nat -> char)
"to extract the i-the character from a string")
@ -375,40 +375,40 @@
"to compare two strings character-wise")
(string<? (string string ... -> boolean)
"to determine whether one string alphabetically"
"precedes another")
" precedes another")
(string>? (string string ... -> boolean)
"to determine whether one string alphabetically"
"succeeds another")
" succeeds another")
(string<=? (string string ... -> boolean)
"to determine whether one string alphabetically"
"precedes another (or is equal to it)")
" precedes another (or is equal to it)")
(string>=? (string string ... -> boolean)
"to determine whether one string alphabetically"
"succeeds another (or is equal to it)")
" succeeds another (or is equal to it)")
(string-ci=? (string string ... -> boolean)
"to compare two strings character-wise"
"in a case-insensitive manner")
" in a case-insensitive manner")
(string-ci<? (string string ... -> boolean)
"to determine whether one string alphabetically"
"precedes another in a case-insensitive manner")
" precedes another in a case-insensitive manner")
(string-ci>? (string string ... -> boolean)
"to determine whether one string alphabetically"
"succeeds another in a case-insensitive manner")
" succeeds another in a case-insensitive manner")
(string-ci<=? (string string ... -> boolean)
"to determine whether one string alphabetically"
"precedes another (or is equal to it)"
"in a case-insensitive manner")
" precedes another (or is equal to it)"
" in a case-insensitive manner")
(string-ci>=? (string string ... -> boolean)
"to determine whether one string alphabetically"
"succeeds another (or is equal to it)"
"in a case-insensitive manner")
" succeeds another (or is equal to it)"
" in a case-insensitive manner")
(string->symbol (string -> symbol)
"to convert a string into symbol")
"to convert a string into a symbol")
(string->number (string -> (union number false))
"to convert a string into a number,"
"produce false if impossible")
" produce false if impossible")
(string->list (string -> (listof char))
"to convert a string into a list of characters")
(list->string ((listof char) -> string)

View File

@ -496,28 +496,31 @@
stx
dup-id)))
(let ([new+olds
(map (lambda (orig-id bind-id)
(let ([import (ormap (lambda (import)
(and (free-identifier=? orig-id
(import-local-id import))
import))
imports)])
(unless import
(raise-syntax-error
#f
(format "identifier `~a' not included in nested require spec"
(syntax-e orig-id))
stx
#'in))
(cons (make-import bind-id
(import-src-sym import)
(import-src-mod-path import)
(import-mode import)
(import-req-mode import)
(import-orig-mode import)
bind-id)
import)))
orig-ids bind-ids)])
(apply
append
(map (lambda (orig-id bind-id)
(let ([rename-imports (filter (lambda (import)
(free-identifier=? orig-id
(import-local-id import)))
imports)])
(unless (pair? rename-imports)
(raise-syntax-error
#f
(format "identifier `~a' not included in nested require spec"
(syntax-e orig-id))
stx
#'in))
(map (lambda (import)
(cons (make-import bind-id
(import-src-sym import)
(import-src-mod-path import)
(import-mode import)
(import-req-mode import)
(import-orig-mode import)
bind-id)
import))
rename-imports)))
orig-ids bind-ids))])
(let ([leftover-imports
(let ([ht (make-immutable-hash
(map (lambda (v) (cons (cdr v) #f))

View File

@ -95,7 +95,8 @@ some platforms:
shares the focus with an active non-floating frame; when this style
is combined with @scheme['no-caption], then showing the frame does
not cause the keyboard focus to shift to the window, and under X,
clicking the frame does not move the focus}
clicking the frame does not move the focus; under Windows, a floating
frame has no taskbar button}
@item{@scheme['metal] --- draws the frame with a brushed-metal
background (Mac OS X); this style is ignored when

View File

@ -36,6 +36,11 @@ All @scheme[window<%>] classes accept the following named instantiation
@index["global coordinates"]{Converts} local window coordinates to
screen coordinates.
Under Mac OS X, the screen coordinates start with @math{(0, 0)} at the
upper left of the menu bar. In contrast, @xmethod[top-level-window<%>
move] considers @math{(0, 0)} to be below the menu bar. See also
@scheme[get-display-left-top-inset].
}
@defmethod[(enable [enable? any/c])
@ -456,7 +461,8 @@ Enqueues an event to repaint the window.
(integer-in -10000 10000))]{
@index["global coordinates"]{Converts} global coordinates to window
local coordinates.
local coordinates. See also @scheme[client->screen] for information
on screen coordinates.
}

View File

@ -188,7 +188,7 @@ evaluated. If it evaluates to @scheme[true], the result of the
@scheme[expr] (often called the ``then'' @scheme[expr]). If the text
@scheme[expr] evaluates to @scheme[false], the result of the
@scheme[if] expression is the result of evaluating the third
@scheme[expr]expression (known as the ``else'' @scheme[expr]). If the
@scheme[expr] (known as the ``else'' @scheme[expr]). If the
result of evaluating the test @scheme[expr] is neither @scheme[true]
nor @scheme[false], it is an error.}

View File

@ -127,17 +127,17 @@ steps:
Alternately, if the extension defines a module (i.e.,
@cpp{scheme_module_name} returns a symbol), then place the shared
object in a special directory so that it is detected by the module
loader when @scheme[require] is used. The special directory is a
platform-specific path that can be obtained by evaluating
@scheme[(build-path "compiled" "native" (system-library-subpath))];
see @scheme[load/use-compiled] for more information. For example, if
the shared object's name is @filepath{example.dll}, then
@scheme[(require "example.ss")] will be redirected to
@filepath{example.dll} if the latter is placed in the sub-directory
@scheme[(build-path "compiled" "native" (system-library-subpath))]
and if @filepath{example.ss} does not exist or has an earlier
timestamp.
object in a special directory with a special name, so that it is
detected by the module loader when @scheme[require] is used. The
special directory is a platform-specific path that can be obtained by
evaluating @scheme[(build-path "compiled" "native"
(system-library-subpath))]; see @scheme[load/use-compiled] for more
information. For example, if the shared object's name is
@filepath{example_ss.dll}, then @scheme[(require "example.ss")] will
be redirected to @filepath{example_ss.dll} if the latter is placed in
the sub-directory @scheme[(build-path "compiled" "native"
(system-library-subpath))] and if @filepath{example.ss} does not
exist or has an earlier timestamp.
Note that @scheme[(load-extension _path)] within a @scheme[module]
does @italic{not} introduce the extension's definitions into the

View File

@ -76,7 +76,7 @@ referenced, where a @tech{phase level} normally corresponds to an
integer (but the special @deftech{label phase level} does not
correspond to an integer). @tech{Phase level} 0 corresponds to the
run time of the enclosing module (or the run time of top-level
expression). Bindings in @tech{phase level} 0 constitute the
expressions). Bindings in @tech{phase level} 0 constitute the
@deftech{base environment}. @tech{Phase level} 1 corresponds to the
time during which the enclosing module (or top-level expression) is
expanded; bindings in @tech{phase level} 1 constitute the

View File

@ -5831,10 +5831,21 @@ static Scheme_Object *check_top(const char *when, Scheme_Object *form, Scheme_Co
if (env->genv->disallow_unbound) {
if (bad || !scheme_lookup_in_table(env->genv->toplevel, (const char *)SCHEME_STX_SYM(c))) {
scheme_wrong_syntax(when, NULL, c,
(env->genv->phase
? "unbound variable in module (transformer environment)"
: "unbound variable in module"));
GC_CAN_IGNORE const char *reason;
if (env->genv->phase == 1) {
reason = "unbound variable in module (transformer environment)";
/* Check in the run-time environment */
if (scheme_lookup_in_table(env->genv->template_env->toplevel, (const char *)SCHEME_STX_SYM(c))) {
reason = ("unbound variable in module (in the transformer environment, which does"
" not include the run-time definition)");
} else if (env->genv->template_env->syntax
&& scheme_lookup_in_table(env->genv->template_env->syntax, (const char *)SCHEME_STX_SYM(c))) {
reason = ("unbound variable in module (in the transformer environment, which does"
" not include the macro definition that is visible to run-time expressions)");
}
} else
reason = "unbound variable in module";
scheme_wrong_syntax(when, NULL, c, reason);
}
}
}