[Date Index]
[Thread Index]
[Author Index]
Re: Notebooks, packages, cells, and literate programming
*To*: mathgroup at smc.vnet.net
*Subject*: [mg64254] Re: Notebooks, packages, cells, and literate programming
*From*: "Mark Adler" <madler at alumni.caltech.edu>
*Date*: Wed, 8 Feb 2006 03:53:45 -0500 (EST)
*References*: <ds9mj6$2t$1@smc.vnet.net>
*Sender*: owner-wri-mathgroup at wolfram.com
Ingolf Dahl wrote:
> Point one: One alternative way to enter inline comments, if you anyway want
> that, is to wrap them up in a ordinary Mathematica function in this way:
>
> Comment[" This is my comment. "];
Good idea. At least that would allow me to put in comments, since the
conversion to packages is messed up by (* *) comments. Though it still
takes up too much space per character and does not provide the visually
distinctive commenting of cmd-7 text.
> Point two: It is possible to do almost anything in Mathematica, but
> everything is not sensible. It is possible to embed Input cells inside a
> Text cell. One could also make a button that merges all such embedded Input
> cells from one Text cell and executes the resulting code (ignoring the pure
> text content outside the embedded cells in the Text cell). Mark, would you
> be happy with such construction, if it was available?
I'm not getting a feel for what that would look like. Given the
apparent limitations (i.e. bugs) in the conversion to packages, my
interim solution is to have the code in two places in the notebook. In
the first section the code is broken up into cells, and that part of
the notebook is used for detailed comments, examples, and unit testing.
In the second part, it's all combined into a format suitable for
conversion to a package. You imply that there is a way to grab stuff
from some cells and execute it. Is it possible to grab stuff from a
set of cells (perhaps marked by some string in the preceding text
cell?) and then merge it into a single big cell somewhere else? Or
similarly, to take that stuff and show the differences (a la the Unix
diff -bc command, ignoring white space differences) with that other big
cell somewhere else?
Sseziwa Mukasa wrote:
> By line do you mean a subexpression of a compound expression? If so,
> you could use Begin to start a new context instead of Block.
No, I'm already using Begin (and BeginPackage) as per the conventions
for a package. But Begin does not allow me to break up a single
expression that is being assigned to a name.
I should have pointed out that while in my case I'd like to break up a
Block, the question applies equally well to any expression. That is,
can I somehow break up "f[x_]:=3x^2" into two lines: "f[x_]:=3" and
"x^2". You can with a command-line kernel, by putting a backslash
after the 3, or by doing something like "f[x_]:=(3" followed by "x^2)".
However the notebook front end forces the kernel to complete the
individual expression on a per-cell basis, preventing splitting an
expression across multiple cells. I had hoped that there was a hidden
option or cell format or something that would prevent the kernel from
trying to evaluate each cell as a complete expression, and just be
patient and wait for the next cell. But alas, there does not appear to
be.
mark
Prev by Date:
**Re: Defining a derivative that distributes for a function**
Next by Date:
**Re: Solve problems**
Previous by thread:
** Re: Notebooks, packages, cells, and literate programming**
Next by thread:
**Goedel Numbers**
| |