public inbox for
 help / color / mirror / Atom feed
From: Per Bothner <>
Subject: Re: Kawa evaluation process
Date: Mon, 27 Jun 2022 22:19:54 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

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/ line 503.
	--Per Bothner

  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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* 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).