简体   繁体   中英

Chunk arguments for noweb

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?

为了避免这种奇怪的神秘语法,请尝试使用NanoLP进行Literate编程(它支持命名参数,变量字典等)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM