Re: MS VirtualFree(), VirtualAlloc()

2010-07-03 Thread BLS

On 02/07/2010 20:11, BLS wrote:

Hi, for reasons I don't completely understand I would like to implement
a BIP Buffer in D2. ;) well async IO is the use case .. I think.

How can I allocate/free buffer-space from virtual memory ?

What I am looking for is a way to do platform independent allocating of
memory from the virtual address space. Like - VirtualAlloc/Free() in MS
Win.

Thanks in advance,
Bjoern




mmap or mallloc is what I get.. Pretty interesting. shit


Templates with strings

2010-07-03 Thread Mike Linford
I'm trying to compile the following file. Can somebody explain to me how 
I can rewrite it so that I don't get Error: non-constant expression? 
All I'm trying to do is create, using templates, a string of all 
characters between two given characters:

  1 module ua;
  2 
  3 template dcharInterval(immutable(dchar) start, immutable(dchar) stop)
  4 {
  5static assert(stop = start);
  6static if(start == stop)
  7   dstring dcharInterval = [start];
  8else
  9   dstring dcharInterval = [start] ~ dcharInterval!(start + 1, 
stop);
 10 }
 11 
 12 dstring LATIN = \u00AAd ~ \u00BAd ~ dcharInterval!(0x00C0, 
0x00D6);
 13 

Thanks.

-- 
Mike Linford


Re: Templates with strings

2010-07-03 Thread BCS

Hello Mike,


I'm trying to compile the following file. Can somebody explain to me
how I can rewrite it so that I don't get Error: non-constant
expression? All I'm trying to do is create, using templates, a string
of all characters between two given characters:



1) where did you get that error? (I'm lazy, sorry)
2) is there a reason you don't use CTFE?

dchar[] Between(dchar start, dchar stop)
{
 if(start  stop) { auto t = start; start = stop; stop = t; }

 dchar[] ret;
 for(dchar d = start; d=stop; d++) ret ~= d;
 return ret;
}

import std.stdio;
void Go(dchar[] s)(){writef(%s\n, s); }
void main(){Go!(Between('a','g'))();}


1 module ua;
2
3 template dcharInterval(immutable(dchar) start, immutable(dchar)
stop)
4 {
5static assert(stop = start);
6static if(start == stop)
7   dstring dcharInterval = [start];
8else
9   dstring dcharInterval = [start] ~ dcharInterval!(start + 1,
stop);
10 }
11
12 dstring LATIN = \u00AAd ~ \u00BAd ~ dcharInterval!(0x00C0,
0x00D6);
13
Thanks.


--
... IXOYE





lexer escape

2010-07-03 Thread Ellery Newcomer

what is the point of having

\?

a valid escape sequence?