[racket] syntax, differently

From: Todd O'Bryan (toddobryan at gmail.com)
Date: Sun Aug 1 19:55:44 EDT 2010

Ah, *functional* mutators. I've been reading the words for the past
several months, but I just now finally got the message. :-)

On Sun, Aug 1, 2010 at 6:42 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
> 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.