Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Confused by augment and inner
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Robby Findler  
View profile  
 More options Sep 24 2012, 7:36 am
From: Robby Findler <ro...@eecs.northwestern.edu>
Date: Mon, 24 Sep 2012 06:34:24 -0500
Local: Mon, Sep 24 2012 7:34 am
Subject: Re: [racket] Confused by augment and inner
Your understanding seems correct to me. You had a syntax error.

#lang racket

(define a%
  (class object%
    (super-new)
    (define/pubment (hello)
      (printf "Hello~n")
      (inner 0 hello))))

(define b%
  (class a%
    (super-new)
    (define/augment (hello)
      ;Call super here?
      (printf ", world!~n"))))

(send (new b%) hello)

On Mon, Sep 24, 2012 at 1:31 AM, Gregory Woodhouse <gregwoodho...@me.com> wrote:
> I am trying to understand how augmentable methods (as described in section
> 13.5 of The Guide) work.

> Between the extremes of allowing arbitrary overriding and disallowing
> overriding entirely, the class system also supports Beta-style augmentable
> methods [Goldberg04]. A method declared with pubment is like public, but the
> method cannot be overridden in subclasses; it can be augmented only. A
> pubment method must explicitly invoke an augmentation (if any) using inner;
> a subclass augments the method using augment, instead of override.

> From this I conclude that if, for example, I have a class a% and a subclass
> b% and I want to augment a method of a% in b% I need to call inner in the
> definition of the method in a%, not b%. Something like this

> #lang racket

> (define a%
>   (class object%
>     (super-new)
>     (define/pubment (hello)
>       (printf "Hello~n")
>       (inner 0))))

> (define b%
>   (class a%
>     (super-new)
>     (define/augment (hello)
>       ;Call super here?
>       (printf ", world!~n"))))

> but this gives me an error (not really a surprise). My assumption is that
> super should be used in the subclass when overriding a method, but if a
> method is to be augmented any potential code in an augmenting class should
> be invoked from the superclass and super is not used in the subclass.
> Obviously, I'm missing something.

> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

____________________
  Racket Users list:
  http://lists.racket-lang.org/users

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.