A couple of stylistic questions that I just have to get off my chest: 1. Is there a reason that mutators don't start with the struct name like all the other functions introduced by "define-struct"? Especially now that "make-struct" defaults to just "struct" in #lang racket, would it make sense to have "struct-set-field" and "struct-set-field!" instead of "set-struct-field" and "set-struct-field!" so that all the functions introduced by struct and define-struct would appear together in an alphabetical list?
2. Just as a personal peeve, I find it confusing that we use dash to separate words in identifier names *and* to separate names of structs and fields in selectors. I've started using a dot to separate the type of structure from the function name to avoid ambiguity. For example, suppose I'm implementing the (very fun) card game "Set." I might have a set-world struct that I've defined. So then I get "set-world-cards". You see the problem. If instead I were to write "set-world.cards", it's pretty clear that I'm calling the selector for the "cards" field on the structure "set-world". The separator character clearly doesn't need to be a dot--underscore is another possibility--and I'm sure that changing the convention would be a nightmare throughout the code, but is it worth considering such a change for HtDP/2e? Todd On Sun, Aug 1, 2010 at 6:42 PM, Matthias Felleisen <[email protected]> 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 <[email protected]> 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 > > _________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users

