Yeah, D feels like that to me too, sometimes. Anyways, for your question -
would using the struct name be good enough? They're easy to get hold of
and usable in switch statements.
If not, how about this:
import std.typetuple;
struct TypeEnum( T... ) {
static pure nothrow @property
Hello!
I have some structs
struct A { int a; }
struct B { int b, c; }
and I'd like to be able to enumerate them (preferrably as integers) based on
their names. I've no idea how this would look, but
some pseudo code that would use this feature:
// pseudo
int type = stream.read!int();
On 12/22/11 23:51 , Matej Nanut wrote:
Hello everyone, I've been fascinated by D lately and have been using it
for all
my school assignments (like simple ray casting and simulated annealing).
What I can't find anywhere is how to do something like
signal(SIGINT, myhandler) (I'm in a Linux
Christian Köstlin Wrote:
after some optimizing i got better, but was still way slower than c++.
so i started some small microbenchmarks regarding fileio:
https://github.com/gizmomogwai/performance in c++, java and d2.
christian
Hello!
Thanks for you effort in putting this together!
I
Hello!
1) How do I create a struct that I can foreach over?
I get the impression opApply has something do to with this, but I can't find
any documentation on it? (And I'm abroad without my TDPL.)
2) Also, is it possible to do something like this?
MyData!(100,100,100) data;
foreach(x,
Heywood Floyd Wrote:
Hello!
1) How do I create a struct that I can foreach over?
I get the impression opApply has something do to with this, but I can't find
any documentation on it? (And I'm abroad without my TDPL.)
2) Also, is it possible to do something like this?
MyData
Christophe Wrote:
Still, is the multi-dimensional part possible?
Sure, you have to make an opApply that takes several parameters in its
delegate.
An exemple:
struct TwoDArray(int nx, int ny)
{
int[nx][ny] data;
int opApply(int delegate(ref int i, ref int j, ref int cell)
Thank you bearophile and Simen for your replies! Very helpful!
I'll keep looking into it...
BR
/HF
bearophile Wrote:
Simen kjaeraas:
Essentially, mark the switch as final, and cover every option.
Likely, the optimizer does that for you if you cover every option but
don't mark the
Is this possible somehow:
int op(int r, int i)
{
static auto tbl = [add, sub, mul];
goto tbl[i % 3];
add:
r++;
goto end;
sub:
r--;
. (Or is it a stupid idea to begin with? Is this overkill? : )
cheers!
BR
/HF
PS. How do you export assembler code from the DMD-compiler?
Simen kjaeraas Wrote:
Heywood Floyd soul...@gmail.com wrote:
Is this possible somehow:
int op(int r, int i)
{
static auto
/libphobos2.a, /usr/local/lib/libdruntime.a); };
to
CommandLineArgs = { NO = (); otherwise =
(/usr/local/lib/libphobos2.a); };
and restart Xcode.
(Sorry for the boring post. Just documenting for future reference.)
BR
/HF
Heywood Floyd Wrote:
Build fails after upgrade to 2.051 with gcc
to be
getting away with on Windows. If it's a bug in the compiler or libraries
I think I'm stuffed as I wouldn't know where to start.
Regards
bob
On 23/12/2010 00:20, Heywood Floyd wrote:
Hi Bob!
My guess: You're listener is set to be non-blocking. That means that when
you call
Hi Bob!
My guess: You're listener is set to be non-blocking. That means that when you
call listener.accept() it will return immediately with an
SocketAcceptException, if there's no connection. And you're basically calling
listener.accept() over and over again in an infinite loop.
The
and have a third thread work on the copied data, without barriers or
guards or stuff like that during the time of actual work?
Kind regards and sorry for a lengthy sporadic post
/Heywood Floyd
Interesting!
I get the same result, ie an infinite loop, with the CPU at 100%
Some things I noticed:
- Changing the for-loops to 100 or 10 doesn't help.
- Changing the atomicOp from += to just + makes it work (although the
account doesn't get changed)
- Adding a Thread.sleep(1000) in one of the
Hello!
I've been trying to strip an executable created with DMD from symbols. Has
anyone any experience with this?
I can't seem to rid my execs of more or less containing the entire class-tree.
Example:
// sym.d - - - -
import std.stdio;
class Bunny{
int x;
int getX()
? Seems the OSX-strip is acting funny? Or
could it have something to do with DMD still? Maybe I should ask in some
darwin-forum about strip...
BR
/HF
Heywood Floyd Wrote:
Hello!
I've been trying to strip an executable created with DMD from symbols. Has
anyone any experience
Good Evenening Ladies and Gentlemen!
== Background ==
So I currently have a bare-bones Cocoa-app. It's just a window with an
OpenGL-view. In the view's draw-function I make the gl-view the current OpenGL
context and then call extern (C) render(). Meanwhile, in a D-file I have the
Ok! Thanks for the advice! Great work on the pluginit got me into D :)
/FH
Michel Fortin Wrote:
On 2010-10-05 10:02:45 -0400, Heywood Floyd soul...@gmail.com said:
But, sometimes I get reeeaally weird bugs. I had one bug where if I
added an empty function to a class in D I got
Rory Mcguire Wrote:
Hi,
What is one supposed to use to flush a TcpSocket.
flush doesn't seem to exist, should I really just use the c function?
-Rory
Was in a similar situation, found this:
http://stackoverflow.com/questions/855544/is-there-a-way-to-flush-a-posix-socket
I
string[int[2]] board;
board[[0,0]] = Rook;
board[[0,1]] = Knight;
foreach( pos, val; board) {
writefln( %s: %s, pos, val);
}
Output:
2 9903680: Knight
2 9903696: Rook
Changing the declaration to
string[int[]] board;
makes it work (for me).
BR
/HF
Mafi Wrote:
I don't really like it. Of course the order of indices feels better but
it breaks the rule of reading types from right to left. It also
introduces more parenthesis and a new keyword into types (amongst const,
immutable and delegate etc). Consider:
shared array[3](const(
Hi!
Breakfast toast: Is there any chance a) and b) below are identical in what they
do?
auto mutex = new Mutex();
auto cond = new Condition(mutex);
// a)
synchronized(mutex){
cond.wait();
}
// b)
mutex.lock();
cond.wait();
mutex.unlock();
I was sprinkling my code with
This had me crazy. I ended up putting the brackets on the variable, like
int marr[3][5];
then it worked like
marr[2][4] = 9;
bearophile Wrote:
Heywood Floyd:
This had me crazy. I ended up putting the brackets on the variable, like
int marr[3][5];
then it worked like
marr[2][4] = 9;
That's present only for compatibility with C syntax, this means that you can
use it to perform a quicker port of C code
Good day!
Consider
// - - - -
class Foo{}
auto one = new Foo();
auto two = new Foo();
writefln(one: %x two: %x, one.classinfo, two.classinfo);
// - - - -
For me this results in two identical memory addresses every time.
Can I rely on this?
Can I design software based on the assumption that
On Jul 2, 2010, at 15:34 , Steven Schveighoffer wrote:
On Fri, 02 Jul 2010 09:32:39 -0400, Steven Schveighoffer
schvei...@yahoo.com wrote:
On Fri, 02 Jul 2010 09:24:20 -0400, Heywood Floyd soul...@gmail.com wrote:
Good day!
Consider
// - - - -
class Foo{}
auto one = new Foo
Hello and Good morning!
I'm trying to use receiveTimeout:
//
import std.stdio,
std.concurrency;
int main(string[] args){
receiveTimeout( 1000L, (int i){writefln(Received: %d,i);}
) ;
return 0;
}
//
:53:25 -0400, Simen kjaeraas simen.kja...@gmail.com
wrote:
Heywood Floyd soul...@gmail.com wrote:
ops = ops[1 .. $]; // === line 335
Well, this looks like a bug to me. Should be
Ops = ops[1 .. $];
Ops is a type, isn't it? Don't you need a variable there?
I agree it's a bug
Thanks!
I will!
/heywood
PS. I like D.
On Jun 29, 2010, at 19:37 , Steven Schveighoffer wrote:
On Tue, 29 Jun 2010 13:05:50 -0400, Heywood Floyd soul...@gmail.com wrote:
Ok, thanks!
How does the chain of command/responsibility work here?
Should I file this to bugzilla
30 matches
Mail list logo