On 6/5/22 04:43, kdevel wrote:
> On Sunday, 5 June 2022 at 00:40:26 UTC, Ali Çehreli wrote:
> [...]
>> Errors are thrown when the program is discovered to be in an invalid
>> state.
>
> The following program throws an `Error` in popFront:
>
> import std.range;
>
> void main ()
> {
>
On 6/5/22 08:07, kdevel wrote:
> On Sunday, 5 June 2022 at 14:24:39 UTC, Ali Çehreli wrote:
> [...]
>> struct S {
>> int[] a;
>> int[] b;
>>
>> void add(int i) {// <-- Both arrays always same size
>> a ~= i;
>> b ~= i * 10;
>> }
>>
>> void foo() {
>> assert(a.length == b.
On 6/5/22 11:03, kdevel wrote:
> On Sunday, 5 June 2022 at 17:04:49 UTC, Ali Çehreli wrote:
>> On 6/5/22 08:07, kdevel wrote:
> [...]
>> Like many other programmers who include me, Sean Parent may be right.[1]
>>
>> Other than being a trivial example to make a point, the code I've
>> shown may be
On 6/5/22 14:04, Alain De Vos wrote:
> Could it be the copy constructor is only called during assignments (like
> C++).
The assignment operator is used during assignments both in C++ and D.
A confusion comes from the fact that construction uses the same operator
as assignment:
a = b; // As
On 6/5/22 12:00, Salih Dincer wrote:
> On Sunday, 5 June 2022 at 18:43:19 UTC, Alain De Vos wrote:
>> Does Foo(3) lives on the stack or the heap ?
I depends. I will respond to your other message.
> Definitely not stack because that's what happens when the new operator
> is used. Article 14.3: ht
On 6/5/22 11:43, Alain De Vos wrote:
> Does Foo(3) lives on the stack or the heap ?
It depends.
> there is a
> conversion.
Suche conversions are called "construction" in D.
> And what happes with
> Foo[3] arr = [one, two, Foo(3)];
Foo[3] is a static array. Static arrays are value types. Thei
On 6/5/22 14:39, Ali Çehreli wrote:
> Actually, both are copy construction:
I am wrong there. I did confuse myself.
>Foo one = Foo(1), two = 2;
As my rewrite shows, they are both construction with an int:
>auto one = Foo(1);
>auto two = Foo(2);
Ali
On 6/5/22 14:57, Ali Çehreli wrote:
> struct Foo {
>Foo dup() {
> auto result = Foo(this.payload);
> // ...
> return result;
>}
> }
>
> In that case, the "named return value optimization" (NRVO) would be
> applied and the object would still be moved to 'x'.
I am wrong ther
On 6/6/22 17:04, arandomonlooker wrote:
> I usually transcribe them as follows, because the previous syntax causes
> a compiler error:
>
> ```d
> int numbersINeed[] = [1, 2, 3, 4, 5];
> ```
As you already know, the correct syntax is 'int[]' :) but it won't work
because -betterC cannot support d
On 6/7/22 12:58, frame wrote:
> ```d
> bool fun() {
> scope(failure) {
> // do something
> return false;
> }
>
> badCode();
> return true;
> }
> ```
>
> I know this is bad as I'm capturing a possible error here - but this is
> what an unexperienced code
On 6/7/22 16:38, arandomonlooker wrote:
There is any chance size inference is going to be implemented into D as
a feature?
Do I remember correctly that there were syntax proposals that used $ or _?
int[$] arr = [ 1, 2 ];
int[_] arr = [ 1, 2 ];
But I can't find past discussions about that
On 6/10/22 01:08, Chris Katko wrote:
> Is it somehow possible to use a struct as a [multidimensional] array
index:
You can define an opIndex that takes any index type if the array is
defined by you:
import std.stdio;
import std.format;
struct indexedPair {
size_t x, y;
}
struct MyArray {
On 6/10/22 07:38, Ali Çehreli wrote:
> I played with that toString function but for some reason it prints all
> Ts. (?)
Fixed it by changing one of the lambdas to take by reference:
void toString(scope void delegate(in char[]) sink) const {
import std.algorithm;
sink.formattedWrite!"%
I know static arrays are not ranges but somehow they work with 'each'.
With map, I need to slice as 'arr[]':
import std;
void main() {
int[3] arr;
arr.each!(e => e);// Compiles
// arr.map!(e => e); // Fails to compile
arr[].map!(e => e); // Compiles
}
Why the inconsistency?
Al
On 6/10/22 08:01, Ali Çehreli wrote:
> I still don't understand the reason though. The rows would be copied
> without ref but should retain their type as bool[3], a static array. (?)
Ok, now I see the very sinister problem: It is a disaster to combine
static array lambda parameters with the laz
On 6/10/22 08:13, z wrote:
> arrays of arrays has different order for declaration and addressing,
> and declaring array of arrays has different order depending on how you
> declare it and wether it's static or dynamic array, *oof*)
>
> To give you an idea of the situation :
> ```D
> int[3][1
On 6/10/22 10:22, Antonio wrote:
> Is there any alternative to ***range front*** that returns a Nullable
> (i.e. **frontAsMonad** or **frontAsNullable**)?
import std;
// Spelling? :)
auto nullablelize(R)(R range) {
alias E = Nullable!(ElementType!R);
struct Nullablelize {
enum empty = f
On 6/10/22 10:37, Chris Katko wrote:
> I want to pipe in string data to a shell/commandline program, then
> retrieve the output. But the documentation I read appears to only show
> usage for 'Files' for stdin/stdout/stderr.
>
> ala something like this:
> D
> string input = "hello\nworld";
> st
On 6/10/22 10:40, Ali Çehreli wrote:
>https://dlang.org/library/std/process/pipe_process.html
I realized you may be happier with the following if all you need is stdout:
https://dlang.org/library/std/process/execute.html
https://dlang.org/library/std/process/execute_shell.html
Ali
On 6/10/22 13:47, Steven Schveighoffer wrote:
> `map` calls the lambda for each call to `front`. If you want a cached
> version, use `cache`:
Others don't know but as I will likely show during a lightning talk at
DConf, I am trying to finish a .cached range algorithm that caches all
elements t
On 6/11/22 04:16, Salih Dincer wrote:
> I think D is very consistent with our feelings. That is, the order in
> memory is in the form of rows x columns.
Yet, there are no rows or columns because neither D nor C (nor C++) have
multip-dimensional arrays. They all have arrays where elements are la
On 6/11/22 00:09, z wrote:
> I rechecked and it should be `X Y Z` for static array, but `Z Y X` for
> indexing/dynamic array creating with `new`
How so? I wrote the following program:
import std.stdio;
void main() {
enum X = 2;
enum Y = 3;
enum Z = 4;
int[X][Y][Z] s;
int[X][Y][] d =
On 6/11/22 13:36, z wrote:
> i meant with the syntax in (1), the spec's documentation appears to say
> they are equivalent in result with `new *type*[X][Y]` form.
>
> (1) https://dlang.org/spec/expression#new_multidimensional (3. multiple
> argument form)
Thank you. I see now: The values in pare
On 6/14/22 02:04, bauss wrote:
> You have to do it like this:
>
> ```
> dgs ~= ( (n) => () { writeln(n); })(i);
> ```
The same thing with a named function as well as with iota():
import std.range;
import std.algorithm;
import std.stdio;
void main() {
void delegate()[] dgs;
auto makeDg(int
On 6/15/22 10:37, Templated Person wrote:
> It there any resources on how to build D static (`.lib` / `.a`) and
> dynamic libraries (`.dll` / `.so`), and then use them from C?
>
> Do I need to link and initialize phobos somehow?
Not Phobos but the D runtime.
> What if I don't want to
> use the D
On 6/16/22 00:58, Salih Dincer wrote:
> I guess the developed cached() and cache() are different things,
> right?
cache caches only the front element.
https://dlang.org/library/std/algorithm/iteration/cache.html
> I tried cached()
cached() is supposed to cache as many elements as needed as
On 6/16/22 09:07, Sergeant wrote:
> May I ask one more question: why a code like this would work in
> D-application but not in D-DLL?
D programs generated by D compilers automatically initialize the D
runtime. You can do the same with rt_init:
pragma (crt_constructor)
extern(C) int initialize
On 6/16/22 09:32, Adam D Ruppe wrote:
> This is why an explicit initialization call is the preferred method -
> there, the time it is called is well-defined by the user after initial
> loading is complete.
Agreed but that excludes using the D runtime in 'static this' (and
shared) blocks, right?
On 6/17/22 10:04, Salih Dincer wrote:
> Isn't foo and bar the same thing? I don't understand what's the
> difference!
>auto foo = to!Foo("123"); //??
>auto bar = Foo("321");
Yes, they are the same thing.
The OP was looking for a generic way of converting any type to any other
type a
On 6/19/22 15:52, Gary Chike wrote:
> On Saturday, 24 April 2021 at 22:13:45 UTC, Ali Çehreli wrote:
>> On 4/24/21 7:46 AM, PinDPlugga wrote:
>> ...
>> As a general solution, you can use a function like this:
>>
>> auto readLine(S = string)(File file = stdin) {
>> while (!file.eof) {
>> auto
On 6/20/22 07:00, Gary Chike wrote:
> Would it be appropriate to forego `readf`
> and read input as a string using `readln` ,benefiting from the `strip`
> function, then convert to their appropriate datatype
Makes sense. The following are related as well:
https://dlang.org/library/std/conv/pa
On 6/21/22 10:09, JG wrote:
Suppose we are often writing something like
```d
theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]=x;
```
One would like to something like
```d
alias shortName =
theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[th
On 7/1/22 12:11, Vinod KC wrote:
The following function is dimedll.testFunc:
> ```d
> module dimedll;
// ...
> export void testFunc() {
> writeln("This is from dll");
> }
> ```
We suspect the name of the file that defines main() is dime.d.
> extern void testFunc();
That symbol belongs to
On 7/5/22 17:14, Gary Chike wrote:
> So, in order to use `parse!int()`, I would need to separate it into two
> statements with a variable acting as an intermediary:
> ```
> auto input = readln();
> auto age = parse!int(input);
Exactly. parse takes the input by reference (necessitating an lvalue)
On 7/6/22 02:26, Bagomot wrote:
> 1) How to make asynchronous HTTP requests with curl in order to receive
> progress and status? And how do you know that the request is completed?
I don't know how dlangui or others automate this but I had fun writing
the following program that uses std.concurre
On 7/6/22 16:17, Ali Çehreli wrote:
> I would consider std.parallelism
And it looks more natural with a std.parallelism.Task:
struct Progress {
size_t percent_;
void set(size_t downloaded, size_t total) {
if (total != 0) {
import core.atomic: atomicStore;
const value = cas
On 7/8/22 06:32, Bagomot wrote:
> I do as in Ali's example, but
> the GUI is still blocked:
I don't know exactly why but something looks suspicious.
> ```d
> auto btn = new Button("Run"d);
> btn.click = delegate(Widget src) {
> auto request = Request("dlang.org");
That is a local variable
On 7/12/22 06:34, rempas wrote:
>static if (is(typeof(obj) == Test)) { printf("YES!!!\n"); }
An alternative:
import std.traits;
static if (isInstanceOf!(Test, typeof(obj))) { printf("YES!!!\n"); }
https://dlang.org/phobos/std_traits.html#isInstanceOf
Ali
On 7/12/22 10:11, Steven Schveighoffer wrote:
> The algorithm to compare *any* arrays is first verify the lengths are
> the same. Then for each element in the array, compare them. Since there
> are 0 elements in both the empty string and the null string, they are
> equal.
Checking .empty() cover
On 7/12/22 11:47, Bagomot wrote:
> I now have a couple more questions about `Task`:
> 1) How to run a non-static class method through `task`?
> 2) How to use `taskPool` to run a series of tasks of the same type (from
> question 1)?
As a friendly reminder, these questions could be more useful in
On 7/13/22 02:25, Bagomot wrote:
> How to do the same with `taskPool` instead of `spawnLinked`?
You are hitting the nail on the head. :) std.parallelism, which taskPool
is a concept of, is for cases where operations are independent.
However, producer and consumer are by definition dependent,
On 7/26/22 16:43, pascal111 wrote:
> In next example code, it used user-made exception,
I am not sure I understand you correctly because the program you show
throws Exception, which is not user-made at all.
If you want to throw a particual exception that you define, you need to
inherit that t
On 7/27/22 04:00, pascal111 wrote:
I noticed more than once that the exclamation "!" is used within
functions typing, and it seems like an operator with new use, for
example "to!int()", ".tee!(l => sum += l.length)",
"enforce!MissingArguments...", so what dose it means?
The binary ! operato
On 8/1/22 15:47, Steven Schveighoffer wrote:
You beat me to it. I used .object and .str:
import std;
void main()
{
JSONValue data = parseJSON(`{ "name": "Hype Editor", "hobby":
"Programming" }`);
writefln("%s", data);
// This already sees the data as an AA but the type is
JSONVa
On 8/4/22 00:57, pascal111 wrote:
> I don't see my post.
Some posts are blocked by the spam filter. (Apparently, your message did
not have a sender name and cannot be passed because of that.)
Ali
On 8/4/22 06:08, pascal111 wrote:
> In next code from
> "https://www.tutorialspoint.com/d_programming/d_programming_ranges.htm";,
That page seems to be adapted from this original:
http://ddili.org/ders/d.en/ranges.html
> we have two issues:
>
> 1) Why the programmer needs to program "empty()"
On 8/4/22 11:05, frame wrote:
> `popFront()`
The function was this:
void popFront() {
students = students[1 .. $];
}
> copies all
> elements except the first one into the variable (and overwrites it), so
> it moves the data forward.
That would be very slow. :) What act
On 8/5/22 01:59, frame wrote:
> On Thursday, 4 August 2022 at 22:14:26 UTC, Ali Çehreli wrote:
>
>> No element is copied or moved. :)
>>
>> Ali
>
> I know that :)
And I know that. :) We don't know who else is reading these threads, so
I didn't want to give wrong impression.
Copying would happe
On 8/6/22 09:33, Salih Dincer wrote:
> the slices feel like ranges, don't they?
Yes because they are ranges. :) (Maybe you meant they don't have range
member functions, which is true.)
D's slices happen to be the most capable range kind: RandonAccessRange.
All of the following operations are
On 8/6/22 14:10, pascal111 wrote:
> the problem is that ranges in D lack the usage of pointers as
> an essential tool to make all of ranges functions they need. If ranges
> exist in C, they would use pointers, and this is
There are a few cases where pointers provide functionality that ranges
ca
On 8/7/22 08:34, pascal111 wrote:
> Everyone knows that slices are not pointers
D's slices are "fat pointers": In D's case, that translates to a pointer
plus length.
> that pointers are real work,
Agreed. Pointers are fundamental features of CPUs.
> but slices are like a simple un-deep tech
On 8/6/22 22:58, Salih Dincer wrote:
> Ranges are not like that, all they do is
> generate.
You may be right. I've never seen it that way.
I've been under the following impression:
- C++'s iterators are based on an existing concept: pointers. Pointers
are iterators.
- D's ranges are based o
On 8/7/22 22:38, rempas wrote:
> I want to create it and be able to successfully initialize the template
> parameters
> of the constructor but until now, I wasn't able to find a way to
> successfully do
> that.
The following method uses a convenience function but it's not really needed:
import
On 8/8/22 00:14, vc wrote:
> i will like to hear thoughts even if it works
> for me
__gshared would work as well but I would consider std.concurrency first.
Just a simple example:
import std.stdio;
import std.concurrency;
import core.thread;
struct Result {
int value;
}
struct Done {
}
v
Here is another one that uses nested templates:
import std.stdio;
template TestArray(ulong element_n) {
struct TestArrayImpl(Type) {
int[element_n] elements;
this(ulong number) {
pragma(msg, "The type is: ", Type);
writeln("Constructing with ", number);
}
}
auto m
On 8/6/22 18:22, 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;
> '''
To add to what has already mentioned,
- chain can be used on ranges that are of different element types
- as usual, some of the ran
On 7/22/22 09:50, Ben Jones wrote:
> any problems with the GC?
The slides don't seem to mention the GC but Amaury Séchet had given a
presentation on bit packing:
http://dconf.org/2016/talks/sechet.html
Ali
On 7/25/22 06:51, ryuukk_ wrote:
> On Monday, 25 July 2022 at 11:14:56 UTC, pascal111 wrote:
>> const(char)[] ch1 = "Hello World!";
>> char[] ch2="Hello World!".dup;
[...]
> `ch1`is a string literal, just like in C, it is null terminated
To be pedantic, ch1 is not the string li
On 8/2/22 09:40, pascal111 wrote:
> Maybe I'd wrong beliefs about lambda function. It's already in C++, so
> it's a traditional feature
Lambdas are a common feature of many programming languages. C++ got
lambdas in their C++11 release, many years after D and many other
languages had them. (It
On 8/2/22 05:39, pascal111 wrote:
> I'm still stuck. Do you have a
> down-to-earth example for beginners to understand this concept?
I will refer to my explanation because down-to-earth has always been my
goal. I hope i succeeded:
http://ddili.org/ders/d.en/templates_more.html#ix_templates_m
On 8/9/22 17:03, pascal111 wrote:
> They said " If at least one of the arguments is NaN, the result is an
> unspecified value.
That's called "unorderedness":
http://ddili.org/ders/d.en/floating_point.html#ix_floating_point.unordered
> as a beginner how can I guess what "NaNs"
> means or if it
On 8/13/22 15:59, kdevel wrote:
> Quote from `src/druntime/src`:
>
> ```
> /**
> * Returns:
> * A reference to the _next error in the list. This is used when
a new
> * $(D Throwable) is thrown from inside a $(D catch) block. The
> originally
> * caught $(D Exception)
On 8/14/22 18:47, johntp wrote:
> I'm using DMD64 D Compiler v2.100.0 on linux mint.
Same version here.
> I copied the author's
> solution and got the same thing.
Wow! Are people actually working on those? :)
At first, I couldn't even get the code to compile due to
const-correctness issues wi
On 8/14/22 19:23, Ali Çehreli wrote:
> // BUG DUE TO WISHFUL THINKING:
> override size_t toHash() const {
>/* Since the 'points' member is an array, we can take
> * advantage of the existing toHash algorithm for
> * array types. */
>return typeid(points).
Related to my DConf 2022 lightning talk, I am noticing that D runtime's
in-place array extension optimization is available only for array data
that are at certain memory alignments.
I used the following program to test it. In addition to repeatedly
adding an element to an array,
- 'version =
Thank you for the quick response.
On 8/16/22 12:31, Steven Schveighoffer wrote:
> On 8/16/22 2:11 PM, Ali Çehreli wrote:
>> Related to my DConf 2022 lightning talk, I am noticing that D
>> runtime's in-place array extension optimization is available only for
>> array data that are at certain memo
On 8/17/22 09:28, Diego wrote:
> I'm writing a little terminal tool, so i think `-betterC` is the best
> and simple solution in my case.
It depends on what you mean with terminal tool bun in general, no, full
features of D is the most useful option.
I've written a family of programs that woul
On 8/16/22 19:33, Steven Schveighoffer wrote:
> Everything in the memory allocator is in terms of pages. A pool is a
> section of pages. The large blocks are a *multiple* of pages, whereas
> the small blocks are pages that are *divided* into same-sized chunks.
Thank you. I am appreciating this d
On 8/17/22 18:31, Steven Schveighoffer wrote:
> 1. I highly recommend trying out the ring buffer solution to see if it
> helps. The disadvantage here is that you need to tie up at least a page
> of memory.
I started to think holding on to multiple pages of memory should not
matter anyway. If re
On 8/17/22 19:27, Steven Schveighoffer wrote:
> On 8/17/22 10:09 PM, Ali Çehreli wrote:
>> > IIRC, your data does not need to be sequential in *physical memory*,
>> > which means you can use a ring buffer that is segmented instead of
>> > virtually mapped, and that can be of any size.
>>
>> I t
On 8/18/22 18:49, Shriramana Sharma wrote:
> Hello. I want to parallelize a computation which has two for loops
An option is to add tasks individually but I am not sure how wise doing
this and I don't know how to determine whether all tasks are completed.
In any case, Roy Margalit's DConf 2022
On 8/21/22 21:39, Andrey Zherikov wrote:
> alias type = typeof(U().func!0);
> pragma(msg, type); // pure nothrow @nogc ref @safe U()
> return
This is where the @property keyword makes a difference:
@property auto ref func(int i)() { return this; }
Now U().func!0
On 8/22/22 09:36, realhet wrote:
> It gives the protection I was needed but is it possible to make this
> prettier?
> auto allParents(){
>struct ParentRange{
> A act;
> @property bool empty() const{ return act is null; }
> @property A front() { return act;
On the main forum, Paul Backus proposed a nested function as well as a
scoped lock.
On 8/26/22 10:13, mw wrote:
>Object lock = (a particular condition) ? realLock : null;
And I want to point out that "a particular condition" must not change
between the check above and the following synchr
On 8/31/22 07:34, musculus wrote:
> Hi. I have an array of tuples that I would like to convert to an array
> of arrays.
I misunderstood as well and wrote the following program which makes
separate arrays. You can make an array of arrays from those with the
following syntax:
auto arrayOfArra
On 9/2/22 11:35, Svyat wrote:
> Time time = 360;
It seems to be more idiomatic to write it like this:
auto time = Time(360);
Or const, immutable, etc.
const time = Time(360); // Now un-assignable
But you would get the same compilation error. So, one way to work with
it is to us
I forgot to say that you don't need to write a constructor for most
structs because Time's constructor-generated default constructor works
like yours and with default arguments:
struct Time {
public int hours, minutes, seconds;
// No constructor needed here.
// Note 'return this;' as th
On 9/3/22 07:25, Steven Schveighoffer wrote:
> There is probably a bug in generate when the element type is an `enum`
> which somehow makes it const.
Yes, Generator is missing an Unqual:
https://issues.dlang.org/show_bug.cgi?id=23319
Salih had asked:
>> Can we solve this issue with our own
On 9/3/22 14:18, Salih Dincer wrote:
>uniform!"[]"(DNA.min, DNA.max);
Even cleaner:
uniform!DNA()
:)
Ali
Let's say I have three modules that work together, which I want to
register on dub: A, B, and C.
Although the most interesting one is C and A and B are used in its
implementation, A and B can be registered individually as well and be
used as C's dependencies.
I know package-less modules are
On 9/3/22 20:04, rikki cattermole wrote:
> This slightly smells, single module dub packages.
>
> What does each module do?
The other issue is NIH because some of their functionality already
exists. :/
A: Block of elements
B: Expanding circular buffer
C: Cache of elements
I would like to reg
On 9/3/22 20:39, Ali Çehreli wrote:
For example, there is fixedsizearray, which does not belong to any package:
https://code.dlang.org/packages/fixedsizearray
On the other hand, arsd-official:minigui does have a package. (And that
answers a question: Dash character is acceptable in package a
The program output is different whether an Error is thrown from main or
from the unittest block:
void foo(string s)
in (s != "hello") {
}
unittest {
foo("hello"); // No stack backtrace
}
void main() {
foo("hello"); // Yes stack backtrace
}
Ali
On 9/4/22 09:35, Paul Backus wrote:
// TODO: omit stack trace only if assert was thrown
// directly by the unittest.
Thank you but I mean... :) I can understand removing a backtrace from
the eyes of an end user but the consumer of a unittest output is a
developer, no?
Ali
On 9/5/22 01:58, anonymouse wrote:
> array [1.7, 3.7, 5.7, 7.7, 9.7] in both cases, which is what is being
> asserted by those two lines.
None of those values can be represented precisely in a floating point
type. Without looking at the code, I wonder whether the tests will pass
if you can man
On 9/7/22 16:24, Synopsis wrote:
> a- What is the difference with this syntax with the exclamation mark?
> ```readf!"%s\n"(f1.num);```
That's the templated version, which is safer because it checks at
compile time (important distinction) that the arguments and the format
specifiers do match.
I am sure nothing is new here and I may have thought of this before but
it was a revelation today. :)
I've been trying to come up with a way of storing arbitrary number of
objects of arbitrary types, which means I would be using a ubyte array.
But then how do I use the data later without need
On 9/8/22 08:02, Paul Backus wrote:
> This is actually pretty much exactly what VariantN does
Great information, thanks! I am slowly getting up there. :)
Ali
On 9/9/22 07:35, Andrey Zherikov wrote:
> might not compile due to many different reasons
I faced a related situation recently: My error string generation was
buggy, which taught me that the compiler does not even compile the
string part of 'static assert' in the 'true' case.
The following p
On 9/9/22 10:35, Dennis wrote:
> On Friday, 9 September 2022 at 16:41:54 UTC, Andrey Zherikov wrote:
>> What's about new `compileOutput` trait that returns compiler output?
>> ```d
>> static assert(__traits(compileOutput, { }) == "message");
>> ```
>
> As a compiler dev, that sounds terrifying. I
On 9/10/22 09:33, Erdem Demir wrote:
> DListOfA returnVal = temp.require("a", DListOfA());--> I wish I
> could use ref DListOfA here
But keeping a reference to a temporary would not work because the life
of that temporary ends by the end of that expression (practically, at
the semicol
On 9/10/22 13:04, Daniel Donnell wrote:
> https://dlang.org/spec/cpp_interface.html
At DConf, Manu indicated that that page is outdated and that D's C++
support is actually a lot better. He kind-of-promised to update that
page but I doubt it happened yet if ever. :)
> one has to be compiled b
On 9/10/22 15:35, jwatson-CO-edu wrote:
> So, my solution
> will be to construct a catch-all struct `Payload` and have that be my
> argument type from which various functions can draw the data of their
> choice.
Two Phobos features may be helpful there:
https://dlang.org/phobos/std_sumtype.ht
On 9/11/22 02:54, Injeckt wrote:
> And what I should do to pass non-static function?
You can combine your class object with other arguments and your thread
function will know how to unwrap your class object to call its member
function:
import std.stdio;
// I am not on Windows, so I am makin
On 9/11/22 09:26, Ali Çehreli wrote:
// This combines a class instance (which is a pointer behind the scene)
// Combine with the class object
In both places I meant "class variable".
Ali
The following range Foo is trying to be helpful by adding as many
attributes as it can ('const' is missing because ranges cannot be
'const' because at least popFront() needs to be mutable):
import std.algorithm;
struct Foo(R) {
R r;
int i;
bool empty() @nogc nothrow pure @safe sco
On 9/12/22 09:48, H. S. Teoh wrote:
>> @nogc nothrow pure @safe
>> unittest
>> {
>> // ...
>> }
>>
>> No, it isn't because unless my unittest code is impure, I can't catch
>> my incorrect 'pure' etc. on my member functions.
> [...]
>
> Sure you can. The `pure unittest` code obviously must i
On 9/12/22 10:29, H. S. Teoh wrote:
write a unittest where you instantiate Foo with a
deliberately-impure type
Yes. A current on-topic thread on the difficulties of covering all
corner cases:
https://forum.dlang.org/thread/dmnfdqiplbldxkecp...@forum.dlang.org
Ali
On 9/12/22 11:29, Steven Schveighoffer wrote:
> So you are thinking about this the wrong way I believe.
Clearly.
> When you put `pure` on a template function, you are saying "only
> instantiations where this function can be pure are allowed".
Makes sense. I was trying to put as many attributes
On 9/12/22 09:39, Paul Backus wrote:
> Yes. Except for `@trusted`, explicit attributes on template code are a
> smell.
Except for 'const' as well because some templates are member functions.
And 'const' on a member function cannot be left to inference because it
happens to be a part of the typ
101 - 200 of 2571 matches
Mail list logo