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

View File

@ -496,28 +496,31 @@
stx stx
dup-id))) dup-id)))
(let ([new+olds (let ([new+olds
(map (lambda (orig-id bind-id) (apply
(let ([import (ormap (lambda (import) append
(and (free-identifier=? orig-id (map (lambda (orig-id bind-id)
(import-local-id import)) (let ([rename-imports (filter (lambda (import)
import)) (free-identifier=? orig-id
imports)]) (import-local-id import)))
(unless import imports)])
(raise-syntax-error (unless (pair? rename-imports)
#f (raise-syntax-error
(format "identifier `~a' not included in nested require spec" #f
(syntax-e orig-id)) (format "identifier `~a' not included in nested require spec"
stx (syntax-e orig-id))
#'in)) stx
(cons (make-import bind-id #'in))
(import-src-sym import) (map (lambda (import)
(import-src-mod-path import) (cons (make-import bind-id
(import-mode import) (import-src-sym import)
(import-req-mode import) (import-src-mod-path import)
(import-orig-mode import) (import-mode import)
bind-id) (import-req-mode import)
import))) (import-orig-mode import)
orig-ids bind-ids)]) bind-id)
import))
rename-imports)))
orig-ids bind-ids))])
(let ([leftover-imports (let ([leftover-imports
(let ([ht (make-immutable-hash (let ([ht (make-immutable-hash
(map (lambda (v) (cons (cdr v) #f)) (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 shares the focus with an active non-floating frame; when this style
is combined with @scheme['no-caption], then showing the frame does is combined with @scheme['no-caption], then showing the frame does
not cause the keyboard focus to shift to the window, and under X, 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 @item{@scheme['metal] --- draws the frame with a brushed-metal
background (Mac OS X); this style is ignored when 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 @index["global coordinates"]{Converts} local window coordinates to
screen coordinates. 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]) @defmethod[(enable [enable? any/c])
@ -456,7 +461,8 @@ Enqueues an event to repaint the window.
(integer-in -10000 10000))]{ (integer-in -10000 10000))]{
@index["global coordinates"]{Converts} global coordinates to window @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] (often called the ``then'' @scheme[expr]). If the text
@scheme[expr] evaluates to @scheme[false], the result of the @scheme[expr] evaluates to @scheme[false], the result of the
@scheme[if] expression is the result of evaluating the third @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] result of evaluating the test @scheme[expr] is neither @scheme[true]
nor @scheme[false], it is an error.} nor @scheme[false], it is an error.}

View File

@ -127,17 +127,17 @@ steps:
Alternately, if the extension defines a module (i.e., Alternately, if the extension defines a module (i.e.,
@cpp{scheme_module_name} returns a symbol), then place the shared @cpp{scheme_module_name} returns a symbol), then place the shared
object in a special directory so that it is detected by the module object in a special directory with a special name, so that it is
loader when @scheme[require] is used. The special directory is a detected by the module loader when @scheme[require] is used. The
platform-specific path that can be obtained by evaluating special directory is a platform-specific path that can be obtained by
@scheme[(build-path "compiled" "native" (system-library-subpath))]; evaluating @scheme[(build-path "compiled" "native"
see @scheme[load/use-compiled] for more information. For example, if (system-library-subpath))]; see @scheme[load/use-compiled] for more
the shared object's name is @filepath{example.dll}, then information. For example, if the shared object's name is
@scheme[(require "example.ss")] will be redirected to @filepath{example_ss.dll}, then @scheme[(require "example.ss")] will
@filepath{example.dll} if the latter is placed in the sub-directory be redirected to @filepath{example_ss.dll} if the latter is placed in
@scheme[(build-path "compiled" "native" (system-library-subpath))] the sub-directory @scheme[(build-path "compiled" "native"
and if @filepath{example.ss} does not exist or has an earlier (system-library-subpath))] and if @filepath{example.ss} does not
timestamp. exist or has an earlier timestamp.
Note that @scheme[(load-extension _path)] within a @scheme[module] Note that @scheme[(load-extension _path)] within a @scheme[module]
does @italic{not} introduce the extension's definitions into the 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 integer (but the special @deftech{label phase level} does not
correspond to an integer). @tech{Phase level} 0 corresponds to the correspond to an integer). @tech{Phase level} 0 corresponds to the
run time of the enclosing module (or the run time of top-level 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 @deftech{base environment}. @tech{Phase level} 1 corresponds to the
time during which the enclosing module (or top-level expression) is time during which the enclosing module (or top-level expression) is
expanded; bindings in @tech{phase level} 1 constitute the 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 (env->genv->disallow_unbound) {
if (bad || !scheme_lookup_in_table(env->genv->toplevel, (const char *)SCHEME_STX_SYM(c))) { if (bad || !scheme_lookup_in_table(env->genv->toplevel, (const char *)SCHEME_STX_SYM(c))) {
scheme_wrong_syntax(when, NULL, c, GC_CAN_IGNORE const char *reason;
(env->genv->phase if (env->genv->phase == 1) {
? "unbound variable in module (transformer environment)" reason = "unbound variable in module (transformer environment)";
: "unbound variable in module")); /* 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);
} }
} }
} }