8
2
I noticed in the bitcoin wiki script page (https://en.bitcoin.it/wiki/Script) that there were two opcodes named:
OP_TOALTSTACK
OP_FROMALTSTACK
It looks like there is another stack that can be used separately as a data store, simply pushing and popping data. I've never heard of this before, but it seems like a very useful feature.
Can anyone verify that this is what the alt stack is actually meant to be used for? If not for just pushing and popping data, what is it for? Do any specific use cases come to mind?
4
+1, but in stack-based languages, whether or not necessary, it is often convenient to have access to a second stack. For example, in Forth, it is a common idiom to (ab)use the return stack (
– Nate Eldredge – 2014-10-26T16:08:00.857>R,R>) for storing temporary data. See http://www.forth.com/starting-forth/sf5/sf5.html for an example. The designers may have had this in mind. Anyway, given the difficulty (chain fork) of adding additional features to the scripting language, one can understand that the designers had an incentive to overdesign.@Nick, I see where you're coming from when there are really only a few types of standard transactions, but some think the Bitcoin scripting language is too simple for its intended use. e.g. Ethereum. I think Satoshi found a good balance with the Bitcoin scripting language, making it flexible but also statically analyzable. – morsecoder – 2014-10-27T17:28:07.617