This the second question of (152743), the preamble of which is reproduced here:
Those who don't have/prefer the front end of Mathematica will either use a plain ASCII editor to write a script in an
.m
file or just use Mathematica directly from a command-line terminal. In either case, everything must be supplied inInputForm
.When working with a Mathematica package, commonly used symbols/functions might be excessively verbose in
InputForm
, and certain shortcuts/aliases would be greatly desired. Examples of built-inInputForm
shortcuts are the infix operators+
(Plus
),-
(Minus
), ... and.
(Dot
).
Two questions that arise as a package developer:
Is there something analogous to
#define
of C and C++ that can be placed at the top of an.m
file that instructs the kernel to make replacements of literal occurrences before the lines are read? (this issue may be easily bypassed if question 1 is answered.)
Answer
No. In fact, even $PreRead
is ignored when reading .m files.
What you can do is define a myGet as
myGet[file_] := Module[{str},
str = Import[file,"Text"];
str = myTextReplacemeansts[str];
ToExpression[str];
]
to make your own substitutions.
Comments
Post a Comment