How do formally you call the 'in' operator?

2011-09-24 Thread Andrej Mitrovic
Information about overloading opIn and opIn_r is missing from the docs, so I'm writing that section. But I don't know what is the formal name of this operator so I can put it in the title. Maybe I should just name the title "Overloading the In Operator"?

Re: allSatisfy could use some constraints

2011-09-22 Thread Andrej Mitrovic
On 9/23/11, Jonathan M Davis wrote: > Though given that allSatisfy!(isNumeric, int, short) will work with > std.traits.isNumeric and not std.string.isNumeric, I suspect that a template > constraint could be added which would fix the problem simply by checking > whether the compilation succeeds or

allSatisfy could use some constraints

2011-09-22 Thread Andrej Mitrovic
import std.string; import std.traits; import std.typetuple; void main() { if (allSatisfy!(isNumeric, int, short)) { } } D:\DMD\dmd2\windows\bin\..\..\src\phobos\std\typetuple.d(576): Error: template instance F is not a template declaration, it is a overloadset This took a good while

Templated ctors can't call each other?

2011-09-22 Thread Andrej Mitrovic
import std.typetuple; import std.traits; struct Foo { this(T1, T2)(T1 x, T2 y) if (allSatisfy!(isIntegral, T1, T2)) { this.x = x; this.y = y; } this(P)(P point) // ..constraints needed of course { this(point.x, point.y); } int x, y; } struct

Re: Issuing compile-time warnings with line numbers?

2011-09-21 Thread Andrej Mitrovic
On 9/21/11, Jacob Carlborg wrote: > Have a look at: http://d-programming-language.org/templates-revisited.html Right, but as I've said conv.to works at compile-time so that's unnecessary. Maybe adding a note there about this would be nice, so people don't spend time reimplementing common compile-

Re: Issuing compile-time warnings with line numbers?

2011-09-20 Thread Andrej Mitrovic
On 9/21/11, Adam D. Ruppe wrote: > I'd suggest having a version(warnings_suck) { static assert(0); } > so people who want more info can just stick a -version= on the build > and get the compiler's help. Yeah that was already planned, no worries. :)

Re: Issuing compile-time warnings with line numbers?

2011-09-20 Thread Andrej Mitrovic
Ah, you're right. It should have been a compile-time argument, conv.to actually works in CTFE: import std.conv; struct Bar { } struct Foo { this(int line = __LINE__)(Bar bar) { pragma(msg, "Warning: Constructing Foo with Bar incurs precision loss. Line: " ~ to!string(line)); } }

Issuing compile-time warnings with line numbers?

2011-09-20 Thread Andrej Mitrovic
Won't compile for obvious reasons: struct Bar { } struct Foo { this(Bar bar, int line = __LINE__) { pragma(msg, "Warning: Constructing Foo with Bar incurs precision loss. Line: " ~ line); } } void main() { auto foo = Foo(Bar()); } That's just an example, but I want to iss

Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Andrej Mitrovic
On 9/20/11, Jonathan M Davis wrote: > We specifically avoid having aliases in Phobos simply for having alternate > function names. Aliases need to actually be useful, or they shouldn't be > there. And function names have to be useful to library users. walkLength is an awful name for something tha

Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Andrej Mitrovic
One other thing, count can only take an array which seems too restrictive since walkLength can take any range at all. So maybe count should be just an alias to walkLength or it should possibly be removed (I'm against fully removing it because I already use it in code and I think the name does make

Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Andrej Mitrovic
On 9/20/11, Jonathan M Davis wrote: > Or std.range.walkLength. I don't know why we really have std.utf.count. I > just > calls walkLength anyway. I suspect that it's a function that predates > walkLength and was made to use walkLength after walkLength was introduced. > But > it's kind of pointless

Re: toUTFz and WinAPI GetTextExtentPoint32W

2011-09-20 Thread Andrej Mitrovic
Don't use length, use std.utf.count, ala: import std.utf; alias toUTFz!(const(wchar)*, string) toUTF16z; GetTextExtentPoint32W(str.toUTF16z, std.utf.count(str), s); I like to keep that alias for my code since I was already using it beforehand. I'm pretty sure (ok maybe 80% sure) that GetTextExt

with() statement doesn't want to work with property functions

2011-09-19 Thread Andrej Mitrovic
struct Bar { int x; } struct Foo { Bar _bar; Bar bar() { return _bar; } } void main() { Foo foo; with (foo.bar) { } } Error: foo.bar() is not an lvalue I've made a getter because I want to control how _bar is manipulated. I've lost the ability to use the w

Re: Is it possible to check if a type is an instance of a template?

2011-09-15 Thread Andrej Mitrovic
On 9/15/11, Jonathan M Davis wrote: > Every template instantiation is a new set of code with _zero_ assocation > with > any other template instantation. Yeah, I know. But I don't think this has to be set in stone. Having some specific compile-time type information about a template instance would

Re: Is it possible to check if a type is an instance of a template?

2011-09-15 Thread Andrej Mitrovic
On 9/15/11, Timon Gehr wrote: > template bar(T : Foo!S,S){ } Yeah, that should do it too. Thanks.

Re: Is it possible to check if a type is an instance of a template?

2011-09-15 Thread Andrej Mitrovic
Cool, that works, thanks. Is this in Phobos by any chance? Otherwise I'll just use a more flexible version of that.

Is it possible to check if a type is an instance of a template?

2011-09-15 Thread Andrej Mitrovic
I can do this: struct Foo(T) { } template bar(T : Foo!int) { } I can check if T is a specific instantiation of Foo. But I want to check whether T is *any* instantiation of Foo. Is this possible to do? Otherwise I'm currently having to hardcode via: template bar(T) if (isOneOf!(T, Foo!int, Foo!d

Why can't templates with default arguments be instantiated without the bang syntax?

2011-09-15 Thread Andrej Mitrovic
struct Foo(T = int) {} void main() { Foo foo; // fail Foo!() bar; // ok } It would be very convenient to be able to default to one type like this. For example, in CairoD there's a Point structure which takes doubles as its storage type, and then there's PointInt that takes ints. The re

Re: How do I create a module-local immutable class object?

2011-09-10 Thread Andrej Mitrovic
foo\bar.d: module foo.bar; private class Foo {} main.d: import foo.bar : Foo; void main() { auto foo = new Foo(); } This should be a compile error, no?

Re: How do I create a module-local immutable class object?

2011-09-10 Thread Andrej Mitrovic
On 9/10/11, Jonathan M Davis wrote: > Personally, I think that marking a class with an attribute should only apply > to the class and _nothing_ in it. Agreed. But this doesn't seem to work currently unless I'm doing something wrong..

Re: How do I create a module-local immutable class object?

2011-09-10 Thread Andrej Mitrovic
On 9/10/11, bearophile wrote: > Andrej Mitrovic Wrote: > >> Wait a minute, I've just realized private on a class definition has no >> effect. Why is that? > > Try to import that class from another module... It doesn't stop imports, that's what I'm sa

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
Ok so this is much more involved than I thought. I need to re-read parts of TDPL again. Sorry for the excessive noise. :p

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
For crying out loud, shared fails too: class Foo { shared this() { value = true; } @property bool value() { return true; } @property void value(bool value) { } } void main() { auto foo1 = new Foo; auto val1 = foo1.value; // fail }

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
On 9/9/11, Jonathan M Davis wrote: > But make the constructor shared. Otherwise, it gets initialized once per > thread in spite of the fact that immutable is implicitly shared. Good call!

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
So much for that idea, immutable breaks property functions. Take a look: class Foo { this() { value = true; } @property bool value() { return true; } @property void value(bool value) { } } void main() { auto foo1 = new Foo; auto val1 = foo1.value; auto fo

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
On 9/9/11, bearophile wrote: > > private class Foo {} > immutable Foo foo1; > > static this() { > foo1 = new immutable(Foo); > } Oh right, that's the syntax. Thanks!

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
Wait a minute, I've just realized private on a class definition has no effect. Why is that?

Re: How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
Ok it seems using const works, so I can use that instead. Still I'm wondering why I can't initialize foo inside a module ctor.

How do I create a module-local immutable class object?

2011-09-09 Thread Andrej Mitrovic
I need to have an object which is initialized only once, so I thought I could use immutable for that. But I can't do this: private class Foo {} immutable Foo foo; static this() { foo = new Foo; } void main() {} And I can't new the object when it's declared. Even if CTFE could new objects, i

Re: package access specifier not usable within a class

2011-09-08 Thread Andrej Mitrovic
Thanks. I'll refactor my code to eliminate the need for package in this case. I was going to use it as a quick workaround anyway. :)

package access specifier not usable within a class

2011-09-08 Thread Andrej Mitrovic
abstract class Foo { package void test(); } class Bar : Foo { override package void test() { } } function test.Bar.test cannot override a non-virtual function TDPL says package can only be used at class-level (i.e. package class Bar : Foo), outside classes or inside a struct. I want to

Re: How would I retrieve the stdout error message of a system/shell command?

2011-09-08 Thread Andrej Mitrovic
On 9/8/11, Steven Schveighoffer wrote: > This is the plan for the revamped version of std.process, which is held up > waiting for DMC changes. That's good news, thanks. I'll try the various pipe/redirect methods soon.

How would I retrieve the stdout error message of a system/shell command?

2011-09-08 Thread Andrej Mitrovic
E.g.: import std.process; void main() { auto res = shell("dmd bla.d"); } where bla.d doesn't exist. This will throw an exception, but even if I caught the exception I will still loose the error message. Is there any way I could grab the error message? In this case it would be: "std.exceptio

Re: Doesn't std.signal completely miss the point?

2011-09-06 Thread Andrej Mitrovic
On 9/5/11, Johannes Pfau wrote: > You're talking about phobos std.signals, not my implementation, right? Yes. On 9/5/11, Johannes Pfau wrote: > However, I think it's useless as long as it can't be used by multiple > threads. But when I wanted to add 'shared' support to it, I always hit > a dead

Re: clear bug?

2011-09-05 Thread Andrej Mitrovic
On 9/6/11, Jonathan M Davis wrote: > Why would you > ever try and use an object that had been cleared? TDPL, that's why. Things might have changed but how would someone new to D know that?

Re: Doesn't std.signal completely miss the point?

2011-09-05 Thread Andrej Mitrovic
On 9/5/11, Johannes Pfau wrote: > I started a std.signal rewrite ~1 year ago: This is what I came up > with: > http://dl.dropbox.com/u/24218791/d/src/signals.html > https://gist.github.com/1194497 This actually works great for me since it supports lambdas, I've tried it and it works. I'll put my

Re: Doesn't std.signal completely miss the point?

2011-09-05 Thread Andrej Mitrovic
Well it seems I can't use this with freeform delegates that are not class fields. This could definitely use some improvement.

Re: Any WinAPI experts here?

2011-09-05 Thread Andrej Mitrovic
Thanks, Vladimir. :) I'm trying to use a minimal subset of the API (ironically, to avoid winapi bugs) for experimenting with Cairo. It's nice having the boilerplate of features already implemented such as clipped drawing and moving windows relative to their parent instead of relative to the screen

Any WinAPI experts here?

2011-09-05 Thread Andrej Mitrovic
This is breaking my neck right now. I have two separate windows, window #2 hides and then shows window #1 whenever it detects the mouse has moved in window #2. So, if the mouse stops moving, it should stop doing that. But instead what I get is an infinite loop. Somehow, the hiding and showing of w

Re: Doesn't std.signal completely miss the point?

2011-09-05 Thread Andrej Mitrovic
I sure hope that code is well tested though. Does anyone know why calloc/realloc are used inside of connect() instead of letting the GC do its thing?

Re: Doesn't std.signal completely miss the point?

2011-09-05 Thread Andrej Mitrovic
On 9/5/11, Cal wrote: > You can have multiple signals per class by naming the mixins: Seems like you're right. I completely missed this in the docs. I think I could make a pull to add another example of multiple signals, I didn't know they were supported.

integer cast in object_.d

2011-09-04 Thread Andrej Mitrovic
I'm looking at compare() in class TypeInfo_Array and it's defined as: override int compare(in void* p1, in void* p2) { void[] a1 = *cast(void[]*)p1; void[] a2 = *cast(void[]*)p2; size_t sz = value.tsize(); size_t len = a1.length; if (a2.length < len) len = a2.length;

Doesn't std.signal completely miss the point?

2011-09-04 Thread Andrej Mitrovic
>From what I can tell std.signal is designed around the idea that an entire class acts as a signal emitter, without the ability to write multiple signals within one class and making arbitrary connections between signals and slots. If you actually read the full paper it links to: http://www.elpauer

Re: Copying a variable state in a delegate literal definition

2011-09-02 Thread Andrej Mitrovic
On 9/3/11, Andrej Mitrovic wrote: > On 9/3/11, Timon Gehr wrote: >> What happens if you declare the function final? > > Doesn't help. But it has to be virtual as every object needs to have > it's own set of delegates. Erm, sorry that reasoning was wrong. The fu

Re: Copying a variable state in a delegate literal definition

2011-09-02 Thread Andrej Mitrovic
On 9/3/11, Timon Gehr wrote: > What happens if you declare the function final? Doesn't help. But it has to be virtual as every object needs to have it's own set of delegates. And wow, it seems to be random as well. If I do this: @property void connect(Signal signal = Signal.MouseClick)(void

About static variables

2011-09-02 Thread Andrej Mitrovic
There's no question here but just an observation. I've recently had this sort of bug: class Foo { void test() { static size_t count; // .. count++; } } void main() { auto foo1 = new Foo; foo1.test(); auto foo2 = new Foo; foo2.test(); // affects the same

Re: Copying a variable state in a delegate literal definition

2011-09-02 Thread Andrej Mitrovic
On 9/2/11, Steven Schveighoffer wrote: > Am I missing something, or is it this simple? > > void appendMenuButton() > { > static size_t menuIndex; > auto frameIndex = menuIndex++; > button.connect!(Signal.MouseClick) = { this.showMenu(frameIndex); }; > } > > -Steve > Actually It *is* t

Re: Copying a variable state in a delegate literal definition

2011-09-02 Thread Andrej Mitrovic
Damn it looks like I've ran into some template bug as well. With this: @property void connect(Signal signal = Signal.MouseClick)(void delegate() dg) { clickHandlers ~= dg; } and a call like this: item.connect = { this.showMenu(0); }; this crashes with an access violation. But

Copying a variable state in a delegate literal definition

2011-09-02 Thread Andrej Mitrovic
So I have this code right here (semi-pseudocode) inside a "MenuBar" widget: void showMenu(index menuIndex) { } void appendMenuButton() { static size_t menuIndex; // create menu button, and then: button.connect!(Signal.MouseClick) = { this.showMenu(menuIndex); }; menuIndex++; } but

Re: Reduce help..

2011-09-02 Thread Andrej Mitrovic
Thanks guys!

Reduce help..

2011-09-02 Thread Andrej Mitrovic
string[2][] results; results ~= ["foo", ""]; results ~= ["foobar", ""]; size_t len; foreach (res; results) { len = max(len, res[0].length); } That gives me '6'. I want to convert this to functional-style code with reduce. I've tried: len = reduce!(max!"a[0].length")(results); That's not it.

Re: isDir won't throw FileException with dirEntries

2011-08-30 Thread Andrej Mitrovic
This is probably relevant to: http://d.puremagic.com/issues/show_bug.cgi?id=6329 http://d.puremagic.com/issues/show_bug.cgi?id=6308 But that is all still broken from what I can tell. It used to work fine in 2.053.

Re: How do I pass multidimensional static arrays to functions expecting dynamic arrays?

2011-08-29 Thread Andrej Mitrovic
Hey btw, do you think we could use this in Phobos? template BaseElementType(R) { static if (isArray!(ElementType!R)) alias BaseElementType!(ElementType!R) BaseElementType; else static if (is(typeof({return R.init.front();}()) T)) alias T BaseElementType; else al

Re: How do I pass multidimensional static arrays to functions expecting dynamic arrays?

2011-08-29 Thread Andrej Mitrovic
Right, but I was just trying to temporarily avoid GC allocation so I've used a static array instead of a dynamic ones. Also, I don't know of another term that is used to describe a int[][] array, other than multidimensional. Anyway this works fine for me (int wasn't a requirement in this case): v

How do I pass multidimensional static arrays to functions expecting dynamic arrays?

2011-08-29 Thread Andrej Mitrovic
Take a look: void main() { int[2] single; // foo(single); // no foo(single[]); // int[2][] slice, ok int[2][2] multi; // bar(multi); // int[2][2] no // bar(multi[]); // int[2][] slice, no // bar(multi[][]); // int[2][] slice, no } void foo(int[] value) {} voi

Re: String multiplication

2011-08-27 Thread Andrej Mitrovic
I've always used array.replicate for this. std.range.replicate seems to be scheduled for deprecation, it only aliases itself to repeat(): /// Equivalent to $(D repeat(value, n)). Scheduled for deprecation. Take!(Repeat!T) replicate(T)(T value, size_t n) { return repeat(value, n); }

Re: Reading by character and by line from stdin

2011-08-26 Thread Andrej Mitrovic
to!(T[]) is awesome. I've ported this little C thingy: sscanf(oneline, "%f %f %f %f %f", &x, &y, &z, &u, &v); to this: to!(float[])(line.split); Can't get easier than that!

Re: Multiple subtyping

2011-08-26 Thread Andrej Mitrovic
with doesn't work properly with alias this, I've already filed this in bugzilla though.

Re: Why no (auto foo = bar) in while loops?

2011-08-24 Thread Andrej Mitrovic
Req'd: http://d.puremagic.com/issues/show_bug.cgi?id=6550

Re: Why no (auto foo = bar) in while loops?

2011-08-24 Thread Andrej Mitrovic
On 8/24/11, Timon Gehr wrote: > it is usually faster > in debug mode Huh.. How come?

Re: Why no (auto foo = bar) in while loops?

2011-08-24 Thread Andrej Mitrovic
P.S. I'm aware I'm loosing the reference to the first foo object but this is just demonstration code.

Why no (auto foo = bar) in while loops?

2011-08-24 Thread Andrej Mitrovic
Here's some code that iterates through "parents" of some class object until it finds an object with no parent (where parent is null): import std.stdio; class Foo { Foo parent; int state; this (int state) { this.state = state; } } void main() { auto foo = new Foo(0);

How do I simulate variadic parameters for template (range) functions?

2011-08-24 Thread Andrej Mitrovic
Here's what I can do with a variadic function: void main() { int[] a = [ 1, 2, 4, 7, 7, 2, 4, 7, 3, 5]; process(a[a.countUntil(7) .. $]); process(1); } void process(int[] vals...) { foreach (val; vals) { } } Very simple, pass one or multiple arguments. But then I thought

What's the technical reason that class ctors aren't virtual?

2011-08-24 Thread Andrej Mitrovic
class Foo { this(int x, int y) { } } class Bar : Foo { } Bar has to define its own ctor even if it only forwards the call to the super() ctor, e.g.: class Bar : Foo { this(int x, int y) { super(x, y); } } But I'm curious why this works this way. If I have a large inheritance tree of cla

Re: reading in text files

2011-08-24 Thread Andrej Mitrovic
Maybe ./readingHamlet < hamlet.txt

Re: help understanding import libraries

2011-08-22 Thread Andrej Mitrovic
Usually this calls for a a build system, e.g. a build script or something, that you use for specific projects which require GtkD or something else. For example (I'm assuming you're on win32), you could have this batch file (build.bat): http://codepad.org/vt0TskPy And you could invoke it via "buil

Re: help understanding import libraries

2011-08-22 Thread Andrej Mitrovic
You are explicitly linking to GtkD.lib and win32.lib, that's what's causing the increase in size.

An issue with templates with non-existant symbols

2011-08-21 Thread Andrej Mitrovic
void foo(T)(T t) if(is(X == struct)) { } void main() { foo(4); } This prints out: test.d(9): Error: template test.foo(T) if (is(X == struct)) does not match any function template declaration test.d(9): Error: template test.foo(T) if (is(X == struct)) cannot deduce template function from argu

Re: help understanding import libraries

2011-08-20 Thread Andrej Mitrovic
On 8/20/11, maarten van damme wrote: > Now only how come that > "dmd hello.d" results in a 1.70 mb application whereas > "dmd -c hello.d" && "dmd hello.obj phobos.lib" results in a 144 kb app In both cases on my system it produces a 464Kb app. You must be doing something wrong. :)

Re: help understanding import libraries

2011-08-19 Thread Andrej Mitrovic
You don't need the damn -L flag, just pass the .lib file directly and DMD will pass it to the linker.

Re: assertion failure in std.range.iota

2011-08-19 Thread Andrej Mitrovic
http://d.puremagic.com/issues/show_bug.cgi?id=6531

assertion failure in std.range.iota

2011-08-18 Thread Andrej Mitrovic
import std.range; import std.stdio; void main() { auto r1 = iota(0.0, 4.0, 0.03); // ok auto r2 = iota(0.0, 3.0, 0.03); // core.exception.AssertError@std.range(4001): Assertion failure } I want a range in steps of 0.03, beginning at 0.0 and ending at the closest point to 3.0. Line 4001

Re: std.format add dash separators to large numbers

2011-08-17 Thread Andrej Mitrovic
Okay but I wasn't really thinking about locales, underscores between digits is a D syntax feature and it makes numbers more readable.

Re: std.format add dash separators to large numbers

2011-08-16 Thread Andrej Mitrovic
I meant underscores not dashes.

std.format add dash separators to large numbers

2011-08-16 Thread Andrej Mitrovic
Can format do something like this yet? auto str = format("%s", 100); assert(str == "1_000_000"); %s would have to be replaced with something else, obviously.

Re: format a string like sprintf?

2011-08-16 Thread Andrej Mitrovic
Is this what you're after? import std.string; void main() { auto str = format("%.4s", 4); assert(str == "0004"); }

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
Thanks!

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
Thanks, but I'll wait for the next release before I use it. In the meantime I guess I'll use this monster: array(until!(not!isWhite)(line)).length

Re: count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
That doesn't work: import std.algorithm; import std.stdio; import std.functional; import std.uni; void main() { auto line = " foo"; writeln(countUntil!(not!isWhite)(line)); } test.d(9): Error: template std.algorithm.countUntil(alias pred = "a == b",R1,R2) if (is(typeof(startsWith!(pred)

count until predicate returns false

2011-08-15 Thread Andrej Mitrovic
This will print the count of whitespace chars in a line: writeln(count!isWhite(line)); What I need is the count of whitspace chars until the first non-whitespace char is found, essentially I need a "countWhile" template: writeln(countWhile!isWhite(line)); Can I do this with existing templates s

Re: Split by length?

2011-08-15 Thread Andrej Mitrovic
On 8/15/11, Steven Schveighoffer wrote: > Ouch! It's not that big of an ouch actually: http://codepad.org/m1zKlP0e

Re: Split by length?

2011-08-14 Thread Andrej Mitrovic
Strings are an exception again, that code won't work for strings. Damn..

Re: Split by length?

2011-08-14 Thread Andrej Mitrovic
Simplified (and slow) implementation: T[] splitLength(T)(T arr, size_t count) if (isArray!T) { T[] result; while (arr.length) { result ~= arr.take(count); arr.popFrontN(count); } return result; }

Split by length?

2011-08-14 Thread Andrej Mitrovic
Is there something in Phobos with which I could do: auto arr = [1, 2, 3, 4, 5, 6]; int[][] newarr = arr.splitLength(2); assert(newarr.length == 3); ?

Re: D with gmp via swig

2011-08-14 Thread Andrej Mitrovic
This seems ancient, but maybe it could help: http://www.dsource.org/projects/bindings/browser/trunk/gmp

Re: const main args?

2011-08-13 Thread Andrej Mitrovic
I don't recall the last time `void main()` was a bottleneck in my apps. :p Maybe it would actually make a big difference in CGI apps though.

Re: const main args?

2011-08-12 Thread Andrej Mitrovic
On 8/13/11, bearophile wrote: > Andrej Mitrovic: > >> void main(string[] args) >> { >> args.popFront; // get rid of name >> >> foreach (arg; args) >> { >> } >> } > > If I see code like that I probably rewrite it lik

Re: const main args?

2011-08-12 Thread Andrej Mitrovic
That's pretty stupid, of course you want to modify the arguments. Classic example: void main(string[] args) { args.popFront; // get rid of name foreach (arg; args) { } }

Re: htod

2011-08-12 Thread Andrej Mitrovic
On 8/12/11, Jason King wrote: > I'm attempting to convert a c header to d using htod. If this is not > current best practice please point me in another direction. > > C:\dir>htod -I c:\d\dm\include ocilib.h > Fatal error: unable to open input file 'stdlib.h' You have an extra space there. Use:

Re: Tuple [] operator

2011-08-08 Thread Andrej Mitrovic
On 8/8/11, Steven Schveighoffer wrote: > > I like this idea. I think it belongs in phobos somewhere, if not already. > > -Steve > Allow me to +1 on that, I've had a need for this (but now I can't remember why, hah!).

Re: NaCl stable ABI

2011-08-05 Thread Andrej Mitrovic
On 8/5/11, Kagamin wrote: > Andrej Mitrovic Wrote: > >> Don't forget having to minimize all the time >> to chat to someone on MSN while playing a game. So there are some >> benefits to having a browser based interface for a game, imo. > > Older games work even b

Interface to C page has been screwed up a little

2011-08-05 Thread Andrej Mitrovic
http://d-programming-language.org/interfaceToC.html Originally the table just showed D and C types, the 32/64 bit columns weren't there. On my last commit I had this: D type | C type c_long (in core.stdc.config) | long c_ulong (in core.stdc.config) | unsigned long long | long long ulong | unsign

Re: Minimum value in a range

2011-08-04 Thread Andrej Mitrovic
Cool. I've submitted a bug report for this, but maybe it's a duplicate.

Re: NaCl stable ABI

2011-08-04 Thread Andrej Mitrovic
I thought MSN had a pretty large network of users. IIRC arstechnica recently had an article comparing the userbase of msn and skype.

Re: NaCl stable ABI

2011-08-04 Thread Andrej Mitrovic
I think we're misunderstanding each other. I'm not saying move the game to the browser, just the part of the game where you can browse the servers for that game. That's the part of QLive that I liked, I don't care if the game actually runs in the browser or not. I don't know what this NaCI busines

Re: Weird timing issue with Thread.sleep

2011-08-04 Thread Andrej Mitrovic
On 8/4/11, Jacob Carlborg wrote: > I would say that the correct solution is to rewrite the examples to work > with any CPU speed. > > -- > /Jacob Carlborg > That's what I did. The framerate isn't clamped, and the threads don't sleep, there's no spinning going on, I've replaced all of that with ti

Re: NaCl stable ABI

2011-08-04 Thread Andrej Mitrovic
On 8/4/11, Nick Sabalausky wrote: > There is nothing you've mentioned that can't be (better) fixed without > cramming everything into a browser. Where would you cram it then? Put MSN inside the game itself?

Re: NaCl stable ABI

2011-08-03 Thread Andrej Mitrovic
I liked QLive before they forced 30 second commercials on server joins for non-subscribers. :( It was cool being able to casually browse to other tabs, then going back to qlive and finding a game. UT for example had an integrated IRC client, but people preferred using mIRC and having a ut://123.1

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
On 8/3/11, Andrej Mitrovic wrote: > if ((t - t_prev).usecs > (1_000_000.0 / FPS)) > { > t_prev = t; > DrawGLScene(); > } > > SwapBuffers(hDC); My mistake here, SwapBuffers belongs inside the if body, there's an unrelated keyboard bug t

Re: Weird timing issue with Thread.sleep

2011-08-03 Thread Andrej Mitrovic
On 8/3/11, Jacob Carlborg wrote: > Why would you want to slow down framerate? Because the examples were written in the 90s and CPUs and graphic cards are so fast these days that the old code runs at an enormous framerate. Anyway, after a bit of googling I've found a solution: enum float FPS = 6

<    4   5   6   7   8   9   10   11   12   13   >