Computing probability distributions on a grid

Kevin Wright writes,

On page 284 of Bayesian Data Analysis, there is a short discussion of calculating a posterior on a (evenly-spaced) grid of points. After this grid is calculated, instructions are given on how to do a random draw from this distribution.

My question is, for a univariate posterior that has finite support, is it necessary to do the sampling? After calculating the target density on a grid of points, why not just use all the grid points to calculate moments/quantiles of the distribution? Are there cases where sampling is preferable?

In my specific example, the prior is a either a Beta distribution (or a discrete distribution on [0,1]) and I find that R can quickly calculate distribution statistics on a grid of a million equally-spaced points.

My response:

It is helpful to have random draws since these can be used to compute anything you want. Using all the grid points (and then weighting by the probabilities) is ok but can be more work because then you have to deal with the weights in all your computations.

And in more than 1 or 2 or 3 dimensions, using the entire grid is almost never practical, so sampling works as a more general strategy.