[racket] syntax, differently

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Sun Aug 1 18:42:12 EDT 2010

So when define-struct introduces functional mutators as planned for a while now, and this program looks like this: 

 (cond
   [(mouse-in? 248 x 424 570 y 649) (set-world-background blah)]
... 

Matthew will be happy? 



On Aug 1, 2010, at 6:14 PM, Todd O'Bryan wrote:

> You'd create the new world and set field values using mutators.
> 
> So
> 
> if (x > 248 && x < 424 && y > 570 && y < 649) {
>    SState newState = new SState();
>    newState.setBackground(blah);
>    newState.setButton(blah2);
>    ...
> }
> 
> On Sun, Aug 1, 2010 at 5:22 PM, Richard Cleis <rcleis at mac.com> wrote:
>> [snip]
>> 
>> I was trying to emphasize that it may be harder to students to keep their
>> code neater compared to some other languages which usually have code that
>> rarely exceed 1 line.
>> Example:
>> Racket using the universe teachpack:
>> (define (s-mouse-engine s x y event)
>>   (cond
>>     [(and
>>       (and (> x 248)           (< x 424))
>>       (and (> y 570)           (< y 649)))
>>         (make-S-STATE
>>          (get-s-background s)                ;;I have made methods here to
>> reduce length, but other wise it would be longer.
>>          (make-button
>>           (s-mouse-engine-worker1 event "button-img")
>>           (get-s-button-x s)                   ;;I have made methods here to
>> reduce length, but other wise it would be longer.
>>           (get-s-button-y s)                   ;;I have made methods here to
>> reduce length, but other wise it would be longer.
>>           (s-mouse-engine-worker1 event "button-initiate")))]
>> 
>> How would you write that in another language that rarely exceeds one line?
>> rac
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>> 
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users



Posted on the users mailing list.