[racket] Redefining selectors - another newbie question

From: David Van Horn (dvanhorn at ccs.neu.edu)
Date: Thu Jul 1 18:10:21 EDT 2010

On 7/1/10 4:14 PM, Matthias Felleisen wrote:
>
> It's not about verbosity alone.
>
> (define-struct posn (x y z))
>
> (define s (struct 1 2 3))
>
> (posn-z s) performs two different tasks
>   -- checks that s is an instance of posn
>   -- then retrieves 3 from the structure
>
> s.z in C or C++ does only the second.
> s.z in Java is statically assigned a type.

If it weren't clear already, I think Matthias meant to write

    (define s (posn 1 2 3))

David


Posted on the users mailing list.