To quote an example from a book:
contract StockPriceOracle {
uint quoteFee = 500;
mapping (string => uint) private stockPrices;
//...
function getStockPrice(string _stockTicker) payable returns (uint _stockPrice) {
if (msg.value == quoteFee) {
//...
_stockPrice = stockPrices[_stockTicker];
} else {
revert();
}
}
}
There is a payable function that returns a value. Correct me if I'm wrong, but as far as I understand, this example does not make any practical sense. For the caller to be able to retrieve the desired information (the stock price), the function would have to emit an event. Or is there a situation where the code above is actually practical?