digitalmars.D - Should we add another SmallArray to DMD?
- Guillaume Chatelet (23/23) Jul 05 2016 DMD currently provides the Array type:
- Guillaume Chatelet (2/5) Jul 06 2016 Walter, Daniel, Thoughts?
- Stefan Koch (4/11) Jul 07 2016 I guess a few number of the perf difference this can make would
- Guillaume Chatelet (7/19) Jul 07 2016 It's not so much about performance gain (although it wouldn't
- Charles Hixson via Digitalmars-d (5/21) Jul 07 2016 If it's just for code sanity, why wouldn't an alias suffice? I often
DMD currently provides the Array type: https://github.com/dlang/dmd/blob/master/src/root/array.d It is primarily designed to interact with C++. It provides the small array optimization which is good, but its stack space is one element and cannot be changed, making it not suitable for small string buffers. As a matter of fact we also have OutBuffer which reimplements the allocation strategy a second time (with no small string optimization) https://github.com/dlang/dmd/blob/master/src/root/outbuffer.d It is also quite old, not tested (at least I didn't find them), and does not follow D idioms. Also note that because Array is "extern (C++)", it's not possible to add SMALLARRAYCAP as a template parameter (bug in the C++ name mangler). Proposal: --------- As for LLVM, create a few tested D idiomatic facilities to use in the front end: SmallVector, SmallString to begin with. Here is a first take at SmallVector (no doc yet) https://gist.github.com/gchatelet/876adfb59abe1dda58ba24d63d4e418d I'm half convinced for now so I would like some feedback before investing more time.
Jul 05 2016
On Tuesday, 5 July 2016 at 19:41:18 UTC, Guillaume Chatelet wrote:DMD currently provides the Array type: https://github.com/dlang/dmd/blob/master/src/root/array.d [...]Walter, Daniel, Thoughts?
Jul 06 2016
On Thursday, 7 July 2016 at 06:39:19 UTC, Guillaume Chatelet wrote:On Tuesday, 5 July 2016 at 19:41:18 UTC, Guillaume Chatelet wrote:I guess a few number of the perf difference this can make would be helpful.DMD currently provides the Array type: https://github.com/dlang/dmd/blob/master/src/root/array.d [...]Walter, Daniel, Thoughts?
Jul 07 2016
On Thursday, 7 July 2016 at 07:56:44 UTC, Stefan Koch wrote:On Thursday, 7 July 2016 at 06:39:19 UTC, Guillaume Chatelet wrote:It's not so much about performance gain (although it wouldn't hurt). It's more about codebase sanity: idiomatic D, documentation, tests. I think it's currently hard to contribute to DMD. Sure it improved a lot with the migration to D but it still bears the marks of the past.On Tuesday, 5 July 2016 at 19:41:18 UTC, Guillaume Chatelet wrote:I guess a few number of the perf difference this can make would be helpful.DMD currently provides the Array type: https://github.com/dlang/dmd/blob/master/src/root/array.d [...]Walter, Daniel, Thoughts?
Jul 07 2016
On 07/07/2016 03:51 AM, Guillaume Chatelet via Digitalmars-d wrote:On Thursday, 7 July 2016 at 07:56:44 UTC, Stefan Koch wrote:If it's just for code sanity, why wouldn't an alias suffice? I often alias types to create a "type" for a specialized purpose. Of course, if you want a real type you could wrap it in a struct...which I do with classes when it's *IMPORTANT* that the finalizer be called.On Thursday, 7 July 2016 at 06:39:19 UTC, Guillaume Chatelet wrote:It's not so much about performance gain (although it wouldn't hurt). It's more about codebase sanity: idiomatic D, documentation, tests. I think it's currently hard to contribute to DMD. Sure it improved a lot with the migration to D but it still bears the marks of the past.On Tuesday, 5 July 2016 at 19:41:18 UTC, Guillaume Chatelet wrote:I guess a few number of the perf difference this can make would be helpful.DMD currently provides the Array type: https://github.com/dlang/dmd/blob/master/src/root/array.d [...]Walter, Daniel, Thoughts?
Jul 07 2016