Re: Converting objects to strings
Posted: Fri Apr 18, 2008 12:47 am
yes.. should have remembered that - the only solution to that without some sort of dynamic extension is to make cobra provide its own augmented version of the system classes/intefaces and only allow/expose those in cobra ... yucky
Shouldnt the "To??String" check be first ( at least for non baseclass objects) otherwise a user class that also supports one of the I{LIst,Dict,ENumerable} interfaces
will never get its own to??String implementation checked for or called
I presume reflection lookup is a relatively expensive op in .NET.
Does C#/.Net provide a simple cheap way to tag a class? (in Java I'd use a tag interface, check for that and invoke if exists\otherwise continue on with the
cobra runtime handling (List and delegate invocation))
You're right about the "care for access to these details" - most user programs will use the system collections ( or their interfaces anyway) so end up passing
through the cobra runtime lookup/invocation for to{tech,Display}String which means access to that needs to be the cheapest/fastest path withous disallowing an override by user classes..
Other random synapse firings...
Are there still only the basic 7 baseclass types to check for ??
null, bool,string,IList,IDict,IEnumerable, Enum
fallback to ToString...
if that s all just make a precedence ordered list of type -> delegate and expose it for user augmentation if need be ...
also,
for system library baseclasses if ToTechString is basically just ToDisplayString prefixed by the type ( from getType) do you still need both??
do the implementation only for To DisplayString and ToTechString becomes composited from "[x.getType][x.toDisplayString]'..
User implemented types can still implement their own if desired.
Shouldnt the "To??String" check be first ( at least for non baseclass objects) otherwise a user class that also supports one of the I{LIst,Dict,ENumerable} interfaces
will never get its own to??String implementation checked for or called
I presume reflection lookup is a relatively expensive op in .NET.
Does C#/.Net provide a simple cheap way to tag a class? (in Java I'd use a tag interface, check for that and invoke if exists\otherwise continue on with the
cobra runtime handling (List and delegate invocation))
You're right about the "care for access to these details" - most user programs will use the system collections ( or their interfaces anyway) so end up passing
through the cobra runtime lookup/invocation for to{tech,Display}String which means access to that needs to be the cheapest/fastest path withous disallowing an override by user classes..
Other random synapse firings...
Are there still only the basic 7 baseclass types to check for ??
null, bool,string,IList,IDict,IEnumerable, Enum
fallback to ToString...
if that s all just make a precedence ordered list of type -> delegate and expose it for user augmentation if need be ...
also,
for system library baseclasses if ToTechString is basically just ToDisplayString prefixed by the type ( from getType) do you still need both??
do the implementation only for To DisplayString and ToTechString becomes composited from "[x.getType][x.toDisplayString]'..
User implemented types can still implement their own if desired.