[racket-dev] printing images in REPL

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Sat Aug 28 22:18:42 EDT 2010

And sorry: here's a keyword: read-language. You'll want to set up your
language so that it can answer those queries. Then drracket will call
the info proc with 'configure-runtime. I could have sworn that was
documented somewhere, but I'm not finding it (I think that must be a
bug in searching or the entry got lost or something). In any case
drracket usees it like this:

                (let ([configs (get-info 'configure-runtime '())])
                  (for ([config (in-list configs)])
                    ((dynamic-require (vector-ref config 0)
                                      (vector-ref config 1))
                     (vector-ref config 2))))))))

where get-info comes from read-language.

And yes, this is on my list to add to the guide-like docs in the tools manual.

hth,
Robby

On Sat, Aug 28, 2010 at 8:49 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> Did you forget what I explained at PLT day? You don't seem to be
> asking questions in terms of those things, so I'm not sure whether
> what I say is getting thru at all.
>
> Robby
>
> On Sat, Aug 28, 2010 at 8:47 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
>> ... which was my original question.  But thanks.
>>
>> On Sat, Aug 28, 2010 at 9:36 PM, Robby Findler
>> <robby at eecs.northwestern.edu> wrote:
>>> I guess you don't have the print handler set up right.
>>>
>>> On Sat, Aug 28, 2010 at 8:23 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
>>>> The value I was returning is whatever kind of object is returned when
>>>> you embed an image in the Definitions window.  That is, this was a
>>>> pasted, atomic image, not one created by a computation.  I guess
>>>> they're not treated the same, but I'm surprised that ASL processing
>>>> the Definitions window didn't do the right conversion...
>>>>
>>>> On Thu, Aug 26, 2010 at 8:25 PM, Robby Findler
>>>> <robby at eecs.northwestern.edu> wrote:
>>>>> At the moment there is a barn-door sized security hole in DrRacket,
>>>>> whereby it will take any snip% instance from the user's program and
>>>>> just display it in the repl. You can exploit this for Good by making
>>>>> the current-print of your language turn some values into snips (like
>>>>> images and things). 2htdp/image already does this, so that should just
>>>>> work if you return those. Its hard to tell what value Shriram's
>>>>> program was returning tho. But if it is a bitmap% object, he just has
>>>>> to do
>>>>>
>>>>>  (make-object image-snip% ...the-bitmap-goes-here...)
>>>>>
>>>>> We will close this hole at some point, when we have a reasonable way
>>>>> to allow people to add new kinds of values without the security
>>>>> breach.
>>>>>
>>>>> Robby
>>>>>
>>>>> On Thu, Aug 26, 2010 at 6:17 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
>>>>>> From what I can tell, it comes from ensuring that DrRacket shares the
>>>>>> htdp/image (or whatever) namespace with the running program so the
>>>>>> structs are the same and DrRacket's default renderer is detecting it.
>>>>>> I'm not sure how to replicate it though. (I tried for a bit so I could
>>>>>> make #lang frtime work.)
>>>>>>
>>>>>> Jay
>>>>>>
>>>>>> On Thu, Aug 26, 2010 at 11:55 AM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
>>>>>>> What is the #lang magic that makes
>>>>>>>
>>>>>>>> (get-image-from-web "http://racket-lang.org/logo.png")
>>>>>>> (instantiate (class ...) ...)
>>>>>>>
>>>>>>> show the image rather than just its constructor?
>>>>>>>
>>>>>>> Shriram
>>>>>>> _________________________________________________
>>>>>>>  For list-related administrative tasks:
>>>>>>>  http://lists.racket-lang.org/listinfo/dev
>>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Jay McCarthy <jay at cs.byu.edu>
>>>>>> Assistant Professor / Brigham Young University
>>>>>> http://teammccarthy.org/jay
>>>>>>
>>>>>> "The glory of God is Intelligence" - D&C 93
>>>>>> _________________________________________________
>>>>>>  For list-related administrative tasks:
>>>>>>  http://lists.racket-lang.org/listinfo/dev
>>>>>
>>>>
>>> _________________________________________________
>>>  For list-related administrative tasks:
>>>  http://lists.racket-lang.org/listinfo/dev
>>
>


Posted on the dev mailing list.