Re: [racket-users] how to use union types

2019-02-28 Thread Brian Craft
So, when working with large data that is internal to an app, where schema 
is guaranteed by serialization, there's no way to load that without another 
O(N) pass to satisfy the type checker?


On Thursday, February 28, 2019 at 1:03:48 PM UTC-8, Sam Tobin-Hochstadt 
wrote:
>
> Yes, a cast to a List type checks all the elements of the list. 
> There's no way to tell if every element of list is a string in less 
> than O(N) time -- that information just isn't available anywhere. 
>
> Sam 
>
> On Thu, Feb 28, 2019 at 3:52 PM Brian Craft  > wrote: 
> > 
> > Really? A cast is also O(N)? 
> > 
> > On Thursday, February 28, 2019 at 11:11:01 AM UTC-8, Sam Tobin-Hochstadt 
> wrote: 
> >> 
> >> Any of these solutions need a O(N) traversal of the data. That's 
> >> because we need to do a full traversal to be sure we got an actual 
> >> (Listof String) from read-json -- there's no way around it. 
> >> 
> >> Sam 
> >> 
> >> On Thu, Feb 28, 2019 at 2:04 PM Brian Craft  
> wrote: 
> >> > 
> >> > I would think there'd be a large performance issue, as well, due to 
> needing an O(N) walk of the data. I'm having type checker issues with 
> (time), so haven't tested it, but maybe (cast) will get me past those. 
> >> > 
> >> > Thanks! 
> >> > 
> >> > On Monday, February 25, 2019 at 4:26:52 PM UTC-8, Philip McGrath 
> wrote: 
> >> >> 
> >> >> An alternative to figuring out how to satisfy the type checker is to 
> use `cast`, e.g.: 
> >> >> #lang typed/racket 
> >> >> (require typed/json) 
> >> >> (string-join 
> >> >>  (cast 
> >> >>   (string->jsexpr 
> >> >>"[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]") 
> >> >>   (Listof String))) 
> >> >> 
> >> >> Obviously this has pros and cons, the main pro being that it runs. 
> The biggest con, in my view, is that you effectively are dropping into 
> untyped world. If you figure out how to satisfy the type checker, you get 
> assurance that your code is well-typed, which is presumably what you want 
> if your using Typed Racket in the first place. Using `cast` means that you 
> are responsible for making sure that expression has the type you say it 
> does, without help from Typed Racket, or you will get a runtime error. For 
> example, I often forget that `read-json` might return `eof` rather than a 
> `JSExpr`. Also, `cast` uses the contract machinery, which can carry 
> performance costs. 
> >> >> 
> >> >> But the fact that it runs is not a small benefit, especially if it 
> lets you fill in other parts of your program and come back to remove the 
> `cast` later. It also lets you take advantage of Typed Racket to generate 
> any complicated runtime checks. 
> >> >> 
> >> >> -Philip 
> >> >> 
> >> >> 
> >> >> On Mon, Feb 25, 2019 at 6:49 PM  wrote: 
> >> >>> 
> >> >>> A JSExpr is one of a couple of things: 
> >> >>> 
> >> >>> - A list 
> >> >>> - A hash with symbol keys 
> >> >>> - A number 
> >> >>> - A string 
> >> >>> - A boolean 
> >> >>> - Null 
> >> >>> 
> >> >>> The (andmap string?) approach implicitly assumes you're giving it a 
> list. But it might be something else instead, so you want this: (and (list? 
> js) (andmap string? js)) 
> >> >>> 
> >> >>> On Monday, February 25, 2019 at 3:44:38 PM UTC-8, Brian Craft 
> wrote: 
> >> >>>> 
> >> >>>> So, that also gives me a type error: 
> >> >>>> 
> >> >>>>  Type Checker: Polymorphic function `andmap' could not be applied 
> to arguments: 
> >> >>>> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b 
> >> >>>>  (-> a c : d) (Listof a) 
> >> >>>> Arguments: (-> Any Boolean : String) (U EOF JSExpr) 
> >> >>>> 
> >> >>>>   in: (andmap string? s) 
> >> >>>> 
> >> >>>> 
> >> >>>> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam 
> Tobin-Hochstadt wrote: 
> >> >>>>> 
> >> >>>>> I think (andmap string? ...) is probably the easiest way to check 

Re: [racket-users] how to use union types

2019-02-28 Thread Brian Craft
Really? A cast is also O(N)?

On Thursday, February 28, 2019 at 11:11:01 AM UTC-8, Sam Tobin-Hochstadt 
wrote:
>
> Any of these solutions need a O(N) traversal of the data. That's 
> because we need to do a full traversal to be sure we got an actual 
> (Listof String) from read-json -- there's no way around it. 
>
> Sam 
>
> On Thu, Feb 28, 2019 at 2:04 PM Brian Craft  > wrote: 
> > 
> > I would think there'd be a large performance issue, as well, due to 
> needing an O(N) walk of the data. I'm having type checker issues with 
> (time), so haven't tested it, but maybe (cast) will get me past those. 
> > 
> > Thanks! 
> > 
> > On Monday, February 25, 2019 at 4:26:52 PM UTC-8, Philip McGrath wrote: 
> >> 
> >> An alternative to figuring out how to satisfy the type checker is to 
> use `cast`, e.g.: 
> >> #lang typed/racket 
> >> (require typed/json) 
> >> (string-join 
> >>  (cast 
> >>   (string->jsexpr 
> >>"[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]") 
> >>   (Listof String))) 
> >> 
> >> Obviously this has pros and cons, the main pro being that it runs. The 
> biggest con, in my view, is that you effectively are dropping into untyped 
> world. If you figure out how to satisfy the type checker, you get assurance 
> that your code is well-typed, which is presumably what you want if your 
> using Typed Racket in the first place. Using `cast` means that you are 
> responsible for making sure that expression has the type you say it does, 
> without help from Typed Racket, or you will get a runtime error. For 
> example, I often forget that `read-json` might return `eof` rather than a 
> `JSExpr`. Also, `cast` uses the contract machinery, which can carry 
> performance costs. 
> >> 
> >> But the fact that it runs is not a small benefit, especially if it lets 
> you fill in other parts of your program and come back to remove the `cast` 
> later. It also lets you take advantage of Typed Racket to generate any 
> complicated runtime checks. 
> >> 
> >> -Philip 
> >> 
> >> 
> >> On Mon, Feb 25, 2019 at 6:49 PM  wrote: 
> >>> 
> >>> A JSExpr is one of a couple of things: 
> >>> 
> >>> - A list 
> >>> - A hash with symbol keys 
> >>> - A number 
> >>> - A string 
> >>> - A boolean 
> >>> - Null 
> >>> 
> >>> The (andmap string?) approach implicitly assumes you're giving it a 
> list. But it might be something else instead, so you want this: (and (list? 
> js) (andmap string? js)) 
> >>> 
> >>> On Monday, February 25, 2019 at 3:44:38 PM UTC-8, Brian Craft wrote: 
> >>>> 
> >>>> So, that also gives me a type error: 
> >>>> 
> >>>>  Type Checker: Polymorphic function `andmap' could not be applied to 
> arguments: 
> >>>> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b 
> >>>>  (-> a c : d) (Listof a) 
> >>>> Arguments: (-> Any Boolean : String) (U EOF JSExpr) 
> >>>> 
> >>>>   in: (andmap string? s) 
> >>>> 
> >>>> 
> >>>> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt 
> wrote: 
> >>>>> 
> >>>>> I think (andmap string? ...) is probably the easiest way to check 
> that. 
> >>>>> 
> >>>>> Sam 
> >>>>> 
> >>>>> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  
> wrote: 
> >>>>>> 
> >>>>>> In typed racket, parsing a string list gives me a JSExpr, which is 
> a union. I need to pass it to functions that operate on string lists, but 
> can't figure out how to please the type checker. Maybe with occurrence 
> typing? But I don't know how to assert "this is a list of strings". 
> >>>>>> 
> >>>>>> -- 
> >>>>>> 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...@googlegroups.com. 
> >>>>>> For more options, visit https://groups.google.com/d/optout. 
> >>> 
> >>> -- 
> >>> 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...@googlegroups.com. 
> >>> For more options, visit https://groups.google.com/d/optout. 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] performance, json

2019-02-28 Thread Brian Craft
I added some type annotations & tried it. The result is 16s, substantially 
slower.

Haven't tried tjson, yet. I'm not actually even that interested in json, it 
was just something at-hand to try.

>From this thread, it sounds like there's some knowledge about racket 
performance that isn't yet in the docs. Are there any other resources on 
performance?

On Friday, February 22, 2019 at 10:36:23 AM UTC-8, johnbclements wrote:
>
>
> It would be interesting to see how much faster (if at all) it is to run 
> the TR version of this code. 
>
> John 
>
>
> > On Feb 22, 2019, at 9:47 AM, Brian Craft  > wrote: 
> > 
> > I'm doing a few performance tests, just to get an idea of racket 
> performance. The following result surprised me a bit. Parsing 1M strings 
> from a json array, like 
> > 
> > (define samples (time (read-json (open-input-file "test.json" 
> > 
> > running with 'racket test.rkt' 
> > 
> > Comparing to js, java, and clojure: 
> > 
> > js 0.128s 
> > java 0.130s 
> > clojure 1.3s 
> > racket 10s 
> > 
> > This is pretty slow. Is this typical? Are there other steps I should be 
> taking, for performance? 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-28 Thread Brian Craft
I would think there'd be a large performance issue, as well, due to needing 
an O(N) walk of the data. I'm having type checker issues with (time), so 
haven't tested it, but maybe (cast) will get me past those.

Thanks!

On Monday, February 25, 2019 at 4:26:52 PM UTC-8, Philip McGrath wrote:
>
> An alternative to figuring out how to satisfy the type checker is to use 
> `cast`, e.g.:
> #lang typed/racket
> (require typed/json)
> (string-join
>  (cast
>   (string->jsexpr
>"[\"The\",\"quick\",\"brown\",\"fox\",\"...\"]")
>   (Listof String)))
>
> Obviously this has pros and cons, the main pro being that it runs. The 
> biggest con, in my view, is that you effectively are dropping into untyped 
> world. If you figure out how to satisfy the type checker, you get assurance 
> that your code is well-typed, which is presumably what you want if your 
> using Typed Racket in the first place. Using `cast` means that you are 
> responsible for making sure that expression has the type you say it does, 
> without help from Typed Racket, or you will get a runtime error. For 
> example, I often forget that `read-json` might return `eof` rather than a 
> `JSExpr`. Also, `cast` uses the contract machinery, which can carry 
> performance costs.
>
> But the fact that it runs is not a small benefit, especially if it lets 
> you fill in other parts of your program and come back to remove the `cast` 
> later. It also lets you take advantage of Typed Racket to generate any 
> complicated runtime checks.
>
> -Philip
>
>
> On Mon, Feb 25, 2019 at 6:49 PM > wrote:
>
>> A JSExpr is one of a couple of things:
>>
>> - A list
>> - A hash with symbol keys
>> - A number
>> - A string
>> - A boolean
>> - Null
>>
>> The (andmap string?) approach implicitly assumes you're giving it a list. 
>> But it might be something else instead, so you want this: (and (list? js) 
>> (andmap string? js))
>>
>> On Monday, February 25, 2019 at 3:44:38 PM UTC-8, Brian Craft wrote:
>>>
>>> So, that also gives me a type error:
>>>
>>>  Type Checker: Polymorphic function `andmap' could not be applied to 
>>> arguments:
>>> Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
>>>  (-> a c : d) (Listof a)
>>> Arguments: (-> Any Boolean : String) (U EOF JSExpr)
>>>
>>>   in: (andmap string? s)
>>>
>>>
>>> On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt 
>>> wrote:
>>>>
>>>> I think (andmap string? ...) is probably the easiest way to check that. 
>>>>
>>>> Sam
>>>>
>>>> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  wrote:
>>>>
>>>>> In typed racket, parsing a string list gives me a JSExpr, which is a 
>>>>> union. I need to pass it to functions that operate on string lists, but 
>>>>> can't figure out how to please the type checker. Maybe with occurrence 
>>>>> typing? But I don't know how to assert "this is a list of strings".
>>>>>
>>>>> -- 
>>>>> 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...@googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] type annotation example

2019-02-28 Thread Brian Craft
It was just random. I'd installed it previously & lost track of how long it 
had been.

On Wednesday, February 27, 2019 at 7:44:24 PM UTC-8, Sam Tobin-Hochstadt 
wrote:
>
> Brian, 
> Since this has turned out to be relevant for other reasons, can you 
> say how you ended up using version 6.0? Was it automatically available 
> to you somewhere, or did you install it? 
>
> Sam 
>
> On Mon, Feb 25, 2019 at 1:46 PM Brian Craft  > wrote: 
> > 
> > yeah, maybe version. Has this changed since 6.0? 
> > 
> > On Monday, February 25, 2019 at 10:39:23 AM UTC-8, johnbclements wrote: 
> >> 
> >> When I paste that code into a file called `foo`, it runs fine. 
> Transcript: 
> >> 
> >> hardy:/tmp clements> cat foo 
> >> #lang typed/racket 
> >> (require typed/racket/base) 
> >> 
> >> (: fn (-> String Symbol)) 
> >> (define (fn str) 'foo) 
> >> hardy:/tmp clements> racket foo 
> >> hardy:/tmp clements> 
> >> 
> >> I can’t honestly guess what the problem is. Wrong version of racket? 
> >> 
> >> John 
> >> 
> >> 
> >> > On Feb 25, 2019, at 10:11 AM, Brian Craft  
> wrote: 
> >> > 
> >> > Doing a cut & paste from the typed racket docs, I'm getting a compile 
> error. Input file: 
> >> > 
> >> > #lang typed/racket 
> >> > (require typed/racket/base) 
> >> > 
> >> > (: fn (-> String Symbol)) 
> >> > (define (fn str) 'foo) 
> >> > 
> >> > 
> >> > 'fn' taken from this page: 
> >> > 
> >> > 
> https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29
>  
> >> > 
> >> > 
> >> > Running with 'racket foo', gives me 
> >> > Type Checker: ->: bad syntax 
> >> >   in: (-> String Symbol) 
> >> > 
> >> > 
> >> > What am I doing wrong? 
> >> > 
> >> > 
> >> > -- 
> >> > 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...@googlegroups.com. 
> >> > For more options, visit https://groups.google.com/d/optout. 
> >> 
> >> 
> >> 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] how to use union types

2019-02-25 Thread Brian Craft
So, that also gives me a type error:

 Type Checker: Polymorphic function `andmap' could not be applied to 
arguments:
Domains: (-> a b ... b c) (Listof a) (Listof b) ... b
 (-> a c : d) (Listof a)
Arguments: (-> Any Boolean : String) (U EOF JSExpr)

  in: (andmap string? s)


On Monday, February 25, 2019 at 3:22:12 PM UTC-8, Sam Tobin-Hochstadt wrote:
>
> I think (andmap string? ...) is probably the easiest way to check that. 
>
> Sam
>
> On Mon, Feb 25, 2019, 6:20 PM Brian Craft  > wrote:
>
>> In typed racket, parsing a string list gives me a JSExpr, which is a 
>> union. I need to pass it to functions that operate on string lists, but 
>> can't figure out how to please the type checker. Maybe with occurrence 
>> typing? But I don't know how to assert "this is a list of strings".
>>
>> -- 
>> 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...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] how to use union types

2019-02-25 Thread Brian Craft
In typed racket, parsing a string list gives me a JSExpr, which is a union. 
I need to pass it to functions that operate on string lists, but can't 
figure out how to please the type checker. Maybe with occurrence typing? 
But I don't know how to assert "this is a list of strings".

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] type annotation example

2019-02-25 Thread Brian Craft
yeah, maybe version. Has this changed since 6.0?

On Monday, February 25, 2019 at 10:39:23 AM UTC-8, johnbclements wrote:
>
> When I paste that code into a file called `foo`, it runs fine. Transcript: 
>
> hardy:/tmp clements> cat foo 
> #lang typed/racket 
> (require typed/racket/base) 
>
> (: fn (-> String Symbol)) 
> (define (fn str) 'foo) 
> hardy:/tmp clements> racket foo 
> hardy:/tmp clements> 
>
> I can’t honestly guess what the problem is. Wrong version of racket? 
>
> John 
>
>
> > On Feb 25, 2019, at 10:11 AM, Brian Craft  > wrote: 
> > 
> > Doing a cut & paste from the typed racket docs, I'm getting a compile 
> error. Input file: 
> > 
> > #lang typed/racket 
> > (require typed/racket/base) 
> > 
> > (: fn (-> String Symbol)) 
> > (define (fn str) 'foo) 
> > 
> > 
> > 'fn' taken from this page: 
> > 
> > 
> https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29
>  
> > 
> > 
> > Running with 'racket foo', gives me 
> > Type Checker: ->: bad syntax 
> >   in: (-> String Symbol) 
> > 
> > 
> > What am I doing wrong? 
> > 
> > 
> > -- 
> > 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...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] type annotation example

2019-02-25 Thread Brian Craft
Doing a cut & paste from the typed racket docs, I'm getting a compile 
error. Input file:

#lang typed/racket
(require typed/racket/base)

(: fn (-> String Symbol))
(define (fn str) 'foo)


'fn' taken from this page:

https://docs.racket-lang.org/ts-guide/more.html#%28part._when-annotations~3f%29


Running with 'racket foo', gives me
Type Checker: ->: bad syntax
  in: (-> String Symbol)


What am I doing wrong?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] performance, json

2019-02-22 Thread Brian Craft
I'm doing a few performance tests, just to get an idea of racket 
performance. The following result surprised me a bit. Parsing 1M strings 
from a json array, like

(define samples (time (read-json (open-input-file "test.json"

running with 'racket test.rkt'

Comparing to js, java, and clojure:

js 0.128s
java 0.130s
clojure 1.3s
racket 10s

This is pretty slow. Is this typical? Are there other steps I should be 
taking, for performance?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] carmack s-expression tweet

2015-03-27 Thread Brian Craft
Was this a reference to a particular racket lib? And if so, which one?

https://twitter.com/ID_AA_Carmack/status/577878167542734848

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket] place-image winking effect with low y coord

2014-10-06 Thread Brian Craft
With 'record?' I don't see this in the gif, but do see it on-screen, which
is curious. Maybe a hardware acceleration bug? Also don't see it if I
render the scene in the interactions window. I only see it when running
with big-bang.

If I change the initial state to 100 I don't see this. It only happens on
low y value.

On Mon, Oct 6, 2014 at 8:52 AM, Spencer florence 
wrote:

> huh, I’m unable to reproduce this as well.
>
> Brian, if you use the `record?` clause in big-bang do you see the same
> behavior in the generated gif? [ add (record? "/tmp”) to the big-bang
> expression, similar to what Matthias did in his example ]
>
> Also do you see the same behavior if you change the initial state to be
> 100?
>
> —Spencer
>
>
>
> On Mon, Oct 6, 2014 at 10:05 AM, Brian Craft 
> wrote:
>
>>  If I record to a gif the effect isn't in the gif, though it does happen
>> on-screen while it is recording the gif. Here's a video, using a camera
>> phone. Sorry for the poor quality.
>>
>>
>> https://drive.google.com/file/d/0BxB9fW-JZz-ST3dfeFNxakRhMnRzcGtPQUtuaWJxMVRQTEFz/view
>>
>> Pause it around the 1 sec mark.
>>
>> On Mon, Oct 6, 2014 at 7:10 AM, Matthias Felleisen 
>> wrote:
>>
>>>
>>> Sorry, I don't understand what you mean. I have modified the main
>>> function so that (1) the whole thing is slower and (2) it records the whole
>>> thing as an animated gif:
>>>
>>> (define (main)
>>>   (big-bang 0;; initial state
>>> (record? #t) ;; <---
>>> (on-tick add-3-to-state 1/10);; when the clock
>>> ticks, add ...   <-
>>> (to-draw draw-a-ufo-onto-an-empty-scene) ;; when the state
>>> changes, draw ...
>>>     (stop-when state-is-300)))   ;; when the UFO's y
>>> coordinate is 300, stop.
>>>
>>>
>>>
>>> The animated gif is here:
>>>
>>>  http://www.ccs.neu.edu/home/matthias/Tmp/UFO/i-animated.gif
>>>
>>> -- Matthias
>>>
>>>
>>>
>>> On Oct 5, 2014, at 11:52 PM, Brian Craft 
>>> wrote:
>>>
>>> > The same effect occurs in
>>> racket/share/pkgs/realm/chapter5/ufo-source.rkt.  When the state is
>>> increasing from 0, the image is not moving down the screen. It stays in one
>>> place, but is initially clipped to 0 horizontal lines. Then 1 line, then 2,
>>> and only when the state is 1/2 the image height does it start moving down
>>> the screen.
>>> >
>>> > Also, if I call (draw-a-ufo-onto-an-empty-scene 0) in the interactions
>>> window, I once again get a different result: it renders the lower half of
>>> the image. This is the same behavior I see with my code.
>>> >
>>> > Maybe a platform issue? (version) reports 6.0. I'm running it on
>>> ubuntu.
>>> >
>>> >
>>> >
>>> > On Sun, Oct 5, 2014 at 6:13 PM, Matthias Felleisen <
>>> matth...@ccs.neu.edu> wrote:
>>> >
>>> > Can you send the full program please? Thanks -- Matthias
>>> >
>>> >
>>> >
>>> > On Oct 5, 2014, at 8:52 PM, Brian Craft wrote:
>>> >
>>> > > Hello -- Newbie here. I'm going through "Realm of Racket". I'm
>>> seeing an odd effect when using this to-draw handler in big-bang:
>>> > >
>>> > > (define (draw-a-ufo-onto-an-empty-scene game)
>>> > >   (let ([pos (game-pos game)])
>>> > > (place-image IMAGE-of-UFO (round (vec-x pos)) (round (vec-y pos))
>>> > >  (empty-scene WIDTH HEIGHT
>>> > >
>>> > > vec is (struct vec (x y))
>>> > >
>>> > > As the y coordinate approaches zero, IMAGE-of-UFO gets clipped on
>>> the top and bottom, looking a bit like it's winking out of existence,
>>> rather than sliding off the canvas. This doesn't happen on any other edge.
>>> It's only as y approaches zero. It starts when the edge of the image meets
>>> the edge of the scene. That is, if the image is 20px high, and y starts at
>>> 30, and decreases by 1 on each tick, it will move up the canvas for 30..10,
>>> but from 10 on the image will not change position, but will instead be
>>> clipped on the top & bottom, until it disappears.
>>> > >
>>> > > This does not happen in the interactions window. If I call the above
>>> function in the interactions window, it renders as expected, with the image
>>> moving smoothly off the edge.
>>> > >
>>> > >
>>> > > 
>>> > >  Racket Users list:
>>> > >  http://lists.racket-lang.org/users
>>> >
>>> >
>>>
>>>
>>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] place-image winking effect with low y coord

2014-10-06 Thread Brian Craft
If I record to a gif the effect isn't in the gif, though it does happen
on-screen while it is recording the gif. Here's a video, using a camera
phone. Sorry for the poor quality.

https://drive.google.com/file/d/0BxB9fW-JZz-ST3dfeFNxakRhMnRzcGtPQUtuaWJxMVRQTEFz/view

Pause it around the 1 sec mark.

On Mon, Oct 6, 2014 at 7:10 AM, Matthias Felleisen 
wrote:

>
> Sorry, I don't understand what you mean. I have modified the main function
> so that (1) the whole thing is slower and (2) it records the whole thing as
> an animated gif:
>
> (define (main)
>   (big-bang 0;; initial state
> (record? #t) ;; <---
> (on-tick add-3-to-state 1/10);; when the clock
> ticks, add ...   <-
> (to-draw draw-a-ufo-onto-an-empty-scene) ;; when the state
> changes, draw ...
> (stop-when state-is-300)))   ;; when the UFO's y
> coordinate is 300, stop.
>
>
>
> The animated gif is here:
>
>  http://www.ccs.neu.edu/home/matthias/Tmp/UFO/i-animated.gif
>
> -- Matthias
>
>
>
> On Oct 5, 2014, at 11:52 PM, Brian Craft  wrote:
>
> > The same effect occurs in
> racket/share/pkgs/realm/chapter5/ufo-source.rkt.  When the state is
> increasing from 0, the image is not moving down the screen. It stays in one
> place, but is initially clipped to 0 horizontal lines. Then 1 line, then 2,
> and only when the state is 1/2 the image height does it start moving down
> the screen.
> >
> > Also, if I call (draw-a-ufo-onto-an-empty-scene 0) in the interactions
> window, I once again get a different result: it renders the lower half of
> the image. This is the same behavior I see with my code.
> >
> > Maybe a platform issue? (version) reports 6.0. I'm running it on ubuntu.
> >
> >
> >
> > On Sun, Oct 5, 2014 at 6:13 PM, Matthias Felleisen 
> wrote:
> >
> > Can you send the full program please? Thanks -- Matthias
> >
> >
> >
> > On Oct 5, 2014, at 8:52 PM, Brian Craft wrote:
> >
> > > Hello -- Newbie here. I'm going through "Realm of Racket". I'm seeing
> an odd effect when using this to-draw handler in big-bang:
> > >
> > > (define (draw-a-ufo-onto-an-empty-scene game)
> > >   (let ([pos (game-pos game)])
> > > (place-image IMAGE-of-UFO (round (vec-x pos)) (round (vec-y pos))
> > >  (empty-scene WIDTH HEIGHT
> > >
> > > vec is (struct vec (x y))
> > >
> > > As the y coordinate approaches zero, IMAGE-of-UFO gets clipped on the
> top and bottom, looking a bit like it's winking out of existence, rather
> than sliding off the canvas. This doesn't happen on any other edge. It's
> only as y approaches zero. It starts when the edge of the image meets the
> edge of the scene. That is, if the image is 20px high, and y starts at 30,
> and decreases by 1 on each tick, it will move up the canvas for 30..10, but
> from 10 on the image will not change position, but will instead be clipped
> on the top & bottom, until it disappears.
> > >
> > > This does not happen in the interactions window. If I call the above
> function in the interactions window, it renders as expected, with the image
> moving smoothly off the edge.
> > >
> > >
> > > 
> > >  Racket Users list:
> > >  http://lists.racket-lang.org/users
> >
> >
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] place-image winking effect with low y coord

2014-10-05 Thread Brian Craft
The same effect occurs in racket/share/pkgs/realm/chapter5/ufo-source.rkt.
When the state is increasing from 0, the image is not moving down the
screen. It stays in one place, but is initially clipped to 0 horizontal
lines. Then 1 line, then 2, and only when the state is 1/2 the image height
does it start moving down the screen.

Also, if I call (draw-a-ufo-onto-an-empty-scene 0) in the interactions
window, I once again get a different result: it renders the lower half of
the image. This is the same behavior I see with my code.

Maybe a platform issue? (version) reports 6.0. I'm running it on ubuntu.



On Sun, Oct 5, 2014 at 6:13 PM, Matthias Felleisen 
wrote:

>
> Can you send the full program please? Thanks -- Matthias
>
>
>
> On Oct 5, 2014, at 8:52 PM, Brian Craft wrote:
>
> > Hello -- Newbie here. I'm going through "Realm of Racket". I'm seeing an
> odd effect when using this to-draw handler in big-bang:
> >
> > (define (draw-a-ufo-onto-an-empty-scene game)
> >   (let ([pos (game-pos game)])
> > (place-image IMAGE-of-UFO (round (vec-x pos)) (round (vec-y pos))
> >  (empty-scene WIDTH HEIGHT
> >
> > vec is (struct vec (x y))
> >
> > As the y coordinate approaches zero, IMAGE-of-UFO gets clipped on the
> top and bottom, looking a bit like it's winking out of existence, rather
> than sliding off the canvas. This doesn't happen on any other edge. It's
> only as y approaches zero. It starts when the edge of the image meets the
> edge of the scene. That is, if the image is 20px high, and y starts at 30,
> and decreases by 1 on each tick, it will move up the canvas for 30..10, but
> from 10 on the image will not change position, but will instead be clipped
> on the top & bottom, until it disappears.
> >
> > This does not happen in the interactions window. If I call the above
> function in the interactions window, it renders as expected, with the image
> moving smoothly off the edge.
> >
> >
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] place-image winking effect with low y coord

2014-10-05 Thread Brian Craft
Hello -- Newbie here. I'm going through "Realm of Racket". I'm seeing an
odd effect when using this to-draw handler in big-bang:

(define (draw-a-ufo-onto-an-empty-scene game)
  (let ([pos (game-pos game)])
(place-image IMAGE-of-UFO (round (vec-x pos)) (round (vec-y pos))
 (empty-scene WIDTH HEIGHT

vec is (struct vec (x y))

As the y coordinate approaches zero, IMAGE-of-UFO gets clipped on the top
and bottom, looking a bit like it's winking out of existence, rather than
sliding off the canvas. This doesn't happen on any other edge. It's only as
y approaches zero. It starts when the edge of the image meets the edge of
the scene. That is, if the image is 20px high, and y starts at 30, and
decreases by 1 on each tick, it will move up the canvas for 30..10, but
from 10 on the image will not change position, but will instead be clipped
on the top & bottom, until it disappears.

This does not happen in the interactions window. If I call the above
function in the interactions window, it renders as expected, with the image
moving smoothly off the edge.

  Racket Users list:
  http://lists.racket-lang.org/users