2 ms·
You can do that optimization in FP languages if you have unique types, ie, types that can only have one reference to them. You use the list as if it's immutable
by icebraining 9y ago
You can do that optimization in FP languages if you have unique types, ie, types that can only have one reference to them. You use the list as if it's immutable, by creating a new list with the new command and the rest of the previous list. But since the compiler can prove that the old list is no longer referenced, it can reuse it and simply make the update in-place.
- jcelerier 9y agocould you show an actual example where commands are polymorphic types (e.g. they come from a separate DLL) and this optimization actually happens ? (the actual "updating" of the command doesn't need to cross DLL boundaries, eg a DLL both provides a command, instantiates it, and updates it. The command queue is instantiated by another DLL though).
- tome 9y agoI don't know what icebraining is talking about becaue AFAIK there aren't widely used languages with unique types, except perhaps Rust.