Hello Wael:

We intend to support the syntax shown in your code snippet: using a type 
variable or type formal in a constructor call where a type name is expected.  
We also expect to be able to support using the result of a type function in 
that context, though that is a lower priority.

I have created a work item for this issue, and will inform you when progress is 
made.

Tom Hildebrandt
Chapel Team
________________________________________
From: Wael R. Elwasif [[email protected]]
Sent: Wednesday, December 10, 2014 8:10 AM
To: [email protected]
Subject: Instantiating an object based on generic type argument

Hello ,
   I'm trying to implement a simple class factory-like behavior using a
generic function with a type argument. Something like

proc factory(type t){
   var x : t;
   x = new t() ;      // This won't work
   result = x.bar()
   delete x;
   return result;
}

new expects an identifier that represents a class name, and of course
will not work when given a type variable.

I suspect that this functionality (or something equivalent) is not
possible using Chapel's current definition, but I wanted to double check
in case I missed something in the documentation.


Thanks
Wael

--
Wael R. Elwasif
Computer Science Research Group
Oak Ridge National Laboratory


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
Chapel-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/chapel-users

Reply via email to