On Sunday, 14 May 2017 at 01:15:03 UTC, Lewis wrote:
On Saturday, 13 May 2017 at 19:22:09 UTC, Steven Schveighoffer
wrote:
It's just out of date. Can't remember the version, but this
did use to allocate. It doesn't any more. But only for this
case. In most cases it does allocate.
Okay cool, t
On Tuesday, 17 January 2017 at 20:21:34 UTC, Nordlöw wrote:
Is there a way to mimic C++-style `mutable` members in D?
You could store a ptr to the member outside:
import std.stdio;
private int* _pid;
struct A
{
int id;
this(int id)
{
this
We have a handy dandy syntax for this:
if (MyClassInt subclass = cast(MyClassInt)value) {
writeln(subclass.value);
}
If it doesn't cast to said type (it will be null) that branch
won't execute.
Just out of interest: it looks like a dynamic_cast in C++ which
is considered as slow oper
On Sunday, 27 November 2016 at 20:52:06 UTC, Marduk wrote:
Dear all,
I would like to have a kind of template class like the
following:
class Example {
this(Type_left x, Type_right y) {
this.left = x;
this.right = y;
}
Type_left left;
Type_right right;
}
Suc
On Tuesday, 22 November 2016 at 13:06:27 UTC, Nordlöw wrote:
On Monday, 21 November 2016 at 20:04:51 UTC, Ali Çehreli wrote:
mixin template RvalueRef()// <-- DOES NOT TAKE A PARAMETER
ANY MORE
{
alias T = typeof(this);
static assert (is(T == struct));
@nogc @safe
ref const(
On Monday, 21 November 2016 at 12:44:47 UTC, Jonathan M Davis
wrote:
On Monday, November 21, 2016 12:08:30 Patric Dexheimer via
Digitalmars-d- learn wrote:
No. D doesn't have that, though it's easy enough to do the same
thing with a helper template. However, Ketmar seems to like to
use his own
On Tuesday, 18 October 2016 at 10:35:44 UTC, Nordlöw wrote:
On Monday, 2 May 2016 at 17:43:56 UTC, Namespace wrote:
immutable auto a = [1,2,3].s;
Will that have zero run-time overhead compared to:
immutable int[3] a = [1,2,3];
?
I'm not quite sure if pragma(inline, true) would result
The Code below still works, so I guess it's some problem with the
constraint of "exists".
import std.stdio;
enum Foo
{
A = "B"
}
void test(string a)
{
}
void main()
{
test(Foo.A);
Foo.A.test();
}
On Sunday, 25 September 2016 at 04:54:31 UTC, grampus wrote:
Dear all
For example, I have a struct
struct point{int x;int y}
point a;
Is there an easy way to access x and y by using a["x"] and
a["y"]
I guess I need to overload [], but can't figure out how.
Someone can help? Thank you very m
On Thursday, 7 July 2016 at 09:59:23 UTC, Jacob Carlborg wrote:
Is it possible to get the name of a C++ class, "extern(C++)
class Foo {}", at runtime just as it's possible to do the same
for a D class, like "object.classinfo.name"?
Maybe with a template?
void class_name(T)(T obj) if (is(
Just for you, a slightly adapted version:
import std.stdio;
struct A {
public int id = 0;
this(int id) {
this.id = id;
}
ref A byRef() {
return this;
}
}
void foo(ref const A a) {
writeln(a.id
On Saturday, 2 July 2016 at 21:19:04 UTC, ketmar wrote:
On Saturday, 2 July 2016 at 21:17:33 UTC, Namespace wrote:
On Saturday, 2 July 2016 at 21:15:29 UTC, ketmar wrote:
On Saturday, 2 July 2016 at 21:05:18 UTC, Namespace wrote:
Try this little trick:
or don't. such pointers to structs are
On Saturday, 2 July 2016 at 21:15:29 UTC, ketmar wrote:
On Saturday, 2 July 2016 at 21:05:18 UTC, Namespace wrote:
Try this little trick:
or don't. such pointers to structs are *dangerous*.
Either that "dangerous" thing or 2^N template bloat.
On Saturday, 2 July 2016 at 19:40:53 UTC, phant0m wrote:
On Saturday, 2 July 2016 at 19:25:37 UTC, ketmar wrote:
note the first "()", though: this is effectively a template
function, which compiler will instantiate either with "ref" or
without it.
Yeah, I've noticed it. Always using function
The Factory-Pattern would be a good idea.
On Friday, 20 May 2016 at 18:42:44 UTC, Ali Çehreli wrote:
On 05/20/2016 10:28 AM, Namespace wrote:
> On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis
wrote:
>> On Thursday, May 19, 2016 20:44:54 ciechowoj via
Digitalmars-d-learn
>> wrote:
>>> Is there D equivalent of C++'s mutable keyw
On Thursday, 19 May 2016 at 23:21:14 UTC, Jonathan M Davis wrote:
On Thursday, May 19, 2016 20:44:54 ciechowoj via
Digitalmars-d-learn wrote:
Is there D equivalent of C++'s mutable keyword? Like the one
that allows to modify a field of struct from constant method.
Or some alternative solution?
On Monday, 2 May 2016 at 20:05:15 UTC, Steven Schveighoffer wrote:
On 5/2/16 3:38 PM, Namespace wrote:
The assembler might be safe in some instances, but that
doesn't
reflect the original internal representation in the compiler.
Some
other configuration of calls may allow the compiler to reuse
The assembler might be safe in some instances, but that doesn't
reflect the original internal representation in the compiler.
Some other configuration of calls may allow the compiler to
reuse that memory, and then you run into problems.
I'm wondering if you used my rewrite if it would actually
On Monday, 2 May 2016 at 19:08:52 UTC, Steven Schveighoffer wrote:
On 5/2/16 3:02 PM, Namespace wrote:
On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote:
A slice of a no-longer-existing temporary! Admittedly, this
is not an
issue with your code, but a deeper issue of allowing slicing
of r
A slice of a no-longer-existing temporary! Admittedly, this is
not an issue with your code, but a deeper issue of allowing
slicing of rvalues.
This works:
int[] as = [1, 2, 3].s;
writeln(as[2]);
Bug or feature? Or did I may misunderstood you?
You can drop auto. It's just a placeholder
On Monday, 2 May 2016 at 18:57:49 UTC, Namespace wrote:
A slice of a no-longer-existing temporary! Admittedly, this is
not an issue with your code, but a deeper issue of allowing
slicing of rvalues.
This works:
int[] as = [1, 2, 3].s;
writeln(as[2]);
Of course this slice is only valid as
On Monday, 2 May 2016 at 13:00:27 UTC, Erik Smith wrote:
Is there a way to initialize a static array and have it's size
inferred (and that works for arrays of structs using braced
literals)? This would make it easier to maintain longer static
array definitions. The code below doesn't work whe
On Tuesday, 26 April 2016 at 09:07:59 UTC, Begah wrote:
I am trying to create an asset manager for my textures. I had
the idea ( it may be a wrong idea ) to create a hashmap of my
textures with a string as the key. When the program request a
texture, it firts check if it is in the hashmap and t
auto ref add(V)(auto ref V v1, auto ref V v2);
// default this(this)
Vec3f vec1;
// accepts both lvalues and rvalues
auto res = add(vec1, Vec3f(1, 2, 3.14));
auto ref produces template bloat. That is no real solution for
the rvalue ref problem. But there is (more or less) a workaround:
On Monday, 7 March 2016 at 18:17:18 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 7 March 2016 at 16:30:48 UTC, Namespace wrote:
Thanks to the wildcard modifier inout. Is there any possible
way to do the same in C++?
In this specific case you could do it with a macro if you don't
mind dirty macr
Let's use an example:
import std.stdio;
class Visitor {
public:
void visit(inout A) {
writeln("visit A");
}
void visit(inout B) {
writeln("visit B");
}
}
class A {
public:
void accept(Visitor v) inout {
v.visit(this);
}
}
class B : A {
publ
On Thursday, 25 February 2016 at 10:59:43 UTC, Rene Zwanenburg
wrote:
On Thursday, 25 February 2016 at 10:44:49 UTC, Andrea Fontana
wrote:
Check this simple code:
http://dpaste.dzfl.pl/2772c9144f1c
I can't understand how to minimize code duplication for
function like get().
Of course on real c
Try inout:
import std.stdio;
struct Inner
{
int field = 3;
}
struct Test
{
auto get() inout { return inner; }
private Inner inner;
}
void main()
{
{
Test test;
test.get.field = 4;
}
On Sunday, 13 December 2015 at 06:33:55 UTC, Jack wrote:
Hello, so I've been experimenting with the framework and I
tried to implement a game that has more than two windows.
The first window is the main game and the second window is a
smaller one with the various commands you can select.
So
This seems to work:
struct RefVal(T) {
private T* ptr;
this(T* val) {
ptr = val;
}
ref auto opAssign(U)(auto ref U value) {
*ptr = value;
return *ptr;
}
auto get
Well to start, I just copied the code for loading the map and
tried to build it, substituting the variables like Rect and
others.
Then it went crazy all of a sudden:
http://dpaste.com/2D59A2B
The whole thing went mad, and I was sure I had my imports
correct:
import dtiled.data;
import dtil
On Friday, 27 November 2015 at 13:00:16 UTC, Jack wrote:
Greetings!
I've been using Dgame for quite a while now and I have been
learning quite a lot from using playing with it. Then I found
Tiled that's a tool to draw tilemaps, and DTiled to implement
it.
Link [ http://code.dlang.org/packag
On Sunday, 18 October 2015 at 13:29:50 UTC, Ola Fosheim Grøstad
wrote:
On Sunday, 18 October 2015 at 12:50:43 UTC, Namespace wrote:
On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc
wrote:
https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow
Andrei suggested posting mor
On Tuesday, 13 October 2015 at 23:26:14 UTC, Laeeth Isharc wrote:
https://www.quora.com/Why-is-Python-so-popular-despite-being-so-slow
Andrei suggested posting more widely.
Maybe also interesting:
https://docs.google.com/presentation/d/1LO_WI3N-3p2Wp9PDWyv5B6EGFZ8XTOTNJ7Hd40WOUHo/mobilepresent
On Monday, 7 September 2015 at 14:12:25 UTC, Bahman Movaqar wrote:
I need some help understand the behaviour of my code[1].
Specifically I have trouble with `add` method on line 79.
My impression is that since it returns `this`, multiple
invocations can be chained like `obj.add(X).add(Y).add(
Thank you for answering so quickly. If you don't mind me asking
when will v0.7 be out?
Not so soon. But maybe I'll release v0.6.5 with this feature at
the end of september.
For now you need to store your Texture in e.g. a Texture manager.
Note that Texture is (in constrast to Sprite) a struct and not a
class, so it is a value type. Dgame tries to use as many value
types as possible to reduce the amount of garbage.
Edit:
Basically my code is:
//Texman.d//
Class TextureManager
{
//variables
void addSprite(string sprite_file, string name)
{
Surface wiki_img = Surface(sprite_file);
Texture wiki_tex = Text
On Wednesday, 29 July 2015 at 09:25:50 UTC, Snape wrote:
I'm in the early stages of building a little game with OpenGL
(in D) and I just want to know the facts about the GC before I
decide to either use it or work around it. Lots of people have
said lots of things about it, but some of that inf
Look at my example:
import std.stdio;
import std.string;
import std.conv : to;
void main()
{
while (true) {
write("Roll the dice: Enter a number: ");
int dieNumber = readln.strip.to!int;
if (dieNumber < 4) {
writeln("You won!");
}
else
Dear Ali,
thank you for helping! Problem happens when passing by value as
in param.
Change 'foo' to this:
ref S foo(ref S s)
{
s.val+=1;
return s;
}
On Wednesday, 17 June 2015 at 20:58:10 UTC, jmh530 wrote:
On Wednesday, 17 June 2015 at 20:33:11 UTC, Namespace wrote:
import std.stdio;
template BaseTypeOf(T) {
static if (is(T : U[], U))
alias BaseTypeOf = BaseTypeOf!(U);
else
alias BaseTypeOf = T;
}
void foo(T :
import std.stdio;
template BaseTypeOf(T) {
static if (is(T : U[], U))
alias BaseTypeOf = BaseTypeOf!(U);
else
alias BaseTypeOf = T;
}
void foo(T : U[], U)(T arr) if (is(BaseTypeOf!(U) == real)) {
}
void main() {
//real _x;
real[2] x;
On Monday, 25 May 2015 at 11:11:50 UTC, Chris wrote:
I'm a bit at a loss here. I cannot get the longest possible
match. I tried several versions with eager operators and stuff,
but D's regex engine(s) always seem to return the shortest
match. Is there something embarrassingly simple I'm missing
On Wednesday, 20 May 2015 at 06:31:13 UTC, Mike Parker wrote:
I don't understand why this behaves as it does. Given the
following two templates:
```
void printVal(T)(T t) {
writeln(t);
}
void printVal(T : T*)(T* t) {
writeln(*t);
}
```
I find that I actually have to explicitly
On Tuesday, 19 May 2015 at 20:02:07 UTC, rsw0x wrote:
On Tuesday, 19 May 2015 at 19:45:38 UTC, Namespace wrote:
On Tuesday, 19 May 2015 at 19:36:23 UTC, rsw0x wrote:
On Tuesday, 19 May 2015 at 18:37:31 UTC, bitwise wrote:
On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe
wrote:
On Tuesday,
On Tuesday, 19 May 2015 at 19:36:23 UTC, rsw0x wrote:
On Tuesday, 19 May 2015 at 18:37:31 UTC, bitwise wrote:
On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe
wrote:
On Tuesday, 19 May 2015 at 18:15:06 UTC, bitwise wrote:
Is this also true for D?
Yes. The GC considers all the unreference
On Tuesday, 19 May 2015 at 09:43:06 UTC, Chris wrote:
On Tuesday, 19 May 2015 at 09:10:50 UTC, Namespace wrote:
On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote:
The following
string[string] myarray = ["key":"value"];
string entry;
entry = myarray["key"]; // => vgc: indexing an associative
On Monday, 18 May 2015 at 14:30:43 UTC, Chris wrote:
The following
string[string] myarray = ["key":"value"];
string entry;
entry = myarray["key"]; // => vgc: indexing an associative
array may cause GC allocation
Why is _accessing_ an assoc treated as indexing it?
No error if you use myarray
On Sunday, 17 May 2015 at 18:49:40 UTC, dan wrote:
Is it possible to define a class F so that
auto f=new F();
writeln("The value of f at 7 is ",f(7));
compiles and works as expected?
So the idea would be to be able to use notation like
f(7)
instead of
f.eval(7)
or something along
On Sunday, 17 May 2015 at 09:59:41 UTC, Daniel Kozak wrote:
On Sun, 17 May 2015 09:33:27 +
Namespace via Digitalmars-d-learn
wrote:
On Sunday, 17 May 2015 at 09:30:16 UTC, Gary Willoughby wrote:
> On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote:
>> Is this error an ICE
On Sunday, 17 May 2015 at 09:30:16 UTC, Gary Willoughby wrote:
On Sunday, 17 May 2015 at 09:25:33 UTC, Namespace wrote:
Is this error an ICE? I think so, because I see the internal
filename, but I'm not sure.
Error: e2ir: cannot cast malloc(length * 8u) of type void* to
type char[]
Have you
Is this error an ICE? I think so, because I see the internal
filename, but I'm not sure.
Error: e2ir: cannot cast malloc(length * 8u) of type void* to
type char[]
On Thursday, 14 May 2015 at 13:26:27 UTC, ivoras wrote:
On Thursday, 14 May 2015 at 12:46:48 UTC, Adam D. Ruppe wrote:
I would just use a regular `string[]` array...
Is it resizable? Somehow I didn't get that impression from the
docs. Apparently it doesn't even have an "insert" method:
http:
On Tuesday, 5 May 2015 at 21:58:57 UTC, bitwise wrote:
On Tue, 05 May 2015 17:33:09 -0400, Namespace
wrote:
I've discussed that so many times... just search for auto /
scope ref... ;)
It will never happen.
See:
http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1
http:/
I've discussed that so many times... just search for auto / scope
ref... ;)
It will never happen.
See:
http://forum.dlang.org/thread/ntsyfhesnywfxvzbe...@forum.dlang.org?page=1
http://forum.dlang.org/thread/ylebrhjnrrcajnvtt...@forum.dlang.org?page=1
http://forum.dlang.org/thread/mailman.2989.13
On Friday, 1 May 2015 at 10:04:46 UTC, Namespace wrote:
How about this:
struct A {
int x = 42;
}
struct B {
int x = 7;
}
T factory(T)() {
return T();
}
void main()
{
auto a = factory!(A);
}
Of course, you can restrict the type to A or B, or both:
T factory(T)() if (is
How about this:
struct A {
int x = 42;
}
struct B {
int x = 7;
}
T factory(T)() {
return T();
}
void main()
{
auto a = factory!(A);
}
Same output:
[1, 10]
true
[1]
false
with dmd 2.067.1
On Thursday, 30 April 2015 at 21:30:36 UTC, TheGag96 wrote:
I was looking at the d-idioms website today and saw this code
example:
http://p0nce.github.io/d-idioms/#Adding-or-removing-an-element-from-arrays
And I was kind of irked. I just recently working with removing
an element from an array
On Monday, 20 April 2015 at 21:58:59 UTC, Ali Çehreli wrote:
On 04/20/2015 02:44 PM, Namespace wrote:
> Thank you. Do you mean this is worth a PR, to add this
> functionality to Phobos?
I am not familiar with such a need so I don't have a strong
opinion.
However, if an object needs to be emp
Thank you. Do you mean this is worth a PR, to add this
functionality to Phobos?
My current code looks like this:
http://dpaste.dzfl.pl/19b78a600b6c
On Sunday, 19 April 2015 at 21:17:18 UTC, Ali Çehreli wrote:
On 04/19/2015 09:04 AM, Namespace wrote:
> Is it somehow possible to reuse the memory of an object?
Yes, when you cast a class variable to void*, you get the
address of the object.
> @nogc
> T emplace(T, Args...)(ref T obj, auto re
It seems that D has currently no direct support to reuse object
memory.
D should add a new-placement syntax:
Foo f = new Foo(42);
new (f) Foo(23);
and/or should add an emplace overload which takes an object:
T emplace(T, Args...)(ref T obj, auto ref Args args) if (is(T ==
class))
And if I have an already instantiated object?
Foo f = new Foo();
// reuse f's memory
Is there an nicer way to override the memory instead of:
void[] buf = (cast(void*) f)[0 .. __traits(classInstanceSize,
Foo)];
buf = typeid(Foo).init[]; // or: buf = f.classinfo.init[];
?
The
Is it somehow possible to reuse the memory of an object?
My current idea is:
@nogc
T emplace(T, Args...)(ref T obj, auto ref Args args) nothrow if
(is(T == class)) {
if (obj is null)
return null;
enum size_t SIZE = __traits(classInstanceSize, T);
void[] buf = (cast(vo
On Tuesday, 7 April 2015 at 17:21:09 UTC, Daniel Kozak wrote:
On Tue, 07 Apr 2015 16:40:29 +
via Digitalmars-d-learn
wrote:
Hi!
Excuse me if this is obvious, but I can't recall coming across
anything similar and a quick search returns nothing relevant:
struct Foo {
}
struct FooWrap
On Tuesday, 7 April 2015 at 10:48:38 UTC, ParticlePeter wrote:
Hi, I think I have a bug report for DerelictGL3, but cannot
find the related Forum
( http://dblog.aldacron.net/forum/index.php ), is it still in
the process of being moved ?
Regards, ParticlePeter
Post it there: https://github.co
2. When you malloc, you use 'two.sizeof' and 'ten.sizeof'.
Integers are 4 bytes, so you were allocating 4 bytes for each
of these (not 2 or 10 bytes as is alluded to above).
Yeah, my mistake. I saw the mistake but could not describe it
correctly. :)
On Monday, 6 April 2015 at 15:15:48 UTC, Johan Engelen wrote:
On Monday, 6 April 2015 at 14:55:58 UTC, Namespace wrote:
debug {
pragma(lib, "libcmtd.lib");
} else {
pragma(lib, "libcmt.lib");
}
Thanks for the quick reply!
Worth adding an example like that to
http://dlang.org/version.h
On Monday, 6 April 2015 at 14:50:29 UTC, Johan Engelen wrote:
How do conditionally compile code for either release
("-release") or debug ("-debug")?
Something like this:
version(Debug) {
pragma(lib, "libcmtd.lib");
} else {
pragma(lib, "libcmt.lib");
}
In the documentation [1], I don't
On Saturday, 4 April 2015 at 09:05:03 UTC, bearophile wrote:
Namespace:
I've written a straight forward linked list implementation
here:
https://github.com/nomad-software/etcetera/blob/master/source/etcetera/collection/linkedlist.d
Even though I'm using the GC to manage memory, maybe it will
On Friday, 3 April 2015 at 22:38:00 UTC, Gary Willoughby wrote:
On Friday, 3 April 2015 at 22:08:52 UTC, Kitt wrote:
Thanks for the help =) I guess I've been in C# land at work
for way too long now, my low level C skills are evaporating!
I've written a straight forward linked list implementati
Wow, I can't even begin to explain how red my cheeks are right
now. You're completely right; I have no idea what my head was
thinking. Sure enough, call malloc with the correct type, and
the error goes away =P
Thanks for the help =) I guess I've been in C# land at work for
way too long now, m
On Friday, 3 April 2015 at 22:02:13 UTC, Kitt wrote:
Hello. I’m trying to write my own version of a list that
doesn’t rely on the garbage collector. I’m working on a very
bare bones implementation using malloc and free, but I’m
running into an exception when I attempt to call free. Here is
a v
On Sunday, 29 March 2015 at 16:29:40 UTC, ketmar wrote:
On Sun, 29 Mar 2015 16:00:05 +, matovitch wrote:
On Sunday, 29 March 2015 at 14:50:24 UTC, ketmar wrote:
On Sun, 29 Mar 2015 13:45:10 +, matovitch wrote:
you can also use unions.
Good idea ! In my case I think it was better to
Something like that?
struct PrimitiveRef(T)
{
private T* _value;
@property
ref inout(T) get() inout pure nothrow {
assert(_value);
return *_value;
}
alias get this;
this(T val) {
On Tuesday, 17 March 2015 at 09:56:09 UTC, Jonathan M Davis wrote:
On Monday, March 16, 2015 18:46:59 Namespace via
Digitalmars-d-learn wrote:
May this be worth of an enhancement request? Or was this
already
rejected?
And, no, I want no mutable references such as C++.
Walter has been
On Monday, 16 March 2015 at 19:20:09 UTC, anonymous wrote:
On Monday, 16 March 2015 at 18:47:00 UTC, Namespace wrote:
const(Matrix)* m = &t.getCurrentModelViewMatrix(); //
currently
}
But IMO it would be a lot nicer if I could store the reference
like this:
ref const(Matrix) m =
Currently, if you want to store a long getter into a variable
without copying it (because it may be a big struct), your only
way is to store it as a pointer:
struct Matrix {
float[16] values= [
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
];
}
str
On Saturday, 14 March 2015 at 16:55:09 UTC, Charles Cooper wrote:
Interesting. I think in the second example there are
pathological cases where one has similar declarations in two
modules at the same line.
Yes, that right, I've kept it simple, but of course it is not
complete safe. :)
You can do it this way:
struct dollars_t {
uint _dollar;
this(uint d) {
_dollar = d;
}
alias _dollar this;
}
struct cents_t {
uint _cent;
this(uint c) {
_cent = c;
}
alias _cent this;
}
void do_something_with_dollars(dollars_t d) {
wri
On Thursday, 12 March 2015 at 21:41:07 UTC, Ali Çehreli wrote:
On 03/12/2015 01:19 PM, Namespace wrote:
> On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
>> On 03/12/2015 06:01 AM, ayush wrote:
>>
>> > Is D a lot like c++ ?
>>
>> I came to D from C++. I remember the following bein
On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
On 03/12/2015 06:01 AM, ayush wrote:
> Is D a lot like c++ ?
I came to D from C++. I remember the following being notable
differences:
- In D, classes have reference semantics. I quickly realized
that this is not an issue becaus
On Wednesday, 11 March 2015 at 15:22:43 UTC, Ali Çehreli wrote:
On 03/11/2015 04:40 AM, Namespace wrote:
> I can call draw on Drawable, because it is declared public
and I cannot
> call draw on Sprite because it is declared protected (this is
already a
> bit weird, why can I redeclare the interf
Could it be that this is intentional and has always worked?
On Wednesday, 11 March 2015 at 14:34:32 UTC, ketmar wrote:
On Wed, 11 Mar 2015 13:48:45 +, Namespace wrote:
This code does not work:
enum Test {
Foo,
static if (__VERSION__ >= 2067)
Bar,
}
Quatz
}
Any chance that this could work?
nope. `static if` is statement,
This code does not work:
enum Test {
Foo,
static if (__VERSION__ >= 2067)
Bar,
}
Quatz
}
Any chance that this could work?
Or even shorter:
import std.stdio;
T foo(T, Args...)(auto ref const T val, auto ref const Args u)
{
static if (Args.length > 0) {
static if (is(T == string))
return val ~ foo(u);
else
return val + foo(u);
} else {
return val;
}
}
void
import std.stdio;
T foo(T)(auto ref const T val)
{
return val;
}
T foo(T, Args...)(auto ref const T val, auto ref const Args u)
{
static if (is(T == string))
return val ~ foo(u);
else
return val + foo(u);
}
void main()
{
writeln(foo("some ", "test")); // prin
Let's say we have these files:
module Foo.Graphic.Drawable;
interface Drawable {
void draw(bool);
}
module Foo.Graphic.Sprite;
import Foo.Graphic.Drawable;
class Sprite : Drawable {
protected:
void draw(bool enable) {
import core.stdc.stdio : pri
I'm unsure, but I think this code should work:
module A.B.Foo;
import core.stdc.stdio : printf;
struct Foo {
package(A) void foo() {
printf("Hallo\n");
}
}
package(A) void bar() {
printf("Hallo\n");
}
and
module A.C.Bar;
import A.B.Foo;
void main() {
Foo f
On Thursday, 26 February 2015 at 20:55:52 UTC, Rinzler wrote:
Thanks! Actually I had already seen that page, but I was asking
for other open-source projects. If there's someone working on a
D dedicated IDE or not.
You could search on dub: http://code.dlang.org/
On Wednesday, 25 February 2015 at 20:46:32 UTC, ketmar wrote:
On Wed, 25 Feb 2015 20:36:32 +, Namespace wrote:
That last thing works. But I have no clue why. o.O Anyway,
thanks a lot!
this is a smart hack. that should be NEVER used in production
code.
anyway, it's good that you don't u
On Wednesday, 25 February 2015 at 19:53:16 UTC, Ivan Timokhin
wrote:
On Wed, Feb 25, 2015 at 07:32:48PM +, Namespace wrote:
void glCheck(lazy void func, string file = __FILE__, uint line
= __LINE__) {
func();
glCheckError(file, line);
}
How can I specify that 'fu
On Wednesday, 25 February 2015 at 20:15:10 UTC, anonymous wrote:
On Wednesday, 25 February 2015 at 19:32:50 UTC, Namespace wrote:
void glCheck(lazy void func, string file = __FILE__, uint line
= __LINE__) {
func();
glCheckError(file, line);
}
How can I specify that '
void glCheck(lazy void func, string file = __FILE__, uint line =
__LINE__) {
func();
glCheckError(file, line);
}
How can I specify that 'func' is @nogc? Or can define the
function otherwise?
On Monday, 9 February 2015 at 05:50:00 UTC, uri wrote:
On Saturday, 7 February 2015 at 23:29:01 UTC, Namespace wrote:
On Saturday, 7 February 2015 at 22:09:03 UTC, Gan wrote:
Is there a better D graphics library in the works?
I'm using SFML(which is very easy and has lots of features)
but it
Let me hear what comes out. ;)
1 - 100 of 106 matches
Mail list logo