texmacs-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Texmacs-dev] Literate Programming in TeXmacs?


From: Ralf Hemmecke
Subject: Re: [Texmacs-dev] Literate Programming in TeXmacs?
Date: Tue, 22 May 2007 01:37:35 +0200
User-agent: Thunderbird 2.0.0.0 (X11/20070326)

On 05/21/2007 10:03 PM, Felix Breuer wrote:
One of the unique features of TeXmacs are its session plugins. I have
frequently have found myself wanting to "rerun" a sequence of
computations in a session with some slight modifications. In this
fashion an interactive session can even turn step by step into a
program. Thus, it is a natural idea to integrate a potential LP feature
of TeXmacs with its session features.

You know texmacs better, I am still learning, i.e. I could not understand what you wanted to say.

A simple implementation that serves both purposes might look as
follows. Suppose snippets of code in the document are wrapped in an
environment like

  <lp-code|label|body>

where label is an arbitrary string that marks which snippets belong
together and body is an arbitrary TeXmacs tree that is "the code".

Hm, for "label" I don't want just any string but finally any text, i.e.
an expression like
   $\sqrt[3]{a+5}$

(sorry, I currently speak TeX better) should be allowed as "label" and also show nicely inside TeXmacs. But I guess that taking the corresponding texmacs encoding of this root expression as label should be OK.

> Now
the LP implementation might have a function

   (label-to-code label filter)

at its core that does:

  * collect all nodes in the document that are of type "lp-code" and
    have label _label_ as their first argument
  * apply the export filter _filter_ to the second arguments of each of
    the nodes in turn
  * concatenate the resulting list of strings and return it.

The resulting string could then either be written to a file or fed to a
session line by line.


Some comments:

* This bare-bones solution should be really simple to implement.

Good. Why has nobody done it?

* One can add custom source code formatting and generation methods
  simply by writing a style file and accompanying export filter. This
  would
  - make use of standard TeXmacs mechanisms
  - tie in with the use of filters to store entire TeXmacs documents as
    ASCII source code files as David and I had envisioned
  - allow one to copy-and-paste fancy formatted code from TeXmacs into
    a text editor.

Completely uninteresting for me at the moment. Formatting is something that comes last. I want a button that starts code extraction, that's all.

* Instead of using a fixed environment name like "lp-code" and
  plain-text labels, one should probably use DRD properties and loci (I
  just have no idea how these work).

DRD? loci?

* One could add facilities to reorder code chunks during code
  generation later on.

I wonder if you know about noweb. The routine you have described above just means that you have only <<*>> chunks in your literate program. That is essentially the same as Mathematica's notebook style or Maple's worksheet format.

The point is that there are definitions of chunks like the one you describe above

<defcodechunk|label|body>

and then there should also be something like

<defcodechunk|label|
  <usecodechunk|label1>
  <usecodechund|label2>
>

where even the spacing in front of "<usecodechunk...>" matters if the code corresponding to label1 expands over several lines.

Ralf




reply via email to

[Prev in Thread] Current Thread [Next in Thread]