Re: String Appender Fails (Memory Allocation Failure)

2011-07-14 Thread Loopback
Anybody got an idea?

Re: tiny web server in D

2011-07-14 Thread Dr.Smith
Thank you Adam, Your code is comprehensive. I will read it closely for ideas. I seek a minimalist approach for locally run applications.

Re: Forcing compile time evaluation of pure functions

2011-07-14 Thread bearophile
> In GCC there is a way to (sometimes) do it, see the __builtin_constant_p here: > http://www.delorie.com/gnu/docs/gcc/gcc_81.html Google code search gives about 8,100 answers: http://www.google.com/codesearch#search/&q=%22__builtin_constant_p%22&type=cs Bye, bearophile

Re: Forcing compile time evaluation of pure functions

2011-07-14 Thread bearophile
scarrow: > I'd really like to figure out how to have Hash("foo") be static and > Hash(variable) be dynamic. In GCC there is a way to (sometimes) do it, see the __builtin_constant_p here: http://www.delorie.com/gnu/docs/gcc/gcc_81.html Time ago I have asked for something similar in D too, becaus

Re: Forcing compile time evaluation of pure functions

2011-07-14 Thread scarrow
I think invoking a template to call the pure function (StaticEval!(Hash("foo")) isn't much different from StaticHash!("foo"). You still have to explicitly know whether you're dealing with a compile time constant or not. I'd really like to figure out how to have Hash("foo") be static and Hash(vari

Re: Lazy and delegates - out-of-scopeness - what happens?

2011-07-14 Thread Jacob Carlborg
On 2011-07-14 20:42, Cecil ward wrote: If I pass lazy expressions or delegates to as arguments to functions, what happens with variables mentioned in the lazy expression or in the delegate body if those variables are on the stack or otherwise out of scope, or are objects that may be freed? Does

Lazy and delegates - out-of-scopeness - what happens?

2011-07-14 Thread Cecil ward
If I pass lazy expressions or delegates to as arguments to functions, what happens with variables mentioned in the lazy expression or in the delegate body if those variables are on the stack or otherwise out of scope, or are objects that may be freed? Does the compiler partially protect the progr

Re: how to raw read a struct or value?

2011-07-14 Thread Graham Fawcett
On Thu, 14 Jul 2011 13:05:33 -0400, Steven Schveighoffer wrote: > On Thu, 14 Jul 2011 09:36:47 -0400, Graham Fawcett > wrote: > >> On Thu, 14 Jul 2011 09:01:29 +, hasnoth wrote: >> >>> auto file = io.File("test.txt", "rb"); >>> auto fp = file.getFP(); >>> int x; >>> io.fread(&x, x.size

Re: how to raw read a struct or value?

2011-07-14 Thread Steven Schveighoffer
On Thu, 14 Jul 2011 09:36:47 -0400, Graham Fawcett wrote: On Thu, 14 Jul 2011 09:01:29 +, hasnoth wrote: auto file = io.File("test.txt", "rb"); auto fp = file.getFP(); int x; io.fread(&x, x.sizeof, 1, fp); what's the “d method” to do that? The same method: import core.stdc.s

Re: Problems with static linking of c libraries

2011-07-14 Thread Trass3r
Am 14.07.2011, 16:36 Uhr, schrieb Danny Arends : Hey all, I'm trying to build a D application which statically links in the the blas and lapack libraries (from http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html ). When downloading the pre-build libraries from the website I link th

Problems with static linking of c libraries

2011-07-14 Thread Danny Arends
Hey all, I'm trying to build a D application which statically links in the the blas and lapack libraries (from http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html ). When downloading the pre-build libraries from the website I link them in using: pragma(lib, "blas"); pragma(lib, "lapack");

Re: tiny web server in D

2011-07-14 Thread Adam Ruppe
std.socket is too low level for serving webpages. It just provides the means to talk on the network, but doesn't do any application protocols like http. I've written a little http server in D, but it uses linux system calls instead of std.socket, so it only works on linux. http://arsdnet.net/dcod

Re: tiny web server in D

2011-07-14 Thread Dr.Smith
The program as such can regurgitate a web page provided these additional lines: string webpage = "index.html"; string output = "HTTP/1.1 200 OK\r\n Content-Type: text/html; charset=UTF-8\r\n\r \n" ~ to!string(read(webpage) ~ "\r\n"; This does not serve a page as localhost:port/webpage.html, but

Re: wrapping a void* by a ubyte[] array?

2011-07-14 Thread Daniel Murphy
Cast to ubyte* and slice? ubyte[] array = (cast(ubyte*)pointer)[0..length]; "teo" wrote in message news:ivn0n8$14ig$1...@digitalmars.com... > Is there any way of wrapping a void* by a ubyte[] array? The void* comes > from mmap.

Re: wrapping a void* by a ubyte[] array?

2011-07-14 Thread Simen Kjaeraas
On Thu, 14 Jul 2011 17:07:20 +0200, teo wrote: Is there any way of wrapping a void* by a ubyte[] array? The void* comes from mmap. byte[] array = cast(ubyte[])mmap(addr, length, ...)[0..length;] -- Simen

Re: Problems with static linking of c libraries

2011-07-14 Thread Loopback
On 2011-07-14 17:06, Danny Arends wrote: Wow THANX, Using the COFF2OMF tool at least got me a step further, now it finds and accepts the lib files, however, it now fails with the following error: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. h

Re: Problems with static linking of c libraries

2011-07-14 Thread Danny Arends
Wow THANX, Using the COFF2OMF tool at least got me a step further, now it finds and accepts the lib files, however, it now fails with the following error: OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html

wrapping a void* by a ubyte[] array?

2011-07-14 Thread teo
Is there any way of wrapping a void* by a ubyte[] array? The void* comes from mmap.

Re: Problems with static linking of c libraries

2011-07-14 Thread Loopback
You need to convert the libraries to OMF format from COFF. These are some tools which can do this: Coffimplib: http://www.digitalmars.com/ctg/coffimplib.html Coff2OMF: http://www.digitalmars.com/ctg/coff2omf.html ObjConv: http://www.agner.org/optimize/objconv.zip

Problems with static linking of c libraries

2011-07-14 Thread Danny Arends
Hey all, I'm trying to build a D application which statically links in the the blas and lapack libraries (from http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html ). When downloading the pre-build libraries from the website I link them in using: pragma(lib, "blas"); pragma(lib, "lapack"

Re: how to raw read a struct or value?

2011-07-14 Thread Graham Fawcett
On Thu, 14 Jul 2011 09:01:29 +, hasnoth wrote: > auto file = io.File("test.txt", "rb"); > auto fp = file.getFP(); > int x; > io.fread(&x, x.sizeof, 1, fp); > > what's the “d method” to do that? The same method: import core.stdc.stdio : fread; fread(&x, x.sizeof, 1, fp); or, if you

Re: A problem with const

2011-07-14 Thread Daniel Murphy
I don't think there's a bug report specifically on this. "bearophile" wrote in message news:ivmigl$98a$1...@digitalmars.com... > Daniel Murphy: > >> Yeah, type deduction with modifiers is inconsistent. >> >> In some cases matching T to const(U) gives U == tailconst(T), but not in >> others. >> T

Re: A problem with const

2011-07-14 Thread bearophile
Daniel Murphy: > Yeah, type deduction with modifiers is inconsistent. > > In some cases matching T to const(U) gives U == tailconst(T), but not in > others. > The problem exists with pointers, arrays, and (if we ever get it) Michel > Fortin's const(Object)ref. Is this already in Bugzilla, or d

Re: A problem with const

2011-07-14 Thread Daniel Murphy
Yeah, type deduction with modifiers is inconsistent. In some cases matching T to const(U) gives U == tailconst(T), but not in others. The problem exists with pointers, arrays, and (if we ever get it) Michel Fortin's const(Object)ref. A big part of the problem is that it can match with implicit

A problem with const

2011-07-14 Thread bearophile
A D2 program: T[] foo(T)(const T[] x) { //static assert(is(U == int)); // false static assert(is(T == const(int))); return new T[1]; } U[] bar(U)(const U[] y) { static assert(is(U == int)); return foo(y); } void main() { bar([1]); } DMD 2.054 gives: test.d(8): Error: can

how to raw read a struct or value?

2011-07-14 Thread hasnoth
auto file = io.File("test.txt", "rb"); auto fp = file.getFP(); int x; io.fread(&x, x.sizeof, 1, fp); what's the �d method� to do that?