[Issue 8887] static arrays passed by value in extern C/C++ functions should not compile

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Nov 4 16:48:30 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=8887


bearophile_hugs at eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs at eml.cc


--- Comment #2 from bearophile_hugs at eml.cc 2012-11-04 16:48:28 PST ---
>From Walter:
https://github.com/D-Programming-Language/dmd/pull/1215#issuecomment-9770031

> This change breaks existing code,

What existing code? (And the D1 code that relies on is now broken).


> requires an awkward workaround for existing uses,

Even if they exist they are niche usages, right? It's better to keep the D
semantics saner/cleaner. As Python Zen says, few special cases are not special
enough to justify this hole in the D type system.

In D it's important not just to fix holes in the design of C, but also holes
coming from changes between D1 and D2. I think this type system hole was an
oversight while D2 fixed-sized array semantics argument pass changed.


> and has only a marginal benefit.

The benefit is helping all future C programmers that don't remember that D
passes fixed-sized arrays by value, for years and years to come. From my
experience I've seen that lot of people don't remember that.

Those C programmers will write extern(C) and they will come in the D.learn
group to ask why their code doesn't work. I will try to keep count how many
such posts will appear in D.learn.

One of the design rules of D is that D acts as C or it gives an error. In this
case it silently passes wrong data to C functions, so here there's a breaking
of the D design rules.

So I think this hole should be fixed.

-- 
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