From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14739 invoked by alias); 2 Apr 2019 13:47:49 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 14731 invoked by uid 89); 2 Apr 2019 13:47:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-15.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=kawa, Syntax, HTo:U*kawa, super X-HELO: aibo.runbox.com Received: from aibo.runbox.com (HELO aibo.runbox.com) (91.220.196.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 02 Apr 2019 13:47:46 +0000 Received: from [10.9.9.212] (helo=mailfront12.runbox.com) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1hBJlM-0000p4-IC; Tue, 02 Apr 2019 15:47:42 +0200 Received: by mailfront12.runbox.com with esmtpsa (uid:757155 ) (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) id 1hBJl0-00029p-Un; Tue, 02 Apr 2019 15:47:19 +0200 Subject: Re: Syntax for calling super implementation when overriding a method To: Duncan Mak , kawa mailing list References: From: Per Bothner Message-ID: Date: Tue, 02 Apr 2019 13:47:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2019-q2/txt/msg00001.txt.bz2 On 4/1/19 11:58 AM, Duncan Mak wrote: > Hello Per, > > I see that there's syntax (this) for referring to the current instance. > > When I'm defining a class hierarchy, and I'd like to override a method in a > subclass, is there a similar syntax, i.e. (super)? > > For now, I'm doing this (superclass:method instance ...), but it'd be nice > not having to explicitly name the superclass. The Kawa manual suggests using invoke-special, and has a few examples: (invoke-special supersuper (this) 'methodname arg ...) where 'methodname is '*init* in the case of a constructor. However (as you and the manual also notes), this is annoyingly verbose. One approach is as you suggest: ((super):methodname arg ...) This would start by having (super) expand to a distinct variant of ThisExpr, but changing the code-generation to call invokespecial. An alternative (possibly easier to implement) might be (invoke-super 'methodname arg ...) Either of these would be a good project in terms of learning more about how Kawa works. -- --Per Bothner per@bothner.com http://per.bothner.com/