[plt-scheme] Overriding private methods with class.ss?

From: Henk Boom (lunarc.lists at gmail.com)
Date: Sat Aug 18 20:31:24 EDT 2007

On 18/08/07, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> At Sat, 18 Aug 2007 15:31:00 -0400, "Henk Boom" wrote:
> > Hi, I was reading the class.ss documentation in the help desk, and as
> > far as I can tell there is no way to have private overridable methods:
>
> It's not obvious (and I haven't yet gotten to the `class' part in the
> new guide), but `define-local-member-name' is what you're looking for.
>
>
> The `define-local-member-name' form binds an identifier to a fresh
> representation of an external name. In the scope of the binding, uses
> of the identifier as a method name refer to a method that is not
> accessible outside the scope of the binding.
>

This seems to be dividing the scope at the wrong place for this purpose.

> Here's an example (based on your problem):
>
<snip>
>
>  ;; But you can't see `handle-key' out here:
>  (send (new c%) handle-key 'key) ; => no such method for `send'
>  (class c%
>    (define/override (handle-key x) #f)
>    (super-new))                  ; => no such method to override

I can see this feature being useful, but not in this context =(. In
this case I would want the last example above to work, as subclasses
in other modules might want to override this method as well, while at
the same time having it be hidden in the rest of those same modules.
What I would really want is for it to function as any other method
_except_ for it to be impossible to use with (send ..).

    Henk Boom


Posted on the users mailing list.