[racket] confused beginner

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sat Oct 4 09:48:37 EDT 2014

What you used is called a "computed string" that is, you expect bitmap to evaluate the argument path-stringy to a string. 

But, in BSL, bitmap expects to be handed a literal string constant (or a module path):

---------------------------------------------------------------------
(require 2htdp/image)

;; with a module path 
(bitmap 2htdp/planetcute/character-cat-girl.png)

;; with a fixed string
(bitmap "plt/pkgs/htdp-pkgs/htdp-lib/2htdp/planetcute/character-cat-girl.png")
---------------------------------------------------------------------

Both of these will succeed and retrieve the cat girl from the Planet Cute collection that comes with Racket -- Matthias




On Oct 4, 2014, at 9:36 AM, Andrew Ulrich wrote:

> Hi, I've got a really simple problem, I think.  Why is it that when I try to do the following:
> 
> (require 2htdp/image)
> (define path-stringy "images/some.png")
> (bitmap (path-stringy))
> 
> I get the following error:
>  bitmap: expected the argument to specify a local path (via a string) or a module path (e.g. `icons/b-run.png') in: (bitmap (path-stringy))
> 
> I mean, shouldn't path-stringy evaluate to a string before it's passed into bitmap?  If not, then how do I use bitmap for anything dynamic?
> 
> Thanks,
> Andrew
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/users



Posted on the users mailing list.