[Issue 5348] Variable Length Arrays
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Nov 15 15:08:14 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5348
timon.gehr at gmx.ch changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timon.gehr at gmx.ch
--- Comment #6 from timon.gehr at gmx.ch 2011-11-15 15:07:25 PST ---
(In reply to comment #5)
> Currently this works, and ct_function() is run at compile-time because fixed
> array length definitions is a compile-time context, so in D it forces CTFE:
>
>
> int ct_function(int x) {
> return x * 2;
> }
> void main() {
> int[ct_function(5)] a;
> }
>
>
> If VLA come in D, and if their definition syntax is the same as the current
> fixed array definition syntax, then that length definition stops being a
> compile-time context, and the compiler is not forced (but free any way) to run
> ct_function() at compile-time.
It is not necessarily able to solve the particular halting problem instance.
The best that could be done without breaking backwards compatibility would be
to define the semantics of
int[foo()] a;
as either:
if foo() can be executed at compile time, take the result as the array length,
else either don't terminate compilation or introduce a VLA.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list