On Saturday, 23 March 2024 at 11:04:04 UTC, Dmitry Olshansky
wrote:
On Saturday, 23 March 2024 at 09:08:45 UTC, Per Nordlöw wrote:
Is there a reason why
```d
class Base {}
class Derived : Base {}
@safe pure nothrow unittest {
Base b;
Derived d;
b = d; // pass
B
On Monday, 22 January 2024 at 08:54:54 UTC, zjh wrote:
On Monday, 22 January 2024 at 08:27:36 UTC, Joel wrote:
```d
import std;
struct Person {
string name, email;
ulong age;
auto withName(string name) { this.name=name; return this; }
auto withEmail(string email) { this.email=e
On Saturday, 20 January 2024 at 15:59:59 UTC, Anonymouse wrote:
I remember reading this was an issue and now I ran into it
myself.
```d
import std.stdio;
void main()
{
auto names = [ "foo", "bar", "baz" ];
void delegate()[] dgs;
foreach (name; names)
{
dgs ~= () => wri
On Tuesday, 16 January 2024 at 15:39:07 UTC, Anonymouse wrote:
If I make a `scope` variable of the delegate and pass *it* to
`receiveTimeout`, there no longer seems to be any mention of
the closure in the error (given 2.092 or later).
```d
void foo(Thing thing) @nogc
{
void sendThing(const
On Tuesday, 16 January 2024 at 10:56:58 UTC, Anonymouse wrote:
I'm increasingly using nested delegates to partition code.
```d
void foo(Thing thing)
{
void sendThing(const string where, int i)
{
send(thing, where, i);
}
sendThing("bar", 42);
}
```
...
3. Those reference
On Saturday, 6 January 2024 at 17:57:06 UTC, Paul Backus wrote:
On Friday, 5 January 2024 at 20:41:53 UTC, Noé Falzon wrote:
In fact, how can the template be instantiated at all in the
following example, where no functions can possibly be known at
compile time:
```
auto do_random_map(int dele
On Saturday, 18 November 2023 at 18:52:07 UTC, JN wrote:
Latest DMD for Windows downloaded from here:
https://downloads.dlang.org/releases/2.x/2.105.3/dmd-2.105.3.exe reports version as dirty:
DMD64 D Compiler v2.105.3-dirty
Copyright (C) 1999-2023 by The D Language Foundation, All
Rights Rese
On Friday, 22 September 2023 at 17:52:51 UTC, FeepingCreature
wrote:
"Integer representation" here refers to the ANSI index or
Unicode codepoint, ie. the filename must not contain `\x00` to
`\x31`.
Er oops, make that `\x00` to `\x1f`.
On Friday, 22 September 2023 at 17:44:50 UTC, Vino wrote:
Hi All,
Request you help in understanding why the below code is
always returning true when it should return false as per the
documentation.
Documentation
```
filename must not contain any characters whose integer
representation is
On Sunday, 17 September 2023 at 15:55:37 UTC, Vitaliy Fadeev
wrote:
Is it possible to write like this in D?
```d
struct Message
{
ulong timestamp;
}
Message LongMessage
{
ubyte[255] s;
}
//
// it mean
//
// struct LongMessage
// {
// Message _super;
// alias _super this;
// u
On Sunday, 3 September 2023 at 10:11:22 UTC, Vino wrote:
Hi All,
Any update as to when the function described in the below
ticked would be action-ed, I am more interested in isBinary
(check a file whether is is binary file or not)
http://d.puremagic.com/issues/show_bug.cgi?id=9455
From,
On Thursday, 31 August 2023 at 05:16:02 UTC, Vino wrote:
Hi All,
Request your help on the below error
Program
```
void main()
{
import std.stdio:writeln;
import std.algorithm.iteration : splitter;
auto splitter_ptr = &splitter!((a, b) => a.splitter(b).array);
On Tuesday, 22 August 2023 at 16:22:52 UTC, harakim wrote:
On Monday, 21 August 2023 at 11:05:36 UTC, FeepingCreature
wrote:
Can you print some of the wrong sizes? D's DirEntry iteration
code just calls `FindFirstFileW`/`FindNextFileW`, so this
*shouldn't* be a D-specific issue, and
On Monday, 21 August 2023 at 07:52:28 UTC, harakim wrote:
I have been doing some backups and I wrote a utility that
determines if files are an exact match. As a shortcut, I check
the file size. So far so good on this with millions of files
until I found something odd: getSize() and DirEntry's .
On Tuesday, 15 August 2023 at 17:59:27 UTC, vino wrote:
Hi All,
Request your help in finding duplicate element without sorting
as per the below example
```
Example:
string[] args = [" test3", "test2 ", " test1 ", " test1 ", " "];
Output Required:
If duplicate element found then print "Dupli
On Tuesday, 15 August 2023 at 20:09:28 UTC, Joel wrote:
On Tuesday, 15 August 2023 at 16:54:49 UTC, FeepingCreature
wrote:
But does *not* import `std.ascii`! So there's no ambiguity
inside the `sort` string expression between the two `toLower`
functions..
How do I get it to work?
I
On Tuesday, 15 August 2023 at 16:47:36 UTC, Joel wrote:
How come toLower works in the sort quotes, but not in the map?
```d
void main() {
import std;
"EzraTezla"
.to!(char[])
.byCodeUnit
.sort!"a.toLower c.toLower)
.writeln;
}
```
When you pass a string t
On Thursday, 13 July 2023 at 11:55:17 UTC, Ki Rill wrote:
Why does the first example `class A` work, but the second one
with `class B` does not?
```D
class A {
immutable int a;
this(in int a) {
this.a = a;
}
}
class B {
immutable int[] b;
this(in int[] b) {
On Saturday, 8 July 2023 at 17:15:26 UTC, Cecil Ward wrote:
I have a dynamic array of dstrings and I’m spending dstrings to
it. At one point I need to append a zero-length string just to
increase the length of the array by one but I can’t have a slot
containing garbage. I thought about ++arr.le
On Monday, 3 July 2023 at 09:50:20 UTC, Arafel wrote:
Hi!
I am a D user coming from java, rather than from C/C++
(although obviously also have some exposure to them), and thus
apparently one of the few people here who likes OO (within
reason, of course).
So while I appreciate the fact that
On Monday, 3 July 2023 at 09:50:20 UTC, Arafel wrote:
Hi!
I am a D user coming from java, rather than from C/C++
(although obviously also have some exposure to them), and thus
apparently one of the few people here who likes OO (within
reason, of course).
So while I appreciate the fact that
On Friday, 30 June 2023 at 19:05:23 UTC, Cecil Ward wrote:
I have code roughly like the following:
dstring str = "name"d;
uint ordinal = (( str in Decls.ordinals ) !is null) ?
Decls.ordinals[ str ] : -1;
struct Decls
{
uint[ dstring] ordinals;
}
//and
Decls.ordinals[
On Friday, 23 June 2023 at 18:43:06 UTC, Steven Schveighoffer
wrote:
It should be a spec change. Change POD to say "type" instead of
"struct".
The goal of `isPOD` is to determine how careful generic code
needs to be to pass the type around, or copy it. Changing it to
false implies that it is
On Friday, 23 June 2023 at 14:22:24 UTC, DLearner wrote:
Hi
Was looking for compile-time detection of a struct variable.
However, the following test code gave the two 'FAILS' shown
below.
Comments?
```
void main() {
import std.stdio : writeln;
import std.traits;
string mxnTst(string
On Sunday, 18 June 2023 at 10:21:16 UTC, IchorDev wrote:
On Sunday, 18 June 2023 at 10:04:14 UTC, FeepingCreature wrote:
On Sunday, 18 June 2023 at 09:48:40 UTC, IchorDev wrote:
Does anyone understand why this happens?
Is there any way to subvert this behaviour, or is it actually
a bug?
Yes
On Sunday, 18 June 2023 at 09:48:40 UTC, IchorDev wrote:
Does anyone understand why this happens?
Is there any way to subvert this behaviour, or is it actually a
bug?
Yes, see also my bug report,
https://issues.dlang.org/show_bug.cgi?id=20008
"__traits(allMembers) of packages is complete non
On Wednesday, 5 April 2023 at 09:19:17 UTC, Alexander Zhirov
wrote:
How to compile the example given in the book correctly? When
compiling, an error occurs that the main function is missing.
If I replace `shared static this()` with `void main()', then
everything starts. What does the compilatio
On Wednesday, 8 March 2023 at 10:49:32 UTC, Markus wrote:
So, having no clue about D (just bought some books), I wanted
to ask if nice looking code can become slow, in general. In the
mentioned case it's just that I like the packaging of functions
into some sort of scope (OOP) versus the flat C
On Wednesday, 1 March 2023 at 09:37:48 UTC, rempas wrote:
Thank you! You are amazing for explaining it! I was so focused
on thinking that I'm doing something wrong with the type that I
didn't noticed that the pointers, points to nowhere so the
function obviously has nowhere to write to. Like...
On Wednesday, 1 March 2023 at 09:37:48 UTC, rempas wrote:
Thank you! You are amazing for explaining it! I was so focused
on thinking that I'm doing something wrong with the type that I
didn't noticed that the pointers, points to nowhere so the
function obviously has nowhere to write to. Like...
On Wednesday, 1 March 2023 at 08:26:07 UTC, FeepingCreature wrote:
```d
uint32_t[1] value;
value[0] = screen.black_pixel;
xcb_create_gc(connection, black, win, mask, value.ptr);
```
To expand on this:
```d
uint32_t[2] value;
uint32_t* value_ptr = value.ptr;
// We are allowed to access the
On Wednesday, 1 March 2023 at 08:12:05 UTC, rempas wrote:
I'm looking into
[this](https://www.x.org/releases/X11R7.7/doc/libxcb/tutorial/index.html) tutorial to learn XCB and I'm trying to write the code in D with betterC. In the section 9.1 (sorry, I cannot give a section link, the article does
On Monday, 20 February 2023 at 07:11:49 UTC, Mike Parker wrote:
On Monday, 20 February 2023 at 06:26:34 UTC, FeepingCreature
wrote:
There have now been three pages produced by three people all
agreeing with each other.
At what point does it start being spam?
Yes, it's all just nois
On Monday, 20 February 2023 at 05:21:44 UTC, forky wrote:
On Friday, 10 February 2023 at 07:04:31 UTC, Max Samukha wrote:
...
Having class-private doesn't preclude module-private. Dennis
even submitted a PR implementing class-private, but it stalled
because people couldn't agree on whether cl
On Thursday, 16 February 2023 at 02:27:23 UTC, Mike Parker wrote:
On Thursday, 16 February 2023 at 02:26:44 UTC, Mike Parker
wrote:
Wrong. I'm arguing things:
Geez. "I'm arguing 2 things:"
Springboarding off this post:
This thread is vastly dominated by some people who care very much
ab
On Tuesday, 22 November 2022 at 21:45:29 UTC, []() {}() wrote:
On Tuesday, 22 November 2022 at 21:00:58 UTC, []() {}() wrote:
"Being able to declare a “friend” that is somewhere in some
other file runs against notions of encapsulation." (This is the
motivation for that article it seems).
On Thursday, 17 November 2022 at 04:39:35 UTC, thebluepandabear
wrote:
I am creating a TUI library and I have a class with the
following constant fields:
```
class Label : Renderable {
const string text;
const TextAlignment textAlignment;
const Color color;
this(Dimensions dime
On Sunday, 7 August 2022 at 01:22:18 UTC, pascal111 wrote:
Why we use "chain" while we have "~":
'''D
int[] x=[1,2,3];
int[] y=[4,5,6];
auto z=chain(x,y);
auto j=x~y;
'''
Chain doesn't allocate any memory. This can be useful
occasionally.
On Sunday, 31 July 2022 at 07:43:06 UTC, Salih Dincer wrote:
Why are you using const for strings? After all, they are
protected by immutable. Moreover, since you do not use refs,
copies are taken in every function and also you have created
extra copy for results.
Note sure if I'm misunderst
On Wednesday, 25 August 2021 at 12:11:01 UTC, Johann Lermer wrote:
Hi all,
I have a little problem understanding alias this. I always
thought, that alias this only makes implicit conversions from
the aliased object to this. Then, why do lines 18 and 22
compile in the code below? And, btw, lin
On Sunday, 8 August 2021 at 11:30:41 UTC, james.p.leblanc wrote:
Hello,
With structs, I understand that "invariant checking" is called
(from dlang tour):
It's called after the constructor has run and before the
destructor is called.
It's called before entering a member function
On Tuesday, 18 May 2021 at 16:27:13 UTC, Alain De Vos wrote:
After each } i write a ;
And let the compiler tell me it is an empty instruction.
What are the general rules where ; is not needed after a }
Is `;` ever needed after a `}`?
I guess in `void delegate() dg = { writeln!"Hello World"; };
On Sunday, 18 April 2021 at 23:04:26 UTC, ShadoLight wrote:
On Wednesday, 14 April 2021 at 14:06:18 UTC, FeepingCreature
wrote:
On Wednesday, 14 April 2021 at 13:43:20 UTC, Berni44 wrote:
[..]
Covariance is related ...
[..]
The opposite (contravariance) happens ...
[..]
Nice answer
On Wednesday, 14 April 2021 at 13:43:20 UTC, Berni44 wrote:
I'm trying to understand, what virtual functions are. I found
the
[specs](https://dlang.org/spec/function.html#virtual-functions), but I can't make head or tail of it.
- What is a `vtbl[]`? Obviously a function pointer table. But
whe
On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote:
hi all,
If i have an array:
byte[3] = [1,2,3];
How to get string "123" from it?
Thanks in advance.
string str = format!"%(%s)"(array);
On Thursday, 25 February 2021 at 06:57:57 UTC, FeepingCreature
wrote:
On Thursday, 25 February 2021 at 06:47:11 UTC, Mike wrote:
hi all,
If i have an array:
byte[3] = [1,2,3];
How to get string "123" from it?
Thanks in advance.
string str = format!"%(%s)"(array);
On Sunday, 21 February 2021 at 18:07:49 UTC, JN wrote:
class Foo
{
}
void main()
{
Foo Foo = new Foo();
}
this kind of code compiles. Is this expected to compile?
Yes, why wouldn't it? main is a different scope than global; you
can override identifiers from global in main. And "Foo" only
On Wednesday, 27 January 2021 at 02:14:39 UTC, H. S. Teoh wrote:
Yes, definitely try this. This will completely eliminate the
overhead of using an AA, which has to allocate memory (at
least) once per entry added. Especially since the data has to
be sorted eventually anyway, you might as well
On Monday, 25 January 2021 at 11:15:28 UTC, frame wrote:
After a while my program crashes.
I'm inspecting in the debugger that some strings are
overwritten after a struct is assigned to an associative array.
- I have disabled the GC.
- All happens in the same thread.
- The strings belong to a
On Monday, 30 November 2020 at 14:33:22 UTC, realhet wrote:
Hi,
class A{
A parent;
A[] items;
void myDestroy(){
items.each!(i => i.myDestroy);
parent = null;
// after this point I think the GC will release it
automatically, and it will call ~this() too. Am I right?
}
}
I
On Wednesday, 19 August 2020 at 14:43:22 UTC, Victor Porton wrote:
On Wednesday, 19 August 2020 at 14:06:16 UTC, Victor Porton
wrote:
This declaration does compile:
enum x;
But what is it? Is it an equivalent of
enum x { }
?
What in the specification allows this looking a nonsense
enum x;
On Wednesday, 19 August 2020 at 14:06:16 UTC, Victor Porton wrote:
This declaration does compile:
enum x;
But what is it? Is it an equivalent of
enum x { }
?
What in the specification allows this looking a nonsense
enum x;
?
It's an enum type whose members we don't know.
So we can't dec
On Tuesday, 4 August 2020 at 17:36:53 UTC, Michael Reese wrote:
Thanks for suggesting! I tried, and the union works as well,
i.e. the function args are registered. But I noticed another
thing about all workarounds so far:
Even if calls are inlined and arguments end up on the stack,
the linker p
On Wednesday, 17 June 2020 at 12:39:11 UTC, FeepingCreature wrote:
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote:
Hi all! I have a programm in D (The simplest OS), which should
be compiled into .bin or .iso format to be possible to run it
on VirtualBox. How can I compile it to
On Wednesday, 17 June 2020 at 12:30:24 UTC, Quantium wrote:
Hi all! I have a programm in D (The simplest OS), which should
be compiled into .bin or .iso format to be possible to run it
on VirtualBox. How can I compile it to .bin / .iso format and
which compiler should I use?
Try this page? ht
On Tuesday, 2 June 2020 at 13:58:13 UTC, Bienlein wrote:
Because of the problems with checked exceptions they were
deliberately left out in C#. Here is an interview with Anders
Hejlsberg, the creator of C# at MS, where he explains the
reasons for this decision:
https://www.artima.com/intv/hand
On Monday, 17 February 2020 at 11:07:33 UTC, foozzer wrote:
Hi all,
There's something in Phobos for that?
Thank you
Here you go:
import std;
// extract the types that make up the tuple
auto transposeTuple(T : Tuple!Types[], Types...)(T tuples)
{
// templated function that extracts the i
On Monday, 20 January 2020 at 06:48:08 UTC, DanielG wrote:
I can't seem to figure out what dub's dustmite command is
looking for with its regexes. No matter what I try - no matter
how simple - the initial test fails.
I am able to run dustmite standalone just fine with the
following test scrip
On Monday, 29 July 2019 at 05:58:21 UTC, dmm wrote:
So, d try to be smart, only make thing worse?
D is behaving exactly as it should here. You simply have a wrong
model of what an array is in D.
In C++, an array owns its memory. In D, an array is a thin
wrapper around GC managed memory. As
On Sunday, 7 April 2019 at 03:47:25 UTC, Alex wrote:
rules are meant to be broken.
No they're not! Almost by definition not!
More comprehensively, if you break a rule you take responsibility
for the outcome. You wanna use stringof? "Don't use stringof for
that." "rules are meant to be broken
On Monday, 28 January 2019 at 15:16:54 UTC, Steven Schveighoffer
wrote:
It will inspect the allocated length from the GC if the array
is appendable from the beginning. So it's not always going to
reallocate.
e.g.:
string x = "abc".idup;
auto app = x.appender;
app ~= "xyz"; // does not reall
On Friday, 25 January 2019 at 14:33:16 UTC, Steven Schveighoffer
wrote:
On 1/25/19 3:20 AM, FeepingCreature wrote:
On Thursday, 24 January 2019 at 17:49:34 UTC, Ali Çehreli
wrote:
Aren't the semantics of .clear that it's invalid to access
references to .data after calling .clear, p
On Thursday, 24 January 2019 at 17:49:34 UTC, Ali Çehreli wrote:
On 01/24/2019 04:35 AM, FeepingCreature wrote:
> On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote:
>> On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper
wrote:
>>> Sorry if this is a stupid ques
On Tuesday, 27 March 2018 at 12:31:05 UTC, Simen Kjærås wrote:
On Tuesday, 27 March 2018 at 12:17:58 UTC, Ellie Harper wrote:
Sorry if this is a stupid question, but is there something
special required to call Appender.clear? When I attempt even
just a simple use I am getting compile errors re
On 21.04.2010 16:43, Ellery Newcomer wrote:
> On 04/21/2010 05:43 AM, FeepingCreature wrote:
>> On 20.04.2010 01:49, Ellery Newcomer wrote:
>>> Are there any good libraries for ctfe/code generation?
>>>
>>> I don't know, things like parsing support for co
On 20.04.2010 01:49, Ellery Newcomer wrote:
> Are there any good libraries for ctfe/code generation?
>
> I don't know, things like parsing support for compile time strings,
> string formatting, type <-> string
>
> My project seems to be growing ctfe, and it's all horribly hacky and
> ugly code.
On 24.02.2010 22:19, BCS wrote:
> Hello FeepingCreature,
>
>> On 24.02.2010 05:16, BCS wrote:
>>
>>> I need a function that works like the following:
>>>
>>>> T* New(T)() { return new T; }
>>>>
>>> But that also works with st
On 24.02.2010 05:16, BCS wrote:
> I need a function that works like the following:
>
>> T* New(T)() { return new T; }
>
> But that also works with static arrays:
>
>> auto i = New!(int)();
>> auto a = New!(int[27])();
>
> The cleanest solution I can think of is:
>
>> T* New(T)() { return (new
68 matches
Mail list logo