What do you call functions which get and set?
The jQuery framework has a lot of functions which will either retrieve or mutate values depending on the parameters passed:
$(this).html(); 开发者_运维百科 // get the html
$(this).html('blah'); // set the html
Is there a standard name for functions which behave like this?
AFAIK, there is no "standard" name for a single function that acts both as a getter and as a setter. It's an idiom not very commonly used, but it's possible in some languages, and as long as it's well documented, there's no harm in using it.
Some call it a property.
Is there a standard name for functions which behave like this?
Getters and Setters.
EDIT:
I just realized that you want a single function to do this. The technical term for this is a bad idea. Unless your language provides properties, trying to rig up a single function to do this is very unreadable.
精彩评论