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
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;
== 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
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?
== 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 (for instance, as being mod 2^size)? Can I
reliably say that -long.min == 0L?
== 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
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)
{
== 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
== 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
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
== 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?
>
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?
== 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
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
== 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
&
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?
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)
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
== 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
== 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
> >
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:
== 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;
== 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;
> >&
== 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.
>
Is there a way to get a single keystroke in D2? Any method I've tried requires
pushing Enter before the stroke is registered.
== 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
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.
== 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:
> > >
== 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
Does GDC support D2?
== 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
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
== 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
> >
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
== 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
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
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
== 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)
> > {
> >
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.
== 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)()
> > {
> >...
> > }
&
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?
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
== 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.
>
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
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;
}
== 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/
== 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
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
== 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
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.
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
Ah, that clears it up. Thanks!
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.
What's the difference between assert and enforce in D?
== 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
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?
== 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
== 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
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.
== 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(
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
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
> 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
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
// ...
// ...
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?
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
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"?
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
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
Nevermind, I see my error.
Thank you!
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
Tomek got it right. Fixed by copying the objects, rather than using pointers.
Thanks!
73 matches
Mail list logo