Compile time variadic functions

Kevin Bealer Kevin_member at pathlink.com
Wed Mar 15 13:27:46 PST 2006


In article <dv7mtk$1ai3$1 at digitaldaemon.com>, Walter Bright says...
>
>In article <dv4j1r$eil$1 at digitaldaemon.com>, Oskar Linde says...
>>*) Another thing that would be nice is an auto (type inferred) return 
>>type for functions:
>>
>>auto func(int x) { return x+1; }
>
>That would be cool, but it has some severe chicken-and-egg problems. The problem
>is that the function body must be fully semantically analyzed before the return
>type can be deduced. Think of what happens when many functions call each other!

I think languages like SML have this feature and the associated problem you
mention.  I was told in an A.I. course that the result of adding this to the
language, is that the SML compiler needs a "theorem prover" to figure out what
the return type from something is.

I suspect you could solve logic 101 puzzles, by reformulating them as compile
time type inference problems for an SML compiler.  Something like C++
metaprogramming.  (I think this possibility is a pretty good argument against
adding such a feature. :))

Kevin





More information about the Digitalmars-d mailing list