Re: stack trace hack for recent Phobos?

2009-07-16 Thread Robert Fraser
Trass3r wrote: Robert Fraser schrieb: Windows or Unix? Currently I only need Windoze, but knowing the linux situation wouldn't be bad either. There's no Windows stack trace that works with the newest Phobos AFAIK, however if you're using D2, you could probably copy Tango's stacktrace

Re: need help convert c code

2009-07-16 Thread Robert Fraser
D. Reeds wrote: can anybody help me translate this c code into d, im using D1+tango combo. i'm new to D and got stucked on multi-dimension array part. int levenshtein_distance(char *s,char*t) //Compute levenshtein distance between s and t { //Step 1 int k,i,j,n,m,cost,*d,distance;

Re: dmd crashes with out of memory error

2009-07-14 Thread Robert Fraser
File is probably too big. Remember that for every byte in your binary, DMD is likely allocating several hundred for the literal xpression object + codegen for the expression, etc., and frees very little dynamically allocated memory. Trass3r wrote: Here are the files, if you want to try out:

Re: Regex

2009-07-09 Thread Robert Fraser
BLS wrote: Vladimir Voinkov wrote: std.regex can't be used in compile time function call. It's quite frustrating... see dsource.org .. afaik there is a compile time regex project. hth http://www.dsource.org/projects/scregexp But the generated functions aren't CTFE-compatible AFAIK. A CTFE

Linking to MinGW-generated library woes

2009-06-15 Thread Robert Fraser
Has anyone been able to successfully link (statically) to a library generated by MinGW? I compiled the libraries in question (FFMpeg avutil, avformat, and avcodec) under MinGW, ran objconv on it to convert it to OMF (no errors) and passed it to optlink along with MinGW's libgcc. At this point

Re: D_Version2 problem

2009-06-11 Thread Robert Fraser
David Ferenczi wrote: == Quote from Sergey Gromov (snake.sc...@gmail.com)'s article Sun, 18 Jan 2009 22:28:12 +0100, Hoenir wrote: The D_Version2 version identifier doesn't work properly for me. Tried compiling with dmd 1.039. D_Version2 is set even if I pass -v1 to it. Is this a bug or am I

Re: Creating a dynamic link library

2009-06-08 Thread Robert Fraser
Fractal wrote: Hello Using Windows, I created a DLL with D, and when I try to create my test executable (also with D), the ImpLib program displays an error saying that there is no any exported function. The DLL source only contains a class with the export attribute like: export class Foo {

Re: Garbage collection in D

2009-06-04 Thread Robert Fraser
bearophile wrote: Yes, for such tiny benchmarks I have seen several times 10-12 higher allocation performance in Java compared to D1-DMD. But real programs don't use all their time allocating and freeing memory... Bye, bearophile For the compiler I'm working on now (in D), I wanted to check

Re: Garbage collection in D

2009-06-03 Thread Robert Fraser
What's the difference between: D 1: 40.20 DMD D 2: 21.83 DMD D 2: 18.80 DMD, struct + scope and: D 1: 8.47 DMD D 2: 7.41 DMD + scope ...?

Re: Garbage collection in D

2009-06-03 Thread Robert Fraser
Sam Hu wrote: bearophile Wrote: I have tried the new JavaVM on Win, that optionally performs escape analysis, and the results are nice: Timings, N=100_000_000, Windows, seconds: D 1: 40.20 DMD D 2: 21.83 DMD D 2: 18.80 DMD, struct + scope C++: 18.06 D 1: 8.47 DMD D 2:

Re: legal identifier check

2009-05-31 Thread Robert Fraser
BCS wrote: Hello Saaa, You have to write it yourself. Here's a good starting point: http://www.digitalmars.com/d/1.0/lex.html#identifier Yes, that was my starting point and it seemed quite complex, thus my question :) I think I'll stay with my simple check for now as it isn't really

Re: Encoding problems...

2009-05-28 Thread Robert Fraser
grauzone wrote: Robert Fraser wrote: Jarrett Billingsley wrote: On Wed, May 27, 2009 at 8:55 PM, Robert Fraser fraseroftheni...@gmail.com wrote: Hi all, Quick question: I want to use some unicode identifiers, but I get unsupported char 0xe2, both with using and not using a BOM

Re: Encoding problems...

2009-05-28 Thread Robert Fraser
BCS wrote: Reply to Robert, Hmm... I'd say x.⊆(y) is preferable x.isSubsetOf(y), but it's not a huge deal. Only until you have to type it. I think universal alpha includes only the union of things that can be easily typed on standard keyboards. I don't think any keyboard (ok maybe an APL

Re: Encoding problems...

2009-05-27 Thread Robert Fraser
Jarrett Billingsley wrote: On Wed, May 27, 2009 at 8:55 PM, Robert Fraser fraseroftheni...@gmail.com wrote: Hi all, Quick question: I want to use some unicode identifiers, but I get unsupported char 0xe2, both with using and not using a BOM. The characters in question are the superset

Re: Class allocation from tuple

2009-05-21 Thread Robert Fraser
bearophile wrote: I have a tuple of classes (D1 language), I'd like to instantiate one of them directly with new, but it seems I can't: template Tuple(T...) { alias T Tuple; } class Foo { static void foo(){} } class Bar {} alias Tuple!(Foo, Bar) ClassTuple; void main() { alias

Re: any html parser with d binding

2009-05-20 Thread Robert Fraser
reimi gibbons wrote: 2) how reliable is bcd to create binding for c libraries? C? Very reliable (unless it uses weird compiler directives). C++ is a bit trickier.

Re: struct opCmp?

2009-05-14 Thread Robert Fraser
Nick Sabalausky wrote: Lars T. Kyllingstad pub...@kyllingen.nospamnet wrote in message news:gui4ml$2g0...@digitalmars.com... I think you have to use opEquals to overload ==. opCmp only applies to , =, , and =. Oh, I figured either opEquals would be defined in terms of opCmp or an

Re: Who wants to have some fun memory debugging?

2009-05-13 Thread Robert Fraser
grauzone wrote: Wild guess: there's a false pointer, that keeps one element in the list from being collected, and because the list-prev pointers are still there, all following elements won't be collected either in consequence. If I had time, I'd try two experiments: 1. before freeing

Re: A couple of questions

2009-05-13 Thread Robert Fraser
Simen Kjaeraas wrote: Sam Huwrote: Q4.In the delegate somFnExp:front(),popFront,empty() are all not defined??Anyway it is not an interface ,so why it is allowed? Basically, is(typeof(X)) is D magic. One could interpret it as 'is X a valid type', or perhaps more correctly as 'does X

Who wants to have some fun memory debugging?

2009-05-12 Thread Robert Fraser
Running this program with Tango SVN + DMD 1.045 or Tango 0.98 + DMD 1.041 on WinXP SP3 32-bit results in a memory leak (the program keeps increasing in size at every iteration) leak.d: --- module leak; import tango.stdc.stdio; import tango.core.Memory;

Re: Who wants to have some fun memory debugging?

2009-05-12 Thread Robert Fraser
Simpler version, sans printf: module leak; import tango.core.Memory; struct Data { Data* prev; char[4092] something; } public void main() { Data* data; Data* newData; int i; while(true) { for(i = 0; i 10_000; i++) { newData = new Data;

Re: Stack allocator?

2009-04-20 Thread Robert Fraser
Denis Koroskin wrote: On Sun, 19 Apr 2009 10:15:41 +0400, Tim Matthews tim.matthe...@gmail.com wrote: On Sat, 18 Apr 2009 16:42:28 -0700 Robert Fraser fraseroftheni...@gmail.com wrote: I remember a while back someone posted an easy dynamic stack allocator... anyone have the link? Thanks

Re: Stack allocator?

2009-04-20 Thread Robert Fraser
Denis Koroskin wrote: On Sun, 19 Apr 2009 10:15:41 +0400, Tim Matthews tim.matthe...@gmail.com wrote: On Sat, 18 Apr 2009 16:42:28 -0700 Robert Fraser fraseroftheni...@gmail.com wrote: I remember a while back someone posted an easy dynamic stack allocator... anyone have the link? Thanks

Re: project euler #10: optimization with primes

2009-04-01 Thread Robert Fraser
bearophile wrote: import d.func, d.primes, d.string; void main() { const int N = 1_000_000_000; putr( sum(xtakeWhile((int i){ return i N;}, xprimes(N))) ); } Yeah that's shorter (vertically; it's almost as long in characters), but how much lisp do you have to smoke to understand it?

Re: Moving from 1.0 to D2

2009-03-12 Thread Robert Fraser
jicman wrote: 12:49:34.90dmd Digital Mars D Compiler v1.022 I'd recommend upgrading to 1.041 first ;-P (especially considering all the bug fixes performance improvements in it).

Re: enum to string

2009-03-12 Thread Robert Fraser
Jarrett Billingsley wrote: There's also std.typecons which has an enum generator that will create toString and I think fromString functions as well. Which should be easily portable to D1.

Re: Char[] confusing

2009-03-03 Thread Robert Fraser
Qian Xu wrote: Lutger wrote: s[4] means the fifth element of s[] s[0..4] is a slice from the first to the fifth, but not including the fifth element. The last element in a slice is always one past the end of that slice. Thank you both. I have to do math in mind in order to keep my code

Re: parsing parameters

2009-02-23 Thread Robert Fraser
BCS wrote: Reply to Ellery, BCS wrote: I don't understand your question. Are you suggesting that something be added or asking why something is allowed? Why is it allowed? for example: int myfun(int=10); Theory 1: it's a side effect of two features: this is allowed int myFunc(int)

Re: Can i safely cast void* from void[]?

2009-02-08 Thread Robert Fraser
Heinz wrote: Hi, I remember i read around the D site that dinamic arrays can be stored in system memory in a 'non contiguous' way (different locations). I was trying to find again that page but haven't had any lucky. I'm not crazy, i know i saw it. Anyway, i need this info to ensure that i

Re: foreach/opApply is the visitor pattern

2009-02-01 Thread Robert Fraser
BCS wrote: Correct me if I'm wrong but I thing that D's opApply is a form of the Visitor pattern where the calling function's stack frame is the visitor object. This just occurred to me. Maybe I've been missing something re the visitor pattern but I think this make for a nice, cool and easy