diff --git a/examples/images/humpback.jpg b/examples/images/humpback.jpg new file mode 100644 index 0000000..aab9368 Binary files /dev/null and b/examples/images/humpback.jpg differ diff --git a/examples/using-resources.rkt b/examples/using-resources.rkt new file mode 100644 index 0000000..cd9d44b --- /dev/null +++ b/examples/using-resources.rkt @@ -0,0 +1,4 @@ +#lang planet dyoo/whalesong + +(require (planet dyoo/whalesong/resource)) +(file-resource "images/humpback.jpg") \ No newline at end of file diff --git a/lang/kernel.rkt b/lang/kernel.rkt index 6526f4f..96d1186 100644 --- a/lang/kernel.rkt +++ b/lang/kernel.rkt @@ -72,6 +72,7 @@ let-values let*-values define-struct + struct if cond else diff --git a/resource.rkt b/resource.rkt index be04a18..87c96f9 100644 --- a/resource.rkt +++ b/resource.rkt @@ -1,5 +1,4 @@ #lang s-exp "lang/kernel.rkt" -(provide (all-defined-out)) - -(define-struct bytes-resource (name type bytes)) +(require "resource/main.rkt") +(provide (all-from-out "resource/main.rkt")) diff --git a/resource/compile-time.rkt b/resource/compile-time.rkt new file mode 100644 index 0000000..c0956a9 --- /dev/null +++ b/resource/compile-time.rkt @@ -0,0 +1,22 @@ +#lang s-exp "../lang/kernel.rkt" + +(provide file-resource) + + +(require "structs.rkt") + +;; Macros for recording the definition of resources in a program. +(require (for-syntax racket/base)) + + +;; file-resource: +;; +(define-for-syntax (file-resource stx) + (syntax-case stx () + [(_ path) + (syntax/loc stx + (let-syntax ([compile-time-code + (lambda (stx) + (displayln "at compile time") + #'(void))]) + (resource path)))])) diff --git a/resource/main.rkt b/resource/main.rkt new file mode 100644 index 0000000..8c5c54f --- /dev/null +++ b/resource/main.rkt @@ -0,0 +1,4 @@ +#lang s-exp "../lang/kernel.rkt" + +(require "compile-time.rkt") +(provide (all-from-out "compile-time.rkt")) diff --git a/resource/structs.rkt b/resource/structs.rkt new file mode 100644 index 0000000..6432f1b --- /dev/null +++ b/resource/structs.rkt @@ -0,0 +1,6 @@ +#lang s-exp "../lang/kernel.rkt" + +(provide (all-defined-out)) + + +(struct resource (path))