From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [IPv6:2a0c:5a00:149::25]) by sourceware.org (Postfix) with ESMTPS id F177F3857340 for ; Tue, 28 Jun 2022 05:20:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F177F3857340 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=bothner.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=bothner.com Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1o63du-00FVSK-QZ for kawa@sourceware.org; Tue, 28 Jun 2022 07:20:06 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=bothner.com ; s=selector2; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:To:Subject:MIME-Version:Date:Message-ID; bh=LRGc5d6XM70xQwnxHAOHdkixDZaloFMZloHl1A/LbBo=; b=lb87+I47nG8OJ0ycyHzxpSLKjE 4IrvK1ZlXs7ViOmIXOOSFmcNYBCO/lLXGp1oWkIFJ21G52SENXrXL/bt1qXnsZc6E7of9B4iU8MlY UO+e6OwrwukUjEhvom5Gwdqt+YbT5IcdQZ62ZwUnHXVnzcHQR4FOX2rIrkECbVQxgkd5Hm4OXIXmk zEpL3WHpc7UiAAu+m7ixvqQ5M2W8CMPMo6aKSmg6my2xFfiM7xb3H2aDwWdDZ2yarMuVD7S3+uCIV LrkAyhRSYhO+JJNkVlgv/LsKlMzVqcaB78pJsve1nRZb7B3t7KrBSu5h02aY4QVhmEo5Q/2rcvFoo nqJ3wElw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1o63du-0003yC-B6 for kawa@sourceware.org; Tue, 28 Jun 2022 07:20:06 +0200 Received: by submission03.runbox with esmtpsa [Authenticated ID (524175)] (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) id 1o63dn-0003ni-3Y for kawa@sourceware.org; Tue, 28 Jun 2022 07:19:59 +0200 Message-ID: Date: Mon, 27 Jun 2022 22:19:54 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: Kawa evaluation process Content-Language: en-US To: kawa@sourceware.org References: From: Per Bothner In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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, 28 Jun 2022 05:20:10 -0000 On 6/27/22 21:54, Panicz Maciej Godek via Kawa wrote: > So I've been wondering if there's an option to create a "box" that would be > transparent to the process of evaluation (possibly with some tweaks to > Kawa): that I would have an object that holds a string and a value, and > when the evaluator asks it for the value, it would provide whatever value > would result from parsing the string? Wel, we mostly have that. Every atom (almost - see below) appears as the car of a cons cell in a list. So we can associate extra information with the Pair. Since Pair is a class you can inherit from, you can create subclass of Pair with extra information. This is how line number information is handled in Kawa - see the PairWithPosition class. Note a PairWithPosition can specify a range in a sourcefile, which gives you the actual source string for the atom. The comments in the file hint at generalizing the filename/position pair to use a general gnu.text.SourceMapper. Or you can you can create new subclasses of PairWithPosition. There are some limitations to the atom/car-of-Pair identity. One is in the case of an impure list (dotted pair) - which isn't valid in source code anyway except inside quotes. Another limitation is for atoms that are top-level forms. Kawa handles that by wrapping such an atom in a fake begin list - see gnu/kawa/lispexpr/LispReader.java line 503. -- --Per Bothner per@bothner.com http://per.bothner.com/