Put the clams into a colander and shake them about very vigorously under fast-running cold water, as this should break apart any that were filled with silt and prevent the dish from being sabotaged. Discard any clams that are open and don’t close when you tap them.
Over a medium heat melt the butter or heat the oil in a frying pan that has a lid and is big enough to happily accommodate the clams. Throw in the onion, ham and bay leaves and sauté them until the onion is tender, whilst taking care not to burn them or the butter. This will take about 8 minutes.
Grind in some black pepper and follow with the garlic, then stir everything together for 30 seconds or so. Sprinkle over a good splash of sherry vinegar (if using) and allow it to evaporate.
Add the flour, if using, and stir it in for a further minute or so, taking particular care not to let it brown. Pour in the sherry, then stir in the clams and cover the pan with the lid. Jiggle everything around briefly.
Steam the clams for 3–4 minutes, or until only just opened. Remove the lid and stir in the parsley. The sauce should have thickened. Check the seasoning and add sea salt if you think it is needed, then serve immediately, picking out and discarding any clams that remain closed as you come across them.