Chapter the 18th (in which Jason reveals his own ignorance?)
Graham Glass (talking about X# and "data oriented languages") envisions:
"...for example, instead of reverse() being a method on a String class, reverse() would be a free-floating entity that operates on Strings to create reversed Strings. a String itself would be also be a free-floating entity that has no intrinsic operations."[graham glass: what's next?]
Hmmm, where have I seen this before? oh yeah:
char * pszName = "Hello"; //pszName has no instrinsic operations pszName = strrev(pszName);
Maybe I just don't get it. Admittedly in this example the "strrev" thing isn't really an "entity" that I can do anything with, nor can I create a new one out of thin air - the list of these things is fixed at compile time. I can get slightly more dynamic behavior if I use function pointers.
STRINGPROC pOperation = /* some function */ pOperation(pszName);
In C++ I could even make it stateful:
class Reverse { string operator()() { return /* something */ } }
Reverse still is fixed at compile time; I can't create new ones at runtime. Since my brain is currently in the Reflection.Emit space I can't help but point out that in the CLR I could create brand new types of operations by emitting new classes and creating instances of my new types (the Regular Expressions library and the XML Serializers do this behind the scenes). I could envision a world where different operations could be composed into new operations without forcing developers to fall all the way down to ILGenerator.Emit(), but if the operations have any state they really starts to look like objects to me, so I'm not sure why Graham says:
i personally don't believe that objects as a first-class concept are really that great
I guess I've just been corrupted after working with objects for ten years :). Hard to really know what X# will look like at this point, so...
10:14:48 AM
|