Re: void main returning int - why compiles?

2011-01-01 Thread bearophile
Manfred Nowak: > _and_ foo() is not marked to have no side effects. You are right, thank you for the quotation. So I have updated this, because it's not a bug: http://d.puremagic.com/issues/show_bug.cgi?id=5399 I'm sure there's a rationale behind that special case in the D specs. Is someone ab

cstrings

2011-01-01 Thread Ellery Newcomer
are there any other cstring -> dstring functions than to!string(char*) ? something like to!(char[])(char*) (the memory allocation bothers me)

Re: sizeof

2011-01-01 Thread Ellery Newcomer
curious. prints 12, DMD 2.051 linux On 01/01/2011 06:15 PM, Manfred_Nowak wrote: Ellery Newcomer wrote: d code prints 12 prints 16 ( DMD 2.051 on win32) -manfred

Re: sizeof

2011-01-01 Thread Manfred_Nowak
Ellery Newcomer wrote: > d code prints 12 prints 16 ( DMD 2.051 on win32) -manfred

Re: void main returning int - why compiles?

2011-01-01 Thread Manfred_Nowak
Daren Scot Wilson wrote: > As shown, the "total evil" return statement gets a value from subroutine > foo(). >From the docs: | Expression is allowed even if the function specifies a void return | type. The Expression will be evaluated, but nothing will be returned. | If the Expression has no sid

sizeof

2011-01-01 Thread Ellery Newcomer
Hello. Been trying to link to some C code with gdc on 64 bit, and I've been racking my brain over the following: //tok.d import std.stdio; struct x { union _u_{ ulong uq; struct _s_ { ushort dw; uint dd; }; _s_ s; }; _u_ u;

Re: void main returning int - why compiles?

2011-01-01 Thread bearophile
http://d.puremagic.com/issues/show_bug.cgi?id=5399

Re: void main returning int - why compiles?

2011-01-01 Thread bearophile
Simen kjaeraas: > One would expect that to work. If void functions did not allow returning > the results of functions, the above function would have had to be changed > to something like this: > > ReturnType!Fn wrap( alias Fn )( ParameterTypeTuple!Fn args ) { > static if ( is( typeof( return

Re: void main returning int - why compiles?

2011-01-01 Thread David Nadlinger
On 1/1/11 10:08 PM, Simen kjaeraas wrote: This is by design, the feature is made for generic functions. Consider: ReturnType!Fn wrap( alias Fn )( ParameterTypeTuple!Fn args ) { return Fn( args ); } I am not sure if this simple argument is valid – if Fn was of return type void, you would, type

Re: Compiler error on struct with invariant and postblitz

2011-01-01 Thread Alex Khmara
On Sat, 01 Jan 2011 20:56:20 -, Jonathan M Davis wrote: On Saturday 01 January 2011 11:17:36 Alex Khmara wrote: Please help: is it compiler bug or I'm doing something wrong? This code: module properties; struct PropertyList { <-->invariant() { <--><-->assert(1); <-->} <-->this(this)

Re: void main returning int - why compiles?

2011-01-01 Thread Simen kjaeraas
Daren Scot Wilson wrote: As shown, the "total evil" return statement gets a value from subroutine foo(). Being somehow so perfect in its evilness, this passes through the compiler without a burp. The resulting executable returns zero (or my bash shell defaults to zero when receiving noth

Re: Compiler error on struct with invariant and postblitz

2011-01-01 Thread Jonathan M Davis
On Saturday 01 January 2011 11:17:36 Alex Khmara wrote: > Please help: is it compiler bug or I'm doing something wrong? > > This code: > > module properties; > > struct PropertyList { > <-->invariant() { > <--><-->assert(1); > <-->} > > <-->this(this) { > <--><-->_props = []; > <-->} > > <-->s

Re: dmd compile with imported modules

2011-01-01 Thread Jonathan M Davis
On Saturday 01 January 2011 07:07:12 spir wrote: > On Sat, 1 Jan 2011 13:34:47 + (UTC) > > useo wrote: > > Hey guys, > > > > I've the following problem... when I write a simple class, for > > example: > > > > ... > > module myclasses.exampleClass; > > > > class exampleClass { > > void writ

Re: dmd compile with imported modules

2011-01-01 Thread Jesse Phillips
David Nadlinger Wrote: > On 1/1/11 2:42 PM, David Nadlinger wrote: > > There has been some discussion on this recently, but for now, rdmd > > should be the tool to use. > > Oh, if you are looking for a dedicated »build tool«, you might also want > have a look at xfBuild which was created to ma

Re: Loop through all modules and module members?

2011-01-01 Thread Andrej Mitrovic
*the* J switch. On 1/1/11, Andrej Mitrovic wrote: > On 1/1/11, Philippe Sigaud wrote: >> I'm not sure it's doable at >> compile-time right now: you need to have access to the module code, as >> text. Do imports work in CT-evaluable functions? >> >> Philippe >> > > You're gonna love this: > > mod

Re: Loop through all modules and module members?

2011-01-01 Thread Andrej Mitrovic
On 1/1/11, Philippe Sigaud wrote: > I'm not sure it's doable at > compile-time right now: you need to have access to the module code, as > text. Do imports work in CT-evaluable functions? > > Philippe > You're gonna love this: module mymodule; void main() { pragma(msg, import(.stringof[7..$

Re: Compiler error on struct with invariant and postblitz

2011-01-01 Thread Alex Khmara
I forgot to mention - it's dmd 2.051

Compiler error on struct with invariant and postblitz

2011-01-01 Thread Alex Khmara
Please help: is it compiler bug or I'm doing something wrong? This code: module properties; struct PropertyList { <-->invariant() { <--><-->assert(1); <-->} <-->this(this) { <--><-->_props = []; <-->} <-->string[] _props; } gives compiler error: Error: __result = this is not mutable Error:

Re: dmd compile with imported modules

2011-01-01 Thread spir
On Sat, 1 Jan 2011 13:34:47 + (UTC) useo wrote: > Hey guys, > > I've the following problem... when I write a simple class, for > example: > > ... > module myclasses.exampleClass; > > class exampleClass { > void writeHelloWorld() { > writeln("Hello World"); > } > > And import myclasses.exa

Re: void main returning int - why compiles?

2011-01-01 Thread bearophile
> If you want I may add a bug report to Bugzilla that shows this as > "accepts-invalid": > > int foo(int x) { > return x; > } > void main() { > return foo(1); > } Simpler: int foo() { return 1; } void main() { return foo(); } But maybe this bug report is already present. Bye, bear

Re: dmd compile with imported modules

2011-01-01 Thread David Nadlinger
On 1/1/11 2:42 PM, David Nadlinger wrote: There has been some discussion on this recently, but for now, rdmd should be the tool to use. Oh, if you are looking for a dedicated »build tool«, you might also want have a look at xfBuild which was created to manage module dependencies for recompila

Re: dmd compile with imported modules

2011-01-01 Thread David Nadlinger
On 1/1/11 2:34 PM, useo wrote: I always have to compile the mainfile-module with "dmd mainfile.d myclasses/exampleClass.d" because of the obj-files. My projects are always growing and I don't want list all 100 or more classes/files in the command line. Is there any possibility to automatically im

dmd compile with imported modules

2011-01-01 Thread useo
Hey guys, I've the following problem... when I write a simple class, for example: ... module myclasses.exampleClass; class exampleClass { void writeHelloWorld() { writeln("Hello World"); } And import myclasses.exampleClass in the following: ... module mainfile; import myclasses.exampleClass;

Re: Loop through all modules and module members?

2011-01-01 Thread Philippe Sigaud
On Sat, Jan 1, 2011 at 11:14, bearophile wrote: > %u: > >> I would like to perform compile-time reflection on a module (such as >> enumerating all the classes inside the module) and/or on all modules in the >> code -- are either of these possible? And if so, how? > > You may add your enhancement r

Re: Loop through all modules and module members?

2011-01-01 Thread bearophile
%u: > I would like to perform compile-time reflection on a module (such as > enumerating all the classes inside the module) and/or on all modules in the > code -- are either of these possible? And if so, how? You may add your enhancement requests here, explaining why you need them: http://d.purem

Re: void main returning int - why compiles?

2011-01-01 Thread bearophile
Daren Scot Wilson: > I'm wondering why the following compiles. It's yet another small compiler bug, fit for Bugzilla. If you want I may add a bug report to Bugzilla that shows this as "accepts-invalid": int foo(int x) { return x; } void main() { return foo(1); } Bye, bearophile

Re: void main returning int - why compiles?

2011-01-01 Thread Matthias Pleh
On 2011-01-01 09:32, Jonathan M Davis wrote: On Friday 31 December 2010 23:37:17 Daren Scot Wilson wrote: I'm wondering why the following compiles. I'm using LDC. Perhaps it's a bug, or there's some subtlety about D. I have deliberately, out of a combination of idleness and desire for mischi

Re: void main returning int - why compiles?

2011-01-01 Thread Jonathan M Davis
On Friday 31 December 2010 23:37:17 Daren Scot Wilson wrote: > I'm wondering why the following compiles. I'm using LDC. Perhaps it's a > bug, or there's some subtlety about D. I have deliberately, out of a > combination of idleness and desire for mischief, have main() declared as > returning