factored out is_scalar in expression class