From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 96304385841A for ; Tue, 30 Aug 2022 18:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96304385841A Received: by mail-ot1-x329.google.com with SMTP id h9-20020a9d5549000000b0063727299bb4so8662432oti.9 for ; Tue, 30 Aug 2022 11:24:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=thajeIqa1zRR+ZNJflP/p/k3xAq2moDdNK07igYpt7g=; b=NHjLb3pkbLzzdfjaE7iq7wc9uP4n3sOStbHFpLq+bgkHKLAmKqen4hRPoopupiFuGu BO1A2G1j1SSuchnVNE/i8DjdywWozqmuWfGS+e/TNgfglwC6drX4khm1ioUMMUVLbFjl k29M9Rmxpdy/kHysTL7/o8Za0tYxJqAwg4Wnq6q82g0v7e3wb5R6UsWejv4DsXzJ3Vnw RfPCkKwb/KFaUgFPbJycBfRyxLM8Eq04gIvJB+LYymzBly2Njjkoet6foAztzj9RhL5Y 5bjrk5EL7ci08wJLaraBTUPBL0UTS6cgSZUjWsyrRLBwhlC2v7nsnSzvUgDEdoZ5kaWx nx/Q== X-Gm-Message-State: ACgBeo16oNR7OWpauE2TNIorOvTkLY6OjW0NQ0+DpSTFaLMQicFQU7IN xeew/CeGeziRSYwpOz8MLT9Xwxb4ZLPK3WJrTaWDFKmX2E8= X-Google-Smtp-Source: AA6agR7RKQkTPzBznmMTPNPfJBtiBTTHtNbNnbdaMharhiHCBnJwuLEwNOpsM0znYICg3L+INtItcahLy0e4SDGY0Dg= X-Received: by 2002:a9d:2c9:0:b0:639:2c93:7d5c with SMTP id 67-20020a9d02c9000000b006392c937d5cmr8663625otl.377.1661883892628; Tue, 30 Aug 2022 11:24:52 -0700 (PDT) MIME-Version: 1.0 References: <51486d80-0d3f-aa47-caca-9b23b2618174@bothner.com> In-Reply-To: <51486d80-0d3f-aa47-caca-9b23b2618174@bothner.com> From: daniel szmulewicz Date: Tue, 30 Aug 2022 21:24:41 +0300 Message-ID: Subject: Re: The Expression problem To: kawa@sourceware.org X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URI_DOTEDU autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: kawa@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Kawa mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2022 18:24:55 -0000 Thank you for the prompt response. This reference indeed tells me how to create new classes or extend existing classes. However, I was interested in a way to add functionality without touching existing code. For example, make all instances on the java.lang.String class respond to `foo`, as in (foo "a string") -> "bar". To quote from a paper , "the expression problem (aka the extensibility problem) refers to a fundamental dilemma of programming: to which degree can your application be structured in such a way that both the data model and the set of virtual operations over it can be extended without the need to modify existing code, without the need for code repetition and without runtime type errors." Not all languages have viable solutions to the Expression problem. Clojure and ABCL haved designs that address it, and I was wondering where Kawa is positioned. Kind regards, Daniel On Tue, Aug 30, 2022 at 1:12 AM Per Bothner wrote: > On 8/29/22 14:35, daniel szmulewicz via Kawa wrote: > > > I was wondering what was Kawa's stance regarding the Expression problem, > > ie. extending existing Java classes. > > ABCL provides a mechanism to specialize on Java classes as documented in > > section 4.5.2 of the user manual. Clojure provides defprotocol and > defmulti > > to extend existing types. I skimmed through the Kawa manual and am still > > unsure. I am very curious to hear more from the experts. > > You can definitely extend existing Java classes and inetrfaces. See: > > https://www.gnu.org/software/kawa/Defining-new-classes.html > > True multiple inheritance is supported. > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [IPv6:2607:f8b0:4864:20::329]) by sourceware.org (Postfix) with ESMTPS id 96304385841A for ; Tue, 30 Aug 2022 18:24:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 96304385841A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-x329.google.com with SMTP id h9-20020a9d5549000000b0063727299bb4so8662432oti.9 for ; Tue, 30 Aug 2022 11:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc; bh=thajeIqa1zRR+ZNJflP/p/k3xAq2moDdNK07igYpt7g=; b=j7R0vrxnNDSsibevQgPOVhEqw9XqDUjyPed9wXi9RzCO61BL1ThDN1OFInEGk3ftgN RNSfjkK5NLSvMKWywlPztMQ5On7D57Am9ii8mOha0QuMdQdP8LkbAtVGy5YaPg/ngX0w DUjicK7AbQCQ2Xm2u7TB25FykqPL7ded9K768U6LdCVGF8TtbS/nwEDgxVAOkjkd2DNd 11/8JwuVpGsfHieCnWiXyha77jpFNEzTLVF5UteY4svMeJWwtmOqo0fhcq58hWOEoZfM B0y8FIVkcqUv8ho6STe3Q5QQReSo2LSNSfYt6un/zeeKReyW0TwjL5FGTKr7rn93Hz4u If5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc; bh=thajeIqa1zRR+ZNJflP/p/k3xAq2moDdNK07igYpt7g=; b=NHjLb3pkbLzzdfjaE7iq7wc9uP4n3sOStbHFpLq+bgkHKLAmKqen4hRPoopupiFuGu BO1A2G1j1SSuchnVNE/i8DjdywWozqmuWfGS+e/TNgfglwC6drX4khm1ioUMMUVLbFjl k29M9Rmxpdy/kHysTL7/o8Za0tYxJqAwg4Wnq6q82g0v7e3wb5R6UsWejv4DsXzJ3Vnw RfPCkKwb/KFaUgFPbJycBfRyxLM8Eq04gIvJB+LYymzBly2Njjkoet6foAztzj9RhL5Y 5bjrk5EL7ci08wJLaraBTUPBL0UTS6cgSZUjWsyrRLBwhlC2v7nsnSzvUgDEdoZ5kaWx nx/Q== X-Gm-Message-State: ACgBeo16oNR7OWpauE2TNIorOvTkLY6OjW0NQ0+DpSTFaLMQicFQU7IN xeew/CeGeziRSYwpOz8MLT9Xwxb4ZLPK3WJrTaWDFKmX2E8= X-Google-Smtp-Source: AA6agR7RKQkTPzBznmMTPNPfJBtiBTTHtNbNnbdaMharhiHCBnJwuLEwNOpsM0znYICg3L+INtItcahLy0e4SDGY0Dg= X-Received: by 2002:a9d:2c9:0:b0:639:2c93:7d5c with SMTP id 67-20020a9d02c9000000b006392c937d5cmr8663625otl.377.1661883892628; Tue, 30 Aug 2022 11:24:52 -0700 (PDT) MIME-Version: 1.0 References: <51486d80-0d3f-aa47-caca-9b23b2618174@bothner.com> In-Reply-To: <51486d80-0d3f-aa47-caca-9b23b2618174@bothner.com> From: daniel szmulewicz Date: Tue, 30 Aug 2022 21:24:41 +0300 Message-ID: Subject: Re: The Expression problem To: kawa@sourceware.org Content-Type: multipart/alternative; boundary="00000000000014034105e7797fd8" X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,URI_DOTEDU autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20220830182441.D6ITOOhvS4fPehd-TgEWIB70yua5KW-824jh4TzKaA4@z> --00000000000014034105e7797fd8 Content-Type: text/plain; charset="UTF-8" Thank you for the prompt response. This reference indeed tells me how to create new classes or extend existing classes. However, I was interested in a way to add functionality without touching existing code. For example, make all instances on the java.lang.String class respond to `foo`, as in (foo "a string") -> "bar". To quote from a paper , "the expression problem (aka the extensibility problem) refers to a fundamental dilemma of programming: to which degree can your application be structured in such a way that both the data model and the set of virtual operations over it can be extended without the need to modify existing code, without the need for code repetition and without runtime type errors." Not all languages have viable solutions to the Expression problem. Clojure and ABCL haved designs that address it, and I was wondering where Kawa is positioned. Kind regards, Daniel On Tue, Aug 30, 2022 at 1:12 AM Per Bothner wrote: > On 8/29/22 14:35, daniel szmulewicz via Kawa wrote: > > > I was wondering what was Kawa's stance regarding the Expression problem, > > ie. extending existing Java classes. > > ABCL provides a mechanism to specialize on Java classes as documented in > > section 4.5.2 of the user manual. Clojure provides defprotocol and > defmulti > > to extend existing types. I skimmed through the Kawa manual and am still > > unsure. I am very curious to hear more from the experts. > > You can definitely extend existing Java classes and inetrfaces. See: > > https://www.gnu.org/software/kawa/Defining-new-classes.html > > True multiple inheritance is supported. > -- > --Per Bothner > per@bothner.com http://per.bothner.com/ > --00000000000014034105e7797fd8--