https://wiki.dlang.org/api.php?action=feedcontributions&user=Anon&feedformat=atomD Wiki - User contributions [en]2024-03-29T05:58:43ZUser contributionsMediaWiki 1.31.2https://wiki.dlang.org/?title=DIPs&diff=7204DIPs2016-01-21T04:17:29Z<p>Anon: </p>
<hr />
<div>{| class="wikitable sortable"<br />
! ID<br />
! Title<br />
! Status<br />
! Description<br />
|-<br />
| [[DIP1]]<br />
| Template DIP<br />
| Draft<br />
| This is a DIP template that can be used as a model to start a new proposal.<br />
|-<br />
| [[DIP2]]<br />
| Const code bloat<br />
| '''Approved'''<br />
| proposed solution for [http://d.puremagic.com/issues/show_bug.cgi?id=1961 bug 1961].<br />
|-<br />
| [[DIP3]]<br />
| Remove inheritance protection<br />
| '''Approved'''<br />
| non-public inheritance in a single inheritance language that has a single root object hierarchy makes little sense.<br />
|-<br />
| [[DIP4]]<br />
| Properties<br />
| [[DIP6|Superseded by DIP6]]<br />
| an alternate usage/definition syntax for properties.<br />
|-<br />
| [[DIP5]]<br />
| Properties 2<br />
| [[DIP6|Superseded by DIP6]]<br />
| a variant of DIP4.<br />
|-<br />
| [[DIP6]]<br />
| Annotations<br />
| '''Approved'''<br />
| extend the D programming language with annotations.<br />
|-<br />
| [[DIP7]]<br />
| Operator overloading<br />
| '''Approved'''<br />
| Revamped operator overloading.<br />
|-<br />
| [[DIP8]]<br />
| Improving Runtime Type Info<br />
| Draft<br />
| Templating RTTI.<br />
|-<br />
| [[DIP9]]<br />
| Redo toString API<br />
| Draft<br />
| Replace inefficient aggregate toString API with efficient delegate-based version that supports formatting.<br />
|-<br />
| [[DIP10]]<br />
| Qualified constructors and destructors for structs<br />
| Draft<br />
|<br />
|-<br />
| [[DIP11]]<br />
| Automatic downloading of imports<br />
| Draft<br />
| Support automatically downloading imported files via new import path specifications or pragmas.<br />
|-<br />
| [[DIP12]]<br />
| C API Headers<br />
| '''Approved'''<br />
| Collection of D headers for common C libraries.<br />
|-<br />
| [[DIP13]]<br />
| Import path binding<br />
| Draft<br />
| Allow to bind an import path to a package.<br />
|-<br />
| [[DIP14]]<br />
| Import path binding in source code<br />
| Draft<br />
| Allow to bind an import path to a package from within sources.<br />
|-<br />
| [[DIP15]]<br />
| Import of packages<br />
| [[DIP37|Superseded by DIP37]]<br />
| Improve imports of packages with submodules.<br />
|-<br />
| [[DIP16]]<br />
| Transparently substitute module with package<br />
| [[DIP37|Superseded by DIP37]]<br />
|<br />
|-<br />
| [[DIP17]]<br />
| Sane volatile statement<br />
| [[DIP20|Superseded by DIP20]]<br />
|<br />
|-<br />
| [[DIP18]]<br />
| Non-GC Threads<br />
| Draft<br />
|<br />
|-<br />
| [[DIP20]]<br />
| Volatile read/write intrinsics<br />
| '''Implemented'''<br />
| Intrinsics to perform C-style volatile loads/stores from/to memory.<br />
|-<br />
| [[DIP21]]<br />
| Fixing property<br />
| Draft<br />
|<br />
|-<br />
| [[DIP22]]<br />
| Private symbol visibility<br />
| Draft<br />
| Modification of private & Co symbol rules to reduce name clashes. Add internal linkage storage class.<br />
|-<br />
| [[DIP23]]<br />
| Fixing property redux<br />
| Draft<br />
| Initial<br />
|-<br />
| [[DIP24]]<br />
| Fixing properties and optional parens.<br />
| Draft<br />
| Fixing properties and optional parens. Only those. In a general and straightforward way. (counter proposal to DIP23)<br />
|-<br />
| [[DIP25]]<br />
| Sealed references<br />
| '''Implemented 2.067'''<br />
|<br />
|-<br />
| [[DIP26]]<br />
| Properties the other way round<br />
| Draft<br />
|<br />
|-<br />
| [[DIP27]]<br />
| Function definition<br />
| Draft<br />
|<br />
|-<br />
| [[DIP28]]<br />
| Property definition<br />
| Draft<br />
|<br />
|-<br />
| [[DIP29]]<br />
| Unique pointers<br />
| Draft<br />
| Unique pointers can be implicitly cast to/from immutable and shared.<br />
|-<br />
| [[DIP30]]<br />
| Delegate definition<br />
| Draft<br />
|<br />
|-<br />
| [[DIP31]]<br />
| Defined compile time paradox resolution<br />
| Draft<br />
|<br />
|-<br />
| [[DIP32]]<br />
| Uniform tuple syntax<br />
| Draft<br />
|<br />
|-<br />
| [[DIP33]]<br />
| A standard exception hierarchy<br />
| Draft<br />
|<br />
|-<br />
| [[DIP34]]<br />
| Static array literals<br />
| Draft<br />
|<br />
|-<br />
| [[DIP35]]<br />
| [[DIP25|Sealed References]] Amendment<br />
| Draft<br />
|<br />
|-<br />
| [[DIP36]]<br />
| Rvalue References<br />
| Rejected<br />
|<br />
|-<br />
| [[DIP37]]<br />
| Importing Packages as if They Were Modules<br />
| '''Implemented'''<br />
| Allow for packages to be imported as if they were modules by providing a ''package.d'' file.<br />
|<br />
|-<br />
| [[DIP38]]<br />
| Safe references without runtime checks<br />
| Draft<br />
|<br />
|-<br />
| [[DIP39]]<br />
| Safe rvalue references: backwards compatible, safe against ref/nonref code evolution, compatible with UFCS and DIP38.<br />
| Draft<br />
|<br />
|-<br />
| [[DIP40]]<br />
| Template parameter deduction for constructors.<br />
| Draft<br />
|<br />
|-<br />
| [[DIP41]]<br />
| dmd/rdmd command line overhaul.<br />
| Draft<br />
|<br />
|-<br />
| [[DIP42]]<br />
| Support enum E(T) = expression; for manifest constants<br />
| '''Implemented'''<br />
|<br />
|-<br />
| [[DIP43]]<br />
| D/Objective-C<br />
| Draft<br />
| Adds language extensions to make D ABI compatible with Objective-C.<br />
|-<br />
| [[DIP44]]<br />
| scope(this)<br />
| Draft<br />
| Extends scope guards to class / struct lifetime.<br />
|-<br />
| [[DIP45]]<br />
| making export an attribute<br />
| Draft<br />
| Turn export into an attribute and fix various shortcomings of its current implementation.<br />
|-<br />
| [[DIP46]]<br />
| region based storage allocation<br />
| Draft<br />
| Library addition to GC to allow for region based allocation strategies<br />
|-<br />
| [[DIP47]]<br />
| Outline Member Functions of Aggregates<br />
| Draft<br />
| Allow class/struct member function definitions to be placed outside of the class/struct declaration.<br />
|-<br />
| [[DIP48]]<br />
| Interface specifications for aggregate types<br />
| Draft<br />
|<br />
|-<br />
| [[DIP49]]<br />
| Define qualified postblit<br />
| Draft<br />
| Fix D2 type-system hole.<br />
|-<br />
| [[DIP50]]<br />
| AST Macros<br />
| Draft<br />
| Abstract Syntax Tree macros. A general solution for language extensions.<br />
|-<br />
| [[DIP51]]<br />
| not-virtual-by-default<br />
| Draft<br />
| Change the behaviour of class methods so they are not virtual by default.<br />
|-<br />
| [[DIP52]]<br />
| Implicit conversions<br />
| Draft<br />
| Add more implicit conversion options for user-defined types.<br />
|-<br />
| [[DIP53]]<br />
| Qualified constructor revisited<br />
| Draft<br />
| Make qualified constructor definition more simple and understandable.<br />
|-<br />
| [[DIP54]]<br />
| Revamp of Phobos tuple types<br />
| Draft<br />
| Address frequent informational confusion around std.typetuple & friends, initiate transition to std.meta.* package<br />
|-<br />
| [[DIP55]]<br />
| Access Data Items In Ancestor Stack Frames<br />
| Draft<br />
| Support for *caller pointer in functions and adding class features to functions<br />
|-<br />
| [[DIP56]]<br />
| Provide Pragma to control function inlining<br />
| Draft<br />
| Add pragma(inline,true); and pragma(inline,false);<br />
|-<br />
| [[DIP57]]<br />
| static foreach<br />
| Draft<br />
|<br />
|-<br />
| [[DIP58]]<br />
| Make ".." a binary operator<br />
| Draft<br />
|<br />
|-<br />
| [[DIP59]]<br />
| ??<br />
| Draft<br />
|<br />
|-<br />
| [[DIP60]]<br />
| Add @nogc function attribute<br />
| '''Implemented'''<br />
|<br />
|-<br />
| [[DIP61]]<br />
| Add namespace scopes to support calling external C++ functions in C++ namespaces<br />
| '''Implemented'''<br />
|<br />
|-<br />
| [[DIP62]]<br />
| Volatile type qualifier for unoptimizable variables in embedded programming<br />
| '''Rejected'''<br />
|<br />
|-<br />
| [[DIP63]]<br />
| Operator overloading for raw templates<br />
| Draft<br />
|<br />
|-<br />
| [[DIP64]]<br />
| Attribute Cleanup<br />
| Draft<br />
|<br />
|-<br />
| [[DIP65]]<br />
| Exception handling syntax cleanup<br />
| '''Rejected'''<br />
|<br />
|-<br />
| [[DIP66]]<br />
| (Multiple) alias this<br />
| Conditionally Approved<br />
|<br />
|-<br />
| [[DIP67]]<br />
| Associative Ranges<br />
| '''Rejected'''<br />
|<br />
|-<br />
| [[DIP68]]<br />
| Add @nogc attribute on types<br />
| Draft<br />
|<br />
|-<br />
| [[DIP69]]<br />
| Implement scope for escape proof references<br />
| Draft<br />
|<br />
|-<br />
| [[DIP70]]<br />
| @api/extern(noinfer) attribute<br />
| Draft<br />
|<br />
|-<br />
| [[DIP71]]<br />
| 'noscope' and 'out!param' attributes<br />
| Draft<br />
|<br />
|-<br />
| [[DIP72]]<br />
| Provide a Uniform Compiler Info Syntax<br />
| Draft<br />
|<br />
|-<br />
| [[DIP73]]<br />
| D Drafting Library<br />
| Draft<br />
|<br />
|-<br />
| [[DIP74]]<br />
| Reference Counted Class Objects<br />
| Draft<br />
|<br />
|-<br />
| [[DIP75]]<br />
| Release Process<br />
| Approved experimentally for 2.068<br />
|<br />
|-<br />
| [[DIP76]]<br />
| Autodecode should not throw<br />
| Draft<br />
| Like std.utf.byDchar, it should emit Replacement Character instead<br />
|<br />
|-<br />
| [[DIP77]]<br />
| Fix Unsafe RC Pass By Ref<br />
| Draft<br />
| Fix memory safety issue in DIP25<br />
|-<br />
| [[DIP78]]<br />
| AST Macros Lite<br />
| Draft<br />
| Abstract Syntax Tree macros without syntax extensions in the language.<br />
|-<br />
| [[DIP79]]<br />
| Negation of attributes<br />
| Draft<br />
| Negation of attributes without the need for new keywords.<br />
|-<br />
| [[DIP80]]<br />
| Phobos additions<br />
| Draft<br />
| Additions that would make phobos even more useful.<br />
|-<br />
| [[DIP81]]<br />
| Writing files at compile time<br />
| Draft<br />
|-<br />
| [[DIP82]]<br />
| static unittest blocks<br />
| Draft<br />
| Allow for unittest blocks to be declared inside of templates which are compiled and run exactly once rather than once per instantiation.<br />
|-<br />
| [[DIP83]]<br />
| Configurable Assert Diagnostics<br />
| Draft<br />
| Allow for assert's to do pretty printing of its failing expression. Printing is configurable via specific sets of (template) function overloads.<br />
|-<br />
| [[DIP84]]<br />
| Static Inheritance<br />
| Draft<br />
| Express intent to the compiler that a user-defined type conforms to a static interface.<br />
|-<br />
| [[DIP85]]<br />
| Lazy initialization of const members<br />
| Draft<br />
| Allow limited mutation of const objects, ensuring the mutation is not observable by external code.<br />
|-<br />
| [[DIP86]]<br />
| "deprecated" attribute/storage class consistency<br />
| Draft<br />
| Allow "deprecated ( stringLiteral )" to act as a storage class.<br />
|-<br />
| [[DIP87]]<br />
| Enhanced foreign-language binding<br />
| Draft<br />
| Improve extern() to be more generic and support binding symbols that share a name with a D keyword.<br />
|}<br />
<br />
----<br />
[[Category:DIP]]</div>Anonhttps://wiki.dlang.org/?title=DIP87&diff=7203DIP872016-01-21T04:14:55Z<p>Anon: Created page with "{| class="wikitable" !Title: !'''Enhanced foreign-language binding''' |- |DIP: |87 |- |Version: |1 |- |Status: |Draft |- |Created: |2016-01-21 |- |Last Modified: |{{REVISIONYE..."</p>
<hr />
<div>{| class="wikitable"<br />
!Title:<br />
!'''Enhanced foreign-language binding'''<br />
|-<br />
|DIP:<br />
|87<br />
|-<br />
|Version:<br />
|1<br />
|-<br />
|Status:<br />
|Draft<br />
|-<br />
|Created:<br />
|2016-01-21<br />
|-<br />
|Last Modified:<br />
|{{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY}}<br />
|-<br />
|Author:<br />
|Anon<br />
|-<br />
|Links:<br />
|<br />
|}<br />
<br />
== Abstract ==<br />
This DIP proposes a unified foreign language binding and name mangling syntax, to extend/replace existing approaches.<br />
<br />
== Rationale == <br />
Currently, D has a mixed bag approach to binding symbols from other languages, each with their own functionality:<br />
<br />
<ul><br />
<li><syntaxhighlight lang="D">pragma(mangle, "foo")</syntaxhighlight><br />
Changes only the symbol mangling, not the calling convention. Mostly useful for binding C symbols that share a name with a D keyword.</li><br />
<li><syntaxhighlight lang="D">extern(LinkageType)</syntaxhighlight><br />
Changes mangling and calling convention, but does not support binding to a name that is a D keyword.</li><br />
<li><syntaxhighlight lang="D">@selector("foo")</syntaxhighlight><br />
For Objective-C support. Does most of what this proposal aims to do, but is custom built for Objective-C, instead of being a multi-purpose tool.<br />
</li><br />
<li><syntaxhighlight lang="D">extern(C++, ns)</syntaxhighlight><br />
Supports mangling C++ symbols in namespaces. Also introduces the namespaces as symbols, which is not well loved by the community. Cannot bind symbols that share a name with a D keyword.</li><br />
</ul><br />
<br />
This proposal aims to replace all of these with a single, extendable, uniform syntax. This solves some of the current woes with binding C and C++, while opening up possibilities for adding additional language support in future without further breaking changes.<br />
<br />
== Description ==<br />
<br />
<ol><br />
<li>Deprecate <syntaxhighlight lang="D" enclose="none">pragma(mangle, "foo")</syntaxhighlight>, <syntaxhighlight lang="D" enclose="none">@selector("foo")</syntaxhighlight>, and <syntaxhighlight lang="D" enclose="none">extern(C++, ns)</syntaxhighlight></li><br />
<br />
<li>Change LinkageAttribute in the grammar to:<br />
<br/><br/>extern ( LinkageType [, StringLiteral ] )<br />
<br />
<br/><br/>Which has the following semantics:<br />
<ol><br />
<li>Functions will be called with appropriate calling convention.</li><br />
<li>Symbols will be mangled according to the expectations of LinkageType</li><br />
<li>The name sent to the mangler is the concatenation of all the string parameters given to <syntaxhighlight lang="D" enclose="none">extern()</syntaxhighlight>.</li><br />
<li>A symbol inside an <syntaxhighlight lang="D" enclose="none">extern(LinkageType)</syntaxhighlight> block implicitly gains LinkageType, and it is an error have multiple <syntaxhighlight lang="D" enclose="none">extern()</syntaxhighlight>s on one symbol with different LinkageTypes</li><br />
<li>The exact formatting of the string parameter is specific to each LinkageType, and should be sensible for the language being bound.</li><br />
<li>A symbol inside a struct, class, or similar inherits the LinkageType of its parent, and appends any needed separator automatically.</li><br />
</ol><br />
</li><br />
<li>Add LinkageType <syntaxhighlight lang="D" enclose="none">auto</syntaxhighlight>, which infers LinkageType from containing blocks, and defaults to D if there are none.</li><br />
</ol><br />
<br />
== Usage ==<br />
<syntaxhighlight lang="D"><br />
// Still works<br />
// Mangles as "foo"<br />
extern(C) int foo();<br />
<br />
// No more pragma(mangle)<br />
// Mangles as "body"<br />
extern(C, "body") int body_();<br />
<br />
// cppMangle("foo")<br />
extern(C++) int foo();<br />
<br />
// cppMangle("ns::foo")<br />
extern(C++, "ns::foo") int foo();<br />
<br />
// NB: Mangles as if it didn't have a module, and is a breaking change.<br />
// "_D3fooFZi"<br />
extern(D) int foo();<br />
<br />
// "_D4bodyFZi"<br />
extern(D, "body") int body_();<br />
<br />
// Namespace block, does *not* introduce any symbols on its own<br />
extern(C++, "ns::")<br />
{<br />
// No extern() directly on the symbol, so it appends its own name<br />
// cppMangle("ns::foo")<br />
int foo();<br />
<br />
// auto to infer LinkageType from previous extern()<br />
// cppMangle("ns::body")<br />
extern(auto, "body") int body_();<br />
<br />
// It is a good idea to not use auto on blocks<br />
extern(C++, "sub::")<br />
{<br />
// cppMangle("ns::sub::foo")<br />
int foo();<br />
}<br />
}<br />
<br />
// Maintains current behavior, does not add to the symbol's mangled name<br />
extern(C++)<br />
{<br />
// cppMangle("foo")<br />
int foo();<br />
}<br />
<br />
// Extend same behavior to other languages<br />
extern(C, "SDL_")<br />
{<br />
// "SDL_init"<br />
void init();<br />
}<br />
<br />
// Even D<br />
extern(D, "std.ascii.")<br />
{<br />
// std.ascii.isAlphaNum.mangleof<br />
bool isAlphaNum(dchar) pure nothrow @nogc @safe;<br />
}<br />
<br />
// Nested symbols (those inside other symbols) append any<br />
// needed separator for the mangler automatically.<br />
extern(C++, "Object")<br />
interface Object_<br />
{<br />
// cppMangleOf("Object::foo")<br />
int foo();<br />
}<br />
<br />
// NB: The Objective-C mangler must add missing parameters<br />
// the same way selector generation currently does.<br />
extern(Objective-C)<br />
class SomeClass<br />
{<br />
// selector: "length"<br />
// mangle: "_i_SomeClass_length"<br />
int length();<br />
<br />
// selector: "moveTo_f:f:"<br />
// mangle: "_i_SomeClass_moveTo_f_f_"<br />
void moveTo(float x, float y);<br />
<br />
// selector: "myMoveTo:d:"<br />
// mangle: "_i_SomeClass_myMoveTo_d_"<br />
extern(auto, "myMoveTo:") void moveTo(double x, double y);<br />
}<br />
</syntaxhighlight><br />
<br />
== Backwards Compatibility ==<br />
Code that currently uses <syntaxhighlight lang="D" enclose="none">pragma(mangle)</syntaxhighlight>, <syntaxhighlight lang="D" enclose="none">extern(C++, ns)</syntaxhighlight>, <syntaxhighlight lang="D" enclose="none">extern(D)</syntaxhighlight>, or <syntaxhighlight lang="D" enclose="none">@selector</syntaxhighlight> would need to be updated.<br />
<br />
There no longer would be a way to get <syntaxhighlight lang="D" enclose="none">extern(D)</syntaxhighlight>'s currently functionality explicitly, which may be detrimental to some generic code. However, simply omitting <syntaxhighlight lang="D" enclose="none">extern(D)</syntaxhighlight> entirely gives the current behavior.<br />
<br />
There no longer would be a way to change a symbol's mangling without also changing its calling convention, but that might be a good thing.<br />
<br />
Binding C++ namespaces would no longer introduce the namespace as a symbol, leaving scoping to D's module system. Again, this is believed to be a good thing.<br />
<br />
== Copyright ==<br />
This document has been placed in the Public Domain.</div>Anon