On 10/03/2016 07:19 PM, Chalix wrote:
If I "import foo;" in my project, it will be compiled alongside.
Not necessarily. dmd won't compile foo unless you tell it to by putting
foo.d on the command line. If foo is only imported, dmd parses the file
but it doesn't compile it.
So
there is no n
On 10/04/2016 09:22 PM, Begah wrote:
I seem to be missing something.
It seems that if you want to create a shared object of a structure ( or
class ), then I have to copy every functions and add "shared" to it.
This seems way more work than it should.
For example why can't this simply work :
cl
On 10/06/2016 04:32 PM, Nordlöw wrote:
Is there a concept in D similar to Rust's `collect`:
https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.collect
If not, I'm eager to implement it to support D-style containers.
What would the desired interface look like?
Perhaps:
0.iota(n
On 10/06/2016 07:44 PM, ag0aep6g wrote:
https://dlang.org/phobos/std_container_util.html#.make
More specifically, the second overload is where it's at:
https://dlang.org/phobos/std_container_util.html#.make.2
On 10/06/2016 09:54 PM, TheGag96 wrote:
Interestingly enough, I found that using .each() actually compiles
without the []
[...]
why can the compiler consider it a range here but not
.sort()?
each is not restricted to ranges. It accepts other `foreach`-ables, too.
The documentation says that
On 10/09/2016 10:57 PM, jython234 wrote:
1. Where do I use the "shared" keyword?
Mainly on data, I'd say. But I'm only dabbling in concurrency stuff.
I've done things like making
whole classes shared, which doesn't seem to make the member methods
shared either.
It does make the methods shar
On 10/11/2016 09:55 AM, orip wrote:
auto foo(int[] ints) {
import std.range;
if (ints.length > 10) {
return chain(ints[0..5], ints[8..$]);
} else {
//return ints; // Error: mismatched function return type inference
of int[] and Result
return chain(ints[0..0], ints[0..$]); // Thi
On 10/11/2016 06:24 AM, Jon Degenhardt wrote:
The example I gave uses ref parameters. On the surface it would seem
reasonable to that passing a static array by ref would allow it to be
modified, without having to slice it first.
Your ref parameters are only for the per-element operations. You'r
On 10/12/2016 01:56 PM, tcak wrote:
I feel like I remember that this was added to D a while ago, but I am
not sure. Is it possible to create anonymous classes?
public interface Runnable{
void run();
}
runIt( new Runnable(){
void run(){
/* do stuff */
}
});
runIt(new class
On 10/12/2016 10:40 PM, mikey wrote:
import std.exception;
class Worker {
private:
uint _wage = 10_000;
public:
@property uint wage() { return _wage; }
@property void wage(uint wage)
in {
enforce(wage >= 10_000 && wage <= 1_000_000_000
On 10/12/2016 10:49 PM, mikey wrote:
import std.exception;
interface Widthy {
@property inout(int) width() inout;
@property void width(int width) in { enforce(width < 0); }
}
class Test : Widthy {
private:
int _w;
public:
@property inout(i
On 10/14/2016 12:18 PM, Nordlöw wrote:
import std.algorithm.iteration : filter;
import std.algorithm.mutation : move;
import std.range : iota;
static private struct S
{
import core.memory : GC;
@disable this(this);
this(int x)
{
_ptr = cast(typeof(_ptr))GC.malloc((*_ptr)
On Friday, 14 October 2016 at 14:00:53 UTC, ag0aep6g wrote:
As for ways to make this work:
1) You can move s to the heap yourself:
[...]
2) Or you can move it into a struct that gets returned (more
involved):
[...]
3) Put a struct on the heap that acts as the closure:
auto below5(size_
On 10/21/2016 06:55 PM, Basile B. wrote:
This very simple stuff:
class Item
{
alias children this;
Item[] children;
void populate()
{
children ~= new Item;
assert(children.length == 1);
}
}
void main()
{
Item root = new Item;
root.populate;
}
leads t
On 10/24/2016 04:25 PM, Dorian Haglund wrote:
The following code crashes with DMD64 D Compiler v2.071.2:
import std.algorithm;
import std.stdio;
import std.range;
int main()
{
repeat(8, 10).chunks(3).writeln();
return 0;
}
Looks like a bug. Doesn't happen with 2.072.0-b2, so it has appar
On 10/24/2016 05:59 PM, Meta wrote:
repeat(8, 10).chunks(3).writeln();
This will throw an AssertError because 10 is not evenly divisible by 3.
chunks doesn't require that the length of the range be evenly divisible
by the chunk size.
See https://dlang.org/phobos/std_range.html#.Chunks
On 10/25/2016 11:30 AM, Benjamin Thaut wrote:
Please consider the following program:
[...]
I would assume that this program should run forever and never run out of
memory. But instead it triggers an assert inside alocator_list in pass
11. So I assume this is some bug in std.allocator?
I can c
On 11/01/2016 06:52 PM, Nordlöw wrote:
Should I always, when possible, prefer `immutable` over `const`?
I'd say: prefer immutable.
And does `immutable` increase the possibility of the compiler doing
optimizations, such as common subexpression elimination?
Or can the compiler infer `const` de
On 11/06/2016 05:00 PM, Alex wrote:
On Sunday, 6 November 2016 at 15:13:56 UTC, Alex wrote:
ok... played with the code a little bit.
If I remove the @trusted attribute in line 657 inside atomic.d
everything works as expected...
Any ideas, why it is so?
By the way, replacement with @safe works
On 11/07/2016 12:21 PM, Alex wrote:
On Sunday, 6 November 2016 at 16:07:54 UTC, ag0aep6g wrote:
[...]
Very weird. Would be great if you could provide a test case. Doesn't
need to be minimal.
I would if I would know how... :) the problem is, setting up the
debugger itself was not a simple task
On 11/07/2016 06:18 PM, Alex wrote:
On Monday, 7 November 2016 at 17:12:32 UTC, Alex wrote:
dmd -c -of./app.o -debug -g -gc -O -profile -w ./app.d -vcolumns
dmd -of./app ./app.o -g -gc
Knowing this, I tried to find the option which does the difference. This
was the profile option. So, if I om
On 11/07/2016 06:30 PM, Somebody wrote:
void moveFrom(int[] a, in int[] b) @trusted in{
assert(a.length >= b.length);
} body {
memmove(cast(void*)a.ptr, cast(void*)b.ptr, b.length * int.sizeof);
}
Is this ok? And if not, how should it be done, preferably without
changing the condition or
On 11/07/2016 09:16 PM, Somebody wrote:
Can the version switch be used to detect noboundscheck?
Apparently, yes: `version (D_NoBoundsChecks)`.
http://dlang.org/spec/version.html#predefined-versions
I was thinking
that if, it could be used to make an overload of enforce that acts just
like in
On 11/19/2016 10:26 PM, Charles Hixson via Digitalmars-d-learn wrote:
It's worse than that, if they modify the length the array may be
reallocated in RAM so that the pointers held by the containing class do
not point to the changed values. (Read the header comments...it's not
nice at all.)
Arg
On 11/20/2016 01:33 AM, Charles Hixson via Digitalmars-d-learn wrote:
Yes. I was hoping someone would pop up with some syntax making the
array, but not its contents, const or immutable, which I couldn't figure
out how to do, and which is what I really hoped would be the answer, but
it appears th
On 11/20/2016 04:34 AM, Charles Hixson via Digitalmars-d-learn wrote:
Whether you would call the change "break things for your code" might be
dubious. It would be effectively broken, even if technically my code
was doing the correct thing. But my code wouldn't be storing the data
that needed st
On 11/20/2016 08:30 PM, Charles Hixson via Digitalmars-d-learn wrote:
Well, that precise approach wouldn't work. (The traits aren't a part of
the sturct, e.g.),
What do you mean by "traits"?
On 11/20/2016 09:09 PM, Charles Hixson via Digitalmars-d-learn wrote:
Thinking it over a bit more, the item returned would need to be a
struct, but the struct wouldn't contain the array, it would just contain
a reference to the array and a start and end offset. The array would
need to live somew
On 11/21/2016 07:36 AM, Stefan Koch wrote:
On Monday, 21 November 2016 at 03:58:00 UTC, MGW wrote:
On Sunday, 20 November 2016 at 18:58:04 UTC, Basile B. wrote:
On Sunday, 20 November 2016 at 17:47:50 UTC, MGW wrote:
import core.sys.windows.windows: MessageBoxA;
void test() {
for(int i; i
On 11/21/2016 08:27 AM, Stefan Koch wrote:
Someone could still be hanging on to an old Reference of buf.
Who could "someone" be? It's a self-contained example, and buf doesn't
leave the test function.
On Monday, 21 November 2016 at 16:37:32 UTC, Kagamin wrote:
Anything in .data and .bss sections and stack. See
https://issues.dlang.org/show_bug.cgi?id=15723
Ok, not an actual reference then, but a false pointer.
On 11/24/2016 06:15 PM, Jot wrote:
I think you are failing to realize the first axiom I presented. I only
updated dmd2. This shouldn't change the object and library files. They
should essentially compile to the same thing and it shouldn't matter.
As far as I can tell, this isn't generally true.
On 11/24/2016 06:47 PM, Steven Schveighoffer wrote:
void foo(T)(T t){writeln("a");}
void foo(T...)(T t){writeln("b");}
foo(1);
Compiles? If so, which prints out?
I was surprised by the answer. I can't find docs for it. Is the behavior
intended?
Took me a bit to find it, but it is documented:
On 11/24/2016 09:18 PM, Jot wrote:
And dmd2.exe does not recognize that an object file is out of date?
Seems like a bug to me...
I don't know enough about these things to make definite statements, but
I wouldn't expect dmd to detect such situations. Do object file formats
have ways to store i
On 11/27/2016 09:52 PM, Marduk wrote:
class Example {
this(Type_left x, Type_right y) {
this.left = x;
this.right = y;
}
Type_left left;
Type_right right;
}
Such that at runtime I can instantiate it with different types:
new Example(int a, int b);
new Example
On 11/27/2016 10:02 PM, Marduk wrote:
I read in an old post in these forums that with a dynamic mixin it is
possible to add structures and classes at runtime. I searched "dynamic
mixin" but I did not find more information.
Can you link that post, please? I can't imagine what "dynamic mixin"
co
On 11/27/2016 10:19 PM, Marduk wrote:
On Sunday, 27 November 2016 at 21:10:30 UTC, ag0aep6g wrote:
Can you link that post, please? I can't imagine what "dynamic mixin"
could refer to.
Sure, it's here:
http://forum.dlang.org/post/xmnnsdiuwyjrhkasy...@forum.dlang.org
Ok, that's a hypothetical.
On 11/29/2016 02:21 AM, Basile B. wrote:
The cast from a class type to a sub class in itself does absolutely
nothing.
That can't be right. A bad downcast gives you null, so it has to check
the dynamic type information. Compare with upcasts which are statically
known to be correct, so they don
On 11/30/2016 10:42 AM, Bauss wrote:
Usually casts to base classes can be determined if they're valid at
compile-time.
Yeah, that's what I said. A cast to a base class is an "upcast". Upcasts
don't need run-time checks. The other direction (cast to more derived
class) is a downcast. Downcasts
On 12/10/2016 04:39 AM, unDEFER wrote:
man remove:
remove - remove a file or directory
That's documentation for C, not for D.
The function which removes only files named unlink.
The D must guarantee the same behaviour of remove on all OSes.
D has no obligation to follow C in function nami
On 12/11/2016 12:43 PM, TheGag96 wrote:
On Sunday, 11 December 2016 at 11:17:50 UTC, rikki cattermole wrote:
Not public, please pastebin.
https://github.com/TheGag96/evo-pacman/blob/master/source/pacman/tree.d#L135
I just put it on GitHub. No idea why the repo wasn't public even after I
set
On 12/13/2016 10:27 PM, Xavier Bigand wrote:
voidset()
{
GLfloat[]data = [
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
0.0f, 1.0f, 0.0f,
];
glBindVertexArray(mVAO);
glBufferData(GL_ARRAY_BUFFER, data.sizeof, cast(voi
On 12/15/2016 06:44 PM, David Zhang wrote:
It is my understanding that a class can have a struct as one of its
members, and it will be allocated in-line with the rest of the class'
members.
Yup.
My question is this; how might I be able to do this with
another class? I want to be able to alloc
On 12/15/2016 09:51 PM, David Zhang wrote:
However, it leaves me with another question, how
much (if any) space would the static array require from the class?
Depends on SomeClass. The array's size is just the value of
__traits(classInstanceSize, SomeClass). There's no overhead.
You can prin
On Thursday, 15 December 2016 at 21:37:34 UTC, David Zhang wrote:
So the size of Foo would be the size of SomeClass plus members?
ie. Is the size of the array stored too?
With these definitions:
class SomeClass {}
class Foo
{
this()
{
import std.conv: emplace;
em
On Friday, 16 December 2016 at 18:25:42 UTC, David Zhang wrote:
I though all classes were aligned to sizeof(size_t) boundaries?
I don't know.
Wouldn't it then just be
align(sizeof(size_t)) byte[__traits(classInstanceSize,
SomeClass)] scStorage;
I guess? I really don't have much of a clue
On 01/15/2017 07:58 AM, Nestor wrote:
I eventually came up with this, but it seems an ugly hack:
import std.stdio;
uint getAge(int , ubyte mm, ubyte dd) {
ubyte correction;
import std.datetime;
SysTime t = Clock.currTime();
if (t.month < mm) correction = 1;
else if (t.month == mm)
On Saturday, 28 January 2017 at 18:04:58 UTC, Nestor wrote:
I believe I saw somewhere that in D a char was not neccesarrily
the same as an ubyte because chars sometimes take more than one
byte,
In D, a `char` is a UTF-8 code unit. Its size is one byte,
exactly and always.
A `char` is not a
On Friday, 27 January 2017 at 23:22:17 UTC, Nick Sabalausky wrote:
Suppose an array is being used like a FIFO:
---
T[] slice;
// Add:
slice ~= T();
// Remove:
slice = slice[1..$];
---
Assuming of course there's no other references to the memory,
as thi
On Sunday, 29 January 2017 at 21:41:57 UTC, albert-j wrote:
int[] arr;
foreach (i; 0..10)
arr ~= i;
writeln("Original array: ",arr);
// [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] -- OK
auto arrMap = arr.filter!(x => x > 5).map!(x => x^^2);
arrMap is a range. The filter and map
On 01/30/2017 11:58 AM, Profile Anaysis wrote:
the code from https://dlang.org/library/std/concurrency/generator.html
gives a seg fault at the end.
import std.concurrency;
import std.stdio;
void main()
{
auto tid = spawn(
{
while (true)
{
writeln(receiveOnl
On 01/30/2017 11:58 AM, Profile Anaysis wrote:
Also, if one tries to create a global generator an error about PAGESIZE
not being a compile time value is given.
That means you can't initialize it statically, because PAGESIZE is not
known statically. But you can have a global (module scope, thre
On 01/30/2017 12:55 PM, Jack Applegame wrote:
Code:
import std.stdio;
struct Foo {
int val = 0;
~this() {
writefln("destruct %s", val);
}
}
void bar(ARGS...)() {
ARGS args;
args[0].val = 1;
writefln("val = %s", args[0].val);
}
void main() {
bar!Foo();
}
On 01/30/2017 01:33 PM, albert-j wrote:
On Monday, 30 January 2017 at 12:31:33 UTC, albert-j wrote:
OK, got it. Can you do removal without reallocation with
std.container.array?
Array!int arr;
foreach (i; 0..10) arr ~= i;
Sorry, sent too early.
arr = arr[].remove!(x=> x > 5); /
On 02/04/2017 12:31 PM, Profile Anaysis wrote:
I am trying to iterate over the combinations of a set using the code
https://rosettacode.org/wiki/Power_set#D
I have an array which I call powerSet on and I get a result of
MapResult. I have tried to foreach or front/popFront and even each() on
it
On 02/04/2017 03:53 PM, Profile Anaysis wrote:
well, I simply took the code from the page I linked and did a front() on
the MapResult and it say the type was wrong. I thought it would give me
the type I put in which was an array.
In the code you can see that powerSet does two levels of `map`. I
On Sunday, 5 February 2017 at 20:36:57 UTC, Mark Fisher wrote:
static auto ref BindArg(alias Func,alias arg,args...)() {
return Func(arg,args);
}
[...]
BindArg(f,"1",2,3);
You forgot an exclamation mark there:
BindArg!(f,"1",2,3);
On 02/12/2017 12:15 AM, Random D user wrote:
I can init a variable from mutable source without defining any
constructor or assignment operators, but not if the source is const. I
would imagine the behavior to be the same with mutable and const source,
since it's just reading the source and copyin
On Sunday, 12 February 2017 at 20:08:05 UTC, bitwise wrote:
It seems like you're saying that 'shared' should mean both
'thread safe' and 'not thread safe' depending on context, which
doesn't make sense.
Makes sense to me: A `shared` variable is shared among threads.
Accesses are not thread-sa
On 02/13/2017 01:27 AM, Moritz Maxeiner wrote:
__gshared int a = 0;
// thread 1:
a = 1;
int b = a;
writeln(b);
// thread 2:
a += 1;
In the above, you may expect `b` to be either 1, or 2, depending on how
the cpu interleaves the memory access, but it can, in fact, also be 0,
since neither the c
On Wednesday, 15 February 2017 at 22:34:22 UTC, H. S. Teoh wrote:
auto debugPrint(alias fun, A...)(A args) {
writefln("%s(%(%s, %))", __traits(identifier, fun), [args]);
return fun(args);
}
string arg = "hello";
string myCall = debu
On 02/17/2017 07:41 PM, berni wrote:
The command that works is
dmd a.d b.o
where b.o is a precompiled c file, similar to
https://github.com/dlang/druntime/blob/master/src/core/stdc/errno.c
When using rdmd it doesn't work anymore. When I make rdmd --chatty, I
can find the reason: b.o is ommited
On 02/17/2017 09:24 PM, Ali Çehreli wrote:
It's the Unicode character "U+FFFD
REPLACEMENT CHARACTER", which is represented by 2 chars in D.
It takes 3 `char`s to represent U+FFFD:
void main()
{
import std.stdio;
writeln("\uFFFD".length); /* prints "3" */
}
On Saturday, 18 February 2017 at 20:15:55 UTC, timmyjose wrote:
2. I am more interested in learning D as a pure systems
programming language so that I can develop my own tools (not
looking to develop an OS, just some grep-scale tools to start
off with). In that regard, I have a few concerns abo
On 02/19/2017 12:51 PM, timmyjose wrote:
a). So the GC is part of the runtime even if we specify @nogc
Yup. @nogc is per function, not per program. Other functions are allowed
to use the GC.
b). Do we manually trigger the GC (like Java's System.gc(), even though
that's not guaranteed), or d
On 02/19/2017 12:13 PM, berni wrote:
And here is what I get when compiling:
$> rdmd test.d
segmentation fault
$> rdmd --extra-file=test2.d test.d
segmentation fault
$> rm -rf /tmp/.rdmd-1000/
$> rdmd --extra-file=test2.d test.d
A
$> rdmd -version
rdmd build 20170122
[...]
Should I report this
On Sunday, 19 February 2017 at 19:19:25 UTC, berni wrote:
Is it possible to force a function to be inlined?
https://dlang.org/spec/pragma.html#inline
On 02/20/2017 03:44 PM, timmyjose wrote:
Things I don't like so much:
1). The std.range: iota function(?) is pretty nice, but the naming seems
a bit bizarre, but quite nice to use.
Yeah, the name is weird. A little googling suggests it comes from C++
[1] which took it from APL.
2). The aut
On Wednesday, 22 February 2017 at 19:26:15 UTC, berni wrote:
In my program, I read a postscript file. Normal postscript
files should only be composed of ascii characters, but one
never knows what users give us. Therefore I'd like to make sure
that the string the program read is only made up of
On Sunday, 26 February 2017 at 19:34:33 UTC, thorstein wrote:
// Reads CSV-like files with only numeric values in each column
// new_ndv replaces ndv, which is the original no-data-value
double[][]* readNumMatCsv(char[] filePath, int numHeaderLines,
char[] ndv, char[] new_ndv)
* "no-data-value
On 02/27/2017 01:35 AM, Bastiaan Veelo wrote:
template eval_all(funcs...)
{
void eval_all(int val)
{
import std.parallelism;
//foreach (i, f; parallel(funcs))// Tries to evaluate f(void)
foreach (i, f; funcs)// How do I parallelise this?
values[
On 02/27/2017 10:52 AM, Bastiaan Veelo wrote:
On Monday, 27 February 2017 at 02:02:57 UTC, ag0aep6g wrote:
[...]
enum fptr(alias f) = &f;
(This is still a bit magical to me: it this a shorthand for a template?)
Yes, it's short for this:
template fptr(alias f) { enum fptr = &f; }
"addrOf" i
On 03/02/2017 10:10 PM, Guillaume Chatelet wrote:
On Thursday, 2 March 2017 at 20:30:47 UTC, Guillaume Chatelet wrote:
Here is the same code in D:
void main(string[] args)
{
import std.math;
FloatingPointControl fpctrl;
fpctrl.rounding = FloatingPointControl.roundUp;
writefln("%.
On 03/02/2017 10:49 PM, Guillaume Chatelet wrote:
Thx for the investigation!
Here is the code for FloatingPointControl
https://github.com/dlang/phobos/blob/master/std/math.d#L4809
Other code (enableExceptions / disableExceptions) seems to have two code
path depending on "version(X86_Any)", round
On 03/03/2017 05:39 PM, ag0aep6g wrote:
dmd generates SSE instructions for floating point math.
FloatingPointControl only minds the control register for the FPU. But
SSE instructions are not affected by that. SSE has a separate control
register: MXCSR.
I've filed an issue:
https://issues.dl
On 03/08/2017 02:15 AM, XavierAP wrote:
I see the default allocator is the same GC heap used by 'new'. Just for
my learning curiosity, does this mean that if I theAllocator.make()
something and then forget to dispose() it, it will be garbage collected
the same once no longer referenced? And so ar
On 03/11/2017 06:41 PM, Eric wrote:
I'm trying to build the master branch of DMD on redhat 7.
I get the following errors:
ddmd/root/newdelete.c:26:8: error: expected identifier or ‘(’ before
string constant
extern "C"
^
ddmd/root/newdelete.c:31:17: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ o
On 03/13/2017 01:02 AM, Inquie wrote:
Ok, it doesn't work for appending though ;)
[...]
Tuple!(int, "A", double, "B")[] y;
y ~= tuple(3, 2.5);
Interestingly, this works:
Tuple!(int, "A", double, "B")[] y;
y.length += 1;
y[$ - 1] = tuple(3, 2.5);
On 03/13/2017 03:26 PM, Jack Applegame wrote:
I'm pretty sure that this code should compile
(https://dpaste.dzfl.pl/cf1e1ee6ef4b):
struct A(T) {
~this() {
char[T.sizeof] data;
}
}
struct B(T) {
A!T foo;
}
struct C {
B!C bar;
}
void main() {
C c;
}
But it doesn't:
On 03/14/2017 12:02 AM, Stefan Koch wrote:
On Monday, 13 March 2017 at 22:59:36 UTC, ag0aep6g wrote:
[...]
struct A(T) {
void m() {
char[T.sizeof] data;
}
}
/* ... rest as above ... */
I don't see how the destructor makes a difference. Soo, bug?
Try to use m.
Work
On 03/13/2017 11:58 PM, Stefan Koch wrote:
On Monday, 13 March 2017 at 22:05:24 UTC, Jack Applegame wrote:
Is this a bug?
No it's not
struct C
{
B!C;
}
is an error.
Howto compute C ? <--\
let's check the members; |
The member needs a template. |
Howto compute the template
On 03/15/2017 03:01 AM, Inquie wrote:
If I do something like
enum X = Methods!(C);
foreach(x; X)
{
mixin(x);
}
I get an error about x not being a compile time variable. (code above is
simplified, the error has nothing to do with the form but of the
foreach(x )
"Compile time variable" ma
On 03/15/2017 02:00 PM, Inquie wrote:
Thanks, it explains it, but there is one difference. The array is
assigned to an enum, so surely the compiler can figure that out? It
should be similar to AliasSeq.
The enum array is similar to an AliasSeq in that you can them both in
contexts that require
Phobos has it: std.meta.aliasSeqOf "converts an input range [...] to an
alias sequence." [1]
Woops, forgot to give the URL for that "[1]". Here it is:
http://dlang.org/phobos/std_meta.html#aliasSeqOf
On 03/18/2017 01:22 PM, Oleg B wrote:
enum arr = cast(ubyte[])[0,0,0,1,0,0,0,2,0,0,0,3,0,0,0,4];
auto arr1 = cast(void[])arr;
immutable arr2 = cast(immutable(void)[])arr;
enum arr3 = cast(void[])arr;
Aside: The casts here do nothing to affect the outcome.
writeln(cast(ush
On 03/19/2017 10:32 PM, Nordlöw wrote:
Is there an in-place version of std.uni.toLower()
toLowerInPlace
On 03/20/2017 05:55 PM, StarGrazer wrote:
typeof(&method) fails unless method is static. Says & requires this.
Works for me:
class C
{
void method() {}
typeof(&method) x;
}
typeof(&C.method) y;
Tested with dmd 2.073.2.
Note that the type of x and y is `void function()`, not
On 03/21/2017 04:09 PM, StarGrazer wrote:
On Tuesday, 21 March 2017 at 15:01:43 UTC, ag0aep6g wrote:
On 03/20/2017 05:55 PM, StarGrazer wrote:
typeof(&method) fails unless method is static. Says & requires this.
Works for me:
class C
{
void method() {}
typeof(&method) x;
}
typeo
On 03/25/2017 11:37 PM, zabruk70 wrote:
union Union1
{
align(1):
byte[5] bytes5;
struct
{
align(1):
char char1;
uint int1;
}
}
void main ()
{
import std.stdio: writefln;
writefln("Union1.sizeof=%d", Union1.sizeof); //prints 8, not 5
}
I'm not sure how the align stuff
On Sunday, 26 March 2017 at 10:34:21 UTC, Dlearner wrote:
I came back to this project and realised my mistakes (Importer
is a class for the C++ API, and we're using the C API).
So I fixed all my errors, but now I get an access violation.
As far as I can tell, it seems to be an issue with
`aiGet
On 03/26/2017 11:31 PM, Dlearner wrote:
SDL_Surface* surface = IMG_Load(filename.ptr);
if (surface is null) {
writeln("surface is null: ", to!string(IMG_GetError()));
} else {
writeln(filename);
}
From console:
surface is null: Couldn't open Models/Nanosuit/helmet_dif
On 04/07/2017 07:06 PM, Russel Winder via Digitalmars-d-learn wrote:
factorial.d(71,15): Error: template std.bigint.BigInt.__ctor cannot deduce
function from argument types !()(string) immutable
On 04/08/2017 02:18 PM, Russel Winder via Digitalmars-d-learn wrote:
https://github.com/russel/Fac
On 04/08/2017 11:59 PM, Meta wrote:
enum a = 0;
template test1()
{
enum b1 = a; //Okay, a is in scope at the declaration site
//enum c = d1; Error: undefined identifier d1
This line works just fine, actually. There's really no difference
between a normal template and a mixin template
On 04/09/2017 07:44 AM, Meta wrote:
On Saturday, 8 April 2017 at 22:37:18 UTC, ag0aep6g wrote:
[...]
This line works just fine, actually. There's really no difference
between a normal template and a mixin template when you use it in a
mixin.
[...]
Hmm, you're right, but this is not how it is
On 04/09/2017 04:36 PM, Boris-Barboris wrote:
Hello, I have a similar problem. For the life of me I can't make CTFE
work while manipulating collections. Source:
This post is only loosely related to the thread. Generally, please make
a new thread for a new problem.
import std.meta;
import st
On 04/09/2017 10:49 PM, Duarte wrote:
---
import std.stdio;
pure void foo()
{
debug
{
stdout.writeln("1");
}
stdout.writeln("2");
}
void main(string[] args)
{
foo();
}
---
Using either '-debug' or '-release', the second stdout will give an
On 04/13/2017 11:06 PM, Jesse Phillips wrote:
-
[...]
private static immutable list = AliasSeq!(
tuple("a", "q"),
tuple("b", "r"),
);
[...]
switch(search) {
--->foreach(li; list) { // li initialization is skipped
On 04/16/2017 11:20 AM, Joel wrote:
What would you put instead of this C# code, in D?
```C#
// Arrange
const string templateString = "My {pet} has {number}
{ailment}.";
var pairs = new
{
pet = "dog",
number = 5,
On 04/17/2017 09:29 PM, Jesse Phillips wrote:
On Thursday, 13 April 2017 at 21:33:28 UTC, ag0aep6g wrote:
[...]
By the way, in my opinion, `case li[0]:` shouldn't compile with the
static immutable `list`. `list` and `li[0]` are dynamic values. The
compiler only attempts (and succeeds) to evalua
On 04/18/2017 02:48 AM, Jethro wrote:
I generally need this for regex stuff and it's quite annoying it doesn't
work.
if (!match(s, "\s*(?P.),").empty())
{
// Need the result of match to do things!
}
but this doesn't work:
if (!(auto r = match(s, "\s*(?P.),")).empty())
{
}
Stanislav Blinov
601 - 700 of 758 matches
Mail list logo