Chunk arguments for noweb

264 views Asked by At

In nuweb, I can do something like this

@d Define the chunk with argument
echo "Hello, @1";

Then I can use it in other chunks by passing arguments:

@d Second chunk
@<Define the chunk with argument@(John@)@>

It will generate the following line:

echo "Hello, John";

I know, that in this particular case I can use in chunks another means (a variable), but such passing of arguments to the chunks is very useful for various code declarations, then you need to use bits of code that are almost the same, but not completely (for example, calling functions with various names). This is a useful feature. It works in nuweb fine.

Right now I switched to noweb, but I don't see any way to pass an argument to chunk. Is there any way to do this in noweb like in nuweb?

1

There are 1 answers

0
RandomB On

To avoid such weird cryptic syntax, try NanoLP for Literate Programming (it supports named arguments, variables dictionaries and many other)