Re: copying const struct

2013-10-15 Thread Jack Applegame
On Monday, 14 October 2013 at 18:36:00 UTC, Maxim Fomin wrote: Funniest thing happen in cases like this when he reports the bug himself and soon fixes it, later bug is hit by someone else but during reporting it is realized that bug is already fixed, pull is pushed to master and everyone

Re: howto dispatch to derived classes?

2013-10-15 Thread Manfred Nowak
=?UTF-8?B?QWxpIMOHZWhyZWxp?= wrote: a virtual function like accept() can do the trick This would require changes in the whole class hierarchy. But because of The actual type of the object is implicitly stored in the vtbl of each type. and in addition, because the statement | writeln(

Is this a bug, if so, how would you summarize it?

2013-10-15 Thread safety0ff
See this code: http://dpaste.dzfl.pl/b3ae1667 On DMD it gives the error message if version=bug, but not if version=bug AND version=workaround1 (through 6). On LDC it segfaults at run time if version=bug, but not if version=bug AND version=workaround1 (through 6). Workaround1 - workaround4

Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread DoctorCaptain
dmd v2.063.2 Hi there! I'm terribly hopeful that you're more interested in the problem at hand than my choice of title. I've been using D for a while as my language of choice for various projects here and there, and I've recently discovered that template programming is magic. This is good. As

Re: Array copy warning

2013-10-15 Thread bearophile
Benjamin Thaut: I'm just in the progress of upgrading to dmd 2.063 and I now get the following warnings in my code: Warning: explicit element-wise assignment I am having problems with code like this, that used to work: import std.algorithm: reduce; struct Foo { int x, y; } void main() {

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
I've successfully built Pegged and I'm now trying to build vibe.d which requires dub so ... andrew@islay:~$ cd dub-0.9.18/ andrew@islay:~/dub-0.9.18$ ls binbuild-files.txt CHANGELOG.md examples LICENSE_DE.txt package.json source build.cmd build.sh curl.lib installer

Re: Starting D with a project in mind.

2013-10-15 Thread Dicebot
On Tuesday, 15 October 2013 at 12:31:49 UTC, Andrew wrote: Any ideas what I'm doing wrong ? Thanks for all of the hand-holding BTW. What is your GDC version? Looks like one with pre-2.063 front-end as it does not support `alias X = ...` syntax. vibe.d developers do try to support latest two

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread Benjamin Thaut
Am 15.10.2013 10:03, schrieb DoctorCaptain: dmd v2.063.2 Hi there! I'm terribly hopeful that you're more interested in the problem at hand than my choice of title. I've been using D for a while as my language of choice for various projects here and there, and I've recently discovered that

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread Benjamin Thaut
Your going way to complicated by actually passing the variadic arguments to the generator function. If you don't pass the variadic arguments to the generator function its way simpler and also works ;-) http://dpaste.dzfl.pl/59e2547b

Re: objects as AA keys

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 05:44:25 UTC, captaindet wrote: hi, i am a bit confused. the official language ref ( http://dlang.org/hash-map.html ) states: Classes can be used as the KeyType. For this to work, the class definition must override the following member functions of class

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread Artur Skawina
On 10/15/13 10:03, DoctorCaptain wrote: If what I am asking is unclear, I will be more than happy to explain in a different way. I tried to be simultaneously as succinct and as comprehensive as possible with what the issue is. I'm not sure what exactly you're trying to do, but... The issue

should chain be pure

2013-10-15 Thread Daniel Davidson
I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? The relevant section of code is: ... auto sortedRage = assumeSorted!(a.when b.when)(opSlice()); auto trisection =

Re: should chain be pure

2013-10-15 Thread bearophile
Daniel Davidson: I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? Phobos is slowly being annotated with pure/nothrow (and @safe) but not all functions are already tagged. You could fix the

Re: should chain be pure

2013-10-15 Thread Daniel Davidson
On Tuesday, 15 October 2013 at 13:43:55 UTC, bearophile wrote: Daniel Davidson: I would like to correctly annotate my functions with pure. I've hit a function that is calling chain which breaks purity. Is chain really not pure? Phobos is slowly being annotated with pure/nothrow (and @safe)

Re: should chain be pure

2013-10-15 Thread bearophile
Daniel Davidson: If you are agreeing that chain should be pure and it is just following all the calls and making all of them pure, until that happens by the professionals - is there a casting solution so I can fake a pure and move on? chain is a template, and in Phobos often templates are

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
What is your GDC version? Looks like one with pre-2.063 front-end as it does not support `alias X = ...` syntax. vibe.d developers do try to support latest two released front-end versions but it is not as easy as it sounds (I hope situation will improve a lot once CI is finally up and

Re: Starting D with a project in mind.

2013-10-15 Thread Dicebot
On Tuesday, 15 October 2013 at 14:38:32 UTC, Andrew wrote: I think it's the latest version of GDC :- https://github.com/jpf91/GDC/tree/arm which apparently supports 2.062. Ugh, don't know about ARM build but GDC itself currently supports 2.063.2 version for both 4.8 and 4.9 branch. In the

Re: Starting D with a project in mind.

2013-10-15 Thread Stefan Frijters
On Tuesday, 15 October 2013 at 14:56:06 UTC, Dicebot wrote: On Tuesday, 15 October 2013 at 14:38:32 UTC, Andrew wrote: Is this something I can update easily ? If rebuilding GDC from sources so that it will catch 2.063.2 frontend version is an option - it may help. Looking at

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
Looking at https://github.com/jpf91/GDC/commits/arm , 2.063.2 support is also included in the ARM branch, cf. commit 1aa5755 from June 30, so you should have it already I think. Where did you get the 2.062 info from? 2.062 was mentioned on the GDC website as the latest supported D2. So I'm

Re: Starting D with a project in mind.

2013-10-15 Thread Dicebot
On Tuesday, 15 October 2013 at 18:41:50 UTC, Andrew wrote: Looking at https://github.com/jpf91/GDC/commits/arm , 2.063.2 support is also included in the ARM branch, cf. commit 1aa5755 from June 30, so you should have it already I think. Where did you get the 2.062 info from? 2.062 was

Re: Starting D with a project in mind.

2013-10-15 Thread H. S. Teoh
On Tue, Oct 15, 2013 at 09:19:56PM +0200, Andrew wrote: pragma(msg, __VERSION__); ``` 2060L - seems I'm further advanced than everybody else :-) Wow that's pretty old. The current language version supported by GDC is 2063L. You should probably consider upgrading GDC to at least 2.0.62

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
2060L - seems I'm further advanced than everybody else :-) Sorry, I thought it was 2.052, but now I see it's well behind since it should be 2.063. I'm rebuilding again from the master.

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
pragma(msg, __VERSION__); ``` 2060L - seems I'm further advanced than everybody else :-)

Re: Starting D with a project in mind.

2013-10-15 Thread Stefan Frijters
On Tuesday, 15 October 2013 at 19:23:13 UTC, Andrew wrote: 2060L - seems I'm further advanced than everybody else :-) Sorry, I thought it was 2.052, but now I see it's well behind since it should be 2.063. I'm rebuilding again from the master. Aha, oops, I have the same 2060L, but that is

Re: objects as AA keys

2013-10-15 Thread captaindet
On 2013-10-15 08:32, Daniel Davidson wrote: On Tuesday, 15 October 2013 at 05:44:25 UTC, captaindet wrote: hi, i am a bit confused. the official language ref ( http://dlang.org/hash-map.html ) states: Classes can be used as the KeyType. For this to work, the class definition must override

Re: objects as AA keys

2013-10-15 Thread Ali Çehreli
On 10/14/2013 10:44 PM, captaindet wrote: Classes can be used as the KeyType. For this to work, the class definition must override the following member functions of class Object: hash_t toHash() bool opEquals(Object) int opCmp(Object) ... it seems to work out of the box - without

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread DoctorCaptain
Fixing links: If the template I am trying to instantiate IS NOT variadic, and I pass in an alias of an instantiated template, then the receiving template has all of the type information it needs. Example: dpaste.dzfl.pl/6d618af9 http://dpaste.dzfl.pl/6d618af9 If the template I am trying to

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread DoctorCaptain
On Tuesday, 15 October 2013 at 13:14:46 UTC, Benjamin Thaut wrote: Your going way to complicated by actually passing the variadic arguments to the generator function. If you don't pass the variadic arguments to the generator function its way simpler and also works ;-)

cannot call impure function ~this

2013-10-15 Thread Namespace
I get this error: /d701/f223.d(11): Error: pure function 'f223.getA' cannot call impure function 'f223.A.~this' with this code: import std.stdio; struct A { public: ~this() { writeln(DTor); } } A getA() pure nothrow { return A(); } void

Re: how to handle memory ownership when interfacing with C/C++ via internal pointers

2013-10-15 Thread timotheecour
On Thursday, 10 October 2013 at 23:02:29 UTC, Timothee Cour wrote: Short version: I have a struct A* aptr allocated in C/C++ with an internal pointer aptr-ptr (say a double*) I want to store a reference x (say double[]) in D to aptr only through aptr-ptr, not through aptr directly as it's

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread DoctorCaptain
I missed an extremely critical point. The working example with the single arbitrary template instantiation as a data member of the generated class, http://dpaste.dzfl.pl/6d618af9 , has the template instantiation aliases inside of main, meaning the alias is NOT within the scope of GrabBagT, but

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
Aha, oops, I have the same 2060L, but that is presumably because I forgot to 'git checkout arm', and the master branch on Johannes' fork is not up-to-date. The reason why this works while normal GDC doesn't is that this is so old it doesn't include some explicit architecture static ifs that

Re: Starting D with a project in mind.

2013-10-15 Thread Dicebot
On Tuesday, 15 October 2013 at 22:28:59 UTC, Andrew wrote: I don't really understand why there are so many .d files that just seem to wrap standard os stuff - why not just use the standard installed C headers and avoid all of this overhead that needs maintaining ? Those .d files are

Re: Starting D with a project in mind.

2013-10-15 Thread Dicebot
P.S. I'd recommend to try to contact Johannes Pfau and ask if he has any plans for updating his ARM Phobos fork to recent version. Such changes should be probably integrated Phobos upstream eventually.

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
After roughly hacking all of the 'static assert unimplemented' lines in libphobos to just do whatever X86 does, I got it to build and install. Now I'm on 2063L and now hello world builds to 8MB instead of 2MB (although it strips to 760k - twice the previous version). So now I resume my quest

Re: Starting D with a project in mind.

2013-10-15 Thread Andrew
Unfortunately, this is an area where difference in developer count is really notable. It is a dead end - support for more exotic platforms like ARM is lacking because there too few people who need it and new bypassers are scared from further investigation because of lacking support. There is

Re: [Font] Getting font folder on all platforms

2013-10-15 Thread Flamaros
On Friday, 6 September 2013 at 20:54:53 UTC, Flamaros wrote: On Friday, 6 September 2013 at 16:05:43 UTC, Tourist wrote: On Thursday, 5 September 2013 at 19:48:07 UTC, Flamaros wrote: I am searching the right way to find fonts folder for each platforms (Windows, linux, macOS X) On Windows

Re: Starting D with a project in mind.

2013-10-15 Thread Brad Roberts
On 10/15/13 3:38 PM, Dicebot wrote: Unfortunately, this is an area where difference in developer count is really notable. It is a dead end - support for more exotic platforms like ARM is lacking because there too few people who need it and new bypassers are scared from further investigation

how to pass multiple arguments via a mixin

2013-10-15 Thread Timothee Cour
is there a general solution to pass multiple arguments to a function via a mixin? see below for a partial solution using Alias, which fails for the last case below: void main(){ import std.stdio; string a=A; string b=B; writeln(a,b);// OK (prints AB) writeln(a,b);//OK (prints both

Re: how to pass multiple arguments via a mixin

2013-10-15 Thread Dicebot
On Wednesday, 16 October 2013 at 00:36:46 UTC, Timothee Cour wrote: ... Have you tried run-time tuple? ``` import std.typecons; writeln(mixin(tuple(a,b).expand)); ```

Re: Problem: Cannot create class out of nothing using witchcraft

2013-10-15 Thread DoctorCaptain
I've gotten extremely close. The DPaste link that follows demonstrates three different templates: The first template is capable of generating the string for and mixing in the definition of a class that has a single arbitrary argument. An object of that class is instantiated, and its

Re: how to pass multiple arguments via a mixin

2013-10-15 Thread Timothee Cour
doesn't work with ref args: void fun(ref int a,ref int b){ a=1; } void main(){ int a,b; import std.typecons; fun(mixin(tuple(a,b).expand)); assert(a==1);//fails } and we can't do a logic such as: if there's ref args use Alias, otherwise use tuple().expand because there could be a mix

how to get a (ref) tuple from a static array ?

2013-10-15 Thread Timothee Cour
how to write a expand function that satisfies the following? void fun(ref int a,ref int b){ a=1; } void main(){ int[2]c; fun(c.expand); assert(c[0]==1); }

Re: Syntax for heap allocated void initialized arrays

2013-10-15 Thread Timothee Cour
On Sat, Sep 21, 2013 at 7:23 AM, bearophile bearophileh...@lycos.comwrote: simendsjo: I'm setting every element in the array, and every field of the element, so I should be safe, right? I think that's sufficiently safe. If the GC run before you have initialized those fields, and some of

Return a const structure by reference.

2013-10-15 Thread Agustin
I'm having trouble trying to return a const reference of a structure. public struct Structure { } public class A { private Structure structure; this(Structure structure) { this.structure = structure; } public ref const Structure getStructure() const {

Re: Return a const structure by reference.

2013-10-15 Thread Ali Çehreli
On 10/15/2013 09:28 PM, Agustin wrote: I'm having trouble trying to return a const reference of a structure. public struct Structure { } public class A { private Structure structure; this(Structure structure) { this.structure = structure; } public