Re: Public imports with D interface files?

2011-09-03 Thread Sean Eskapp
ort probably triggers creation > of a module constructor as it really creates aliases for the symbols > from the imported module. > David > On 9/4/11 3:17 AM, Sean Eskapp wrote: > > I'm compiling a very simple D interface file: > > > > module std

Public imports with D interface files?

2011-09-03 Thread Sean Eskapp
I'm compiling a very simple D interface file: module std_ext.typetuple; public import std.typetuple class TypeArray(T...) { } Compiling it as such: dmd -debug -unittest -D -Dddocs -w -H -o- std_ext/typetuple.d And including it as such: import std_ext.typetuple;

Re: How to use -H?

2011-09-03 Thread Sean Eskapp
== Quote from David Nadlinger (s...@klickverbot.at)'s article > On 9/3/11 8:17 PM, Sean Eskapp wrote: > > I'm trying to create import libraries for use in other projects, using the > > -H > > flag, but dmd is still trying to create an executable. How do I spec

How to use -H?

2011-09-03 Thread Sean Eskapp
I'm trying to create import libraries for use in other projects, using the -H flag, but dmd is still trying to create an executable. How do I specify that all I want are the interface files?

Re: Is integer overflow defined?

2011-09-01 Thread Sean Eskapp
== Quote from Timon Gehr (timon.g...@gmx.ch)'s article > On 09/01/2011 06:20 PM, Sean Eskapp wrote: > > Is integer overflow defined (for instance, as being mod 2^size)? > I am quite sure that all operations are defined as operations on two's > complement integers, whi

Is integer overflow defined?

2011-09-01 Thread Sean Eskapp
Is integer overflow defined (for instance, as being mod 2^size)? Can I reliably say that -long.min == 0L?

Re: struct opEquals does not work with parameter of same type - bug or feature?

2011-08-29 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Monday, August 29, 2011 22:41:26 Sean Eskapp wrote: > > I am trying to build a struct with equality testing, using this code: > > > > struct Foo > > { > > const bool opEquals(Fo

struct opEquals does not work with parameter of same type - bug or feature?

2011-08-29 Thread Sean Eskapp
I am trying to build a struct with equality testing, using this code: struct Foo { const bool opEquals(Foo f) { return true; } } This gives me the error that the parameter should be of type "ref const Foo". Fine. struct Foo { const bool opEquals(ref const Foo f) {

Re: Why aren't function attributes inferred?

2011-08-20 Thread Sean Eskapp
== Quote from Nick Sabalausky (a@a.a)'s article > "Sean Eskapp" wrote in message > news:j2ooko$15m4$1...@digitalmars.com... > > Since the compiler can clearly tell when a function is not const, safe, > > pure, > > or nothrow, why can't they just be as

Re: Regarding nothrow and @safe

2011-08-20 Thread Sean Eskapp
== Quote from Timon Gehr (timon.g...@gmx.ch)'s article > On 08/20/2011 08:18 PM, Sean Eskapp wrote: > > bearophile: > >> As far as I know they have decided to make memory overflow errors, so they > >> are > > not exceptions, you can't catch them. Other

Re: Regarding nothrow and @safe

2011-08-20 Thread Sean Eskapp
bearophile: > As far as I know they have decided to make memory overflow errors, so they are not exceptions, you can't catch them. Other people will confirm this or not. In this case, how would you go about handling out-of-memory situations? A systems programming language should certainly give th

Re: Why aren't function attributes inferred?

2011-08-20 Thread Sean Eskapp
== Quote from Timon Gehr (timon.g...@gmx.ch)'s article > On 08/20/2011 06:50 PM, Sean Eskapp wrote: > > Since the compiler can clearly tell when a function is not const, safe, > > pure, > > or nothrow, why can't they just be assumed, unless proven otherwise? >

Why aren't function attributes inferred?

2011-08-20 Thread Sean Eskapp
Since the compiler can clearly tell when a function is not const, safe, pure, or nothrow, why can't they just be assumed, unless proven otherwise?

Re: How do "pure" member functions work?

2011-08-20 Thread Sean Eskapp
== Quote from Timon Gehr (timon.g...@gmx.ch)'s article > On 08/20/2011 06:24 PM, Sean Eskapp wrote: > > == Quote from David Nadlinger (s...@klickverbot.at)'s article > >> On 8/20/11 5:13 PM, Sean Eskapp wrote: > >>> Does marking a member function a

Regarding nothrow and @safe

2011-08-20 Thread Sean Eskapp
Does nothrow mean the function itself does not through exceptions, or that the function body, as well as any called functions, do not throw? I wonder because allocating new memory inside a @safe nothrow function works, even though I'm used to "new" allocations throwing exceptions or Out-Of-Memory e

Re: How do "pure" member functions work?

2011-08-20 Thread Sean Eskapp
== Quote from David Nadlinger (s...@klickverbot.at)'s article > On 8/20/11 5:13 PM, Sean Eskapp wrote: > > Does marking a member function as pure mean that it will return the same > > result given the same parameters, or that it will give the same result, > > given &

How do "pure" member functions work?

2011-08-20 Thread Sean Eskapp
Does marking a member function as pure mean that it will return the same result given the same parameters, or that it will give the same result, given the same parameters and given the same class/struct members?

Foreach over tuple of arrays?

2011-08-07 Thread Sean Eskapp
I have a tuple of arrays of different types, but want to call a template function on each element. How would I do this? void foo(T)(T elem) { ... } I tried like this: ArrayTuple!(T) data; void iterate(alias func, uint n)() { static if(n < T.length)

Compiling 64-bit code under Windows 7?

2011-05-30 Thread Sean Eskapp
I'm trying to compile a very simple file, main.d: void main() { } Under Windows 7, 64-bit, with out-of-the-box DMD v2.053 installation. I get this, however: C:\Users\Me\devl\test>dmd -m64 main.d Internal error: msc.c 268

Re: 64-bit two-step compilation on Ubuntu?

2011-04-25 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > == Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > > > > > I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. > > > > Unfortunately, Code::Blocks doesn't allow the simple one-step > > > > compila

Re: 64-bit two-step compilation on Ubuntu?

2011-04-25 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. > > Unfortunately, Code::Blocks doesn't allow the simple one-step compilation > > that is default with dmd, so it does compiling and linking in two separate > >

64-bit two-step compilation on Ubuntu?

2011-04-25 Thread Sean Eskapp
I'm trying to get a D2 project to build on Ubuntu through Code::Blocks. Unfortunately, Code::Blocks doesn't allow the simple one-step compilation that is default with dmd, so it does compiling and linking in two separate steps. Unfortunately, this is causing some linker errors, the main one being:

Re: Get single keystroke?

2011-03-21 Thread Sean Eskapp
== Quote from Andrej Mitrovic (andrej.mitrov...@gmail.com)'s article > I believe I've found you a solution: > import std.c.stdio; > import std.c.linux.termios; > extern(C) void cfmakeraw(termios *termios_p); > void main() { > termios ostate; /* saved tty state */ > termios nstate;

Re: Get single keystroke?

2011-03-21 Thread Sean Eskapp
== Quote from Andrej Mitrovic (andrej.mitrov...@gmail.com)'s article > On 3/21/11, Sean Eskapp wrote: > > == Quote from Andrej Mitrovic (andrej.mitrov...@gmail.com)'s article > >> Here's something simpler: > >> import std.stdio : writefln; > >&

Re: Get single keystroke?

2011-03-21 Thread Sean Eskapp
== Quote from Andrej Mitrovic (andrej.mitrov...@gmail.com)'s article > Here's something simpler: > import std.stdio : writefln; > extern(C) int kbhit(); > extern(C) int getch(); > void main() > { > while(!kbhit()) > { > // keep polling > // might use thread.sleep here. >

Get single keystroke?

2011-03-21 Thread Sean Eskapp
Is there a way to get a single keystroke in D2? Any method I've tried requires pushing Enter before the stroke is registered.

Re: DMD2 - compiling and linking in separate steps (64-bit)

2011-03-19 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Friday 18 March 2011 20:49:58 Sean Eskapp wrote: > > incompatible /usr/lib/../lib/librt.so when searching > > for -lrt > > /usr/bin/ld: skipping incompatible /usr/lib/../lib/librt.a when searching &g

DMD2 - compiling and linking in separate steps (64-bit)

2011-03-18 Thread Sean Eskapp
I'm trying to use DMD through an IDE, but I'm getting stumped trying to create 64-bit executables under Linux. I can get everything compiled fine, using the -m64 compiler flag, but I can't get it to link. Here's the error list: /usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux- gnu/4.4.

Re: Building DSFML2? (64-bit Linux)

2011-03-18 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Friday, March 18, 2011 18:58:49 Sean Eskapp wrote: > > == Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > > > > On Friday, March 18, 2011 17:56:44 Sean Eskapp wrote: > > >

Re: GDC with D2?

2011-03-18 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Friday, March 18, 2011 19:00:40 Sean Eskapp wrote: > > Does GDC support D2? > Yes. It's also fairly up-to-date now too, I believe (though it is still a bit > behind dmd as I understand it - at least a

GDC with D2?

2011-03-18 Thread Sean Eskapp
Does GDC support D2?

Re: Buliding DSFML2? (64-bit Linux) (New info)

2011-03-18 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Friday, March 18, 2011 17:56:44 Sean Eskapp wrote: > > I've been trying for weeks to build the D bindings of SFML2, but with > > little success. The main issue is that I get a myriad of linker error

Buliding DSFML2? (64-bit Linux)

2011-03-18 Thread Sean Eskapp
I've been trying for weeks to build the D bindings of SFML2, but with little success. The main issue is that I get a myriad of linker errors (documented at http://www.sfml-dev.org/forum/viewtopic.php?p=28345#28345), but I can't figure out what linking options would solve them. Can anybody shed som

Re: DMD on linux? (more problems)

2011-03-03 Thread Sean Eskapp
== Quote from Jesse Phillips (jessekphillip...@gmail.com)'s article > Sean Eskapp Wrote: > > I'm still having issues with the linux dmd. Here's the relevant part > > of the output: > > > > ... > > function func > > function func > >

DMD on linux? (more problems)

2011-03-02 Thread Sean Eskapp
I'm still having issues with the linux dmd. Here's the relevant part of the output: ... function func function func gcc Nullimorphism.o -o Nullimorphism.exe -g -m32 -l -Xlinker - L/usr/lib32 -Xlinker -L/usr/lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt -lphobos2 -lpthre

Re: DMD on linux?

2011-03-02 Thread Sean Eskapp
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Wednesday, March 02, 2011 13:52:29 Sean Eskapp wrote: > > I'm trying to work with D on Ubuntu, but I keep having this issue: > > > > ... > > function func > > function func > > gc

DMD on linux?

2011-03-02 Thread Sean Eskapp
I'm trying to work with D on Ubuntu, but I keep having this issue: ... function func function func gcc Nullimorphism.o -o Nullimorphism.exe -g -m32 -l -Xlinker -L/usr/bin/../lib32 -Xlinker - L/usr/bin/../lib64 -Xlinker --no-warn-search-mismatch -Xlinker --export-dynamic -lrt - lphobos2 -lpthre

Verify tuple is a tuple of class objects?

2011-02-18 Thread Sean Eskapp
Is there a way to "run" a template at compile time, without using a member? What I'm trying to do is verify that every element of a tuple is a class type, and so far, I've been doing this: template VerifyTuple(Type, Types...) { static assert(is(Type : Object), Type.stringof ~ " is not a cl

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Sean Eskapp
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article > On Fri, 18 Feb 2011 17:16:02 +0000, Sean Eskapp wrote: > > I was given this code, to check if Y is a specialization of Bar. How > > does it work? > > > > class Bar(T) > > { > >

Finding out if T is a specialization of another template

2011-02-18 Thread Sean Eskapp
I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } void foo(Y)() { static if (is(Y Z == Bar!Z)) { // Here, Z is now an alias to whichever type Bar is // instantiated with. } else { // Z is invalid here.

Re: Checking if something is a template specialization?

2011-02-18 Thread Sean Eskapp
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article > On Fri, 18 Feb 2011 02:02:51 +0000, Sean Eskapp wrote: > > If I have > > > > class Bar(T) > > { > > } > > > > void foo(Y)() > > { > >... > > } &

Checking if something is a template specialization?

2011-02-17 Thread Sean Eskapp
If I have class Bar(T) { } void foo(Y)() { ... } Is there a way to check inside foo() that Y is in some way an instantiation of Bar? Is there a way to find WHICH instantiation it is?

Opt-out polymorphism?

2011-02-13 Thread Sean Eskapp
Is there a way to specify that a function is nonvirtual, but can still be "overriden" in base classes? e.g. class A { void foo() { writeln("A"); } } class B : A { void foo() { writeln("B"); } } void main() { (new A).foo(); (new B).foo(); } Should

Re: Double-dispatch

2011-02-13 Thread Sean Eskapp
== Quote from bearophile (bearophileh...@lycos.com)'s article > Sean Eskapp: > > Is there a nicer way to do this in D, or am I stuck with the same thing? > Andrei has recently said no one needs double dispatch (in D) :-) So Andrei > will be interested in your use case. >

Double-dispatch

2011-02-13 Thread Sean Eskapp
I remember in C++, I had to do double-dispatch using the visitor pattern. This is cumbersome, just because each subclass has to have the exact same singly-dispatched code that looks like: void dispatch(Base& other) { other.dispatch(*this); } Is there a nicer way to do this in D, or am I stuck

Get function name at compile time?

2011-02-12 Thread Sean Eskapp
Is there a way to get a function's name at compile time, for instance as part of a template? Using .stringof doesn't work, and I can't find another way to do it. Any help? class FunctionWrapper(alias func) { string name = func.stringof; }

Re: Invoke garbage collector?

2011-02-09 Thread Sean Eskapp
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article > On Wed, 09 Feb 2011 15:58:13 -0500, bearophile > wrote: > > Sean Eskapp: > > > >> so is there a way to invoke a GC cleanup in some way? > > > > http://www.digitalmars.com/d/2.0/phobos/

Re: Invoke garbage collector? (Scoped Instances)

2011-02-09 Thread Sean Eskapp
== Quote from Trass3r (u...@known.com)'s article > > However, I need the resources to be freed more quickly than the GC is > > apparently doing > You could use scoped instances if you need to clean them up soon after > creation. To my knowledge, these are being removed from the language, and so, c

Invoke garbage collector?

2011-02-09 Thread Sean Eskapp
I'm having an unfortunate DSFML issue, where failing to free objects like Images or Sprites causes exceptions to eventually be thrown. Calling the built-in member dispose() causes access violations, so I assume it's not for programmer use. However, I need the resources to be freed more quickly tha

Re: Debugging D?

2011-02-06 Thread Sean Eskapp
== Quote from Robert Clipsham (rob...@octarineparrot.com)'s article > On 06/02/11 20:29, Sean Eskapp wrote: > > Are debug symbols compiled with -gc stored in a separate file? Visual Studio > > refuses to debug my things, and windbg seems to be remarkably unhelpful. > I sug

Debugging D?

2011-02-06 Thread Sean Eskapp
Are debug symbols compiled with -gc stored in a separate file? Visual Studio refuses to debug my things, and windbg seems to be remarkably unhelpful.

Garbage-collected structs vs garbage-collected classes

2011-01-22 Thread Sean Eskapp
When I was using a class to wrap SDL functions and structs, I would have a problem that Derelict would unload before the garbage-collector cleaned up my classes, resulting in errors when these classes destructed and tried to call SDL functions in the process. However, the exact same code using stru

Re: assert vs enforce?

2011-01-22 Thread Sean Eskapp
Ah, that clears it up. Thanks!

Re: How to use structs for RAII?

2011-01-22 Thread Sean Eskapp
Actually this becomes rather annoying, since I can't use any closures on the object. Stupidly, I can still use closures with an object which is deleted at the end of the function.

assert vs enforce?

2011-01-22 Thread Sean Eskapp
What's the difference between assert and enforce in D?

Re: How to use structs for RAII?

2011-01-22 Thread Sean Eskapp
== Quote from bearophile (bearophileh...@lycos.com)'s article > Sean Eskapp: > > It was recommended to me to use structs for RAII instead of scope classes, > > since scope is being removed (?). However, since default-constructors for > > structs can't exist, how

How to use structs for RAII?

2011-01-22 Thread Sean Eskapp
It was recommended to me to use structs for RAII instead of scope classes, since scope is being removed (?). However, since default-constructors for structs can't exist, how does one do this?

Re: Structs with pointers?

2011-01-22 Thread Sean Eskapp
== Quote from bearophile (bearophileh...@lycos.com)'s article > Sean Eskapp: > > Nevermind, I realized it's because constness is transitive in pointers. A > > const > > struct with a pointer member has a const pointer member, and those can't be > > im

Re: Structs with pointers?

2011-01-22 Thread Sean Eskapp
== Quote from Sean Eskapp (eatingstap...@gmail.com)'s article > Why doesn't this code work? > struct Bar > { > int* x; > } > void foo(Bar a) {} > void main() > { > const a = Bar(); > foo(a); > } > But replacing int* with some oth

Structs with pointers?

2011-01-22 Thread Sean Eskapp
Why doesn't this code work? struct Bar { int* x; } void foo(Bar a) {} void main() { const a = Bar(); foo(a); } But replacing int* with some other type works fine? Even if a write a postblit function for Bar, it still fails to compile.

Re: How to wrap SDL?

2011-01-22 Thread Sean Eskapp
== Quote from Andrej Mitrovic (andrej.mitrov...@gmail.com)'s article > You can use scoped!() from std.typecons: > import std.stdio; > import std.typecons; > class A > { > ~this() > { > writeln("A destructor"); > } > } > void foo() > { > auto a1 = scoped!A(); > } > void main(

How to wrap SDL?

2011-01-22 Thread Sean Eskapp
I'm using the Derelict SDL bindings, and I'm wrapping some parts of SDL in my own objects. Originally, I was using classes, but this caused a number of errors when the program exited, since Derelict unloaded itself before the garbage collector took care of destructing my classes. So I switched to

const-typed class does not have const members

2011-01-21 Thread Sean Eskapp
The following code yields results as commented. import std.stdio; class A { int b; } void main() { const A a = new A; writeln(typeof(a).stringof); // const(A) writeln(typeof(a.b).stringof); // const(int) writeln((const A).stringof); // const(A) wr

Re: Type-qualified functions?

2011-01-21 Thread Sean Eskapp
> templates: > void foo(T)(T, void delegate(T) fn) > { > } > This parameterizes foo based on T, which could be A, const A, or int, or > whatever works to compile the function. What if the parameters are more general, for instance the first parameter is always a Foo, the second is a delegate whi

Type-qualified functions?

2011-01-21 Thread Sean Eskapp
How does one avoid code duplication in a snippet code like this: class A{} void foo(const A, void delegate(const A) fn) { // some stuff // ... // ... } void foo(A, void delegate(A) fn) { // exact same stuff, with different qualifiers // ... // ...

const vs immutable

2011-01-18 Thread Sean Eskapp
In cases where they are the same, for instance declaring: const int x = oldX + 5; vs immutable int x = oldX + 5; Or in non-class, non-array function parameters, does it make a difference which is used?

How to use std.bind?

2011-01-17 Thread Sean Eskapp
I used to use boost::bind all the time, but std.bind has me stumped, as I keep getting static asserts with a cryptic "argument has no parameters" message. At this point, the code is just: class Foo { void bar(int i) { writeln(i); } } void main() { auto foobar = new Foo; bi

"in" vs "const"

2011-01-17 Thread Sean Eskapp
For function parameters where the "scope" keyword doesn't matter (e.g. intrinsic types, many classes, structs, etc.), does "in" produce different code from "const"?

Casting between tuples

2011-01-12 Thread Sean Eskapp
I have a variable of type TypeTuple!(int, int), and I want to convert all its elements into a variable of type TypeTuple!(string, string). Is there a way to do this? Using a loop fails compilation with "Error: Integer constant expression expected instead of i". I'd also like to be able to convert

Re: Using template typetuples?

2011-01-12 Thread Sean Eskapp
That looks like it.. only, it's not working: void main() { TypeTuple!(int, int) foo; foo[0] = 1; foo[1] = 2; double MakeStuff(in int bar) { return cast(double)bar; } auto foobar = staticMap!(MakeStuff)(foo); } This fails co

Re: Using template typetuples?

2011-01-12 Thread Sean Eskapp
Nevermind, I see my error. Thank you!

Using template typetuples?

2011-01-12 Thread Sean Eskapp
The language documentation covers some basic uses of TypeTuples in templates, but nothing about using them with classes. I would like a template class, which essentially wraps a function, which has template parameters for return value and template tuple arguments. However, what if I want to conver

Re: What's wrong with this code? (OP)

2011-01-08 Thread Sean Eskapp
Tomek got it right. Fixed by copying the objects, rather than using pointers. Thanks!