On Wednesday, 5 August 2020 at 06:02:58 UTC, cy wrote:
Some way to import the compiler itself, instead of calling it
in a subprocess?
Well, I did find this:
https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/
But it's pretty advanced... probably just invoking dmd w
I have used an if-else statement to create an alias to avoid code
duplication but it doesn't let me access it outside the if
statement. Is there a way to solve this?
On Wednesday, 5 August 2020 at 09:05:36 UTC, Flade wrote:
I have used an if-else statement to create an alias to avoid
code duplication but it doesn't let me access it outside the if
statement. Is there a way to solve this?
You're probably looking for static if:
static if (useAlias) {
On Wednesday, 5 August 2020 at 09:25:23 UTC, Simen Kjærås wrote:
On Wednesday, 5 August 2020 at 09:05:36 UTC, Flade wrote:
I have used an if-else statement to create an alias to avoid
code duplication but it doesn't let me access it outside the
if statement. Is there a way to solve this?
You'
On Wednesday, 5 August 2020 at 09:32:58 UTC, Flade wrote:
Thanks! You see it should work but the thing is. I'm using it
inside a function. I'm checking for one of the function's
parameter (if parameter == false) and it says that "the
variable `parameter` cannot be read at compile time. Do you
On Wednesday, 5 August 2020 at 09:39:47 UTC, Simen Kjærås wrote:
On Wednesday, 5 August 2020 at 09:32:58 UTC, Flade wrote:
Thanks! You see it should work but the thing is. I'm using it
inside a function. I'm checking for one of the function's
parameter (if parameter == false) and it says that "
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
```
C:\dev> rdmd -m64 --eval="import core.stdc.time;
writeln(time_t.sizeof);"
4
```
According to MSDN this should not be the case:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-2019
time is a wrapper for _time64 and **time_t is, by default,
equiv
On Wednesday, 5 August 2020 at 16:13:19 UTC, Andrej Mitrovic
wrote:
```
C:\dev> rdmd -m64 --eval="import core.stdc.time;
writeln(time_t.sizeof);"
4
```
According to MSDN this should not be the case:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64?view=vs-20
On Wed, Aug 05, 2020 at 06:02:58AM +, cy via Digitalmars-d-learn wrote:
> D's compile-time-execution is fantastic, but there are some times when
> I'd like to examine the generated code, or produce code that needs to
> pass through earlier phases before CTFE, or do AST stuff. Sometimes I
> simp
Hello.
I'm starting to use D, and therefore Dub.
I didn't find a more suitable category than this one in the forum
to ask my question, I'm sorry if it is not the most suitable.
My concern is thus the following: I can't add packages to my
project, Dub warns me that they are not available.
For
In my efforts to learn D I am writing some code to read files in
different UTF encodings with the aim of having them end up as
UTF-8 internally. As a start I have the following code:
import std.stdio;
import std.file;
void main(string[] args)
{
if (args.length == 2)
{
if (args[
On 2020-08-05 09:57, cy wrote:
Well, I did find this:
https://dlang.org/blog/2017/08/01/a-dub-case-study-compiling-dmd-as-a-library/
That is more for using the frontend, not the backend for generating code.
But it's pretty advanced... probably just invoking dmd would be good...
You can st
Is it possible to implement
template maxSizeOf(T...)
{
static if (T.length == 1)
enum size_t maxSizeOf = T[0].sizeof;
else
{
enum size_t firstSize = T[0].sizeof;
enum size_t maxSizeRest = maxSizeOf!(T[1 .. $]);
enum size_t maxSizeOf = firstSize >= maxSi
When to use core.thread and when std.concurrency for
multithreading in applications? Is one of them a preferred way?
On Thursday, 6 August 2020 at 00:58:39 UTC, Per Nordlöw wrote:
Is it possible to implement
in a non-recursive way?
It is very easy too... just write an ordinary function:
size_t maxSizeOf(T...)() {
size_t max = 0;
foreach(t; T)
if(t.sizeof > max)
On 8/5/20 5:58 PM, Per Nordlöw wrote:
Is it possible to implement
template maxSizeOf(T...)
{
static if (T.length == 1)
enum size_t maxSizeOf = T[0].sizeof;
else
{
enum size_t firstSize = T[0].sizeof;
enum size_t maxSizeRest = maxSizeOf!(T[1 .. $]);
On Thursday, 6 August 2020 at 01:13:41 UTC, Adam D. Ruppe wrote:
size_t maxSizeOf(T...)() {
size_t max = 0;
foreach(t; T)
if(t.sizeof > max)
max = t.sizeof;
return max;
}
pragma(msg, maxSizeOf!(int, char, long));
more love for pho
On Thursday, 6 August 2020 at 01:13:28 UTC, Ali Çehreli wrote:
Boring in D. :p
template maxSizeOf(T...) {
enum maxSizeOf = compute();
auto compute() {
size_t result;
static foreach (t; T) {
if (t.sizeof > result) {
result = t.sizeof;
}
}
return result;
On Thursday, 6 August 2020 at 01:13:41 UTC, Adam D. Ruppe wrote:
It is very easy too... just write an ordinary function:
size_t maxSizeOf(T...)() {
size_t max = 0;
foreach(t; T)
if(t.sizeof > max)
max = t.sizeof;
return max;
}
prag
On Thursday, 6 August 2020 at 01:17:51 UTC, lithium iodate wrote:
more love for phobos pls
template maxSizeOf(T...)
{
template sizeOf(T) { // doesn't exist in phobos?
enum sizeOf = T.sizeof;
}
enum size_t maxSizeOf = maxElement([staticMap!(sizeOf, T)]);
}
`std.meta.staticMa
On Thursday, 6 August 2020 at 01:17:51 UTC, lithium iodate wrote:
more love for phobos pls
That would add a lot to the cost and bring no real benefit
On Thursday, 6 August 2020 at 01:23:33 UTC, Per Nordlöw wrote:
How does the memory usage and speed of this code compare to the
variant that uses template instantiations?
I haven't tested this specifically, but similar tests have come
in at like 1/10th the memory and compile time cost.
There
23 matches
Mail list logo