Merge branch 'master' of git.racket-lang.org:plt
This commit is contained in:
commit
6b1d106285
|
@ -77,7 +77,7 @@
|
|||
(define lines (read-chunks f read-line (lambda (x) x)))
|
||||
(foldl (lambda (f r)
|
||||
(define fst (filter (compose not (curry string=? "")) (split f)))
|
||||
(if (empty? fst) r (combine fst r)))
|
||||
(combine fst r))
|
||||
'() lines))
|
||||
|
||||
(def-reader (read-csv-file f)
|
||||
|
@ -93,10 +93,9 @@
|
|||
(define-syntax (simulate-file stx)
|
||||
(syntax-case stx ()
|
||||
[(simulate-file)
|
||||
(raise-syntax-error #f "expects a reader function as first argument" stx)]
|
||||
(raise-syntax-error #f "expects at least one sub-expression" stx)]
|
||||
[(simulate-file reader str ...) #'(simulate-file/proc (f2h reader) str ...)]))
|
||||
|
||||
|
||||
(define (simulate-file/proc reader . los)
|
||||
(define _1 (check-proc "simulate-file" reader 1 "reader" "one argument"))
|
||||
(define _2
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
procedure-contract-info?
|
||||
procedure-contract-info-arg-contracts procedure-contract-info-return-contract
|
||||
make-lazy-wrap-info lazy-wrap-info-constructor lazy-wrap-info-raw-accessors
|
||||
prop:lazy-wrap lazy-wrap-ref
|
||||
prop:lazy-wrap lazy-wrap? lazy-wrap-ref
|
||||
make-struct-wrap-contract
|
||||
check-struct-wraps!
|
||||
contract=? contract<=?)
|
||||
|
@ -393,7 +393,7 @@
|
|||
ref-proc set!-proc))
|
||||
|
||||
; value should be a lazy-wrap-info
|
||||
(define-values (prop:lazy-wrap lazy-wrap lazy-wrap-ref)
|
||||
(define-values (prop:lazy-wrap lazy-wrap? lazy-wrap-ref)
|
||||
(make-struct-type-property 'lazy-wrap))
|
||||
|
||||
(define (make-struct-wrap-contract name type-descriptor field-contracts syntax)
|
||||
|
|
|
@ -76,15 +76,15 @@
|
|||
(or (hash-ref hash v #f)
|
||||
(let-values (((ty skipped?) (struct-info v)))
|
||||
(cond
|
||||
((and ty (lazy-wrap-ref ty))
|
||||
=> (lambda (lazy-wrap-info)
|
||||
(let ((constructor (lazy-wrap-info-constructor lazy-wrap-info))
|
||||
(raw-accessors (lazy-wrap-info-raw-accessors lazy-wrap-info)))
|
||||
(let ((val (apply constructor (map (lambda (raw-accessor)
|
||||
(recur (raw-accessor v)))
|
||||
raw-accessors))))
|
||||
(hash-set! hash v val)
|
||||
val))))
|
||||
((and ty (lazy-wrap? ty))
|
||||
(let ((lazy-wrap-info (lazy-wrap-ref ty)))
|
||||
(let ((constructor (lazy-wrap-info-constructor lazy-wrap-info))
|
||||
(raw-accessors (lazy-wrap-info-raw-accessors lazy-wrap-info)))
|
||||
(let ((val (apply constructor (map (lambda (raw-accessor)
|
||||
(recur (raw-accessor v)))
|
||||
raw-accessors))))
|
||||
(hash-set! hash v val)
|
||||
val))))
|
||||
(else v)))))
|
||||
(else
|
||||
v)))))
|
||||
|
|
|
@ -137,7 +137,9 @@
|
|||
(access-record-fields r raw-generic-access number-of-fields)
|
||||
port write?)))
|
||||
(cons prop:equal+hash
|
||||
(list record-equal? void void))
|
||||
(list record-equal?
|
||||
(make-equal-hash (lambda (r i) (raw-generic-access r i)) number-of-fields)
|
||||
(make-equal2-hash (lambda (r i) (raw-generic-access r i)) number-of-fields)))
|
||||
(cons prop:lazy-wrap
|
||||
(make-lazy-wrap-info constructor-proc
|
||||
(list raw-accessor-proc ...)
|
||||
|
@ -231,6 +233,29 @@
|
|||
(cons (acc rec i)
|
||||
(recur (+ i 1))))))
|
||||
|
||||
(define (make-equal-hash generic-access field-count)
|
||||
(lambda (r recur)
|
||||
(let loop ((i 0)
|
||||
(factor 1)
|
||||
(hash 0))
|
||||
(if (= i field-count)
|
||||
hash
|
||||
(loop (+ 1 i)
|
||||
(* factor 33)
|
||||
(+ hash (* factor (recur (generic-access r i)))))))))
|
||||
|
||||
(define (make-equal2-hash generic-access field-count)
|
||||
(lambda (r recur)
|
||||
(let loop ((i 0)
|
||||
(factor 1)
|
||||
(hash 0))
|
||||
(if (= i field-count)
|
||||
hash
|
||||
(loop (+ 1 i)
|
||||
(* factor 33)
|
||||
(+ hash (* factor
|
||||
(recur (generic-access r (- field-count i 1))))))))))
|
||||
|
||||
#|
|
||||
(define-record-procedures :pare kons pare? (kar kdr))
|
||||
(kons 1 (kons 2 (kons 3 (kons 5 (kons 6 (kons 7 (kons 8 "asdjkfdshfdsjkf")))))))
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
(define current-extra-files (make-parameter null))
|
||||
(define current-redirect (make-parameter #f))
|
||||
(define current-redirect-main (make-parameter #f))
|
||||
(define current-quiet (make-parameter #f))
|
||||
|
||||
(define (read-one str)
|
||||
(let ([i (open-input-string str)])
|
||||
|
@ -85,6 +86,9 @@
|
|||
'scribble "bad procedure identifier for ++ref-in: ~s" proc-id))
|
||||
(current-xref-input-modules
|
||||
(cons (cons mod id) (current-xref-input-modules))))]
|
||||
#:once-each
|
||||
[("--quiet") "suppress output-file reporting"
|
||||
(current-quiet #t)]
|
||||
#:args (file . another-file)
|
||||
(let ([files (cons file another-file)])
|
||||
(build-docs (map (lambda (file) (dynamic-require `(file ,file) 'doc))
|
||||
|
@ -104,7 +108,8 @@
|
|||
(send renderer set-external-tag-path (current-redirect)))
|
||||
(when (current-redirect-main)
|
||||
(send renderer set-external-root-url (current-redirect-main)))
|
||||
(send renderer report-output!)
|
||||
(unless (current-quiet)
|
||||
(send renderer report-output!))
|
||||
(let* ([fns (map (lambda (fn)
|
||||
(let-values ([(base name dir?) (split-path fn)])
|
||||
(let ([fn (path-replace-suffix
|
||||
|
|
|
@ -34,15 +34,18 @@
|
|||
(list->vector
|
||||
(append
|
||||
extra-cmdline
|
||||
(list "--dest" (path->string base))
|
||||
(list "--dest" (path->string base) "--quiet")
|
||||
(list mode (if (path? fn) (path->string fn) fn))))])
|
||||
(namespace-attach-module (namespace-anchor->empty-namespace anchor) 'setup/xref)
|
||||
(dynamic-require 'scribble/run #f)
|
||||
(cond
|
||||
[(equal? label "HTML")
|
||||
[(equal? suffix #".html")
|
||||
(send-url/file (path-replace-suffix fn suffix))]
|
||||
[else (system (format "open ~a" (path-replace-suffix name suffix)))]))
|
||||
(message-box "Scribble" (get-output-string p) drs-frame))
|
||||
[else
|
||||
(system (format "open ~s" (path->string (path-replace-suffix fn suffix))))]))
|
||||
(let ([s (get-output-string p)])
|
||||
(unless (equal? s "")
|
||||
(message-box "Scribble" s drs-frame))))
|
||||
(message-box "Not Named" "Cannot render unsaved file"))))))
|
||||
|
||||
(define drracket-buttons
|
||||
|
|
|
@ -26,6 +26,59 @@ new languages.
|
|||
|
||||
@; --------------------------------------------------
|
||||
|
||||
@section[#:tag "more-hash-lang"]{More Rackets}
|
||||
|
||||
``Racket'' is more of an idea about programming languages than a
|
||||
language in the usual sense. Macros can extend a base language (as
|
||||
described in @secref["macros"]), and alternate parsers can
|
||||
construct an entirely new language from the ground up (as described in
|
||||
@secref["languages"]).
|
||||
|
||||
The @hash-lang[] line that starts a Racket module declares the
|
||||
base language of the module. By ``Racket,'' we usually mean
|
||||
@hash-lang[] followed by the base language @racketmodname[racket] or
|
||||
@racketmodname[racket/base] (of which @racketmodname[racket] is an
|
||||
extension). The Racket distribution provides additional languages,
|
||||
including the following:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@racketmodname[typed/racket] --- like
|
||||
@racketmodname[racket], but statically typed; see
|
||||
@other-manual['(lib "typed-scheme/scribblings/ts-guide.scrbl")]}
|
||||
|
||||
@item{@racketmodname[lazy] --- like @racketmodname[racket/base], but
|
||||
avoids evaluating an expression until its value is needed; see
|
||||
@other-manual['(lib "lazy/lazy.scrbl")]}
|
||||
|
||||
@item{@racketmodname[frtime] --- changes evaluation in an even more
|
||||
radical way to support reactive programming; see
|
||||
@other-manual['(lib "frtime/scribblings/frtime.scrbl")]}
|
||||
|
||||
@item{@racketmodname[scribble/base] --- a language, which looks more
|
||||
like Latex than Racket, for writing documentation; see
|
||||
@other-manual['(lib "scribblings/scribble/scribble.scrbl")]}
|
||||
|
||||
]
|
||||
|
||||
Each of these languages is used by starting module with the language
|
||||
name after @hash-lang[]. For example, this source of this
|
||||
document starts with @racket[@#,hash-lang[] scribble/base].
|
||||
|
||||
Furthermore, Racket users can define their own languages, as discussed
|
||||
in @secref["languages"]. Typically, a language name maps to its
|
||||
implementation through a module path by adding
|
||||
@racketidfont{/lang/reader}; for example, the language name
|
||||
@racketmodname[scribble/base] is expanded to
|
||||
@racket[scribble/base/lang/reader], which is the module that
|
||||
implements the surface-syntax parser. Some language names act as
|
||||
language loaders; for example, @racket[@#,hash-lang[]
|
||||
@#,racketmodname[planet] _planet-path] downloads, installs, and uses a
|
||||
language via @seclink["top" #:doc '(lib
|
||||
"planet/planet.scrbl")]{@|PLaneT|}.
|
||||
|
||||
@; --------------------------------------------------
|
||||
|
||||
@section[#:tag "standards"]{Standards}
|
||||
|
||||
Standard dialects of Scheme include the ones defined by @|r5rs| and
|
||||
|
@ -80,67 +133,6 @@ information about running @|r6rs| programs with Racket.
|
|||
|
||||
@; --------------------------------------------------
|
||||
|
||||
@section[#:tag "more-hash-lang"]{More Rackets}
|
||||
|
||||
Like ``Scheme,'' even ``Racket'' is more of an idea about
|
||||
programming languages than a language in the usual sense. Macros can
|
||||
extend a base language (as described in @secref["macros"]), but macros
|
||||
and alternate parsers can construct an entirely new language from the
|
||||
ground up.
|
||||
|
||||
The @hash-lang[] line that starts a Racket module declares the
|
||||
base language of the module. By ``Racket,'' we usually mean
|
||||
@hash-lang[] followed by the base language @racketmodname[racket] or
|
||||
@racketmodname[racket/base] (of which @racketmodname[racket] is an
|
||||
extension). The Racket distribution provides additional languages,
|
||||
including the following:
|
||||
|
||||
@itemize[
|
||||
|
||||
@item{@racketmodname[typed/racket] --- like
|
||||
@racketmodname[racket], but statically typed; see
|
||||
@other-manual['(lib "typed-scheme/scribblings/ts-guide.scrbl")]}
|
||||
|
||||
@item{@racketmodname[lazy] --- like @racketmodname[racket/base], but
|
||||
avoids evaluating an expression until its value is needed; see
|
||||
@other-manual['(lib "lazy/lazy.scrbl")]}
|
||||
|
||||
@item{@racketmodname[frtime] --- changes evaluation in an even more
|
||||
radical way to support reactive programming; see
|
||||
@other-manual['(lib "frtime/scribblings/frtime.scrbl")]}
|
||||
|
||||
@item{@racketmodname[scribble/base] --- a language, which looks more
|
||||
like Latex than Racket, for writing documentation; see
|
||||
@other-manual['(lib "scribblings/scribble/scribble.scrbl")]}
|
||||
|
||||
]
|
||||
|
||||
Each of these languages is used by starting module with the language
|
||||
name after @hash-lang[]. For example, this source of this
|
||||
document starts with @racket[@#,hash-lang[] scribble/base].
|
||||
|
||||
Racket users can define their own languages. A language name maps
|
||||
to its implementation through a module path by adding
|
||||
@racketidfont{/lang/reader}. For example, the language name
|
||||
@racketmodname[scribble/doc] is expanded to
|
||||
@racket[scribble/doc/lang/reader], which is the module that implements
|
||||
the surface-syntax parser. The parser, in turn, generates a
|
||||
@racket[module] form, which determines the base language at the level
|
||||
of syntactic forms an functions.
|
||||
|
||||
Some language names act as language loaders. For example,
|
||||
@racketmodname[s-exp] as a language uses the usual Racket parser
|
||||
for surface-syntax reading, and then it uses the module path after
|
||||
@racketmodname[s-exp] for the language's syntactic forms. Thus,
|
||||
@racket[@#,hash-lang[] @#,racketmodname[s-exp] "mylang.rkt"] parses
|
||||
the module body using the normal Racket reader, by then imports
|
||||
the initial syntax and functions for the module body from
|
||||
@racket["mylang.rkt"]. Similarly, @racket[@#,hash-lang[]
|
||||
@#,racketmodname[planet] _planet-path] loads a language via
|
||||
@seclink["top" #:doc '(lib "planet/planet.scrbl")]{@|PLaneT|}.
|
||||
|
||||
@; --------------------------------------------------
|
||||
|
||||
@section[#:tag "teaching-langs"]{Teaching}
|
||||
|
||||
The @|HtDP| textbook relies on pedagogic variants of Racket that
|
||||
|
|
|
@ -111,7 +111,7 @@ by @racket[kind], which must be one of the following:
|
|||
|
||||
@item{@indexed-racket['exec-file] --- the path of the Racket
|
||||
executable as provided by the operating system for the current
|
||||
invocation.
|
||||
invocation. For some operating systems, the path can be relative.
|
||||
|
||||
@margin-note{For GRacket, the executable path is the name of a GRacket
|
||||
executable.}}
|
||||
|
|
|
@ -93,6 +93,7 @@ a part of the separator that surrounds the word @scheme["good"].
|
|||
]
|
||||
The results is similar to the one that @scheme[read-words] produces,
|
||||
except that the organization of the file into lines is preserved.
|
||||
In particular, the empty third line is represented as an empty list of words.
|
||||
}
|
||||
|
||||
@item{@reading[read-csv-file (listof (listof any/c))]{a list of lists of comma-separated values}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
hello world
|
||||
good bye
|
||||
|
||||
i am done
|
||||
|
|
Loading…
Reference in New Issue
Block a user