Re: [racket-users] pictures in code?

2020-08-03 Thread Philip McGrath
On Mon, Aug 3, 2020 at 9:47 AM Hendrik Boom  wrote:

> On Sun, Aug 02, 2020 at 08:58:54PM -0700, Sorawee Porncharoenwase wrote:
> > For DrRacket, it's possible via "Insert > Insert Image". It's been used
> in
> > HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html
>
> Now that's presumably something that works nicely in the DrRacket editor.
> When DrRacket saves it into a file, it presumably uses some notation that
> won't look like a picture in, say, emacs.
>

Yes, that's all correct. My knowledge isn't very deep here, but to answer
the questions you asked:


> But will it still be recognised as an image if I use Racket to run that
> file?
>

Yes. The only difference is that the default printer (for example) doesn't
know how to print pictures, so you will see some output like:
philip$ racket image-literal.rkt
(object:image% ... ...)
when DrRacket would actually print the image. In principle, this is just
like DrRacket's ability to print `1/3` using barred decimal notation.

Can the image be used as a symbol or a constant or is it some other type
> of object?
>

The idea, as I understand it, is that an image is a self-quoting literal
datum like `42`, `"foo`", `#false`, or `#px"\\d+"`.

What kind of a datum is it? Alexis has explained in your other thread why
that's a difficult question.

Practically, I know that image literals answer `#true` to `image?` from the
`2htdp/image `
library. That's the only way I can remember having worked with them, but I
know they are also some other kinds of things: for example, an image
literal is an instance of (a subclass of) `snip%
` from `racket/gui`.

How is this implemented? My vague understanding is that there's some deep
magic baked into `racket/gui` to support image literals, I think around
`mrlib/image-core` and `mrlib/image-core-wxme`. I know there are some
limitations to this approach (though I don't immediately remember what all
of them are), and there have been some discussions about more general
mechanism for languages to support new kinds of literal data. The most
in-depth work I know of is from Lief's `#lang video `,
where she's experimenting with non-linear video editor literals

.

 Hope this helps.

-Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAH3z3gYs1L8Zgiapino%3DRVj3%3DX%3DmYm%3DJ_4c50KMDjESmrYC%2Brg%40mail.gmail.com.


Re: [racket-users] pictures in code?

2020-08-03 Thread Hendrik Boom
On Sun, Aug 02, 2020 at 08:58:54PM -0700, Sorawee Porncharoenwase wrote:
> For DrRacket, it's possible via "Insert > Insert Image". It's been used in
> HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html

Yes!  That's where I saw this many years ago.

Now that's presumably something that works nicely in the DrRacket editor.
When DrRacket saves it into a file, it presumably uses some notation that
won't look like a picture in, say, emacs.
But will it still be recognised as an image if I use Racket to run that file?
Can the image be used as a symbol or a constant or is it some other type 
of object?

-- hendrik

> 
> On Sun, Aug 2, 2020 at 7:07 PM Hendrik Boom  wrote:
> 
> > Is there any way to include pictures in Racket code?
> > Perhaps as constants or as prts of identifiers?
> > The idea is that when editing the program in the Racket editor,
> > the pictures are visible as part of the code,
> > making the code itself more visually self-evident,
> > not as file names to be read from elsewhere.
> >
> > -- hendrik
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/racket-users/20200803020710.d2rvz6gojluubt5t%40topoi.pooq.com
> > .
> >
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/CADcuegvJCAHQYwO-eCcqKfqwhrd%2BGr4PELie_e0%3DO9b2PJ_QAA%40mail.gmail.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200803134732.w5lq45vkglq2pmu6%40topoi.pooq.com.


Re: [racket-users] pictures in code?

2020-08-02 Thread Sorawee Porncharoenwase
For DrRacket, it's possible via "Insert > Insert Image". It's been used in
HtDP. See https://htdp.org/2020-8-1/Book/part_prologue.html

On Sun, Aug 2, 2020 at 7:07 PM Hendrik Boom  wrote:

> Is there any way to include pictures in Racket code?
> Perhaps as constants or as prts of identifiers?
> The idea is that when editing the program in the Racket editor,
> the pictures are visible as part of the code,
> making the code itself more visually self-evident,
> not as file names to be read from elsewhere.
>
> -- hendrik
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200803020710.d2rvz6gojluubt5t%40topoi.pooq.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegvJCAHQYwO-eCcqKfqwhrd%2BGr4PELie_e0%3DO9b2PJ_QAA%40mail.gmail.com.


[racket-users] pictures in code?

2020-08-02 Thread Hendrik Boom
Is there any way to include pictures in Racket code?
Perhaps as constants or as prts of identifiers?
The idea is that when editing the program in the Racket editor,
the pictures are visible as part of the code,
making the code itself more visually self-evident,
not as file names to be read from elsewhere.

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200803020710.d2rvz6gojluubt5t%40topoi.pooq.com.