[racket] confused beginner

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Sat Oct 4 09:54:16 EDT 2014

Hi Andrew,

To add what Matthias say, if you need a "function version" of bitmap,
you can use bitmap/file instead.

    (require 2htdp/image)
    (define path-stringy "images/some.png")
    (bitmap/file path-stringy)

Note that I changed (path-stringy) to path-stringy.

/Jens Axel




2014-10-04 15:48 GMT+02:00 Matthias Felleisen <matthias at ccs.neu.edu>:
>
> 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
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users



-- 
--
Jens Axel Søgaard


Posted on the users mailing list.