On Friday, 26 April 2024 at 13:25:34 UTC, Salih Dincer wrote:
You have a 5-item data tuples as Tuple(1, 2, 3, [1, 3], 5) and
implement the sum (total = 15) with the least codes using the
sum() function of the language you are coding...
Let's start with D:
Here's [STYX](https://gitlab.com/st
question in the header, code in the body, execute on a X86 or
X86_64 CPU
```d
module test;
void setIt(ref bool b) @safe
{
b = false;
}
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actu
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
you have violated the language's safety invariants.
ah mais non.
On Wednesday, 5 June 2024 at 01:18:06 UTC, Paul Backus wrote:
On Tuesday, 4 June 2024 at 16:58:50 UTC, Basile B. wrote:
```d
void main(string[] args)
{
ushort a = 0b;
bool* b = cast(bool*)&a;
setIt(*b);
assert(a == 0b); // what actually happens
On Saturday, 8 June 2024 at 02:22:00 UTC, Xiaochao Yan wrote:
Hi, I am new to D and is experimenting with game development
using D and C.
I had some problem when trying to recreate the
https://dlang.org/spec/importc.html
[...]
Thanks in advance!
on a recent compiler this should work:
```d
On Tuesday, 18 June 2024 at 23:07:47 UTC, Murilo wrote:
I've created a software which performs the Fermat's Primality
Test, however if I input a very big number it causes an error
saying "Illegal instruction (core dumped)". Does anyone know
why?
I've used GDB and here is the message:
Program
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote:
[...]
My question is can I initialize structs like these in one line
without relying on a second line? My usecase scenario doesn't
really allow constructors for the struct, since it's a binding
to an external library via C API.
On Sunday, 30 June 2024 at 11:23:45 UTC, Nick Treleaven wrote:
On Saturday, 29 June 2024 at 23:33:41 UTC, solidstate1991 wrote:
S foo0 = S(TypeEnum.Integer32, S(20)); //Ugly, but works
S foo1 = S(TypeEnum.Integer64, S(20L)); //Error: cannot
Did you mean `U(20)`? The 20 applies to the first fi
On Saturday, 10 August 2024 at 07:46:46 UTC, Vitaliy Fadeev wrote:
## Trouble 1
Pass the structure through registers ?
[...]
How to implement on D?
You dont need to pass whole event. The obvious design for this
kind of things is that you declare a local event that's an union
of all possibl
On Tuesday, 10 May 2022 at 16:10:26 UTC, Ben Jones wrote:
On Tuesday, 10 May 2022 at 16:05:15 UTC, H. S. Teoh wrote:
Using wrapper structs, etc., for this is IMO total overkill.
Just use an enum for your token types. Something like this
would suffice:
That's basically what sumtype is going t
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
What are you stuck at? What was the most difficult features to
understand? etc.
To make it more meaningful, what is your experience with other
languages?
Ali
Overhall I think that D was not hard to learn because well
designed (
On Thursday, 12 May 2022 at 11:50:59 UTC, Alain De Vos wrote:
Some keywords are overloaded and have different meaning when
used in a different place.
Also some syntactic-sugar is way to much meaning too many
different ways to do the same thing. I would prefer one way
which is advised.
`ptr1 i
On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote:
On Thursday, 12 May 2022 at 11:50:59 UTC, Alain De Vos wrote:
Some keywords are overloaded and have different meaning when
used in a different place.
Also some syntactic-sugar is way to much meaning too many
different ways to do the sam
On Thursday, 12 May 2022 at 14:06:13 UTC, Arjan wrote:
On Thursday, 12 May 2022 at 11:05:08 UTC, Basile B. wrote:
On Wednesday, 11 May 2022 at 05:41:35 UTC, Ali Çehreli wrote:
- Operator overloading in certain cases was confusing, I
remember that for one particular form once I had to use your
On Thursday, 12 May 2022 at 15:31:03 UTC, Steven Schveighoffer
wrote:
On 5/12/22 11:18 AM, jmh530 wrote:
On Thursday, 12 May 2022 at 12:13:32 UTC, Basile B. wrote:
[snip]
```
is ( Type : TypeSpecialization , TemplateParameterList )
is ( Type == TypeSpecialization , TemplateParameterList )
is (
On Friday, 13 May 2022 at 16:11:14 UTC, BoQsc wrote:
Haven't used debuggers or debugged a lot just yet, but I've had
this question in my mind and I'd like to inspect some debugging
information manually. Are there some kind of documentation or
specification and are there a lot of information tha
On Tuesday, 29 November 2022 at 18:59:46 UTC, DLearner wrote:
To me, it appears that there are really two (_entirely
separate_) concepts:
A. Supporting the useful concept of variable length (but
otherwise entirely conventional) arrays;
B. Supporting a language feature that acts as a window to
On Wednesday, 30 November 2022 at 03:07:44 UTC, thebluepandabear
wrote:
I am reading through Ali's book about D, and he gives the
following examples for an overflow:
```D
import std.stdio;
void main() {
// 3 billion each
uint number_1 = 30;
uint number_2 = 30;
}
writeln("maximum
On Wednesday, 30 November 2022 at 03:19:49 UTC, Basile B. wrote:
[...]
It's always a wraparound (think modulo) but your examples with
negative number can be explained because there are hidden
unsigned to signed implicit convertions.
That the only special things D does.
forgot to say, you can
On Friday, 20 January 2023 at 03:11:33 UTC, Ruby The Roobster
wrote:
Take this example:
[...]
What is the purpose of this 'Result' type? To serve as a
generic range?
Yes this is a lazy input range. Use `.array` to yield directly as
a concrete value,
then you can append using `~=`.
Note tha
On Saturday, 25 February 2023 at 15:55:33 UTC, solidstate1991
wrote:
I had a lot of trouble trying to get Visual Studio to catch
handled exceptions, which would have been mandatory for
debugging unittests, but I either forgot how to do it, or
something have changed in either the newer versions
On Saturday, 4 March 2023 at 19:19:26 UTC, Chris Piker wrote:
On Monday, 27 February 2023 at 12:09:50 UTC, Basile B. wrote:
At least this is what is done for the Dexed GDB widget, so
that gdb breaks automatically when an Error or an Exception is
new'd
(https://gitlab.com/basile.b/dexed/-/blob/
On Sunday, 12 March 2023 at 15:09:45 UTC, Salih Dincer wrote:
Hi,
[...]
// A, we can get its to guarantee us that parameters
// won't change:
auto inConst(T)(T a, const T b) // const
{ // it's not needed --^ but ^-- why can't this be used
Well you got the great answers to your questio
On Sunday, 19 March 2023 at 07:20:17 UTC, Jeremy wrote:
Hello, is there any difference at all between the following
lines, as an example:
```d
import std.regex;
import std.regex : matchFirst;
```
What technical differences does it make (except for having the
identifier available), using the c
On Sunday, 19 March 2023 at 13:49:36 UTC, bomat wrote:
Thanks for the suggested workaround, I can live with the
`static` solution, I guess.
I still don't understand why it's necessary, though.
Since a `struct` is a value type and, as I understand it, stack
allocated, what difference does it ma
On Wednesday, 26 April 2023 at 18:24:08 UTC, DLearner wrote:
Consider:
```
struct S1 {
int A;
int B;
int foo() {
return(A+B);
}
}
struct S2 {
int A;
int B;
}
int fnAddS2(S2 X) {
return (X.A + X.B);
}
void main() {
import std.stdio : writeln;
S1 Var1 = S1(1, 2);
On Friday, 26 May 2023 at 09:07:07 UTC, Alex Biscotti wrote:
Hello everyone! While researching the phobos library, I
discovered that a class can have multiple destructors if the
destructors are added via mixin injection. Accordingly, the
question is whether a description of such feature should
On Saturday, 27 May 2023 at 13:23:38 UTC, vushu wrote:
[...]
Is there something equivalent in dlang, doesn't seem like d
support specialized overload?
D solution is called [template
constraints](https://dlang.org/spec/template.html#template_constraints).
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote:
How do I generate `setX` methods for all private mutable
variables in my class? Do I need to use `__traits`?
I need this for my
[tiny-svg](https://github.com/rillki/tiny-svg) project to
generate `setX` methods for all Shapes.
Example:
`
On Monday, 5 June 2023 at 15:13:43 UTC, Basile B. wrote:
On Monday, 5 June 2023 at 13:57:20 UTC, Ki Rill wrote:
How do I generate `setX` methods for all private mutable
although I did not spent time on the setter body... I suppose
the question was more about the metprogramming technic, and
t
On Monday, 5 June 2023 at 15:28:34 UTC, Paul Backus wrote:
Is there a reason you can't just make these fields `public`?
My bet is that OP actually wants to generate something like
```d
void setStrokeWidth(uint value)
{
if (value = strokeWidth) return;
strokeWidth = value;
redraw();
On Monday, 5 June 2023 at 15:28:34 UTC, Paul Backus wrote:
Is there a reason you can't just make these fields `public`?
My bet is that OP actually wants to generate something like
```d
void setStrokeWidth(uint value)
{
if (value = strokeWidth) return;
strokeWidth = value;
redraw();
On Tuesday, 6 June 2023 at 14:23:59 UTC, Steven Schveighoffer
wrote:
On 6/5/23 11:33 AM, Basile B. wrote:
[...]
Ugh, don't do it that way. Always give opDispatch a template
constraint or it will suck to use.
Also, given the problem constraints, you can build the method
automatically using
On Friday, 9 June 2023 at 15:07:54 UTC, Murloc wrote:
On Friday, 9 June 2023 at 12:56:20 UTC, Cecil Ward wrote:
On Friday, 9 June 2023 at 11:24:38 UTC, Murloc wrote:
If you have four ubyte variables in a struct and then
an array of them, then you are getting optimal memory usage.
Is this some
On Tuesday, 13 June 2023 at 16:46:26 UTC, DLearner wrote:
Only a small thing, but is it intended that:
```
void main() {
// static assert (false, "Static Assert triggered");
assert(false, "Assert triggered");
}
```
produces
```
core.exception.AssertError@staticassertex01.d(4): Assert
trigge
On Thursday, 15 June 2023 at 01:47:45 UTC, Paul wrote:
I found I can check for key membership in a multi-D aa...
```d
byte zKey = someval;
byte[byte][byte][byte] cubelist;
foreach(byte xK, yzcubelist; cubelist) {
foreach(byte yK, zcubelist; yzcubelist) {
foreach(byte zK, val; zcubelist) {
On Friday, 7 July 2023 at 08:19:28 UTC, Chris Katko wrote:
For a specific system (Linux, e.g):
What is the level of interoperability between the different D
compilers; DMD, LDC, and GDC?
It appears each one has different benefits, and, different
experimental features. Link-time optimization
On Tuesday, 15 August 2023 at 02:30:37 UTC, repr_man wrote:
Consider the following template mixin:
```d
mixin template Base()
{
int x(){ return 10; }
}
```
It could be used in a variety of structs as follows:
```d
struct Child
{
mixin Base!();
}
```
Now, let's suppose we write a function
On Tuesday, 15 August 2023 at 12:20:54 UTC, repr_man wrote:
On Tuesday, 15 August 2023 at 07:02:45 UTC, Basile B. wrote:
You can add a kind of tag with the mixin, that will allow to
to test if the type supplied to `f` is well a Base implementor:
Firstly, thank you for your help. This is probabl
On Monday, 28 August 2023 at 06:38:50 UTC, Vino wrote:
Hi All,
The the below code is not working, hence requesting your help.
Code:
```
import std.stdio;
import std.process: environment;
void main () {
int* ext(string) = &environment.get("PATHEXT");
writeln(*ext);
}
```
Problems is th
On Monday, 28 August 2023 at 10:20:14 UTC, Basile B. wrote:
On Monday, 28 August 2023 at 06:38:50 UTC, Vino wrote:
Hi All,
The the below code is not working, hence requesting your
help.
Code:
```
import std.stdio;
import std.process: environment;
void main () {
int* ext(string) = &envir
On Friday, 8 September 2023 at 07:59:37 UTC, rempas wrote:
I do have the following struct:
[...]
Is there any possible that there is a compiler bug? I do use
ldc2 and `betterC`!
Could this be a problem of copy construction ?
On Friday, 8 September 2023 at 18:59:21 UTC, rempas wrote:
On Friday, 8 September 2023 at 16:02:36 UTC, Basile B. wrote:
Could this be a problem of copy construction ?
I don't think so.
My idea was that if you dont have defined a copy constructor and
if an instance is assigned to another,
On Friday, 8 September 2023 at 19:14:47 UTC, H. S. Teoh wrote:
[...]
My guess is that you have a double-free somewhere, or there's a
buffer overrun. Or maybe some bad interaction with the GC, e.g.
if you tried to free a pointer from the GC heap.
That cant be a GC problem as rempas project is
On Thursday, 14 September 2023 at 03:23:48 UTC, An Pham wrote:
import std.stdio;
void main()
{
float f = 6394763.345f;
import std.format : sformat;
char[80] vBuffer = void;
writeln("6394763.345 = ", sformat(vBuffer[], "%.4f",
f));
On Thursday, 14 September 2023 at 15:19:29 UTC, BoQsc wrote:
https://dlang.org/phobos/core_vararg.html
The common way to use **va_arg** is `va_arg!(int)(_argptr);`
What would be the alternative way or syntax that behave exactly
the same way, even if more verbose?
`va_arg!(int)(_argptr)
On Tuesday, 31 October 2023 at 20:09:44 UTC, Salih Dincer wrote:
[...]
is it possible to do something like `alias add = this;`?
```d
struct Calculate
{
int memory;
string result;
auto toString() => result;
// alias add = this;
import std.string : format;
this(stri
On Thursday, 2 November 2023 at 11:17:42 UTC, Salih Dincer wrote:
On Wednesday, 1 November 2023 at 20:04:52 UTC, Basile B. wrote:
Yes. D constructors are not named but the current
implementation adds a name that is `__ctor`, so add
```d
alias add = __ctor;
```
to you struct.
Yeah, it wor
On Saturday, 4 November 2023 at 13:51:20 UTC, Dadoum wrote:
On Saturday, 4 November 2023 at 13:45:56 UTC, Emmanuel Danso
Nyarko wrote:
[...]
There is a syntax disagreement here that's why the D compiler
is instantly stopping you from doing any symbol generated
interaction with string in C++ i
On Thursday, 23 November 2023 at 16:33:52 UTC, DLearner wrote:
Code below is intended to test simple mixin with lambda
function under -betterC.
Works with full-D, but fails with 'needs GC' errors under
-betterC.
Why is this so, bearing in mind the concatenations are executed
at
compile, not
On Wednesday, 13 December 2023 at 12:49:14 UTC, fred wrote:
[...]
a bug ?
thanks anyway
Try to define the flag as static
```d
static shared(bool) isDone = false;
```
I dont know if that should be a compiler error to have local
shared (I tend to think yes as locals are specific to a frame,
i
On Thursday, 14 December 2023 at 03:58:37 UTC, Joel wrote:
If I get user input, for example, how do I check to see if it's
a valid path, like, file name.
```d
// something like this:
if (getUserInput.isValidPath) {
...
}
```
https://dlang.org/phobos/std_file.html#exists
On Tuesday, 30 January 2024 at 15:38:26 UTC, Paul Backus wrote:
[...]
This definitely isn't allowed in C or C++. I wonder what the
rationale is for having this behavior in D?
[1]: https://dlang.org/spec/expression.html
An hypothesis is that this makes codegening the pre and the post
variant
On Monday, 5 February 2024 at 14:26:45 UTC, Basile B. wrote:
On Tuesday, 30 January 2024 at 15:38:26 UTC, Paul Backus wrote:
[...]
This definitely isn't allowed in C or C++. I wonder what the
rationale is for having this behavior in D?
[1]: https://dlang.org/spec/expression.html
An hypothes
On Thursday, 15 February 2024 at 03:17:11 UTC, Jonathan M Davis
wrote:
On Wednesday, February 14, 2024 7:17:15 PM MST Basile B. via
Digitalmars-d- learn wrote:
From what I remember, it was that there was no reference to
the
source. Things got blitted and you had to fix the copy, already
On Tuesday, 12 March 2024 at 05:38:03 UTC, Liam McGillivray wrote:
I am in need of a data type for holding direction information;
one of 8 directions on a single axis. They are named in terms
of compass directions. If D had a 4-bit datatype, I would just
use this and do `+=2` whenever I want to
On Thursday, 14 March 2024 at 20:58:21 UTC, Andy Valencia wrote:
On Thursday, 14 March 2024 at 18:05:59 UTC, H. S. Teoh wrote:
...
The best way to do multi-type varags in D is to use templates:
import std;
void myFunc(Args...)(Args args) {
Thank you. The first parenthetical l
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray
wrote:
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki)
Andrew Cattermole wrote:
[...]
I tried to rework the functions to use bitwise operations, but
it was difficult to figure out the correct logic. I decided
that it's
On Friday, 15 March 2024 at 00:00:01 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 15/03/2024 12:47 PM, Basile B. wrote:
On Thursday, 14 March 2024 at 23:39:33 UTC, Liam McGillivray
wrote:
On Thursday, 14 March 2024 at 01:58:46 UTC, Richard (Rikki)
Andrew Cattermole wrote:
[...]
I tried
On Saturday, 30 March 2024 at 09:35:24 UTC, Per Nordlöw wrote:
Does anybody recognize the error
```
Attribute 'nocapture' does not apply to function return values
%12 = call noalias nocapture align 8 ptr @_D3xxx(ptr nonnull
%10, { i64, ptr } %11) #2, !dbg !7978
Attribute 'nocapture' does not
On Tuesday, 16 July 2019 at 15:07:11 UTC, Mike Brockus wrote:
If you never seen Meson before then pick up a camera and take a
picture:
🤔 👉 https://mesonbuild.com/
Hello, everyone.
I started adding continues integration as part of my
development cycle and I was wondering how would I write a
'
On Tuesday, 12 November 2019 at 07:59:39 UTC, Bastiaan Veelo
wrote:
On Monday, 11 November 2019 at 20:05:11 UTC, Antonio Corbi
wrote:
[...]
Thanks, Antonio. My problem is that the length of the array
should be a built-in property of WrapIntegerArray (immutable in
this case); what I'd actuall
On Friday, 15 November 2019 at 10:55:55 UTC, IGotD- wrote:
On Friday, 15 November 2019 at 08:58:43 UTC, user1234 wrote:
On Wednesday, 13 November 2019 at 11:07:12 UTC, IGotD- wrote:
I'm trying to find the rationale why GC pointers (should be
names managed pointers) are using the exact same type
I wish something like this was possible, until I change the
return type of `alwaysReturnNull` from `void*` to `auto`.
---
class A {}
class B {}
auto alwaysReturnNull() // void*, don't compile
{
writeln();
return null;
}
A testA()
{
return alwaysReturnNull();
}
B testB()
{
ret
On Tuesday, 3 December 2019 at 07:12:18 UTC, Basile B. wrote:
I wish something like this was possible, until I change the
return type of `alwaysReturnNull` from `void*` to `auto`.
---
class A {}
class B {}
auto alwaysReturnNull() // void*, don't compile
{
writeln();
return null;
}
A
On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana wrote:
On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote:
A testA()
{
return alwaysReturnNull(); // Tnull can be implictly
converted to A
}
still nice tho.
Why not [1]?
[1] typeof(null) alwaysReturn
On Tuesday, 3 December 2019 at 09:44:20 UTC, Basile B. wrote:
On Tuesday, 3 December 2019 at 08:47:45 UTC, Andrea Fontana
wrote:
On Tuesday, 3 December 2019 at 07:24:31 UTC, Basile B. wrote:
A testA()
{
return alwaysReturnNull(); // Tnull can be implictly
converted to A
}
On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis
wrote:
On Tuesday, December 3, 2019 12:12:18 AM MST Basile B. via
Digitalmars-d- learn wrote:
I wish something like this was possible, until I change the
return type of `alwaysReturnNull` from `void*` to `auto`.
---
class A
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis
wrote:
On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via
Digitalmars-d- learn wrote:
[...]
There isn't much point in giving the type of null an explicit
name given that it doesn't come up very often, and typeof
On Tuesday, 3 December 2019 at 09:22:49 UTC, Jan Hönig wrote:
Today i have stumbled on Hacker News into:
https://0.30004.com/
I am learning D, that's why i have to ask.
Why does
writefln("%.17f", .1+.2);
not evaluate into: 0.30004, like C++
but rather to: 0.29
On Tuesday, 3 December 2019 at 23:44:59 UTC, mipri wrote:
On Tuesday, 3 December 2019 at 10:13:30 UTC, mipri wrote:
Speaking of nice stuff and aliases, suppose you want to
return a nice tuple with named elements?
Option 1: auto
auto option1() {
return tuple!(int, "apples", int, "orange
On Tuesday, 3 December 2019 at 10:19:02 UTC, Jonathan M Davis
wrote:
On Tuesday, December 3, 2019 3:03:22 AM MST Basile B. via
Digitalmars-d- learn wrote:
On Tuesday, 3 December 2019 at 09:58:36 UTC, Jonathan M Davis
wrote:
> On Tuesday, December 3, 2019 12:12:18 AM MST Basile B.
On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe
wrote:
On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh wrote:
typeof(return) is one of the lesser known cool things about D
that make it so cool. Somebody should write an article about
it to raise awareness of it. :-D
you
On Wednesday, 4 December 2019 at 23:53:53 UTC, NeeO wrote:
Would someone be able to explain this ? I can only seem to call
a template constructor in one way, but I can't seem to pass
what looks like an accepted type to the template constructor
via a function call.
/+ main.d +/
import std.stdi
On Friday, 6 December 2019 at 07:03:45 UTC, berni44 wrote:
In std.typecons, in Tuple there are two opCmp functions, that
are almost identical; they only differ by one being const and
the other not:
int opCmp(R)(R rhs)
if (areCompatibleTuples!(typeof(this), R, "<"))
{
On Wednesday, 4 December 2019 at 12:54:34 UTC, Basile B. wrote:
On Wednesday, 4 December 2019 at 03:17:27 UTC, Adam D. Ruppe
wrote:
On Wednesday, 4 December 2019 at 01:28:00 UTC, H. S. Teoh
wrote:
typeof(return) is one of the lesser known cool things about D
that make it so cool. Somebody shou
On Sunday, 8 December 2019 at 18:13:59 UTC, DanielG wrote:
On Sunday, 8 December 2019 at 18:01:03 UTC, Steven
Schveighoffer wrote:
Yes, if it can compile when you move things around, and the
result is *correct* (very important characteristic)
Indeed, everything's working as intended when rearr
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
I have this code:
import std.random;
import std.stdio;
void main()
{
auto aa = ["one": 1, "two": 2, "three": 3];
writeln(aa);
auto rnd = rndGen;
auto word = aa.byKey.choice(rnd);
writeln(word);
}
And in the D playgrou
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote:
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
[...]
rndGen is a range.
Use `auto word = aa.byKey.choice(rnd.front())` as index instead.
Then `rndGen.popFront()` to advance.
no sorry, I didn't read and thought you nee
On Saturday, 25 January 2020 at 09:06:53 UTC, mark wrote:
On Saturday, 25 January 2020 at 08:59:23 UTC, Basile B. wrote:
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
[...]
[snip]
[...]
rndGen is a range.
Use `auto word = aa.byKey.choice(rnd.front())` as index
instead.
Then `
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
I have this code:
import std.random;
import std.stdio;
void main()
{
auto aa = ["one": 1, "two": 2, "three": 3];
writeln(aa);
auto rnd = rndGen;
auto word = aa.byKey.choice(rnd);
writeln(word);
}
And in the D playgrou
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
I have this code:
import std.random;
import std.stdio;
void main()
{
auto aa = ["one": 1, "two": 2, "three": 3];
writeln(aa);
auto rnd = rndGen;
auto word = aa.byKey.choice(rnd);
writeln(word);
}
And in the D playgrou
On Saturday, 25 January 2020 at 09:18:01 UTC, Basile B. wrote:
On Saturday, 25 January 2020 at 08:35:18 UTC, mark wrote:
I have this code:
import std.random;
import std.stdio;
void main()
{
auto aa = ["one": 1, "two": 2, "three": 3];
writeln(aa);
auto rnd = rndGen;
auto word = a
On Friday, 24 January 2020 at 14:28:03 UTC, berni44 wrote:
On Friday, 24 January 2020 at 12:22:49 UTC, Dennis wrote:
You can pass the -X flag to dmd, which makes it generate a
.json file describing the compiled file.
Great, that's what I was looking for - although it's also good
to know the _
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote:
I see that DUB has DMD as a library package, but I was not able
to understand how to use it.
Is it possible to use DMD as a library within a D program to
compile a string to machine code and run the compiled code at
runtime?
Tha
On Friday, 7 February 2020 at 18:10:07 UTC, bachmeier wrote:
On Friday, 7 February 2020 at 17:02:18 UTC, solnce wrote:
Hi guys,
I am total newbie and trying to learn a little bit of
programming for personal purposes (web scrapping, small
databases for personal use etc.). I've been trying to i
On Friday, 7 February 2020 at 08:52:44 UTC, mark wrote:
Some languages support this kind of thing:
if ((var x = expression) > 50)
print(x, " is > 50")
Is there anything similar in D?
Yes assuming that the expression is bool evaluable. This includes
- pointers: `if (auto p = giveMeSomePtr()
On Saturday, 8 February 2020 at 03:59:22 UTC, Borax Man wrote:
As linked before, dexed is available here
https://github.com/akira13641/dexed
and I compiled it just a few days ago with success.
It is a fork (check the count of commits).
The most recent version is here https://gitlab.com/basile.
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote:
On Friday, 31 January 2020 at 11:19:37 UTC, Saurabh Das wrote:
I see that DUB has DMD as a library package, but I was not
able to understand how to use it.
Is it possible to use DMD as a library within a D program to
compile a strin
On Monday, 10 February 2020 at 12:31:03 UTC, Basile B. wrote:
On Friday, 31 January 2020 at 14:25:30 UTC, Basile B. wrote:
[...]
about [1] (llvm) I've made a better binding this weekend:
https://gitlab.com/basile.b/llvmd-d
Seriouly I cant believe that at some point in the past I
translated
On Friday, 14 February 2020 at 22:36:20 UTC, PatateVerte wrote:
Hello
I noticed a strange behaviour of the DMD compiler when it has
to call a function with float arguments.
I build with the flags "-mcpu=avx2 -O -m64" under windows 64
bits using "DMD32 D Compiler v2.090.1-dirty"
I have the
On Thursday, 13 February 2020 at 17:15:50 UTC, mark wrote:
I'm starting out with GtkD and have this function:
void main(string[] args) {
Main.init(args);
auto game = new GameWindow();
Main.run();
}
and this method:
void quit(Widget widget) {
Main.quit();
}
When I r
On Sunday, 16 February 2020 at 14:01:13 UTC, Robert M. Münch
wrote:
I want to use a specific branch version if a package. I
specified the branch version in a dub.selections.json file.
But it seems that dub requires a ZIP file that can be
downloaded from code.dlang.org, which of course fails be
On Monday, 17 February 2020 at 09:41:35 UTC, Adnan wrote:
On Monday, 17 February 2020 at 07:50:02 UTC, Mitacha wrote:
On Monday, 17 February 2020 at 05:04:02 UTC, Adnan wrote:
What is the equivalent of Rust's chunks_exact()[1] method in
D? I want to iterate over a spitted string two chunks at a
eg
Sh(echo) < "meh";
struct Sh
{
// you see the idea we have op overload for < here
}
On Monday, 17 February 2020 at 22:34:31 UTC, Stefan Koch wrote:
Upon seeing this I just implemented typeid(stuff).name;
https://github.com/dlang/dmd/pull/10796
With any luck this will be possible in the next release ;)
Can this work using `stuff.classinfo.name` too ?
This is the same as `typ
On Sunday, 23 February 2020 at 12:28:41 UTC, mark wrote:
On Sunday, 23 February 2020 at 09:35:30 UTC, Jacob Carlborg
wrote:
On 2020-02-23 10:03, mark wrote:
Then this would not only help dscanner, but also make it
clear to programmers that the argument could be modified.
It's not necessary f
On Sunday, 23 February 2020 at 17:14:33 UTC, Per Nordlöw wrote:
I would like to setup auto-generation of online documentation
for my public D libraries residing on Github and Gitlab.
What alternatives do I have?
for gitlab they have a system of pages that's quite easy to setup:
something lik
On Monday, 24 February 2020 at 00:50:38 UTC, ric maicle wrote:
[dmd 2.090.1 linux 64-bit]
The following code does not report the correct unit test
summary.
The report says 1 unit test passed.
~
shared static this() {
import core.exception;
assertHandler(&cah);
}
void
cah(string f
So after reading the translation of RYU I was interested too see
if the decimalLength() function can be written to be faster, as
it cascades up to 8 CMP.
After struggling with bad ideas I finally find something that
looks nice:
- count the leading zero of the input
- switch() this count to h
1 - 100 of 726 matches
Mail list logo