On Monday, 2 May 2022 at 20:16:04 UTC, ag0aep6g wrote:
On 02.05.22 21:17, Stanislav Blinov wrote:
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
[...]
```d
template MyAlias(T){
alias MyAlias = int;
}
T simp(T)(MyAlias!T val){
return T.init;
}
int main
On Monday, 2 May 2022 at 20:08:48 UTC, Ali Çehreli wrote:
On 5/2/22 12:17, Stanislav Blinov wrote:
> On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
>
>> Template deduction for aliased function parameter is a very
tricky
>> argument and it's not so simple to handle in certa
On Monday, 2 May 2022 at 16:29:05 UTC, Loara wrote:
Template deduction for aliased function parameter is a very
tricky argument and it's not so simple to handle in certain
cases. Consider for example this code:
```d
template MyAlias(T){
alias MyAlias = int;
}
T
On Wednesday, 27 April 2022 at 14:21:15 UTC, Claude wrote:
This is a long-standing pain point with BetterC (see
https://issues.dlang.org/show_bug.cgi?id=19268).
As for this:
If I compile without the BetterC switch, compilation actually
works but I'll have some linker issues:
```
$ gcc
On Monday, 25 April 2022 at 23:41:47 UTC, Chris Katko wrote:
So to use a typedef'd struct... I have to basically add the
original type on top of the typedef'd type every time? Surely
it's not this clunky?
I mean, why even use a typedef then. Why not use just pair,
sPair, vPair, etc as
On Monday, 25 April 2022 at 14:36:25 UTC, cc wrote:
```d
struct Foo {
string s;
this(string s) { this.s = s; }
}
Foo foo = "a";
Foo[] foos = ["a"]; // Error: cannot implicitly convert
expression `["a"]` of type `string[]` to `Foo[]`
Foo[] foos = cast(Foo[]) ["a"]; // Error:
On Monday, 25 April 2022 at 10:13:43 UTC, Alain De Vos wrote:
Ali, thanks for the answer but i rephrase my question.
How to destroy,free , for garbage-collection-cycle in the
destructor of this code :
// But How to force destroy and free , GC-cycle for heap object
i ?
Short answer: use
On Saturday, 23 April 2022 at 03:41:17 UTC, Alain De Vos wrote:
Feel free to elaborate.
Variables declared at module scope, and static variables in
function/aggregate scopes, unless also annotated as `shared` or
`__gshared`, are thread-local, therefore are placed in
thread-local storage.
On Wednesday, 20 April 2022 at 08:37:09 UTC, Salih Dincer wrote:
On Wednesday, 20 April 2022 at 08:04:42 UTC, Salih Dincer wrote:
I get an unexpected result inside the second foreach() loop.
Anyone know your reason?
It's my fault, here is the solution:
```d
foreach(fun; funs)
{
On Tuesday, 19 April 2022 at 06:05:27 UTC, Ali Çehreli wrote:
One quirk of rawWrite and rawRead is that they want slices of
objects. It is a little awkward when there is just one thing to
write and read. Uncompiled but something like this:
int i = 42;
file.rawWrite(*cast((int[1]*)()));
On Thursday, 14 April 2022 at 08:55:25 UTC, Chris Katko wrote:
Using DMD. v2.098-beta-2
Not sure if right terminology. But I just wrote a nested
function that uses a variable outside its body. The capture
(right term?) is obvious where the invocation is. However, I
have to move the
On Friday, 8 April 2022 at 05:53:03 UTC, Elvis Zhou wrote:
assumeNoEscapeOrWhatever!DynamicArray structs;
structs ~= cast(A*)
is it possible?
That's what `@trusted` is for. And that's also why it should be
used with care, and on the smallest code possible.
```d
struct A {}
struct B { A a;
On Thursday, 7 April 2022 at 10:50:35 UTC, BoQsc wrote:
wchar_t* clang_string = cast(wchar_t *)"AA";
You're witnessing undefined behavior. "AA" is a string
literal and is stored in the data segment. Mere cast to wchar_t*
does not make writing through that
On Wednesday, 6 April 2022 at 08:55:43 UTC, BoQsc wrote:
I have a feeling that some parts of my code contains
unterminated strings and they do overflow into other string
that is to be combined. I'd like to take a look at strings,
analyse them manually and see if any of them end up terminated
On Monday, 4 April 2022 at 07:32:00 UTC, rempas wrote:
In other terms, do these functions auto-initialize memory to be
ready for use?
No. Neither `malloc` nor `realloc` (for which D's `pure...`
variants are mere wrappers) are specified to initialize allocated
memory. `calloc`, however, is -
On Saturday, 19 March 2022 at 13:38:42 UTC, Vinod K Chandran
wrote:
On Saturday, 19 March 2022 at 11:47:53 UTC, Stanislav Blinov
wrote:
No.
First of all Thanks for the reply. The answer "No" is a wonder
to me. Because, from my point of view, `U` is coming from
nowhere. My und
On Saturday, 19 March 2022 at 05:54:26 UTC, Vinod K Chandran
wrote:
Question 1 - `U` is appearing in the first static if statement.
But we had to write `U` on the template line, right? Like -
`template rank(T, U)`
No.
Question 2 - The statif if test is - `T t == U[ ]` What does
that mean
On Friday, 4 March 2022 at 19:51:44 UTC, matheus wrote:
OK but there is another problem, I tested your version and mine
and there is a HUGE difference in speed:
string s, str = "4A0B1de!2C9~6";
Unless I did something wrong (If anything please tell). By the
way on DMD was worse, it was
On Thursday, 3 March 2022 at 12:14:13 UTC, BoQsc wrote:
I need to check if a string contains integers,
and if it contains integers, remove all the regular string
characters.
I've looked around and it seems using regex is the only closest
solution.
```d
import std.stdio;
import std.algorithm
On Saturday, 26 February 2022 at 12:26:21 UTC, Vijay Nayar wrote:
On Saturday, 26 February 2022 at 11:44:35 UTC, Stanislav Blinov
wrote:
https://dlang.org/phobos/std_range_primitives.html#isOutputRange
This method requires the caller to explicitly declare the
output range element type, which
https://dlang.org/phobos/std_range_primitives.html#isOutputRange
On Monday, 21 February 2022 at 10:04:16 UTC, steve wrote:
I am trying to implement a simple map function. I found code to
do this in another post but it only seems to work with lambda
functions and I do not understand why. Any help would be
greatly appreciated
```
import std.stdio;
T[]
On Sunday, 20 February 2022 at 04:38:46 UTC, matheus wrote:
Interesting, since English is not my first language, if in that
sentence instead of "for" there was the word "since", I
wouldn't have been bothered, but since it was the first time I
saw the usage of "for" in that way, I found
On Saturday, 19 February 2022 at 23:37:01 UTC, Vijay Nayar wrote:
What is the main motivator to allow parameters with no names?
1) `extern(C) void* malloc(size_t);`
No need for parameter name at all as that is only a declaration.
You don't have an implementation thus don't need a name for
On Thursday, 17 February 2022 at 21:17:02 UTC, Andrey Zherikov
wrote:
On Thursday, 17 February 2022 at 20:59:43 UTC, Andrey Zherikov
wrote:
Another question: does `auto foo(ARGS...)(ARGS args) { return
a.foo(args); }` correctly forward `ref`, `const` etc.
arguments?
Actually the answer is
On Saturday, 5 February 2022 at 15:10:19 UTC, step8 wrote:
I'm trying to study D programming
Following is code from vibe's example(web_ajax) code:
void getDataFiltered(Fields field, string value)
{
auto table = users.filter!((a) => value.length==0 ||
a[field]==value)().array();
On Friday, 4 February 2022 at 11:26:42 UTC, forkit wrote:
If I had wrote the code below, then I should not expect
anything, whatsoever, from the compiler.
() @trustMe_I_am_a_complete_idiot { char[] palindrome =
cast(char[])"able was I ere I saw elba"; } ();
This is almost exactly what you
On Tuesday, 25 January 2022 at 22:07:43 UTC, Ali Çehreli wrote:
On 1/25/22 13:55, forkit wrote:
> auto RandomChoice(R...)(R r)
Watch out though: The compiler will compile a different
function per set of values. For example, there will be separate
RandomChoice instances for ("hello") vs.
On Monday, 24 January 2022 at 17:23:01 UTC, frame wrote:
I understand that the linkage must match but besides the name
mangling, what's happen here? What is the difference if I
remove the `extern (C)` part from the T alias?
The difference is in how arguments are being passed, which you
seem
On Sunday, 23 January 2022 at 09:38:57 UTC, Siarhei Siamashka
wrote:
On Sunday, 23 January 2022 at 09:08:46 UTC, Stanislav Blinov
wrote:
Using `iota` here incurs additional computation and argument
copies that are actually never used, i.e. wasted work. So I'd
say go with `generate
On Saturday, 22 January 2022 at 23:54:27 UTC, forkit wrote:
On Saturday, 22 January 2022 at 19:55:43 UTC, Stanislav Blinov
wrote:
thanks for the explanation. That really helped :-)
writeln( generate!(() => dice(0.6, 1.4)).take(howManyTimes) );
[1, 1, 1, 1, 0]
(or after reading Al
On Saturday, 22 January 2022 at 19:32:07 UTC, forkit wrote:
trying to make sense of the below:
// ---
module test;
import std;
void main()
{
auto rnd = Random(unpredictableSeed);
int howManyTimes = 5;
// ok - using 'e =>' makes sense
writeln(howManyTimes.iota.map!(e =>
On Saturday, 22 January 2022 at 18:00:58 UTC, vit wrote:
I want implement something like this:
Scratch the previous reply, 'twas a brain fart... Simply take by
value, no need for extra copies at all in that case. Arguments
themselves will become those copies as needed.
```d
import
On Saturday, 22 January 2022 at 18:00:58 UTC, vit wrote:
I want implement something like this:
...
Take by value and make a copy without forwarding:
```d
import std.typecons : Tuple;
import std.meta : allSatisfy;
enum bool isRcPtr(T) = is(T == RcPtr!U, U);
//@safe access to data of
On Friday, 21 January 2022 at 03:50:37 UTC, forkit wrote:
I might have to use a kindof stringbuilder instead, then write
a massive string once to the file.
You're using writeln, which goes through C I/O buffered writes.
Whether you make one call or several is of little consequence -
you're
On Thursday, 20 January 2022 at 12:15:56 UTC, forkit wrote:
void createUniqueIDArray(ref int[] idArray, int recordsNeeded)
{
idArray.reserve(recordsNeeded);
debug { writefln("idArray.capacity is %s",
idArray.capacity); }
// id needs to be 9 digits, and needs to start with 999
On Wednesday, 19 January 2022 at 13:15:35 UTC, michaelbi wrote:
foreach(line; >
File("input.txt").byLine.map!(a=>a.idup).array.transposed)
so why there is a [] at the end of assocArray printed? thanks.
...because there's an empty line at the end of input.txt?
On Thursday, 13 January 2022 at 19:52:27 UTC, forkit wrote:
Any idea on how I can get a ptr (without hardcoding C style)
e.g. something like this:
immutable(string)*[] pointers = strings.filter!(x => x ==
"one").to!pointers.array;
```d
import std.stdio : writeln;
import std.algorithm :
On Wednesday, 12 January 2022 at 16:17:02 UTC, H. S. Teoh wrote:
On Wed, Jan 12, 2022 at 03:41:03PM +, Adam D Ruppe via
Digitalmars-d-announce wrote:
On Wednesday, 12 January 2022 at 15:25:37 UTC, H. S. Teoh
wrote:
>However it turns out that unless you are writing a computer
>game,
On Saturday, 8 January 2022 at 16:24:03 UTC, Ali Çehreli wrote:
On 1/8/22 5:49 AM, Stanislav Blinov wrote:
>> Of course, now I stress that postblit is discouraged.
>
> Bit early, methinks. Copy ctors aren't even fully supported
by the
> runtime yet.
Thanks. The spec disco
On Saturday, 8 January 2022 at 02:07:10 UTC, Ali Çehreli wrote:
1) After about three years, I finally added copy constructors:
http://ddili.org/ders/d.en/special_functions.html#ix_special_functions.copy%20constructor
Of course, now I stress that postblit is discouraged.
Bit early, methinks.
On Wednesday, 5 January 2022 at 04:35:12 UTC, Tejas wrote:
```d
import std.stdio:writeln;
ref int func(return ref int a){
a = 6; // modifies a as expected
return a;
}
void main(){
int a = 5;
auto c = func(a); // I expected c to alias a here
c = 10; // Expected to modify a as
On Wednesday, 29 December 2021 at 10:14:13 UTC, Tobias Pankrath
wrote:
How do I mixin a function only if it is not already present?
Perhaps use opDispatch?
On Wednesday, 29 December 2021 at 02:33:08 UTC, frame wrote:
On Wednesday, 29 December 2021 at 01:11:13 UTC, Stanislav
Blinov wrote:
Because opIndexAssign cannot distinguish at compile time
between initialization and assignment:
```d
Stuff[Key] aa;
aa[key] = Stuff(args); // ostensibly
On Tuesday, 28 December 2021 at 22:30:30 UTC, Ali Çehreli wrote:
On 12/28/21 2:06 PM, Steven Schveighoffer wrote:
void print_num(int mul)(int num) {
Wasn't there a way of telling whether an 'auto ref' parameter
is copied or not?
void print_num()(int num, auto ref int mul) {
// ?
}
On Tuesday, 28 December 2021 at 22:46:16 UTC, frame wrote:
On Tuesday, 28 December 2021 at 10:02:13 UTC, tsbockman wrote:
// Should be a compile-time error, because it might reassign:
test[key] = S(value);
This might be a typo in your example but why should it be a
compile-time error,
On Thursday, 23 December 2021 at 07:14:35 UTC, Salih Dincer wrote:
It seems faster than algorithms in Phobos. We would love to see
this in our new Phobos.
```d
void mallocReplace()
void normalReplace()
string result = str.replace(';',"");
}/* Console Out:
Replace: 436 msecs
Malloc
On Tuesday, 21 December 2021 at 15:42:59 UTC, russhy wrote:
Please keep us updated, that'll be interesting to see how a
pure D printf would look like!
It already exists, it's called std.format.write.formattedWrite,
in terms of which things like std.stdio.writef are implemented.
On Monday, 20 December 2021 at 18:03:09 UTC, rempas wrote:
> Now the problem is that I want it to get the name of so
> symbol and add it to a string literal.
Let's check this example: enum state(alias name) = `name` ~ ` =
10;`;
https://dlang.org/spec/traits.html#identifier
On Sunday, 19 December 2021 at 22:29:21 UTC, vit wrote:
Hello,
Why is copy ctor in this example not called?
Because D runtime isn't properly married to copy constructors
yet. I.e. it's a bug, a variant of this one:
https://issues.dlang.org/show_bug.cgi?id=20879
On Wednesday, 15 December 2021 at 11:36:41 UTC, Manfred Nowak
wrote:
On Tuesday, 14 December 2021 at 08:28:01 UTC, WebFreak001 wrote:
[...]
Alternatively, remove the template `()` from your `struct
Header`
What is the semantic sense of a template having no parameters?
Although the
On Tuesday, 14 December 2021 at 17:20:18 UTC, chopchop wrote:
I am using the "ref" here (I put tinyurl to avoid
over-referencing the post instead of the github page itself):
https://tinyurl.com/bdddkmub
I would like to be able to pass any kind of console to
updateFoodToken ( Console c ), ie
On Tuesday, 14 December 2021 at 15:28:30 UTC, Steven
Schveighoffer wrote:
All the other problems you are having are deriving from this
problem.
Not exactly. One of the problems seems to be a genuine bug:
```d
struct S
{
int[] x;
// doesn't even participate here, neither would
On Tuesday, 14 December 2021 at 08:44:02 UTC, rumbu wrote:
I am trying to understand why in this two different cases
(Simple and Complex), the compiler behaviour is different.
```d
struct SimpleStruct { int x;}
struct ComplexStruct { int[] x; }
void main()
{
SimpleStruct[] buf1;
On Monday, 13 December 2021 at 20:58:42 UTC, forkit wrote:
immutable(char)[] replaceChar(char* str, ulong len, char ch1,
char ch2)
//snip
return to!(immutable(char)[])(str);
}
You're calling a `to` on a char pointer, which, ostensibly, would
look for null terminator. Which there may
On Saturday, 11 December 2021 at 23:44:59 UTC, Adam Ruppe wrote:
On Saturday, 11 December 2021 at 23:17:17 UTC, Stanislav Blinov
wrote:
? No. If it was unsatisfied constraint, the error would've
shown that.
And if you try to instantiate it, you'll see it is an
unsatisfied constraint anyway
On Saturday, 11 December 2021 at 22:59:52 UTC, Adam Ruppe wrote:
On Saturday, 11 December 2021 at 22:50:45 UTC, apz28 wrote:
void foo2(T)(Unqual!T x) if(isUnsigned!T) {}
This means it treats foo2 as if it doesn't exist unless T is
unsigned...
onlineapp.d(15): Error: template
On Saturday, 11 December 2021 at 09:34:17 UTC, Ola Fosheim
Grøstad wrote:
void donttrythisathome(string s, char stripchar) @trusted {
import core.stdc.stdlib;
char* begin = cast(char*)alloca(s.length);
A function with that name, and calling alloca to boot, cannot be
@trusted ;)
On Friday, 10 December 2021 at 23:53:47 UTC, Ola Fosheim Grøstad
wrote:
```d
char[] dontdothis(string s, int i=0, int skip=0){
if (s.length == i) return new char[](i - skip);
if (s[i] == ';') return dontdothis(s, i+1, skip+1);
auto r = dontdothis(s, i+1, skip);
r[i-skip] =
On Friday, 10 December 2021 at 13:22:58 UTC, Matheus wrote:
My C way of thinking while using D:
import std;
string stripsemicolons(string input){
char[] s = input.dup;
int j=0;
for(int i=0;i
Oooh, finally someone suggested to preallocate storage for all
these reinventions of
On Wednesday, 8 December 2021 at 22:18:23 UTC, forkit wrote:
It's also worth noting the differences in compiler output, as
well as the time taken to compile, these two approaches:
(1)
string str = "abc;def;ab".filter!(c => c != ';').to!string;
(2)
string str = "abc;def;ab".replace(";", "");
On Wednesday, 8 December 2021 at 08:07:59 UTC, Petar Kirov
[ZombineDev] wrote:
```d
interface ICallable
{
void opCall() const;
}
alias Action = void delegate();
struct A
{
Action[] dg;
}
```
At this point why not just call a spade a spade and store an
array of ICallables directly?
On Friday, 3 December 2021 at 10:42:37 UTC, Rumbu wrote:
Bug or feature? Is there any workaround?
The error message explains what to do :)
Error: class `mixinover.AnotherVisitor` use of
`mixinover.Visitor.visit(S s)` is hidden by `AnotherVisitor`;
use `alias visit = Visitor.visit;` to
On Thursday, 2 December 2021 at 23:29:17 UTC, Chris Katko wrote:
there's:
```d
import core.thread;
Thread.sleep( dur!("msecs")(10) );
```
but what if you want to simply yield all remaining time back to
the time scheduler?
Is there a D std.library accessible version of POSIX
On Friday, 26 November 2021 at 10:44:10 UTC, Salih Dincer wrote:
* Is the const essential for ranges?
* Is it possible to rewind the pointer (```Node * head;```)
when my head is empty by the const?
`empty` is not required to be `const`, but it is required to
yield the same result if called
On Thursday, 25 November 2021 at 09:00:52 UTC, Imperatorn wrote:
What most ppl do in that case is to just provide a script, for
example build.cmd that just does what it needs. The user just
clicks the script and it does everything for them.
"How can I make it so that I don't need an extra
On Monday, 22 November 2021 at 12:57:27 UTC, Luís Ferreira wrote:
On Mon, 2021-11-22 at 03:36 +, Stanislav Blinov via
Digitalmars-d- announce wrote:
On Sunday, 21 November 2021 at 20:30:51 UTC, Luís Ferreira
wrote:
> I decided to have a simple approach just to show that it is
> easi
On Sunday, 21 November 2021 at 20:30:51 UTC, Luís Ferreira wrote:
I decided to have a simple approach just to show that it is
easier now to do that without workarounds, and by workarounds,
I mean using scope to fetch that info and use a fake dtor, or
even before scope exists, the usage of
On Saturday, 20 November 2021 at 05:37:42 UTC, rikki cattermole
wrote:
And then there are issues such as
https://issues.dlang.org/show_bug.cgi?id=21416 which killed off
any chance of me using them internally.
...and the implementation, as presented, falls apart due to not
forwarding
On Thursday, 18 November 2021 at 22:20:48 UTC, pascal111 wrote:
In next program that rewrites original written texts into new
files, I see that it may need some additions or we can accept
it like this because it's just a simple program that achieve
its task and doesn't need any philosophical
On Sunday, 14 November 2021 at 04:05:45 UTC, forkit wrote:
However, there is no isClass method. Why not?
How do I determine if a member is a class.. I wonder...
```
static if (is(something == class)) { /* ... */ }
```
or, if member is an instance
```
static if (is(typeof(something) ==
On Saturday, 13 November 2021 at 08:04:56 UTC, forkit wrote:
int i;
foreach(m; __traits(allMembers, mixin(__MODULE__)))
// ...
__traits(getLocation, mixin(m))[1]);
What you really should be doing is this:
```d
static import mod = mixin(__MODULE__);
foreach (i, name;
On Saturday, 13 November 2021 at 05:31:51 UTC, forkit wrote:
Code below is self explanatory.
Any assistance on how to get the line number is welcome ;-)
https://dlang.org/spec/traits.html#getLocation
That?
On Thursday, 11 November 2021 at 22:10:04 UTC, forkit wrote:
It's called 'staged learning'.
Staged learning is the only way for humans to learn, due to the
limitations of the human cognitive system. Specifically, the
way short-term memory and long-term memory facilitate learning.
Those who
On Thursday, 11 November 2021 at 21:56:19 UTC, Ali Çehreli wrote:
On 11/11/21 11:34 AM, Stanislav Blinov wrote:
> Pessimization, though, is laughably easy, and
> should be avoided at all costs.
I am not passionate about this topic at all and I am here
mostly because I have fun in this
On Thursday, 11 November 2021 at 00:11:07 UTC, H. S. Teoh wrote:
It depends on what you're doing. In the OP's example, yeah
worrying about allocations is totally blowing things out of
proportions.
But that's the thing. How would one ever learn to know where that
dividing line is if all the
On Wednesday, 10 November 2021 at 23:15:09 UTC, forkit wrote:
On Wednesday, 10 November 2021 at 22:17:48 UTC, russhy wrote:
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache.
So I really don't give a damn about allocations
On Thursday, 11 November 2021 at 09:11:37 UTC, Salih Dincer wrote:
Unless explicitly set, default type is int. 110 is
greater than int.max.
11
```d
enum w = 100_000;
size_t b = w * w;
// size_t b = 10 * 10; // ???
assert(b == 10_000_000_000); // Assert Failure
```
On Thursday, 11 November 2021 at 05:37:05 UTC, Salih Dincer wrote:
is this a issue, do you need to case?
```d
enum tLimit = 10_000; // (1) true result
enum wLimit = 100_000; // (2) wrong result
```
https://dlang.org/spec/enum.html#named_enums
Unless explicitly set, default type is int.
On Wednesday, 10 November 2021 at 06:47:32 UTC, forkit wrote:
btw. My pc has 24GB of main memory, and my CPU 8MB L3 cache. So
I really don't give a damn about allocations .. not one little
bit ;-)
That's not the point. The point is the program is doing
unnecessary non-trivial work while
On Tuesday, 9 November 2021 at 11:03:09 UTC, forkit wrote:
They both produce exactly the same output.
But do vastly different things.
But I tell ya.. the cognitive load .. well.. it increased
dramatically ;-)
Of course it did. Cuz you overthunk it. Dramatically.
Your D version allocates
On Monday, 8 November 2021 at 23:26:39 UTC, tchaloupka wrote:
```
auto gen() {
Foo f; // <--- this one
f.n = 42;
return value(f.move());
}
void main() {
Foo f;
f = gen().unwrap.move;
}
```
~this(0)
~this(0)
~this(0)
~this(42) <- this is a copy (that
On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote:
...e.g.
```d
// ...
mixin ("ReturnType /*...snip...*/ " ~ member ~ "()(Parameters!
/*...snip...*/
```
Note the `()` before parameter list. This would make your member
function a function template, for which attributes will be
inferred
On Friday, 5 November 2021 at 06:19:16 UTC, Li30U wrote:
I am creating a templated object that is a storehouse for a
heap object and executes their methods and returns an array of
results. With the help of a template, I want to achieve this,
but I want to assign the same attributes to the
On Wednesday, 3 November 2021 at 00:50:51 UTC, Siarhei Siamashka
wrote:
!text.join("\n").writeln;
Ahem... You've turned a program that does not allocate to a
program that allocates who knows how much memory?
And Ali... associative arrays? For this? What are you trying to
teach the
On Saturday, 30 October 2021 at 22:47:57 UTC, Elronnd wrote:
If the GC were moving, it would also have to move the pointers
you took to AA elements. You would never get stale pointers in
any event.
Who said you would?..
On Saturday, 30 October 2021 at 20:19:58 UTC, Imperatorn wrote:
https://dlang.org/spec/garbage.html#pointers_and_gc
What test could be written to verify the behaviour?
Assuming the GC was moving?
You'd need a loop allocating different sizes, storing the
addresses somewhere the GC won't
On Saturday, 30 October 2021 at 18:31:16 UTC, Andrey Zherikov
wrote:
I did small test and it printed the same values three times so
even rehash doesn't change the address of the value:
So it seems pretty safe to store a pointer to a value in AA.
And I agree that this should definitely be
On Saturday, 30 October 2021 at 17:45:57 UTC, Steven
Schveighoffer wrote:
You said "deallocating unreferenced elements". I thought you
meant elements unreferenced by the AA.
Yup, I misunderstood you :)
What I mean is, the AA isn't going to change implementations
where it now deallocates
On Saturday, 30 October 2021 at 16:55:03 UTC, Steven
Schveighoffer wrote:
auto v = k in aa;
aa.remove(k);
How can the GC/compiler work out that there is still a
reference?
??? The same way it does for all other references.
I think either you misunderstood me, or I misunderstood you.
On Saturday, 30 October 2021 at 11:59:15 UTC, Steven
Schveighoffer wrote:
It should be documented. There isn't a valid way to remove
these requirements, even if they are currently just an
implementation detail -- code already depends on these
properties.
And D is a GC-based language,
On Friday, 29 October 2021 at 21:00:48 UTC, Steven Schveighoffer
wrote:
This is incorrect, the buckets are each heap allocated. Just
the array of bucket pointers would change.
In addition, AAs do not deallocate the key/value pairs ever.
You are safe to obtain a pointer to a value and it
On Friday, 29 October 2021 at 11:05:14 UTC, Imperatorn wrote:
On Thursday, 28 October 2021 at 01:39:10 UTC, Thomas Gregory
wrote:
I am a maintainer of the
[dhtslib](https://github.com/blachlylab/dhtslib) package and I
have been running into issues with a new implementation of
reference
On Thursday, 28 October 2021 at 05:20:35 UTC, data pulverizer
wrote:
I am trying to compile the following items:
struct sxpinfo_struct {
mixin(bitfields!(
// ...
uint, "debug",1,
// ...
}
```
But I get the error...
`debug` is a language keyword, try a different one, like
On Friday, 10 July 2020 at 10:13:23 UTC, wjoe wrote:
So many awesome answers, thank you very much everyone!
Less overhead,
Using/needing it to interface with something else, and
Efficiency are very good points.
However stack memory needs to be allocated at program start. I
don't see a huge
On Wednesday, 8 July 2020 at 20:11:05 UTC, IGotD- wrote:
int v;
enum sz = mySize!int // works, returns 46
enum sz2 = mySize(v) // doesn't work. Error: variable v cannot
be read at compile time
Here we have a difference between C++ and D as C++ was able
infer the size of v during compile
On Wednesday, 8 July 2020 at 02:06:01 UTC, Steven Schveighoffer
wrote:
Seems simple enough, except that this inner portion is
unrolled, and if I have more than one type to run this on, I
already have an "innerloop" label defined.
Is there a way to define a label using a mixin or something?
On Tuesday, 7 July 2020 at 13:33:41 UTC, Paul Backus wrote:
You can make opApply a template:
int opApply(Dg)(Dg dg)
if (is(Dg : scope int delegate(ref E)))
{
// etc.
}
Because `scope int delegate(ref E) @safe` implicitly converts
to `scope int delegate(ref E)`,
On Monday, 6 July 2020 at 20:06:51 UTC, Kayomn wrote:
Something discovered in the D Language Code Club Discord server
with the help of Wild is that the following code:
struct Test { ~this() {} }
void tester(Test test, Test[] tests...) { }
extern(C) void main() {
tester(Test(), Test());
}
On Wednesday, 1 July 2020 at 18:30:15 UTC, Dennis wrote:
I have a function that checks a global error constant of a C
library (OpenGL) like this:
```
void assertNoOpenGLErrors() {
if (glGetError() != GL_NO_ERROR) {
assert(0); // stack trace points to here instead of
caller
}
1 - 100 of 885 matches
Mail list logo