dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]C@ templates (was Re: Doubts about C@)


From: Gopal V
Subject: Re: [DotGNU]C@ templates (was Re: Doubts about C@)
Date: Sat, 17 Aug 2002 07:08:04 +0530
User-agent: Mutt/1.2.5i

If memory serves me right, S11001001 wrote:
> Well, this is just like the C++ template situation. There's no feasible 
> way to make object files out of templates; as a result, template source 
> code must always be present to instantiate those templates. This means 
> that it's purely up to the compiler; there is no way to handle it 
> directly in IL.

[Template]
public class Template 
{
        [TemplateReplace("_Iter")]
        public void loop(_Iter X) 
        {
                //code here     
        }
}

Would become a template/abstract class which is modified at callsite like

internal class LPQTemplate01
{
        public void loop(LPQ X) 
        {
                //code here
        }       
}

Which is the obvious model as used by C++ (source level modification)
Using the introspection/reflection API I think this modification could
be made at IL level rather than at the C# level .... But I really have 
to read more of IL to say for sure .. But it must be possible as IL
has reflection which is impossible with C++ object code. I would suggest
that we could run through the compiled IL and generate the template
function code ??

But IMO C@ should remain a dynamic code extension of C# .... As I have
been saying all along , we should get our hands into the class structure
in a modify mode ... The obvious advantages would be obvious from what
python has , dynamic class attribute lookup , custom function handling
etc ...

ie if A implements IDynamicType 

A.x ==> A.__getattr__("x"); // if A.__dict__["x"] does not exist 
A.x() ==> (A.__getattr__("x")).__call__(); // allow custom functions

It is obvious that this would make it a hell of a lot slower than C#,
and that is why I suggested IDynamicType .. And the __dict__ idea should
be simple with Reflection or an Internal call .. Maybe a better idea to
use of custom Attributes for this might be possible .. The above ideas 
simplifies the whole idea of Webservices and Remoting of functions and
still should run just as fine in any CLR ... (I didn't say compile !!!)

IDynamicResult x;
RpcServer a=null;
if(remote)
{
        a=new XmlRpcServer("foo.bar.biz",80);
}
else
{
        a=new AppDomainRpcServer(this); // call method on this object
        // maybe make it Inlinable as well
}

x=a.HelloWorld(); // Dynamic calls 
String s;
try
{
        x.UnPack("retval",out s); // unpack "retval" variable to s ..
}
catch(DynamicTypeMismatchException err)
{
        
}

In short kill the Multiple Inheritance , Generics and AOP ideas for 
today .. IMO that is too complicated for a simple language like C@ 
to handle (I hope so) . But make it simpler to interact with XMLRPC 
and similar webservice protocols and you would make it more useful .. 
And the funniest thing is that all this needs a little work on the 
semantic analysis and code gen of C# ... (and maybe a -fcsharp-ext 
option ??)

This `extending C#' would take DotGNU farther than a whole new language
IMO .... But that's just an idea that grew out of an overdose of 
caffeine and a general lack of sleep ..

Gopal
-- 
The difference between insanity and genius is measured by success


reply via email to

[Prev in Thread] Current Thread [Next in Thread]