From: Per Bothner <per@bothner.com>
To: kawa@sourceware.org
Subject: Re: Kawa evaluation process
Date: Mon, 27 Jun 2022 22:19:54 -0700 [thread overview]
Message-ID: <cf5a819e-daa6-2b0a-46cf-5126f3061d25@bothner.com> (raw)
In-Reply-To: <CAMFYt2b3kXftsVW2xy6BAJNgm-xEdgOe9o8Kqphzq86LzEschQ@mail.gmail.com>
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/
next prev parent reply other threads:[~2022-06-28 5:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 4:54 Panicz Maciej Godek
2022-06-28 5:19 ` Per Bothner [this message]
2022-06-28 6:17 ` Panicz Maciej Godek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cf5a819e-daa6-2b0a-46cf-5126f3061d25@bothner.com \
--to=per@bothner.com \
--cc=kawa@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).