www.digitalmars.com         C & C++   DMDScript  

D - Consistent design for functions, template and metaprogramming functions

reply "Philippe Mori" <philippe_mori hotmail.com> writes:
I would really like that defining a template (on class or integral type)
an ordinary (member or not) function and compile-time metaprogramming
functions all look a like.

For metaprogramming function, a keyword would tell that the function
is intended for metaprogramming (or even easier would be that any
function simple enough would be allowed).

Also being able to pass type, integral type constant and value (object)
to a function should look similar. In fact, I think it should even be
possible
to define a function select_first that work either with types or objects.
This
would require that types could be considered as a kind of object in certains
cases...
Aug 19 2003
parent reply Bill Cox <bill viasic.com> writes:
Philippe Mori wrote:
 I would really like that defining a template (on class or integral type)
 an ordinary (member or not) function and compile-time metaprogramming
 functions all look a like.
 
 For metaprogramming function, a keyword would tell that the function
 is intended for metaprogramming (or even easier would be that any
 function simple enough would be allowed).
 
 Also being able to pass type, integral type constant and value (object)
 to a function should look similar. In fact, I think it should even be
 possible
 to define a function select_first that work either with types or objects.
 This
 would require that types could be considered as a kind of object in certains
 cases...
Hi. What would these constructs look like? Could you give some examples? Bill
Aug 19 2003
parent "Philippe Mori" <philippe_mori hotmail.com> writes:
"Bill Cox" <bill viasic.com> a écrit dans le message de
news:bhtnin$27ep$1 digitaldaemon.com...
 Philippe Mori wrote:
 I would really like that defining a template (on class or integral type)
 an ordinary (member or not) function and compile-time metaprogramming
 functions all look a like.

 For metaprogramming function, a keyword would tell that the function
 is intended for metaprogramming (or even easier would be that any
 function simple enough would be allowed).

 Also being able to pass type, integral type constant and value (object)
 to a function should look similar. In fact, I think it should even be
 possible
 to define a function select_first that work either with types or
objects.
 This
 would require that types could be considered as a kind of object in
certains
 cases...
Hi. What would these constructs look like? Could you give some examples? Bill
In fact, since I can only find a few example were we can want both a type or an object (like select_first), then maybe the best would just to have 2 overload: one template and one metafunction. Since I do not yet know very well the syntax, I will give an example for now: class A; class B; A a1; A a2; A a = select_first(a1, a2); // declaration of variable value with type A select_first(A, B) value; or maybe it should be more like // Another possibility select_first(A, B).type value; Maybe the second way will works better with metaclass information available in classinfo... Also if in the example above a1 and a2 would be compile-time constant, I'd like to be able to get a constant with function like syntax and be able to uses that contant where the compiler want such a constant (for ex. for template with integral type argument --- I think it is not yet supported) Does D has something like typeof operator or another way to get the type of an expression and uses it elsewhere (for a declaration or the return type for ex.)
Aug 19 2003