Current thinking is that we might do this with a hook, OR store PHP code associated with a "group" of custom fields in the database.
— original post ----
It would be astoundingly helpful to implement a custom data type that is "php code". Much in the same way that we can ask drupal to display blocks according to whether a set of php code returns true or false, we could have php code that returns a value and CiviCRM would fill in the value of that custom field with the value returned by the function. This would be especially useful if various variables and functions relating to the contact where available to the php code.
For myself, I would love to create a php snippet that automatically assigns a members home constituency based on their primary address.