diff --git a/scribblings/manual.scrbl b/scribblings/manual.scrbl index fd7ebd1..f02235b 100644 --- a/scribblings/manual.scrbl +++ b/scribblings/manual.scrbl @@ -11,7 +11,8 @@ "../js-assembler/get-js-vm-implemented-primitives.rkt") @(require (for-label (this-package-in js)) - (for-label (this-package-in lang/base))) + (for-label (this-package-in lang/base)) + (for-label (this-package-in resource))) @@ -162,6 +163,14 @@ Expected one of the following: [build, get-runtime, get-javascript]. and if this does appear, then Whalesong should be installed successfully. +Note: whenever Whalesong's source code is updated from Github, please +re-run the @tt{raco setup}. Otherwise, Racket will try to recompile +Whalesong on every single use of Whalesong, which can be very +expensive. + + + + @subsection{Making Standalone @tt{.xhtml} files with Whalesong} @@ -391,10 +400,15 @@ program. @subsection{@tt{build}} -Given the name of a program, this builds a standalone @filepath{.xhtml} file that -executes the program in a web browser. The @filepath{.xhtml} should -be completely self-contained. +Given the name of a program, this builds a standalone +@filepath{.xhtml} file into the current working directory that +executes the program in a web browser. +The @filepath{.xhtml} should be self-contained, with an exception: if +the file uses any external resources by using +@racket[define-resource], those resources are written into a +subdirectory called @filepath{res} under the current working +directory. @subsection{@tt{get-javascript}} @@ -413,6 +427,12 @@ All main modules will be executed when the JavaScript function (needs to write a MANIFEST file?) (this almost seems like we need some concept of a JAR... ) + +@subsection{@tt{write-resources}} +[NOT DONE YET] + + + @subsection{@tt{get-runtime}} Prints out the core runtime library that the files generated by @@ -422,152 +442,58 @@ get-javascript depend on. +@section{Including external resources with @racketmodname/this-package[resource]} +@defmodule/this-package[resource] -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -@section{Reference} -@;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +Programs may need to use external file resources that aren't +themselves Racket programs, but instead some other kind of data. +Graphical programs will often use @filepath{.png}s, and web-related +programs @filepath{.html}s, for example. Whalesong provides the +@racketmodname/this-package[resource] library to refer and use these +external resources. When Whalesong compiles a program into a package, +these resources will be bundled alongside the JavaScript-compiled +output. -(This section should describe the whalesong language.) +@defform[(define-resource id path-string)]{ +Defines a resource with the given path name. + +For example, +@codeblock|{ +#lang planet dyoo/whalesong +(require (planet dyoo/whalesong/resource)) +(define-resource my-whale-image-resource "humpback.png") +}| +} + + +@defproc[(resource->url [a-resource resource?]) string?]{ +Given a resource, gets a URL. + +For example, +@codeblock|{ +#lang planet dyoo/whalesong +(require (planet dyoo/whalesong/resource) + (planet dyoo/whalesong/image)) + +(define-resource my-whale-image-resource "humpback.png") + +(define WHALE-IMAGE + (bitmap/url (resource->url my-whale-image-resource))) +}| + +} +@; Not done yet! +@;@defproc[(resource->input-port [a-resource resource?]) string?]{ +@;Given a resource, gets an input-port of its contents. +@;} - - - -@section{The Whalesong language} - -@defmodule/this-package[lang/base] - -This needs to at least show all the bindings available from the base -language. - -@defthing[true boolean]{The boolean value @racket[#t].} -@defthing[false boolean]{The boolean value @racket[#f].} -@defthing[pi number]{The math constant @racket[pi].} -@defthing[e number]{The math constant @racket[pi].} -@defthing[null null]{The empty list value @racket[null].} - - - -@defform[(let/cc id body ...)]{} -@defform[(null? ...)]{} -@defform[(not ...)]{} -@defform[(eq? ...)]{} -@defform[(equal? ...)]{} -@defform[(void ...)]{} - - - -@subsection{IO} -@defform[(current-output-port ...)]{} -@defform[(current-print ...)]{} -@defform[(write ...)]{} -@defform[(write-byte ...)]{} -@defform[(display ...)]{} -@defform[(newline ...)]{} -@defform[(format ...)]{} -@defform[(printf ...)]{} -@defform[(fprintf ...)]{} -@defform[(displayln ...)]{} - - - -@subsection{Numeric operations} - -@defform[(+ ...)]{} -@defform[(- ...)]{} -@defform[(* ...)]{} -@defform[(/ ...)]{} -@defform[(= ...)]{} -@defform[(add1 ...)]{} -@defform[(sub1 ...)]{} -@defform[(< ...)]{} -@defform[(<= ...)]{} -@defform[(> ...)]{} -@defform[(>= ...)]{} -@defform[(abs ...)]{} -@defform[(quotient ...)]{} -@defform[(remainder ...)]{} -@defform[(modulo ...)]{} -@defform[(gcd ...)]{} -@defform[(lcm ...)]{} -@defform[(floor ...)]{} -@defform[(ceiling ...)]{} -@defform[(round ...)]{} -@defform[(truncate ...)]{} -@defform[(numerator ...)]{} -@defform[(denominator ...)]{} -@defform[(expt ...)]{} -@defform[(exp ...)]{} -@defform[(log ...)]{} -@defform[(sin ...)]{} -@defform[(sinh ...)]{} -@defform[(cos ...)]{} -@defform[(cosh ...)]{} -@defform[(tan ...)]{} -@defform[(asin ...)]{} -@defform[(acos ...)]{} -@defform[(atan ...)]{} -@defform[(sqr ...)]{} -@defform[(sqrt ...)]{} -@defform[(integer-sqrt ...)]{} -@defform[(sgn ...)]{} -@defform[(make-rectangular ...)]{} -@defform[(make-polar ...)]{} -@defform[(real-part ...)]{} -@defform[(imag-part ...)]{} -@defform[(angle ...)]{} -@defform[(magnitude ...)]{} -@defform[(conjugate ...)]{} -@defform[(string->number ...)]{} -@defform[(number->string ...)]{} -@defform[(random ...)]{} -@defform[(exact? ...)]{} -@defform[(integer? ...)]{} -@defform[(zero? ...)]{} - -@subsection{String operations} -@defform[(string=? ...)]{} -@defform[(string->symbol ...)]{} -@defform[(string-length ...)] {} -@defform[(string-append ...)] {} - - -@subsection{Symbol operations} -@defform[(symbol? ...)]{} -@defform[(symbol->string? ...)]{} - - - -@subsection{List operations} -@defform[(pair? ...)]{} -@defform[(cons ...)]{} -@defform[(car ...)]{} -@defform[(cdr ...)]{} -@defform[(list ...)]{} -@defform[(length ...)]{} -@defform[(append ...)]{} -@defform[(reverse ...)]{} -@defform[(map ...)]{} -@defform[(for-each ...)]{} -@defform[(member ...)]{} -@defform[(list-ref ...)]{} -@defform[(memq ...)]{} -@defform[(assq ...)]{} - - - -@subsection{Vector operations} -@defform[(vector? ...)]{} -@defform[(make-vector ...)]{} -@defform[(vector ...)]{} -@defform[(vector-length ...)]{} -@defform[(vector-ref ...)]{} -@defform[(vector-set! ...)]{} -@defform[(vector->list ...)]{} -@defform[(list->vector ...)]{} - +@;@defform[(define-remote-resource id url-string])]{ +@;Given a url, creates a remote resource. At the time of Whalesong compilation, +@;Whalesong will freeze a static copy of the file. +@;} @@ -1059,6 +985,159 @@ I'll be attacking once things stabilize.) + + + + + + + + + + +@section{The Whalesong language} + +@defmodule/this-package[lang/base] + +This needs to at least show all the bindings available from the base +language. + +@defthing[true boolean]{The boolean value @racket[#t].} +@defthing[false boolean]{The boolean value @racket[#f].} +@defthing[pi number]{The math constant @racket[pi].} +@defthing[e number]{The math constant @racket[pi].} +@defthing[null null]{The empty list value @racket[null].} + + + +@defform[(let/cc id body ...)]{} +@defform[(null? ...)]{} +@defform[(not ...)]{} +@defform[(eq? ...)]{} +@defform[(equal? ...)]{} +@defform[(void ...)]{} + + + +@subsection{IO} +@defform[(current-output-port ...)]{} +@defform[(current-print ...)]{} +@defform[(write ...)]{} +@defform[(write-byte ...)]{} +@defform[(display ...)]{} +@defform[(newline ...)]{} +@defform[(format ...)]{} +@defform[(printf ...)]{} +@defform[(fprintf ...)]{} +@defform[(displayln ...)]{} + + + +@subsection{Numeric operations} + +@defform[(+ ...)]{} +@defform[(- ...)]{} +@defform[(* ...)]{} +@defform[(/ ...)]{} +@defform[(= ...)]{} +@defform[(add1 ...)]{} +@defform[(sub1 ...)]{} +@defform[(< ...)]{} +@defform[(<= ...)]{} +@defform[(> ...)]{} +@defform[(>= ...)]{} +@defform[(abs ...)]{} +@defform[(quotient ...)]{} +@defform[(remainder ...)]{} +@defform[(modulo ...)]{} +@defform[(gcd ...)]{} +@defform[(lcm ...)]{} +@defform[(floor ...)]{} +@defform[(ceiling ...)]{} +@defform[(round ...)]{} +@defform[(truncate ...)]{} +@defform[(numerator ...)]{} +@defform[(denominator ...)]{} +@defform[(expt ...)]{} +@defform[(exp ...)]{} +@defform[(log ...)]{} +@defform[(sin ...)]{} +@defform[(sinh ...)]{} +@defform[(cos ...)]{} +@defform[(cosh ...)]{} +@defform[(tan ...)]{} +@defform[(asin ...)]{} +@defform[(acos ...)]{} +@defform[(atan ...)]{} +@defform[(sqr ...)]{} +@defform[(sqrt ...)]{} +@defform[(integer-sqrt ...)]{} +@defform[(sgn ...)]{} +@defform[(make-rectangular ...)]{} +@defform[(make-polar ...)]{} +@defform[(real-part ...)]{} +@defform[(imag-part ...)]{} +@defform[(angle ...)]{} +@defform[(magnitude ...)]{} +@defform[(conjugate ...)]{} +@defform[(string->number ...)]{} +@defform[(number->string ...)]{} +@defform[(random ...)]{} +@defform[(exact? ...)]{} +@defform[(integer? ...)]{} +@defform[(zero? ...)]{} + +@subsection{String operations} +@defform[(string? s)]{} +@defform[(string=? ...)]{} +@defform[(string->symbol ...)]{} +@defform[(string-length ...)] {} +@defform[(string-append ...)] {} + + +@subsection{Symbol operations} +@defform[(symbol? ...)]{} +@defform[(symbol->string? ...)]{} + + + +@subsection{List operations} +@defform[(pair? ...)]{} +@defform[(cons ...)]{} +@defform[(car ...)]{} +@defform[(cdr ...)]{} +@defform[(list ...)]{} +@defform[(length ...)]{} +@defform[(append ...)]{} +@defform[(reverse ...)]{} +@defform[(map ...)]{} +@defform[(for-each ...)]{} +@defform[(member ...)]{} +@defform[(list-ref ...)]{} +@defform[(memq ...)]{} +@defform[(assq ...)]{} + + + +@subsection{Vector operations} +@defform[(vector? ...)]{} +@defform[(make-vector ...)]{} +@defform[(vector ...)]{} +@defform[(vector-length ...)]{} +@defform[(vector-ref ...)]{} +@defform[(vector-set! ...)]{} +@defform[(vector->list ...)]{} +@defform[(list->vector ...)]{} + + + + + + + + + + @;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @section{Acknowledgements} @;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -1085,6 +1164,7 @@ improvements: @item{Ethan Cecchetti} @item{Scott Newman} @item{Zhe Zhang} + @item{Jens Axel Søgaard} @item{Shriram Krishnamurthi} @item{Emmanuel Schanzer} ] \ No newline at end of file