In a medium bowl, cream together the butter, sugar, egg yolk and vanilla until smooth. Stir in the flour until well blended, then mix in coconut, raisins and pecans/walnuts (if using). Chill for at least 4 hours or overnight.
Preheat the oven to 170 C / Gas 3. Grease a few baking trays or line with parchment paper. Roll tablespoonfuls of dough into balls or logs and place them 5cm apart onto the prepared baking trays.
Bake for 25 to 30 minutes in the preheated oven or until lightly browned. Remove from baking trays to cool on wire racks.