Dennis brought up a discussion about reducing the size of
object.d that came up in a PR thread. Specifically, moving
things into separate modules, then making object.d a list of
public imports would make it easier to maintain a custom
object.d.
It is unfortunate that my suggestion was used to push an other
idea
A public import, is the same problem
My issue with `object.d` is it is shadowing symbols
`destroy` for example
If i want a `destroy` function, i call destroy, but if i made a
typo in my function or forgot to actually create it, then it'll
silently call `destroy` from `object.d` without letting you know
about it, that's what prompted me to make the PR
I now banned the `destroy` name, and instead use `dispose` as
people on the IRC suggested me to do, wich in restrospec is a
better word indeed
But i figured i should not expect such changes, so instead i now
compile with `-betterC` and a custom `object.d` for all of my
projects
The other unfortunate thing is i now have to deal with issues
like this, and incorporate hacks into my codebases for LDC:
https://github.com/ldc-developers/ldc/issues/2425#issuecomment-1193330845
The consensus was that with D's built-in ability to
differentiate symbols (FQN, static imports), this isn't a
problem. Iain closed the PR after the meeting, noting that we
agreed something needs to be done about object.d, "but not
this".
The worst part is that file should not be needed at all to begin
with
You can't do simple ptr/slice casting without it, and you can't
use enums without it
If `destroy` is essential to D, then it should be upgraded to a
builtin and reserved keyword, if it is just an utility function,
then it shouldn't be in the global scope, or it should be
prefixed `__destroy`
There needs a way to differentiate functions used for language
support like `switch` and `cast` with other utility functions, 2
different concerns
This is what i have to carry to opt out this specific thing
(luckily i do not use any other features): (see at the end of the
post)
And one recent issue i had, because of the custom `object.d`
route:
https://i.imgur.com/Ye9ewJP.png
I couldn't figure out what caused the issue, thanks to Adam,
compiling with `dmd -v` pointed out the problematic import:
`import core.sys.windows.threadaux;`
Pay as you go is the way to go, but the experience should be
drastically improved imo
```D
module object;
alias size_t = typeof(int.sizeof);
alias ptrdiff_t = typeof(cast(void*)0 - cast(void*)0);
alias sizediff_t = ptrdiff_t; // For backwards compatibility only.
/**
* Bottom type.
* See $(DDSUBLINK spec/type, noreturn).
*/
alias noreturn = typeof(*null);
alias hash_t = size_t; // For backwards compatibility only.
alias equals_t = bool; // For backwards compatibility only.
alias string = immutable(char)[];
alias wstring = immutable(wchar)[];
alias dstring = immutable(dchar)[];
bool __equals(T1, T2)(scope const T1[] lhs, scope const T2[] rhs)
@nogc nothrow pure @trusted
if (__traits(isScalar, T1) && __traits(isScalar, T2))
{
if (lhs.length != rhs.length)
return false;
static if (T1.sizeof == T2.sizeof
// Signedness needs to match for types that promote to
int.
// (Actually it would be okay to memcmp bool[] and byte[]
but that is
// probably too uncommon to be worth checking for.)
&& (T1.sizeof >= 4 || __traits(isUnsigned, T1) ==
__traits(isUnsigned, T2))
&& !__traits(isFloating, T1) && !__traits(isFloating, T2))
{
if (!__ctfe)
{
// This would improperly allow equality of integers
and pointers
// but the CTFE branch will stop this function from
compiling then.
import core.stdc.string : memcmp;
return lhs.length == 0 ||
0 == memcmp(cast(const void*) lhs.ptr, cast(const
void*) rhs.ptr, lhs.length * T1.sizeof);
}
}
foreach (const i; 0 .. lhs.length)
{
static if (__traits(isStaticArray, at(lhs, 0))) // "Fix"
for -betterC
{
if (at(lhs, i)[] != at(rhs, i)[]) // T1[N] != T2[N]
doesn't compile with -betterC.
return false;
}
else
{
if (at(lhs, i) != at(rhs, i))
return false;
}
}
return true;
}
bool __equals(T1, T2)(scope T1[] lhs, scope T2[] rhs)
if (!__traits(isScalar, T1) || !__traits(isScalar, T2))
{
if (lhs.length != rhs.length)
{
return false;
}
if (lhs.length == 0)
return true;
static if (useMemcmp!(T1, T2))
{
if (!__ctfe)
{
static bool trustedMemcmp(scope T1[] lhs, scope T2[]
rhs) @trusted @nogc nothrow pure
{
pragma(inline, true);
import core.stdc.string : memcmp;
return memcmp(cast(void*) lhs.ptr, cast(void*)
rhs.ptr, lhs.length * T1.sizeof) == 0;
}