Re: Iterating over the tupleof of a struct

2014-08-22 Thread Suliman via Digitalmars-d-learn
How can I feel struct with foreach loop? struct ConfigStruct { string [string] key1; string [string] key2; } ConfigStruct confstruct; foreach (i, line; readText(ConfigName).splitLines()) { string [] keyvalue = line.split("="); confstruct.key1[keyvalue[0]] = keyvalue[1]; } it's ok for 1

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Ali Çehreli via Digitalmars-d-learn
On 08/22/2014 02:38 PM, Ali Çehreli wrote: > Does that mean that one is the > instance of the other? Will have to test that separately.) I opened the following bug about isInstanceOf!(Foo!int, Foo!int) producing 'true': https://issues.dlang.org/show_bug.cgi?id=13364 Ali

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Ali Çehreli via Digitalmars-d-learn
On 08/22/2014 07:47 PM, Yota wrote: > So what's up with the syntax I tried before? Has it been > deprecated? I don't know the details. I am curious as well. I think it is related to value template parameters. The first example below fails but the second one works. The only difference is that

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Yota via Digitalmars-d-learn
On Friday, 22 August 2014 at 21:38:29 UTC, Ali Çehreli wrote: So, the correct check should use std.traits.TemplateOf first: auto opBinary(string op, That)(That rhs) if (isInstanceOf!(TemplateOf!UnitDef, That) && op == "*") { return UnitDef!(unitString ~ " " ~ rhs.

Re: Iterating over the tupleof of a struct

2014-08-22 Thread Dicebot via Digitalmars-d-learn
On Saturday, 23 August 2014 at 01:32:13 UTC, Meta wrote: On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the struct? And I just realized that that's obviously not the case. It's just an iteration variable

Re: Iterating over the tupleof of a struct

2014-08-22 Thread Meta via Digitalmars-d-learn
On Saturday, 23 August 2014 at 01:24:10 UTC, Meta wrote: What is happening here? Are these two extra ulongs the offsets of the fields in the struct? And I just realized that that's obviously not the case. It's just an iteration variable. Problem solved.

Iterating over the tupleof of a struct

2014-08-22 Thread Meta via Digitalmars-d-learn
Something weird happens when I try to foreach over test.tupleof. If the foreach loop has 2 variables like so: struct Test { string name = "'null'"; int id; } void main() { auto test = Test(); assert(test.name == "'null'"); assert(test.id == 0);

Re: unit testing version statements

2014-08-22 Thread Dicebot via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote: On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option This is how version feature is intentionally designed to work

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Ali Çehreli via Digitalmars-d-learn
On 08/22/2014 02:22 PM, Ali Çehreli wrote: > Admittedly, std.traits.isInstanceOf is the right tool to use Answering myself: Yes, it is. > but both of > the following worked! I figured that out. > auto opBinary(string op, That)(That rhs) > if (isInstanceOf!(UnitDef, That) && Not

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread via Digitalmars-d-learn
On Friday, 22 August 2014 at 21:22:39 UTC, Ali Çehreli wrote: On 08/22/2014 01:45 PM, Yota wrote: On Friday, 22 August 2014 at 20:42:49 UTC, Yota wrote: Heya. I'm working on a simple units-of-measure implementation in DMD 2.066.0, and it doesn't seem to like the signature of my '*' operator b

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Ali Çehreli via Digitalmars-d-learn
On 08/22/2014 01:45 PM, Yota wrote: On Friday, 22 August 2014 at 20:42:49 UTC, Yota wrote: Heya. I'm working on a simple units-of-measure implementation in DMD 2.066.0, and it doesn't seem to like the signature of my '*' operator below. I'm afraid I don't understand what the error description

Re: Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Yota via Digitalmars-d-learn
On Friday, 22 August 2014 at 20:42:49 UTC, Yota wrote: Heya. I'm working on a simple units-of-measure implementation in DMD 2.066.0, and it doesn't seem to like the signature of my '*' operator below. I'm afraid I don't understand what the error description is trying to tell me. Here's a red

Specialization Not Allowed for Deduced Parameter

2014-08-22 Thread Yota via Digitalmars-d-learn
Heya. I'm working on a simple units-of-measure implementation in DMD 2.066.0, and it doesn't seem to like the signature of my '*' operator below. I'm afraid I don't understand what the error description is trying to tell me. Here's a reduced case: public struct UnitDef(string unitString) {

Re: BitArray - preview of what's to come?

2014-08-22 Thread bearophile via Digitalmars-d-learn
Suliman: bool[4] x = [1, 1, 0, 0]; BitArray ba = BitArray(x); When I try to compile this I am getting error: source\app.d(13): Error: cannot implicitly convert expression (x) of type bool[4] to uint What I am doing wrong? It still lacks some features like a constructor that accepts a (l

Re: unit testing version statements

2014-08-22 Thread Jonathan M Davis via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:37:30 UTC, Robert burner Schadek wrote: On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option Well, that's normally how it would be done. But if you need to test them all with

Re: Windows DLL / Windows service

2014-08-22 Thread Tyler Jensen via Digitalmars-d-learn
On Saturday, 7 June 2014 at 16:16:28 UTC, Etienne wrote: On Saturday, 7 June 2014 at 16:07:47 UTC, Adam D. Ruppe wrote: On Saturday, 7 June 2014 at 14:41:15 UTC, Etienne Cimon wrote: no documentation though. Any idea how to attach/detach with a known example? I'd also like to create a windows D

Re: BitArray - preview of what's to come?

2014-08-22 Thread Suliman via Digitalmars-d-learn
bool[4] x = [1, 1, 0, 0]; BitArray ba = BitArray(x); When I try to compile this I am getting error: source\app.d(13): Error: cannot implicitly convert expression (x) of type bool[4] to uint What I am doing wrong?

Re: D with no druntime

2014-08-22 Thread bearophile via Digitalmars-d-learn
Marc Schütz: But it would need to halt the system of course, because throwing a RangeError might not work in his minimalistic environment. Halting the system, or jumping to a error routine seems better than running in undefined state. Bye, bearophile

Re: COFF32 limitations?

2014-08-22 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-08-22 13:55, Kagamin wrote: Which linker do you plan to use? ld on linux or visual studio's link on win32

Re: D with no druntime

2014-08-22 Thread via Digitalmars-d-learn
On Friday, 22 August 2014 at 17:52:30 UTC, Kagamin wrote: On Thursday, 21 August 2014 at 05:13:34 UTC, uri wrote: _d_arraybounds (new to 2066) This one is very useful, I recommend to implement it. It's just easier to live with it, than try to get rid of it. But it would need to halt the sys

Re: COFF32 limitations?

2014-08-22 Thread Kagamin via Digitalmars-d-learn
Which linker do you plan to use?

Re: D with no druntime

2014-08-22 Thread Kagamin via Digitalmars-d-learn
On Thursday, 21 August 2014 at 05:13:34 UTC, uri wrote: _d_arraybounds (new to 2066) This one is very useful, I recommend to implement it. It's just easier to live with it, than try to get rid of it.

Re: RAII limitations in D?

2014-08-22 Thread Russel Winder via Digitalmars-d-learn
On Thu, 2014-08-21 at 19:22 -0700, Timothee Cour via Digitalmars-d-learn wrote: > What would be a good answer to this article? > http://swiftcoder.wordpress.com/2009/02/18/raii-why-is-it-unique-to-c/ > > Especially the part mentioning D:{ > D’s scope keyword, Python’s with statement and C#’s using

Re: core.thread.Fiber --- runtime stack overflow unlike goroutines

2014-08-22 Thread Dicebot via Digitalmars-d-learn
On Friday, 15 August 2014 at 15:50:30 UTC, Dicebot wrote: On Friday, 15 August 2014 at 15:40:35 UTC, Sean Kelly wrote: On Friday, 15 August 2014 at 15:25:23 UTC, Dicebot wrote: No, I was referring to the proposal to supply bigger stack size to Fiber constructor - AFAIR it currently does alloc

Re: [vibe.d] Proper use of preWriteCallback

2014-08-22 Thread Chris via Digitalmars-d-learn
On Friday, 22 August 2014 at 13:58:02 UTC, Chris wrote: Maybe a trivial question: How do I use "preWriteCallback" properly? It doesn't work properly for me yet (I might not see the forest for the trees at the moment). I am trying to set a field in the HTTPServerResponse. http://vibed.org/api/

COFF32 limitations?

2014-08-22 Thread Etienne via Digitalmars-d-learn
I'm wondering about the COFF on windows x86, if I compile a C++ library in Mingw (gcc 4.9), using the new extern(C++, a.b.c) will I be able to statically link it through DMD?

[vibe.d] Proper use of preWriteCallback

2014-08-22 Thread Chris via Digitalmars-d-learn
Maybe a trivial question: How do I use "preWriteCallback" properly? It doesn't work properly for me yet (I might not see the forest for the trees at the moment). I am trying to set a field in the HTTPServerResponse. http://vibed.org/api/vibe.http.fileserver/HTTPFileServerSettings.preWriteCallb

Re: Differences between "const Type function()" and "const(Type) function()"

2014-08-22 Thread via Digitalmars-d-learn
On Friday, 30 May 2014 at 12:57:52 UTC, anonymous wrote: It's not a cast. It's the unambiguous notation for a qualified type. Often you can omit the parentheses. With methods you cannot. With methods you need the parentheses to let the compiler know that you indeed mean the return type to be co

Re: How I can iterate data in structure

2014-08-22 Thread Gary Willoughby via Digitalmars-d-learn
On Friday, 22 August 2014 at 10:44:31 UTC, Marc Schütz wrote: On Friday, 22 August 2014 at 08:44:51 UTC, Suliman wrote: foreach (field; result.tupleof) Why I should here specify type of iterable element, but not first element that I use for iteration? I mean: foreach (_some_type_possible_en

Re: Trouble reproducing compilation error

2014-08-22 Thread via Digitalmars-d-learn
I used Vladimir's digger on your code, this is the output: 442708214b84093fd79b1d37c927c6ef5f1aeb99 is the first bad commit commit 442708214b84093fd79b1d37c927c6ef5f1aeb99 Author: Walter Bright Date: Wed Jul 23 03:59:13 2014 -0700 dmd: Merge pull request #3801 from 9rnsr/fix13180 htt

Re: How I can iterate data in structure

2014-08-22 Thread via Digitalmars-d-learn
On Friday, 22 August 2014 at 08:44:51 UTC, Suliman wrote: foreach (field; result.tupleof) Why I should here specify type of iterable element, but not first element that I use for iteration? I mean: foreach (_some_type_possible_enum_ field; result) ? You mustn't, because your struct could

Re: How I can iterate data in structure

2014-08-22 Thread bearophile via Digitalmars-d-learn
Suliman: foreach (field; result.tupleof) Why I should here specify type of iterable element, but not first element that I use for iteration? I mean: foreach (_some_type_possible_enum_ field; result) ? I don't understand your question. In my code I have not specified types in the foreach

Re: unit testing version statements

2014-08-22 Thread Robert burner Schadek via Digitalmars-d-learn
On Friday, 22 August 2014 at 09:33:10 UTC, Kagamin wrote: Compile and run the tests with different version options. that is not an option

Re: unit testing version statements

2014-08-22 Thread Kagamin via Digitalmars-d-learn
Compile and run the tests with different version options.

unit testing version statements

2014-08-22 Thread Robert burner Schadek via Digitalmars-d-learn
How do I unit test version statements without fixing version in place forever. bool fun() { version(Version1) return true; else version(Version2) return true; else return false; } version = Version1; unittest { assert(fun()); } version = Version2; unittest {

Re: How I can iterate data in structure

2014-08-22 Thread Suliman via Digitalmars-d-learn
foreach (field; result.tupleof) Why I should here specify type of iterable element, but not first element that I use for iteration? I mean: foreach (_some_type_possible_enum_ field; result) ?

Re: How I can iterate data in structure

2014-08-22 Thread bearophile via Digitalmars-d-learn
Suliman: void main() { auto result = readconfig(); foreach (_; result) { // I want to iterate result that I got from structure. } } auto readconfig() { struct ConfigStruct { string key1; st

Re: Value of floating in JSONValue

2014-08-22 Thread Nobody via Digitalmars-d-learn
On Thursday, 21 August 2014 at 18:53:08 UTC, nrgyzer wrote: Hi everyone, I'm facing a problem with the JSON functions. I've to communicate with another PC using JSON. Here's a simple snipped which shows my problem: import std.json; import std.stdio; void main() { double d = 1.23456789

How I can iterate data in structure

2014-08-22 Thread Suliman via Digitalmars-d-learn
void main() { auto result = readconfig(); foreach (_; result) { // I want to iterate result that I got from structure. } } auto readconfig() { struct ConfigStruct { string key1; string key2;