Thor | 21 May 14:42
Picon
Favicon

"repeating pair" regex

Hi,

I tried something like this...
auto m = match("a=42 b=32 c=22", regex(`^(?: \s* (\w+)=(\d+) 
)+$`, `x`));

This works fine...
`^(?: \s* (\w+)=(\d+) )+$`
... and if I duplicate the string x times, it also works...

But I'm hoping to parse a variable number of these 'pairs'... so 
I tried grouping the pairs in (?:)+ but this way it saves only 
the last pair?

Anyone got an idea?

simendsjo | 21 May 13:26
Picon
Gravatar

std.range.put?

Shouldn't the following work?

import std.range;
import std.stdio;

void main() {
     int[] a;
     a.reserve(10);
     //a.put(1); // Attempting to fetch the front of an empty array of int
     a.length = 1;
     writeln(a.length); // 1
     a.put(2);
     writeln(a.length); // 0 - what?
     writeln(a); // [] - come on!

     char[] b;
     //b.put('a'); // range.d(615): Error: static assert  "Cannot put a  
char into a char[]"
}

p0xel | 20 May 23:17
Picon

static functions?

I pretty sure I'm an idiot.

[code]
class foo {
	public static int bar() {
		return 0;
	}
}
[/code]

How do I call bar() without creating an instance of foo? 
foo.bar() results in "Error: undefined identifier 'bar'"

I'm having a really hard time finding anything related to D in 
general.

Stewart Gordon | 20 May 17:48
Picon
Favicon

Re: ProjectEuler problem 35

On 19/05/2012 16:13, maarten van damme wrote:
> A huge optimization could be made by storing and int array of already
> found primes and test all primes smaller then half the to-test number.
> this will speed up a lot.

Do you mean build an array of already-found primes and use them to test new primes?  You 
need only to try dividing by each prime up to the square root of the number being tested.

> Another huge improvement could be made with hardcoding everything up
> to the prime 3 and then iterate with intervals of 2 instead of 1.

Yes, that's a common optimisation.  Faster still would be to test 6k-1 and 6k+1 for each 
positive integer k.  Indeed, I've done more than this in my time: hard-coded all the 
primes up to 30 and the residues modulo 30 that can possibly be of primes above 30.

Stewart.

japplegame | 20 May 15:50
Picon

detecting POD types

I write function template that should works only with POD types 
(i.e. base types, structures, enums etc.). Is there something 
like C++11 std::is_pod 
(http://en.cppreference.com/w/cpp/types/is_pod) template?

Denis Shelomovskij | 20 May 10:41
Picon
Gravatar

druntime investigation troubles

Looks like `_STI_monitor_staticctor` is called by C runtime on Windows. 
And C runtime isn't open-source.

It creates troubles for investigation druntime (for me at least). Why is 
it so? Why not to call everything in C `main`, what's the reason?

If there is no list of stuff done before C `main` druntime isn't 
open-source for me because I can't understand what is taking place just 
with druntime sources.

--

-- 
Денис В. Шеломовский
Denis V. Shelomovskij

Kenji Hara | 20 May 08:57
Picon

Re: How to test for equality of types?

On Saturday, 19 May 2012 at 18:17:16 UTC, Matthias Walter wrote:
> On 2012-05-19 15:28, Philippe Sigaud wrote:
>> On Sat, May 19, 2012 at 12:23 PM, Matthias Walter
>> <xammy <at> xammy.homelinux.net> wrote:
>> 
>>> I would open a bug report with the following code which is a 
>>> bit smaller
>>> than my first wrong version:
>>>
>>> =====================
>> (...)
>>>  pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> 
>>> "MyStruct"
>>>  pragma(msg, AliasStruct.Alias.stringof); // -> "MyStruct"
>>>  static assert(is(typeof(w.aliasStruct) == AliasStruct)); // 
>>> -> true
>>>  static assert(is(typeof(w.aliasStruct).Alias == 
>>> AliasStruct.Alias));
>>> // -> false
>>> }
>> 
>> Seems like a pb concerning whether Alias is a type or a 
>> symbol. See
>> A,B,C,D below:
>> 
>> void main()
>> {
>>  Wrapper w;
>> 
>>  pragma(msg, typeof(w.aliasStruct).Alias.stringof); // -> 
(Continue reading)

bioinfornatics | 20 May 01:53
Favicon
Gravatar

state of web programming

it is a list of project lo look if yo want create a web application in D
- https://github.com/mrmonday/serenity
-
https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff
- https://github.com/Aatch/dfcgi
- https://github.com/rejectedsoftware/vibe.d

Add yours, tell which is better ...

cal | 20 May 00:38
Picon

Limit number of compiler error messages

Is there a way to limit the dmd compiler to outputting just the 
first few errors it comes across?

bioinfornatics | 19 May 19:28
Favicon
Gravatar

vibe.d how build it / intall it?

Dear,
i do not found on vibe.d repository (github) how do a manual install.

Since i am a  linux user (Fedora) they are any documentation to explain
how install it?

after take a look from source tree i think
bin/vibe go to /usr/bin
bin/views to /usr/share/vibe.d/
source/vibe to /usr/include/d/

i think source file into source/vibe should be compiled and linked
together to do a lib, isn't it?

thanks in advance for help (how to do a manual install?)

japplegame | 19 May 15:26
Picon

std.concurrency.send

Multithreading in D confuses me more and more.

import std.concurrency;
import std.stdio;
shared Tid tid;
void main() {
   send(cast(Tid)tid, "Hello, World");
}
void worker() {
    writeln(receiveOnly!string);
}
shared static this() {
   tid = cast(shared)spawn(&worker);
}

I hate these explicit casts. It is impossible sharing anything 
between threads without these ugly casts from/to shared. Seems 
like something wrong in program design when I'm forced to use 
explicit casts. But I don't understand what is it exactly.

For example. I need create mutable object in one thread and send 
to another. I don't need to share this object, just create, send 
and forget. But I have no idea how make this without using shared 
attribute and casting to/from it.


Gmane