On Wednesday, 13 April 2016 at 15:07:09 UTC, rikki cattermole
wrote:
Verified that it is a codegen problem for Win64 and not *nix.
Please file a bug report.
https://issues.dlang.org/show_bug.cgi?id=15921
Done, Thanks
Hello,
I got stuck with a weird array setting behaviour and I need help.
Just have a look at the example.
OS: Win 8.1 Pro
DMD: v2.071.0
Build-cmd: dmd main.d -ofconsole-app.exe -debug -unittest -g -wi
-m64
module dmain;
import std.stdio;
struct Vec {
float a;
}
void main(string[]
On Tuesday, 29 March 2016 at 18:29:27 UTC, Ali Çehreli wrote:
So, dict is a template value parameter of type T[string]. I
don't think you can use an associative array as a template
value parameter. (Can we?)
Found this in D language reference:
On Tuesday, 29 March 2016 at 18:29:27 UTC, Ali Çehreli wrote:
On 03/29/2016 11:21 AM, ref2401 wrote:
So, dict is a template value parameter of type T[string]. I
don't think you can use an associative array as a template
value parameter. (Can we?)
However, it is possible to use anything
OS: Win 8.1 Pro
DMD: v2.070.0
cmd: dmd main.d -ofconsole-app.exe -debug -unittest -wi
Code is successfully compiled until I uncomment test1 function
call in the main.
If it's uncommented I get the following compile-time error:
main.d(58): Error: template instance impl!(string, bool,
I have got a plenty of structs in my project. Their size varies
from 12 bytes to 128 bytes.
Is there a rule of thumb that states which structs I pass by
value and which I should pass by reference due to their size?
Thanks.
On Tuesday, 16 February 2016 at 06:22:33 UTC, Rikki Cattermole
wrote:
Found the problem, you haven't linked against gdi.
Thank you It works. I should have done this:
set filesToUse=main.d gdi32.lib
dmd @filesToUse -ofconsole-app.exe -debug -unittest -wi
On Tuesday, 16 February 2016 at 05:39:26 UTC, Rikki Cattermole
wrote:
Try compiling with 64bit.
If it works, its just the import libs not containing the symbol.
dmd main.d -ofconsole-app.exe -debug -unittest -wi -m64
That's what I'm getting now:
console-app.obj : error LNK2019: unresolved
On Sunday, 31 January 2016 at 14:48:34 UTC, ref2401 wrote:
I am getting runtime error:
core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure
At least tell me can anyone replicate it?
I am getting runtime error:
core.exception.AssertError@std\experimental\allocator\building_blocks\region.d(235): Assertion failure
if LEN equals to 3, 5, 7, 9, ...
void main(string[] args) {
ubyte[1024] memory;
auto stackAlloc = Region!NullAllocator(memory);
IAllocator
Getting this error, could someone explain why?
void main(string[] args) {
InSituRegion!(1024) stackAlloc;
IAllocator alloc = allocatorObject(stackAlloc);
}
..\src\phobos\std\conv.d(5055):
Error: static assert "Don't know how to initialize an object of
type
On Thursday, 28 January 2016 at 16:22:23 UTC, Ali Çehreli wrote:
There is assumeWontThrow which terminates if an exception is
indeed thrown:
http://dlang.org/library/std/exception/assume_wont_throw.html
Ali
nice one, thx
I want to create a static array large enough to store 1MB of
float values.
What am I doing wrong?
Here is a sample code with notes:
void main(string[] args) {
enum size_t COUNT = 1024 * 512 / float.sizeof; // works OK :)
//enum size_t COUNT = 1024 * 512 * 2 / float.sizeof; //
Which type it better to use for array's indices?
float[] arr = new float[10];
int i;
long j;
size_t k;
// which one is better arr[i], a[j]or arr[k] ?
It seem like `size_t` suites well because 'is large enough to
represent an offset into all addressible memory.'
It seems like `std.algorithm.each` is not executed in the example
below.
Could anyone tell why?
Thank you.
import std.algorithm;
void main(string[] args) {
int[] arr = [1, 2, 3, 4, 5];
arr.each!((ref e) => {
writeln(e); // does not print
++e;
DMD 2.069.1
OS Win8.1 Enterprise
On Monday, 30 November 2015 at 12:03:08 UTC, anonymous wrote:
On 30.11.2015 11:50, visitor wrote:
though i don"t understand why it fails silently ??
ref2491's original code is valid, but doesn't have the intended
meaning. `e => {foo(e);}` is the same as `(e) {return ()
{foo(e);};}`, i.e. a
On Tuesday, 10 November 2015 at 08:48:37 UTC, ref2401 wrote:
On Tuesday, 10 November 2015 at 01:04:16 UTC, uiop wrote:
Can you find the sources in your setup ? Any chance that that
phobos.lib is still the the one distributed with dmd 2.068 ?
How can I do that?
When you setup dmd 2.069, did
On Tuesday, 10 November 2015 at 01:04:16 UTC, uiop wrote:
Can you find the sources in your setup ? Any chance that that
phobos.lib is still the the one distributed with dmd 2.068 ?
How can I do that?
When you setup dmd 2.069, did you use the 7z or installer ?
Installer always
btw. Thanks
Hello
I wrote a small hello world app and imported the
`std.experimental.allocator` module.
I'm getting the following optlink error:
---
OPTLINK (R) for Win32 Release 8.00.17
Copyright (C) Digital Mars 1989-2013 All rights reserved.
On Monday, 9 November 2015 at 14:42:01 UTC, ref2401 wrote:
Hello
I wrote a small hello world app and imported the
`std.experimental.allocator` module.
I'm getting the following optlink error:
---
OPTLINK (R) for Win32 Release 8.00.17
Copyright
On Friday, 30 October 2015 at 05:21:17 UTC, Rikki Cattermole
wrote:
What I normally do for memory to be owned by the thread is:
auto foo(IAllocator alloc=theAllocator()) {...}
Where as for if it is global to the process:
auto foo(IAllocator alloc=processAllocator()) {...}
Basically it is the
On Friday, 30 October 2015 at 10:35:03 UTC, Laeeth Isharc wrote:
I'm writing a talk for codemesh on the use of D in finance.
I want to start by addressing the good reasons not to use D.
(We all know what the bad ones are). I don't want to get into
a discussion here on them, but just wanted
As I understand the `std.experimental.allocator` package will be
included in the upcoming DMD 2.069 release. I like the idea of
composable allocators. Though I've got a question which I can not
answer myself.
Let's assume a team which is developing an application that can
benefit from usage
On Friday, 30 October 2015 at 01:26:17 UTC, Rikki Cattermole
wrote:
Take a look at the functions theAllocator and processAllocator.
It would be greate if compiler were able to use `theAllocator`
and `processAllocator` but they don't seem much helpfull.
Terrible naming by the way.
On Friday, 30 October 2015 at 04:11:05 UTC, ref2401 wrote:
It would be greate if compiler were able to use `theAllocator`
and `processAllocator` but they don't seem much helpfull.
Terrible naming by the way.
I should have suggested different names if don't like present
ones
If I declare a class as `final` do I have to mark all methods of
the class as `final` too?
On Wednesday, 16 September 2015 at 14:48:59 UTC, Meta wrote:
Don't do this with a dynamic array, though, as they work a bit
differently from static arrays.
Unfortunately I have to deal with dynamic arrays.
struct MyStruct {
@disable this();
this(int a, string b) {
this.a = a;
this.b = b;
}
int a;
string b;
}
I know there is a way to create one instance of `MyStruct` and
initialize it to void.
MyStruct s = void;
s =
On Wednesday, 16 September 2015 at 14:57:49 UTC, Meta wrote:
In that case, you can use std.array.uninitializedArray or
std.array.minimallyInitializedArray as needed.
http://dlang.org/phobos/std_array.html#uninitializedArray
http://dlang.org/phobos/std_array.html#.minimallyInitializedArray
Hello everyone,
I pass a D array as void* into a function.
When I'm trying to cast a void* parameter to a D array I get
'Access Violation' error.
However if I define ArrayLike struct which looks like D array
then casting will succeed.
What should I do? Should I stick to ArrayLike wrapper and
On Monday, 3 August 2015 at 21:28:29 UTC, Ali Çehreli wrote:
But you still need to communicate how many elements there are
in the array. (I used literal 3).
Yes I do. I hope there is a neat way to pass array's length too.
What is the difference between 'const' and 'in' parameter storage
classes?
When should I use 'const' or 'in'?
The documentation says 'in' is the same as 'const scope' but I
can't write 'const scope ref' though it's legal to write 'in ref'.
Thank you
On Friday, 15 May 2015 at 16:30:29 UTC, Steven Schveighoffer
wrote:
On 5/15/15 12:04 PM, ref2401 wrote:
What is the difference between 'const' and 'in' parameter
storage classes?
When should I use 'const' or 'in'?
The documentation says 'in' is the same as 'const scope' but I
can't
write
On Friday, 15 May 2015 at 16:08:31 UTC, Adam D. Ruppe wrote:
The scope storage class means you promise not to escape any
reference to the data. This isn't enforced but it is similar in
concept to Rust's borrowed pointers - it may someday be
implemented to be an error to store them in an
struct MyStruct {
this(int a, int b) {
this.a = a;
this.b = b;
}
immutable int a;
immutable int b;
}
void main(string[] args) {
MyStruct[] arr = new MyStruct[3];
arr[0] = MyStruct(5, 7);
}
Why does it
On Monday, 11 May 2015 at 13:44:14 UTC, Adam D. Ruppe wrote:
On Monday, 11 May 2015 at 13:37:27 UTC, ref2401 wrote:
Why does it happen?
You'd just be writing to the immutable memory through a
different name.
Consider if someone took a reference to one of those immutable
ints, expecting
struct MyStruct {}
void main(string[] args) {
string str = blah-blah;
auto d1 = (MyStruct) { writeln(delegate-str: , str); };
writeln(typeid(typeof(d1)));
}
dmd: 2067
os: Win8.1
build script: dmd main.d -ofconsole-app.exe -debug -unittest -wi
- if delegate has no
What advantages do ref params give over pointer params?
struct MyStruct {
string str;
this(string str) { this.str = str; }
}
void processRef(ref MyStruct ms) {
writeln(processRef: , ms);
}
void processPointer(MyStruct* ms) {
writeln(processPointer: , *ms);
}
Thank you
processPointer(ms);
I think doing this way is more descriptive.
Now all readers know that ms might be changed inside the function.
Awesome!
I'm intrested in fibers and async io.
Could anyone suggest articles, books or tutorials about the
subject?
Thank you
Builds and runs fine for me. What is your OS and build command?
-Steve
Win 8.1
dmd main.d -ofmain.exe -debug -unittest -wi
if %errorLevel% equ 0 (main.exe)
Hi Everyone,
After I switched to DMD 2067 my code that previously worked began
crashing.
If I change the return statement in the matrixOrtho function
from:
return Matrix(...);
to:
Matrix m = Matrix(...);
return m;
then the error won't occur anymore. What is going on?
If Iterator is a struct then Iterator.input won't be adjusted
properly when the foreach loop ends.
Iterator.input still holds abcde value.
If i mark Iterator as class then Iterator.input will be an empty
string after the foreach loop.
Could anyone explain me the difference please?
Thank you.
struct MyStruct {
// stuff
}
void main(string[] args) {
MyStruct s1 = void;
}
Could anyone describe me what this initialization does, please?
When do I need to use the void initialization?
Thank you.
Why aren't methods of class final by default?
Does D provide a way for explicit interface implementation?
[C#] https://msdn.microsoft.com/en-us/library/ms173157.aspx
It's written here:
http://dlang.org/module.html#staticorder
For several times I've met struct(or static struct) usage in
Phobos for singleton pattern implementation. Unfortunately now i
can remember only core.runtime.Runtime.
So I've got a question. Why do Phobos guys use struct or static
struct for or singleton pattern implementation? Why don't use
What's the difference between static class and static struct?
What should i use?
Thank you.
How can i redirect the unittests error output to a file?
Unfortunately i'm new to using shells.
I use standard windows cmd. Here is my script:
dmd main.d -debug -unittest -wi
if %errorLevel% equ 0 (
start main.exe
) else (
echo --- Building failed! ---
pause
)
I wrote start main.exe 2 errorFile but it doesn't work.
Thanks for the links.
I have shared class instance. There are two threads which can
read/write fields of the class. As i understand i can declare
class as synchronized or i can read/write using
atomicLoad/atomicStore.
What's the difference between these two approaches?
In what circumstances
I learned how 'atomicOp' and 'cas' work and why i need them from
the following sources:
http://ddili.org/ders/d.en/concurrency_shared.html (Ali's book)
http://www.informit.com/articles/article.aspx?p=1609144 (Andrei's
book)
Can anybody tell me how 'atomicFence', 'atomicLoad' and
class MyClass {
Appender!string _stringBuilder;
this() {
_stringBuilder = Appender!string(null);
_stringBuilder.clear();
}
@property string str() {
return _stringBuilder.data;
}
void append(string
Hi.
I have this structure:
struct MyStruct {
enum MyStruct VALUE = MyStruct(5f);
static immutable MyStruct value = MyStruct(5f);
float data;
this(float v) { data = v; }
}
What's the difference between MyStruct.VALUE and MyStruct.value?
How should I decide
thank you
I'm using D 2064.2 and VisualD 0.3.37
VisualD Redirect stdout to output window checkbox is checked.
In simple ConsoleApp unittests work properly. I can debug them
and assertion fail results are printed to the Output window.
But it seems that unittests don't work at all with any
WindowsApp.
I'm seeking for a way to round floats up to specified number of
decimal digits. e.g. roundToDigits(3.1415, 2) should return 3.14.
Is there a standard function for that or what is the most correct
way to do that?
i've found the solution:
void put(T)(T mesh) {
static if (is(T : MyClass!F, string F)) {
writeln(put method: , F);
} else {
static assert(0, Invalid type ' ~
std.traits.fullyQualifiedName!T ~ '.);
}
}
Everything works fine until 'put' method in 'testB' module is
uncommented. With that code I'm getting error saying 'template
instance testA.FormatParser!(F) forward reference of variable
F.'. What does it mean and why is this happening ( to me:)) ]?
module testA; // --
class
Version D 2.062
Please explain what is causing the error
class Base
{ }
class Class(T) : Base
if (is(T == int))
{ }
Error: unrecognized declaration
Error: members expected
Error: Declaration expected, not 'if'
Error: { } expected following aggregate declaration
Version D 2.062
http://dlang.org/template.html#TemplateAliasParameter
Is is said in the documentation that is's possible but i get
compile time error.
template GetString(alias Arg)
{
enum string GetString = Arg.stringof;
}
void main(string[] argv)
{
writeln(GetString!1234);
Version D 2.062
class MyClass
{}
struct MyStruct(T)
if (is(T == class))
{
string _message = nothing;
this(T obj)
{
if (obj is null){
_message = Null reference message;
}
else{
i'm using VisualD.
this assertion fails assert(msg == Null reference message);
in my actual code instead of variable _message an exception is
thrown if (obj is null) == true.
i'm using the unittest block to test exception throwing.
...
this(T obj)
{
if (obj is
public template rgba(uint value)
{
enum Color rgba = Color(
cast(ubyte)((value 24) 0xFF),
cast(ubyte)((value 16) 0xFF),
cast(ubyte)((value 8) 0xFF),
cast(ubyte)(value 0xFF));
}
public struct Color
{
public
I have a template function that must work with an array of float
values.
something like this:
void foo(T : A[], A)(auto ref T arg)
if(is(A == float))
{
...
}
Array may be static or dynamic. But the length of the array must
be 16 or 32. How can i test length value?
thanks)
What does means 'maxRelDiff' parameter?
I looked at the source code of this method and I still didn't get
it.
return fabs((lhs - rhs) / rhs) = maxRelDiff
|| maxAbsDiff != 0 fabs(lhs - rhs) = maxAbsDiff;
In what cases can I use this parameter?
Maybe you want to use std.math.feqrel instead.
that's not what i was asking about
now i got it, thanks.
I get template instance main.MyClass!(int) error instantiating
in the following case:
public class MyClass(TStuff)
{
public void foo(TStuff item)
{}
public void foo(TRange)(TRange items)
if (isInputRange!TRange is(ElementType!TRange == TStuff))
{}
}
Could you please tell me if Phobos contains any Exception class
descendants? If so, does the documentation contain a full list of
these or even the hierarchy scheme?
On Sunday, 21 October 2012 at 20:42:08 UTC, cal wrote:
On Sunday, 21 October 2012 at 20:34:51 UTC, ref2401 wrote:
what should i do to make my binary operation commutative?
You can overload opBinaryRight:
MyClass opBinaryRight(string op: +)(MyClass rhs)
{
if (rhs is null)
{
return
is there any Phobos function to calculate the next power of 2 of
the specified number?
import std.range;
int[] numbers = [1, 3, 5, 7, 9, 11];
auto rangeObject = inputRangeObject(numbers);
auto inputRange = cast(InputRange!(int[]))rangeObject;
why does 'inputRange' equal null?
i have an array of ubytes. how can i convert two adjacent ubytes
from the array to an integer?
pseudocode example:
ubyte[5] array = createArray();
int value = array[2..3];
is there any 'memcpy' method or something else to do this?
general question:
-std.file,
-std.stdio.File,
-std.stream.File
which of the existing approaches i have to choose when working
with files? what shall i look at?
for example, i have a binary file. i want to read the first byte,
process it and then read the following N bytes (N calculation
82 matches
Mail list logo