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.
Replace: 436 msecs
Malloc : 259 msecs
*/
It seems because MallocReplace is cheating a lot:
- it is not called through another function l
On Wednesday, 22 December 2021 at 20:14:01 UTC, Dr Machine Code
wrote:
it differ from assert because it contains the expression, file
and line information. See this
https://stackoverflow.com/questions/14420857/check-expect-example-in-racket
what's the closest thing we have in D? can we make it w
On Monday, 20 December 2021 at 10:49:20 UTC, rempas wrote:
On Monday, 20 December 2021 at 09:30:30 UTC, rumbu wrote:
Thanks a lot for the info. When I try to use this code, I'm
getting the following error:
```
Error: expression expected, not `%`
Error: expression expected, not `%`
```
My fa
On Monday, 20 December 2021 at 08:45:50 UTC, rempas wrote:
Here I am having a problem with templates again. No matter how
much I read, I can't seem to understand how templates/mixins
work.
So any ideas why this doesn't work?
because you cannot have statements directly in a template (the
fac
On Tuesday, 14 December 2021 at 16:21:03 UTC, Steven
Schveighoffer wrote:
On 12/14/21 11:19 AM, Steven Schveighoffer wrote:
Er... scratch that, this isn't construction, it should use
opAssign. Again, probably because memcpy+postblit is used by
the runtime.
If not reported, it should be.
Si
On Tuesday, 14 December 2021 at 12:13:23 UTC, Stanislav Blinov
wrote:
Because is(typeof(immutable(ComplexStruct).x) ==
immutable(int[])). Can't bind an array of immutable to array of
mutable. This would require a deep copy, i.e. copy constructor.
This means that the only way to write a gener
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;
immutable(SimpleStruct)[] ibuf1;
buf1[0 .. 10] = ibuf1[0 .. 10
On Saturday, 11 December 2021 at 14:42:53 UTC, russhy wrote:
Here is mine
- 0 allocations
- configurable
- let's you use it how you wish
- fast
You know that this is already in phobos?
```
"abc;def;ghi".splitter(';').joiner
```
On Friday, 10 December 2021 at 18:47:53 UTC, Stanislav Blinov
wrote:
Be interesting to see if this thread does evolve into a SIMD
http://lemire.me/blog/2017/01/20/how-quickly-can-you-remove-spaces-from-a-string/
On Friday, 10 December 2021 at 11:06:21 UTC, IGotD- wrote:
On Friday, 10 December 2021 at 06:24:27 UTC, Rumbu wrote:
Since it seems there is a contest here:
```d
"abc;def;ghi".split(';').join();
```
:)
Would that become two for loops or not?
I thought it's a beauty contest.
```d
string
On Wednesday, 8 December 2021 at 11:23:45 UTC, BoQsc wrote:
Let's say I want to skip characters and build a new string.
The character I want to skip: `;`
Expected result:
```
abcdefab
```
Since it seems there is a contest here:
```d
"abc;def;ghi".split(';').join();
```
:)
On Friday, 3 December 2021 at 10:57:34 UTC, Stanislav Blinov
wrote:
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 hid
```d
class S {}
class A:S {}
class B:S {}
mixin template vmix(T)
{
void visit(T t) {}
}
class Visitor
{
void visit(S s) {}
mixin vmix!A;
mixin vmix!B;
}
class AnotherVisitor: Visitor
{
override void visit(A a) {}
}
```
This will result in error when I try to override mixin
On Thursday, 25 November 2021 at 11:25:49 UTC, Ola Fosheim
Grøstad wrote:
On Thursday, 25 November 2021 at 10:41:05 UTC, Rumbu wrote:
I am not asking this questions out of thin air, I am trying to
write a conforming lexer and this is one of the ambiguities.
I think it is easier to just look at
On Thursday, 25 November 2021 at 10:10:25 UTC, Dennis wrote:
On Thursday, 25 November 2021 at 08:06:27 UTC, rumbu wrote:
Also, this works also for #line, even if the specification
tells us that all tokens must be on the same line
Where does it say that?
Well:
```
#line IntegerLiteral Filesp
Just playing around with attributes.
This is valid D code:
```d
@
nogc: //yes, this is @nogc in fact, even some lines are between
@
/* i can put some comments
*/
/** even some documentation
*/
// single line comments also
(12)
// yes, comments and newlines are allowed between attribute
On Saturday, 6 March 2021 at 12:15:43 UTC, Mike Parker wrote:
On Saturday, 6 March 2021 at 11:57:13 UTC, Imperatorn wrote:
What... Is this really how it's supposed to be? Makes no sense
to not use any of the existing conventions.
extern(C) and extern(D) are both documented to be the same as
On Friday, 5 March 2021 at 21:47:49 UTC, z wrote:
On Friday, 5 March 2021 at 16:10:02 UTC, Rumbu wrote:
First of all, in 64 bit ABI, parameters are not passed on
stack, therefore a[RBP] is a nonsense.
void complement32(simdbytes* a, simdbytes* b)
a is in RCX, b is in RDX on Windows
a is in RD
On Friday, 5 March 2021 at 12:57:43 UTC, z wrote:
XMM registers work, but as soon as they are changed into YMM
DMD outputs "bad type/size of operands %s" and LDC outputs an
"label YMM0 is undefined" error. Are they not supported?
To illutrate : https://run.dlang.io/is/IqDHlK
By the way, how ca
On Sunday, 28 February 2021 at 09:04:49 UTC, Rumbu wrote:
On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote:
I'm using a windows callback function where the user-defined
value is passed thought a LPARAM argument type. I'd like to
pass my D array then access it from that callback function.
On Sunday, 28 February 2021 at 07:05:27 UTC, Jack wrote:
I'm using a windows callback function where the user-defined
value is passed thought a LPARAM argument type. I'd like to
pass my D array then access it from that callback function. How
is the casting from LPARAM to my type array done in t
On Wednesday, 17 February 2021 at 12:58:29 UTC, Mitacha wrote:
On Wednesday, 17 February 2021 at 11:38:45 UTC, Rumbu wrote:
[...]
If you replace `fold` and `splitter` with this, then it doesn't
allocate:
```
auto fn() @nogc {
return only("k1,k2", "k3,k4")
.map!(x => x.splitter(",
On Wednesday, 17 February 2021 at 10:15:10 UTC, Mitacha wrote:
it'll use empty string as first element in range.
BTW perheps you could use `joinner` instead of this `fold` to
join values with ",".
Thanks for that. I thought to joiner too, but it doesn't work. I
need fold to take a list of s
In the expression below:
return matchAll(content, keywordsPattern)
.map!(a => a.hit.stripLeft("[").strip("]"))
.fold!((a, b) => a ~ "," ~ b)
.splitter(',')
.map!(a => a.stripLeft("\" ").strip("\" "))
.filter!(a => !a.any!(b => b == ' ' |
On Monday, 15 February 2021 at 07:26:56 UTC, Jack wrote:
I need to check if an instance is of a specific type derived
from my base class but this class has template parameter and
this type isn't available at time I'm checking it. Something
like:
class B { }
class A(T) : B { }
class X : B { }
On Saturday, 13 February 2021 at 05:52:34 UTC, Jack wrote:
I have a base class A, where I make specific operator depending
on the derived class type. Currently I'm using something like
this:
c is a class derived from A
bool shouldDoX = (cast(X)c) !is null || (cast(Y)c) !is null ||
(cast(K)c)
On Tuesday, 9 February 2021 at 19:37:17 UTC, WhatMeWorry wrote:
I'm trying to create a super simple dynamic library consisting
of two files:
file2.d --
extern(D):
double addEight(double d) { return (d + 8.0); }
fileB.d -
On Monday, 8 February 2021 at 12:19:26 UTC, Basile B. wrote:
On Monday, 8 February 2021 at 11:42:45 UTC, Vindex wrote:
size_t ndim(A)(A arr) {
return std.algorithm.count(typeid(A).to!string, '[');
}
Is there a way to find out the number of dimensions in an
array at compile time?
yeah.
-
On Sunday, 29 December 2019 at 08:26:58 UTC, Daren Scot Wilson
wrote:
Reading documentation... Array, Algorithms, ... maybe I've been
up too late... how does one obtain the index of, say, 55 in an
array like this
int[] a = [77,66,55,44];
I want to do something like:
int i = a.find_va
On Saturday, 6 February 2021 at 00:35:12 UTC, Ali Çehreli wrote:
On 2/5/21 1:10 PM, Rumbu wrote:
I gave up after reading a lot, but I didn't manage to
understand the meaning "&& ..."
I think it's the universal reference.
Thank you Ali, but nope, it's "parameter pack folding". This
allows s
Can some C++ guru translate in D the template below?
I gave up after reading a lot, but I didn't manage to understand
the meaning "&& ..."
template static uint8_t
composite_index_size(Tables const&... tables) { return
(composite_index_size(tables.size(),
impl::bits_needed(sizeof...(tables)
On Wednesday, 29 January 2020 at 08:40:48 UTC, p.shkadzko wrote:
Has anyone read "d programming language tutorial: A Step By
Step Appoach: Learn d programming language Fast"?
https://www.goodreads.com/book/show/38328553-d-programming-language-tutorial?from_search=true&qid=G9QIeXioOJ&rank=3
Be
On Monday, 27 January 2020 at 11:34:47 UTC, Marcone wrote:
#include
#include
#include
#include "resource.h"
#include
HINSTANCE hInst;
BOOL CALLBACK DlgMain(HWND hwndDlg, UINT uMsg, WPARAM wParam,
LPARAM lParam)
{
switch(uMsg)
{
case WM_INITDIALOG:
{
}
return TRUE;
On Sunday, 5 January 2020 at 13:33:35 UTC, Marcone wrote:
I am using this code to load icon from local directory, but I
want to load icon from resource.res file:
wndclass.hIcon = LoadImage( NULL, "icon.ico", IMAGE_ICON, 0,
0, LR_LOADFROMFILE| LR_SHARED | LR_LOADTRANSPARENT);
You cannot load
I am trying to create an array of functions inside a struct.
struct S {
void f1() {}
void f2() {}
alias Func = void function();
immutable Func[2] = [&f1, &f2]
}
What I got: Error: non-constant expression '&f1'
Tried also with delegates (since I am in a struct context but I
got: no `t
On Sunday, 8 December 2019 at 20:50:05 UTC, Marcone wrote:
I want to add version to my program.
I have configurated my version file "version.txt", but I dont
know how link this file to my program. If Need spec file,
please send the exemple code of spec. Or is is possible add
version file by d
On Monday, 25 November 2019 at 08:20:59 UTC, rumbu wrote:
On Monday, 25 November 2019 at 08:07:50 UTC, Fanda Vacek wrote:
Thanks for answer, I'm coming from C++. But anyway, pointers
are not allowed in @safe code, so this is not always solution.
Workaround exits even for @safe code, so my ques
On Monday, 25 November 2019 at 08:07:50 UTC, Fanda Vacek wrote:
Thanks for answer, I'm coming from C++. But anyway, pointers
are not allowed in @safe code, so this is not always solution.
Workaround exits even for @safe code, so my question remains
the same. What is a rationale for such a lang
On Monday, 25 November 2019 at 03:07:08 UTC, Fanda Vacek wrote:
Maybe I'm missing the thing, but I'm not able to declare local
ref variable even if simple workaround exists. Is this
preferred design pattern?
```
int main()
{
int a = 1;
//ref int b = a; // Error: variable `tst_ref.main
On Friday, 14 June 2019 at 07:52:24 UTC, Marco de Wild wrote:
On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote:
Opposed to Java, D's member variables are static initialised.
Is there any documentation about this? I find it unexpected.
On Thursday, 13 June 2019 at 16:08:52 UTC, Mike wrote:
How would a proper destructor of class Foo look like?
Is it enough to set "array" to null? Or do I have to set every
element of the array to null and then the array, or nothing of
that at all because the garbage collecter collects it, if th
On Tuesday, 21 May 2019 at 07:16:49 UTC, Jim wrote:
On Tuesday, 21 May 2019 at 07:04:27 UTC, rumbu wrote:
On Tuesday, 21 May 2019 at 05:51:30 UTC, Jim wrote:
That's because foo is of type Base, not implementing FeatureX.
Right, Base isn't implementing FeatureX, but foo is really a Foo
That'
On Tuesday, 21 May 2019 at 05:51:30 UTC, Jim wrote:
Hi,
consider this:
interface Base
{
void setup();
}
interface FeatureX
{
void x();
}
class Foo: Base, FeatureX
{
void setup(){};
void x(){};
}
void main()
{
Base foo = new Foo(); // This would be the result of a
factory class
On Friday, 10 May 2019 at 19:10:05 UTC, Machine Code wrote:
Well, I've had similar issue. The error message says "access
denied" which I believe refers to the tmp directory; i.e, the
user that is running your executable has no permissions to
delete that file.
Well, this has nothing to do with
On Thursday, 9 May 2019 at 10:09:23 UTC, Cym13 wrote:
Hi,
this is likely not related to D itself but hopefully someone
can help me with this since I'm rather new to windows
programming, I mainly work on linux. I'm trying to bundle a DLL
in a binary, write it in a temp folder, use it and remov
On Thursday, 5 April 2018 at 17:36:56 UTC, Seb wrote:
On Thursday, 5 April 2018 at 17:06:04 UTC, rumbu wrote:
Is there a standard way to handle errors in a chain of range
transformations?
[...]
Are you aware of ifThrown?
https://dlang.org/phobos/std_exception.html#ifThrown
It's not perfect
Is there a standard way to handle errors in a chain of range
transformations?
Let's say I want to read some comma separated numbers from a file.
auto myArray = file.byLine().splitter().map!(to!int).array();
Now, besides fatal errors (like I/O), let's suppose I want to
handle some errors in a
On Monday, 26 March 2018 at 06:40:34 UTC, Vladimirs Nordholm
wrote:
However I do not understand how to use that with my arguments.
Eg. I would expect to do something like:
void foo(X, Y, Args...)(X x, Y y, Args args)
if(isNumeric!(x) && isNumeric!(y) && args.length >= 1)
{
On Wednesday, 21 March 2018 at 18:50:38 UTC, Vino wrote:
Hi All,
Request your help in calling the windows command to delete all
file and folders recursively as the D function rmdirRecurse
does not delete file in the permission of the file is readonly
in windows 2008 R2
import std.process:
I tried to define a template:
enum isFoo(alias T) =
T.stringof.length >= 3 && T.stringof[0..3] == "abc";
int i;
pragma(msg, isFoo!i);
Error: string slice [0 .. 3] is out of bounds
Error: template object.__equals cannot deduce function from
argument types !()(string, string), candidates are
On Tuesday, 20 March 2018 at 16:56:59 UTC, Dennis wrote:
On Tuesday, 20 March 2018 at 12:18:16 UTC, Adam D. Ruppe wrote:
On Tuesday, 20 March 2018 at 09:44:41 UTC, Dennis wrote:
I suspect you are seeing the Windows antivirus hitting you. D
runtime starts up in a tiny fraction of a second, you
On Monday, 19 March 2018 at 11:35:46 UTC, Dukc wrote:
This topic is technically in wrong place, since the problem is
with C#, not D. But because what I'm asking is more idiomatic
in D than elsewhere, I think I have the best changes to get
understood here.
So, I'm looking for some library, or
On Thursday, 15 March 2018 at 17:18:08 UTC, Miguel L wrote:
On Thursday, 15 March 2018 at 16:31:56 UTC, Stefan Koch wrote:
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote:
Why does std.math.signbit only work for floating point types?
Is there an analogue function for integer types? w
On Wednesday, 14 March 2018 at 00:43:52 UTC, Rubn wrote:
Yah it's not fun.
Some notes:
You might need to set MSVC_CC environment variable cause it
doesn't use the right format for VS path, depending on your
version.
https://github.com/dlang/dmd/blob/v2.079.0/src/vcbuild/msvc-dmc.d#L19
You
I know that there are contributing guides but I fail to
successfully follow any of them:
https://wiki.dlang.org/Starting_as_a_Contributor
1. Bash install script will not run under Windows. Using git bash
will result in error (Command error: undefined switch '-C')
2. Digger it's not compiling
On Tuesday, 13 March 2018 at 12:23:06 UTC, Ozan Süel wrote:
Hi
I have a construction like the following
if (source) {
if (source.pool) {
if (source.pool.repository) {
if (source.pool.repository.directory) {
if (source.pool.repository.directory.users) {
// do someth
On Sunday, 25 February 2018 at 13:33:07 UTC, psychoticRabbit
wrote:
can someone please design a language that does what I tell it!
please!!
is that so hard??
print 1.0 does not mean go and print 1 .. it means go and print
1.0
languages are too much like people.. always thinking for
themsel
On Sunday, 25 February 2018 at 08:08:30 UTC, psychoticRabbit
wrote:
But umm what happended to the principle of least
astonishment?
writeln(1.1); (prints 1.1)
whereas..
writeln(1.0); (prints 1)
I don't get it. Cause it's 'nicer'??
Because writeln(someFloat) is equivalent to writefln("
On Monday, 12 February 2018 at 02:05:16 UTC, aliak wrote:
From spec: Cast expression: "cast ( Type ) UnaryExpression"
converts UnaryExpresssion to Type.
And https://dlang.org/spec/operatoroverloading.html#cast makes
no mention of the return type of opCast. One could think that
the return type
On Monday, 12 February 2018 at 03:13:43 UTC, aliak wrote:
Hi,
Is there a way to get post increment and pre increment working
properly in this scenario?
import std.stdio;
struct A {
int[] a;
this(int a) { this.a = [a]; }
auto opUnary(string op)(){
return A(mixin(op ~ "this
On Sunday, 11 February 2018 at 14:06:32 UTC, rjframe wrote:
On Sat, 10 Feb 2018 10:55:30 +, rumbu wrote:
If you separate initialization to a static this, you'll get a
compile error:
```
immutable uint256[78] pow10_256;
static this() {
// Error: mismatched array lengths, 78 and 2
On Sunday, 11 February 2018 at 01:26:59 UTC, psychoticRabbit
wrote:
On Sunday, 11 February 2018 at 01:13:00 UTC, psychoticRabbit
wrote:
Well, in C.. I can do:
int arr[2] = { [0]=10, [1]=20 };
I cannot work out how to do that in D yet (anyone know??)
Oh. just worked it out after reading thi
On Saturday, 10 February 2018 at 14:55:49 UTC, b2.temp wrote:
On Saturday, 10 February 2018 at 14:35:52 UTC, rumbu wrote:
In this case, it there any way to be sure that I declared all
the elements I intended? Obviously, without counting them by
hand.
At the level of the library use a templa
On Saturday, 10 February 2018 at 12:28:16 UTC, b2.temp wrote:
On Saturday, 10 February 2018 at 10:55:30 UTC, rumbu wrote:
I know that according to language spec
(https://dlang.org/spec/arrays.html#static-init-static) you
can skip declaring all your elements in a fixed size array.
I'm just rec
I know that according to language spec
(https://dlang.org/spec/arrays.html#static-init-static) you can
skip declaring all your elements in a fixed size array.
I'm just recovering from a bug which took me one day to discover
because of this.
I have a large static initialized array, let's say
On Monday, 29 January 2018 at 22:55:12 UTC, I Lindström wrote:
Hello all!
I've been doing console apps for about a year and a half now,
but my requirements are reaching the limits of easy to use with
ASCII-based UI and typed commands so I'm thinking of moving
into GUI-era with my projects. I
On Friday, 19 January 2018 at 23:27:06 UTC, Adam D. Ruppe wrote:
On Friday, 19 January 2018 at 23:16:19 UTC, rumbu wrote:
According to this
(https://dlang.org/spec/hash-map.html#static_initialization)
this is correct static initialization for AA:
That only works inside a function, and, ironic
According to this
(https://dlang.org/spec/hash-map.html#static_initialization) this
is correct static initialization for AA:
immutable RoundingMode[string] ibmRounding =
[
">" : RoundingMode.towardPositive,
"<" : RoundingMode.towardNegative,
"0" : RoundingMode.towardZero,
"=0":
On Thursday, 18 January 2018 at 18:00:51 UTC, rumbu wrote:
On Thursday, 18 January 2018 at 17:54:59 UTC, rumbu wrote:
On Thursday, 18 January 2018 at 12:51:48 UTC, Dominikus Dittes
target = isNegative ? cast(Unsigned!T)(-c) :
cast(Unsigned!T)c;
That would have been better even before the
On Thursday, 18 January 2018 at 17:54:59 UTC, rumbu wrote:
On Thursday, 18 January 2018 at 12:51:48 UTC, Dominikus Dittes
target = isNegative ? cast(Unsigned!T)(-c) : cast(Unsigned!T)c;
That would have been better even before the change, because
the operator '-' used on unsigned types is li
On Thursday, 18 January 2018 at 12:51:48 UTC, Dominikus Dittes
Scherkl wrote:
On Thursday, 18 January 2018 at 06:05:08 UTC, rumbu wrote:
On Thursday, 18 January 2018 at 02:30:17 UTC, Rubn wrote:
On Wednesday, 17 January 2018 at 22:30:11 UTC, rumbu wrote:
code like "m = n < 0 ? -n : n" doesn't
On Thursday, 18 January 2018 at 02:30:17 UTC, Rubn wrote:
On Wednesday, 17 January 2018 at 22:30:11 UTC, rumbu wrote:
code like "m = n < 0 ? -n : n" doesn't worth a wrapper
That code is worth a wrapper, it's called "abs"...
m = abs(n);
Well, since I'm in the learn forum and you seem to have
On Wednesday, 17 January 2018 at 21:12:07 UTC, Rubn wrote:
On Wednesday, 17 January 2018 at 20:30:07 UTC, rumbu wrote:
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
typ
And here is why is bothering me:
auto max = isNegative ? cast(Unsigned!T)(-T.min) :
cast(Unsigned!T)T.max);
The generic code above (which worked for all signed integral
types T in 2.077) must be rewritten like this in 2.078:
static if (T.sizeof >= 4)
auto max = isNegative ? cast(Unsigned
On Wednesday, 17 January 2018 at 19:54:50 UTC, ag0aep6g wrote:
On 01/17/2018 08:40 PM, rumbu wrote:
This started in the last DMD version (2.078):
byte b = -10;
ulong u = b < 0 ? -b : b;
//Deprecation: integral promotion not done for `-b`, use
'-transition=intpromote' switch or `-cast(int)(b)
This started in the last DMD version (2.078):
byte b = -10;
ulong u = b < 0 ? -b : b;
//Deprecation: integral promotion not done for `-b`, use
'-transition=intpromote' switch or `-cast(int)(b)
Why do I need a to promote a byte to int to obtain an ulong? Even
in the extreme case where b is by
On Tuesday, 16 January 2018 at 20:30:43 UTC, H. S. Teoh wrote:
On Tue, Jan 16, 2018 at 07:14:00PM +, rumbu via
Even specialized, now I have another problem:
std.math:
int signbit(X)(X x) { ... }
mylibrary:
int signbit(D: Decimal!bits, int bits) { ... }
=
end user:
import
On Tuesday, 26 December 2017 at 20:21:11 UTC, Adam D. Ruppe wrote:
On Tuesday, 26 December 2017 at 19:41:47 UTC, rumbu wrote:
"Custom" is a templated struct. I cannot imagine all the
instantiations of Custom to write template specialisations for
each of them.
You can specialize on templated s
On Tuesday, 16 January 2018 at 18:32:46 UTC, H. S. Teoh wrote:
Which version of the compiler is this? I'm pretty sure the
std.math.isNaN imported by module a should not be visible in
module b. The latest compiler should emit a deprecation warning
for this.
2.078, but also 2.077. Deprecation
module a;
private import std.math: isNaN;
//custom overload
public bool isNaN(int i) { return false; }
=
module b;
import a;
void foo()
{
bool b = isNaN(float.nan);
//compiles successfully calling std.math.isNaN even it should
not be visible.
}
Is this
Is there any way to parse a format string into a FormatSpec?
FormatSpec has a private function "fillUp" which is not
accessible.
I need to provide formatting capabilities to a custom data type,
I've already written the standard function:
void toString(C)(scope void delegate(const(C)[]) sink
Is that normal?
use std.math;
float f = float.max;
f += 1.0;
assert(IeeeFlags.overflow) //failure
assert(f == float.inf) //failure, f is in fact float.max
On the contrary, float.max + float.max will overflow. The
behavior is the same for double and real.
On Tuesday, 26 December 2017 at 20:21:11 UTC, Adam D. Ruppe wrote:
On Tuesday, 26 December 2017 at 19:41:47 UTC, rumbu wrote:
"Custom" is a templated struct. I cannot imagine all the
instantiations of Custom to write template specialisations for
each of them.
You can specialize on templated s
On Tuesday, 26 December 2017 at 16:15:55 UTC, Adam D. Ruppe wrote:
The mistake you're making is using a constraint when you should
try a specialization:
int signbit(T:Custom)(T x)
{
return 0;
}
That means to use this specialized function when T is Custom.
Now, you just need to merge the
Is there anyway to extend an existing function to accept custom
data types?
Option 1 - global import of std.math
import std.math;
struct Custom {}
int signbit(T)(T x) if (is(T == Custom))
{
return 0;
}
Custom c;
assert(signbit(c) == 0);
assert(signbit(-1.0) == 1);
Er
Is there any way to overload specific floating point operators?
https://dlang.org/spec/expression.html#floating-point-comparisons
I'm using a decimal data type (a struct) and one of the possible
values is NaN, that's why I need these operators.
I know also that this also was discussed, but is
On Saturday, 28 January 2017 at 07:03:51 UTC, medhi558 wrote:
public static NetworkMessage GetInstance(string id)
{
auto v = (id in ProtocolMessageManager.m_types);
if (v !is null)
return
cast(NetworkMessage)ProtocolMessageManager.m_types[id].create();
else
On Saturday, 28 January 2017 at 08:18:15 UTC, medhi558 wrote:
On Saturday, 28 January 2017 at 07:39:51 UTC, rumbu wrote:
On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote:
I have a last question, currently i use :
if(lc.name.indexOf("protocol.messages") != -1)
To know if the class i
On Saturday, 28 January 2017 at 07:10:27 UTC, medhi558 wrote:
I have a last question, currently i use :
if(lc.name.indexOf("protocol.messages") != -1)
To know if the class is a NetworkMessage, Would be possible to
do this
if(lc is NetworkMessage)
Sorry for my English, i speak french.
if (
I'm not sure if this works quite as intended, but I was at
least able to produce a UTF-16 decode error rather than a UTF-8
decode error by setting the file orientation before reading it.
import std.stdio;
import core.stdc.wchar_ : fwide;
void main(){
auto file = File("UTF-
On Wednesday, 14 December 2016 at 11:06:10 UTC, aberba wrote:
I am trying to get a fellow to try D but just setting up on
windows 10 has been headache. He's currently remote. Here's the
problem. (Note I'm a Linux user and haven't used windows 10)
1. He installed dmd 2 but the command "dmd" is
On Tuesday, 29 November 2016 at 10:21:24 UTC, Anders S wrote:
Hi guys,
just started to get into Dlang, comming from C and C++ I like
to use methods like there if possible.
Now I want to catenate something like this, but don't get it to
work
in standard C i code:
char str[80];
sprintf(
On Tuesday, 22 November 2016 at 11:00:52 UTC, Bauss wrote:
On Monday, 21 November 2016 at 09:11:39 UTC, Jonathan M Davis
wrote:
On Monday, November 21, 2016 08:57:11 Bauss via
Digitalmars-d-learn wrote:
[...]
Phobos doesn't have anything like that, but you can use the C
functions from the Wi
On Tuesday, 22 November 2016 at 08:54:36 UTC, Kagamin wrote:
Yep, I need muldiv for long values on x86-64.
Quick and dirty assembler:
version(D_InlineAsm_X86_64):
long muldiv(long a, long b, long c)
{
//windows RCX, RDX, R8
//linux RDI, RSI, RDX
version(Windows)
{
asm
module module1;
void foo(string s) {}
--
module module2;
import module1;
void foo(int i)
{
foo("abc"); //error - function foo(int) is not callable using
argument types(string)
}
Ok, this can be easily solved using "alias foo = module1.foo",
but according to the documenta
On Wednesday, 20 April 2016 at 12:32:48 UTC, Tofu Ninja wrote:
Is there a way to shallow copy an object when the type is
known? I cant seem to figure out if there is a standard way. I
can't just implement a copy function for the class, I need a
generic solution.
extern (C) Object _d_newclass(
Let's suppose that I want to implement a custom arithmetic type.
Looking through phobos at Complex, BigInt, HalfFloat, Variant,
etc, there is no consistent or idiomatic way to implement various
operators or functions on custom types.
1) Regarding unary operator overloading, what's the best way
On Saturday, 2 January 2016 at 14:57:58 UTC, Shriramana Sharma
wrote:
John Colvin wrote:
Strictly speaking you aren't calling a constructor there,
you're writing a struct literal.
Why do you say I'm not calling a constructor?
A class constructor is written as:
auto s = *new* Timespan(1, 2
On Sunday, 27 December 2015 at 23:24:55 UTC, TheDGuy wrote:
On Sunday, 27 December 2015 at 22:51:27 UTC, Ali Çehreli wrote:
On 12/27/2015 07:53 AM, TheDGuy wrote:
Any idea what i am doing wrong?
https://www.youtube.com/watch?v=j_VCa-5VeP8
YouTube says that the video has been removed by the us
On Wednesday, 23 December 2015 at 19:22:01 UTC, Taylor Hillegeist
wrote:
So I have seen alot of projects that need the same sort of
stuff.
graphics libraries
gui libraries
game libraries
ploting libaries
they would all benefit from a backend solution with a common
interface for
color
fonts
1 - 100 of 160 matches
Mail list logo