I thought that << expr
was just a shorthand form of Get[expr]
. I have now found that it clearly isn't. Namely it holds expr
and converts it to a string. Thus << fileName[file]
, will not work if fileName[file]
is some function that has been Set (delayed or not) to the file location. Get[fileName[file]] will work.
The documentation is not that clear on this difference. My confusion has mostly been cleared up, but I thought I should still post since there does not seem to be any post on this and others might have the same confusion. Also evaluate does not seem to help things. I had hoped it would force an evaluation before expr
is converted to a string, but alas, it just gets held and converted to a string too. So should I just be using the full form Get in these situations or am I still missing something about the usage of <<
.
Or instead I can use the shorthand like this
ReleaseHold@Map[ToExpression, Hold[<< expr], {2}]
but then it is not exactly shorter anymore.