0

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.

Kvothe
  • 4,419
  • 9
  • 28
  • It seems to address all your doubts but let me know if you disagree with closing. – Kuba Apr 13 '18 at 13:54
  • 1
    @Kuba, it does. Thanks! (I should have thought of searching for issues with similar functions (>>, >>>). Well next person with this problem should have an easier job finding that question now that it's also linked from the Get perspective.) – Kvothe Apr 13 '18 at 14:10

0 Answers0