From b11bb0d1e78d36200f768a8fa2ebeb25a9a111b5 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Fri, 7 Jul 2017 06:18:44 -0700 Subject: doc: fix call-super-fun error and add example. * txr.1: call-super-fun method intro paragraph wrongly refers to call-super-method. Adding example about how to call a base class method. --- txr.1 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/txr.1 b/txr.1 index c49180bb..4c0abd76 100644 --- a/txr.1 +++ b/txr.1 @@ -24375,7 +24375,7 @@ not to the type against which the calling method is defined. .syne .desc The -.code call-super-method +.code call-super-fun retrieves the function stored in the slot .meta name of the supertype of @@ -24395,6 +24395,28 @@ must name a static slot of that structure type. The object retrieved from that static slot must be callable as a function, and accept the arguments. +.TP* Example: + +Print a message and call supertype method: + +.cblk + (defstruct base nil) + + (defstruct derived base) + + (defmeth base fun (obj arg) + (format t "base fun method called with arg ~s\en" arg)) + + (defmeth derived fun (obj arg) + (format t "derived fun method called with arg ~s\en" arg) + (call-super-fun 'derived 'fun obj arg)) + + ;; Interactive Listener: + 1> (new derived).(fun 42) + derived fun method called with arg 42 + base fun method called with arg 42 +.cble + .coNP Macro @ with-objects .synb .mets (with-objects >> ({( sym << init-form )}*) << body-form *) -- cgit v1.2.3