我刚刚发现了Chapel的配置变量修饰符,它对命令行操作非常有用。有没有其他语言或框架可以模仿这个特性,这样我就不必每次都编写过滤器了?
发布于 2017-07-28 00:53:06
所有不同的chapel config-s的宽度确实是无与伦比的:
config var VAR = 1; // --VAR=10 sets other value from cmdline
// --VAR 20 sets other value too
config const RHO = 1.23456; // --RHO=0.123456 sets other value from cmdline
// --RHO 0.2468 sets other value too
// --RHO=0.39*VAR sets other value for COMPILER
// based on VAR
config param DBG = false; // -s DBG=true sets other value from cmdline
config type B = uint(8); // -sB='uint(16)' sets other value from cmdline
// -sB='if DBG then uint(32) else uint(16)'
// sets other value for COMPILER
// based on DBG虽然还必须有一个编译时已知的类型,这是一个特定的限制(对于强类型的编译语言,既明显又自然),但是使用这些构造的灵活性来设置自适应的运行时可配置行为是很棒的,并且很难在其他语言/编译器环境中并行。
https://stackoverflow.com/questions/45355481
复制相似问题