Re: Trouble with OPTLINK

2010-11-13 Thread Brad Roberts
On 11/13/2010 1:14 PM, bearophile wrote: > Aardvark Soup: > >> I've already tried cleaning up all build files and adding the current >> directory to the system PATH, both to no avail. This does not happen >> while I compile single-file programs that import from the standard >> library. Does any

Re: Switch constants

2010-11-13 Thread bearophile
Daniel Murphy: > switch(x) > { > case 0: >break; // what is x here? > case 1: >goto case 0: > } > etc You are right. Thank you for all the answers. Bye, bearophile

Re: Nested associative arrays

2010-11-13 Thread div0
On 14/11/2010 00:28, Ellery Newcomer wrote: On 11/13/2010 02:02 PM, spir wrote: On Sat, 13 Nov 2010 17:27:08 + But the compiler (D2) accepts nested aa literals remaining anonymous: writeln(["a" : ["b" : "c"]]); // --> "a:b:c" (where "auto aa = ..." fails) The difference is initializer

Re: Switch constants

2010-11-13 Thread Stanislav Blinov
bearophile wrote: In a not-ranged cases body, like in the program below (that doesn't compile), the switch variable is a compile-time constant, so why doesn't the compile see x as constant there? template Foo(uint x) { static if (x <= 1) enum Foo = 1; else enum Foo = x

Re: Nested associative arrays

2010-11-13 Thread Ellery Newcomer
On 11/13/2010 02:02 PM, spir wrote: On Sat, 13 Nov 2010 17:27:08 + But the compiler (D2) accepts nested aa literals remaining anonymous: writeln(["a" : ["b" : "c"]]);// --> "a:b:c" (where "auto aa = ..." fails) The difference is initializer vs expression. initializers occu

Re: Nested associative arrays

2010-11-13 Thread bearophile
div0: > I finally found the bit where it describes associative array literals > and they look identical to initialising a flat array, so god only knows > which one gets picked when. It would be better if they where made different. One of my many enhancement requests, no one disturbs their sleep

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 20:02, spir wrote: On Sat, 13 Nov 2010 17:27:08 + div0 wrote: How about "associative array literal" then? Regardless of what you call it I shouldn't get an assertion failure. True. It's been fixed in dmd2 though, you get: Error: Integer constant expression expected instea

Re: Switch constants

2010-11-13 Thread Daniel Murphy
"bearophile" wrote in message news:ibn320$2uc...@digitalmars.com... > In a not-ranged cases body, like in the program below (that doesn't > compile), the switch variable is a compile-time constant, so why doesn't > the compile see x as constant there? In switch statements, you can do stuff lik

Re: Switch constants

2010-11-13 Thread Dmitry Olshansky
On 14.11.2010 1:21, bearophile wrote: In a not-ranged cases body, like in the program below (that doesn't compile), the switch variable is a compile-time constant, so why doesn't the compile see x as constant there? Well, there is fall-through ;) And there still could be goto's. In essence "c

Switch constants

2010-11-13 Thread bearophile
In a not-ranged cases body, like in the program below (that doesn't compile), the switch variable is a compile-time constant, so why doesn't the compile see x as constant there? template Foo(uint x) { static if (x <= 1) enum Foo = 1; else enum Foo = x * Foo!(x - 1); } i

Re: Trouble with OPTLINK

2010-11-13 Thread bearophile
Aardvark Soup: > I've already tried cleaning up all build files and adding the current > directory to the system PATH, both to no avail. This does not happen > while I compile single-file programs that import from the standard > library. Does anyone have an idea how to fix this? This is a prob

Re: segfault

2010-11-13 Thread spir
On Fri, 12 Nov 2010 08:03:26 -0500 "Steven Schveighoffer" wrote: > Pelle, I spent all this time helping him, and you swoop in with the answer > :) > > Yes, he is right, you need to dup the patterns argument. It is something > I very recently discovered. Wow, first thought dup did not solv

Trouble with OPTLINK

2010-11-13 Thread Aardvark Soup
Every time I try to compile a multi-file project the linker gives me a whole list of "Symbol undefined" errors. For example, given the extremely simple source file test.d: module test; import test2; import std.stdio; void main() { writef("%d",foo); } And test2.d: module test2; int fo

Re: Nested associative arrays

2010-11-13 Thread spir
On Sat, 13 Nov 2010 17:27:08 + div0 wrote: > > How about "associative array literal" then? Regardless of what you call > > it I shouldn't get an assertion failure. > > > > True. It's been fixed in dmd2 though, you get: > > Error: Integer constant expression expected instead of "" > > Whe

Re: segfault

2010-11-13 Thread bearophile
spir: > I'm blocked by a mysterious segfault I seem to be unable to diagnose. I have added an enhancement request to avoid the D pitfall you have found, so the time you have used to find this bug is not wasted and may help future D programmers: http://d.puremagic.com/issues/show_bug.cgi?id=521

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 15:49, Jacob Carlborg wrote: On 2010-11-13 14:56, div0 wrote: On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them)

Re: Nested associative arrays

2010-11-13 Thread Ellery Newcomer
Wow. Yeah, I guess all bets are off when it comes to initializations. In the meantime, I guess you'll have to use string[string][string] tree; tree = ["" : ["" : ""]]; On 11/13/2010 05:02 AM, Jacob Carlborg wrote: Well, yes. The following code: module main; void main () { auto tree = ["" :

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
On 2010-11-13 14:39, bearophile wrote: Jacob Carlborg: module main; void main () { auto tree = ["" : ["" : ""]]; } Using DMD 1.065 results in: Assertion failed: (0), function toExpression, file init.c, line 437. Please put it in Bugzilla if not already present :-) Bye, bearophile

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
On 2010-11-13 14:56, div0 wrote: On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrot

Re: How to uncompress gzip archive compressed by deflate method.

2010-11-13 Thread Zarathustra
Ok, I found the solution: _uncompressed = uncompress(_compressed, *cast(uint*)&_compressed[_compressed.length-4], 30);

Re: Nested associative arrays

2010-11-13 Thread div0
On 13/11/2010 11:02, Jacob Carlborg wrote: On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to ha

Re: Nested associative arrays

2010-11-13 Thread bearophile
Jacob Carlborg: > module main; > > void main () > { > auto tree = ["" : ["" : ""]]; > } > > Using DMD 1.065 results in: > > Assertion failed: (0), function toExpression, file init.c, line 437. Please put it in Bugzilla if not already present :-) Bye, bearophile

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 14:20:05 +0100, Simen kjaeraas wrote: > Michal Minich wrote: > >> first: extern (C) means that the function 'fun' is not defined in D, >> but in C. > > Wrong. It means the function has C calling convention. If it has a body, > it is defined in D, and can be called from C (an

Re: Calling a D function from C

2010-11-13 Thread Simen kjaeraas
Michal Minich wrote: first: extern (C) means that the function 'fun' is not defined in D, but in C. Wrong. It means the function has C calling convention. If it has a body, it is defined in D, and can be called from C (and D). If not, it is defined elsewhere, and can be called from D. -- Sim

Re: How to uncompress gzip archive compressed by deflate method.

2010-11-13 Thread Zarathustra
Thanks for a tip, but it's still does not work. My test gzip file have 10 (minimum gzip header) header bytes and 8 trailing bytes, so I tried: auto _uncompressed = uncompress(_compressed[0x0A.._compressed.length - 0x08]); But the exception still occurs. Maybe the compressed data need to be aligne

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 00:00:00 +0100, Carlo wrote: > On 12/11/2010 16:19, Michal Minich wrote: >> V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: >> >>> Sorry if I bother you again with this probably silly problem. Here is >>> the point. I want to call the D function "fun" from a .c file: >>> >>> \\

Re: Calling a D function from C

2010-11-13 Thread Michal Minich
On Sat, 13 Nov 2010 00:00:00 +0100, Carlo wrote: > On 12/11/2010 16:19, Michal Minich wrote: >> V Fri, 12 Nov 2010 16:14:30 +0100, Carlo wrote: >> >>> Sorry if I bother you again with this probably silly problem. Here is >>> the point. I want to call the D function "fun" from a .c file: >>> >>> \\

Re: Nested associative arrays

2010-11-13 Thread Jacob Carlborg
On 2010-11-12 17:44, Ellery Newcomer wrote: Should be. Are you having problems? (I don't use them much, but fwiw, it seems like tango had some [trivial?] problems with them) On 11/12/2010 10:08 AM, Jacob Carlborg wrote: Is D supposed to be able to handle nested associative arrays ? Well, y