[Issue 5212] Safer typesafe variadics
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Nov 15 14:12:33 PST 2010
http://d.puremagic.com/issues/show_bug.cgi?id=5212
--- Comment #5 from bearophile_hugs at eml.cc 2010-11-15 14:11:15 PST ---
Extra note:
It's a problem of perception: typesafe variadic arguments don't look like
normal function arguments that you know are usually on the stack, they look
like dynamic arrays, and in D most dynamic arrays are allocated on the heap
(it's easy and useful to take a dynamic-array-slice of a stack allocated array,
but in this case the code shows that the slice doesn't contain heap data).
If your function has a signature similar to this one:
void foo(int[3] arr...) {
It's not too much hard to think that 'arr' is on the stack. But dynamic arrays
don't give that image:
void foo(int[] arr...) {
This is why I think it's better for the compiler to test if the arr data is on
the stack, and dup it otherwise (unless a 'scope' is present, in this case both
the test and allocation aren't present).
--
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