<p>The fundamental problem is the syntax of identifiers. The rest is details.</p>
<p>On Aug 18, 2010 11:25 AM, "Ray Racine" <<a href="mailto:ray.racine@gmail.com">ray.racine@gmail.com</a>> wrote:<br type="attribution">> This topic comes up so frequently (schemes structure accessors/mutators) ,<br>
> and has been independently solved in and around the same conceptual solution<br>> (a chaining dot syntax) that I've often wondered why Racket would not make<br>> such a capability "core" to the language. It seems such an obvious<br>
> absolutely should (to some) that I'm interested in hearing the counter<br>> position of why it should not.<br>> <br>> Thanks,<br>> <br>> Ray<br>> <br>> On Wed, Aug 18, 2010 at 10:52 AM, Matthias Felleisen<br>
> <<a href="mailto:matthias@ccs.neu.edu">matthias@ccs.neu.edu</a>>wrote:<br>> <br>>><br>>> Eduardo is providing a macro that helps you abbreviate complex<br>>> selector and mutator chains. The BENFIT you get is that instead<br>
>> of writing<br>>><br>>> (posn-x (bird-posn (sky-bird (world-sky some-world))))<br>>><br>>> you can write -- in Racket --<br>>><br>>> some-world.sky.bird.posn.x<br>>><br>
>> and make Racket programs look as short as C program selectors<br>>> or Java dots or Javascript dots etc.<br>>><br>>> The PRICE you pay is that you annotate variables and fields<br>>> with struct information. That is, you have to say somewhere that<br>
>> some-world is a variable that always stands for a world struct.<br>>> And the sky field in world has to come with information that it<br>>> always is a sky-struct. And so on.<br>>><br>>> ;; ---<br>
>><br>>> To make this available in Racket, you'd have to port his macros<br>>> from R6RS Scheme to Racket. I suspect that this would be a minor<br>>> task.<br>>><br>>> ;; ---<br>>><br>
>> To make this available in the teaching languages, you'd have to<br>>> export these macros in a way that makes sense for students. Or<br>>> you keep it all private to yourself.<br>>><br>>> ;; ---<br>
>><br>>> I assume that you understand the differences between the various<br>>> operations. In Java,<br>>><br>>> pos.draw<br>>><br>>> comes with static knowledge about pos (an object of a certain type)<br>
>> and draw (a field of a certain type) that is exploited to make the<br>>> notation short and safe. It isn't complete safe because of NULL,<br>>> which doesn't exist in Racket or the teaching languages, but let's<br>
>> ignore that.<br>>><br>>> In a language like Ruby,<br>>><br>>> pos.draw<br>>><br>>> just doesn't care, If pos has an draw field at run-time, good enough.<br>>> Even if pos isn't a position but happens to have a draw field, just<br>
>> keep on computing.<br>>><br>>> In Racket and the teaching languages, you are *forced* to write<br>>> down what kind of struct you expect and what field you want:<br>>><br>>> pos.check-it-is-a-posn-and-select-x-then<br>
>><br>>> This gives you safety a la Java (at run-time) and tells the reader<br>>> at each site where you write down a selector expression what you<br>>> expect. It's verbose but readable.<br>>><br>
>><br>>><br>>><br>>> On Aug 18, 2010, at 10:34 AM, Mathew Kurian wrote:<br>>><br>>> ><br>>> ><br>>> > On Wed, Aug 18, 2010 at 2:41 AM, Eduardo Cavazos <<a href="mailto:wayo.cavazos@gmail.com">wayo.cavazos@gmail.com</a>><br>
>> wrote:<br>>> ><br>>> > Mathew Kurian:<br>>> ><br>>> > However, in the case of universe/world teachpacks, where the use of<br>>> > states is a vital component, a set of code can get very long,<br>
>> > especially if the program is very complex and contains multiple<br>>> > structures (in some cases structures inside structures inside<br>>> > structures) within the states.<br>>> ><br>
>> > I agree with the critique of lengthy expressions involving nested records<br>>> (structs).<br>>> ><br>>> > Here's how I deal with it:<br>>> ><br>>> > <a href="http://gist.github.com/364754">http://gist.github.com/364754</a><br>
>> ><br>>> > The particular solution is for R6RS but PLT has the necessary mechanisms<br>>> for it.<br>>> ><br>>> > Ed<br>>> ><br>>> > Hey Ed,<br>>> ><br>
>> > If you have spare time, can you please explain by what you meant in that<br>>> github website. All I saw was a comparison between C and Scheme.<br>>> ><br>>> > Thank you<br>>> ><br>
>> > Mathew K.<br>>> ><br>>> ><br>>> > _________________________________________________<br>>> > For list-related administrative tasks:<br>>> > <a href="http://lists.racket-lang.org/listinfo/users">http://lists.racket-lang.org/listinfo/users</a><br>
>><br>>> _________________________________________________<br>>> For list-related administrative tasks:<br>>> <a href="http://lists.racket-lang.org/listinfo/users">http://lists.racket-lang.org/listinfo/users</a><br>
>><br>> <br>> <br>> <br>> -- <br>> The object of life is not to be on the side of the majority, but to escape<br>> finding oneself in the ranks of the insane. - Marcus Aurelius<br></p>