We already have some verboten column names (.SD springs to mind); why not make these symbols verboten as well? Could be something that only triggers when on is used, so that people don't get annoying errors from fread for example (I have in mind spending 3 minutes freading a huge file only to have it crash at the end when lo and behold the file has dirty column names)...
I also think the no-whitespace thing is okay but maybe could be clearer.
@MichaelChirico Re verboten or late-verboten patterns (that the user only notices when joining), it seems more natural to me to allow most names (except .SD and whatever else is already blocked), but just support backticks, like in Markus' original attempt. That's where the syntax for by= ended up anyways:
DT = data.table(x = 1, "y,z" = 2)
DT[, .N, by=.(x, `y,z`)] # works
DT[, .N, by="x,`y,z`"] # works
Backticks don't work in the string or .(...) forms of on= yet, so maybe just convert this issue into a FR to add it?
Misc comments: Without support for backticks, as far as I know, there's no way to handle Hugh's examples. Lack of support for backticks also forces use of the string form, but that's not a big deal. Maybe related: #1639
@MichaelChirico I think it's only forbidden if you go through the front entrance:
> data.table(`.SD` = 1:3)
Error in name_dots(...) :
A column may not be called .SD. That has special meaning.
> DT = fread(".SD,A\n1,2"); DT
1: 1 2
> setnames(DT, c("Z", ".SD")); DT
1: 1 2