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
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
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
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.
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
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.
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);
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
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
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
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
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
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) {
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
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
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
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?
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
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
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
Which linker do you plan to use?
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.
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
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
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/
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?
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
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
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
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
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
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
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
Compile and run the tests with different version options.
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 {
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)
?
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
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
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;
39 matches
Mail list logo