[racket] Functional struct update with subtypes

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed May 11 22:23:13 EDT 2011

It is a different way of thinking about protection, one that is more
in line with the way such protections usually happen in Racket.

In a language like Java, the class and the package a class is in both
play a role in determining who has access to what, which is why things
like 'protected' make sense there.

In Racket, we already have the do-it-all notion of protection, namely
lexical scope. So define-local-member-name hooks into that protection
mechanism to let you do things like what protected achieves, but in a
way that matches Racket better.

Or, as Matthias puts it: use modules. :)


On Wed, May 11, 2011 at 8:35 PM, Mark Engelberg
<mark.engelberg at gmail.com> wrote:
> I played around briefly with define-local-member-name but it seemed
> like a rather awkward way to achieve "protected"-ness.  From the
> example in the help desk, it seems like the classes need to have some
> sort of let wrapped around them to share a non-public method between
> them.  It seems like to set things up so that each class shares fields
> and methods with subclasses but no outsiders would be quite unwieldy
> with many levels of wrapping and scopes that match the inheritance
> hierarchy, which would be hard to read and hard to keep track of.  Is
> it cleaner than I realize to achieve this?

Posted on the users mailing list.