On 11/16/2011 08:26 PM, Timon Gehr wrote:
auto a = [new Foo, new Bar, new Qux]; // I want that to work.
(It currently does, if that was unclear)
On 11/16/2011 09:00 PM, Steven Schveighoffer wrote:
On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/16/2011 02:22 PM, Steven Schveighoffer wrote:
On Tue, 15 Nov 2011 13:45:02 -0500, Timon Gehr timon.g...@gmx.ch
wrote:
Note that this is an explicit allocation
On 11/16/2011 10:56 PM, Steven Schveighoffer wrote:
On Wed, 16 Nov 2011 16:16:48 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/16/2011 09:00 PM, Steven Schveighoffer wrote:
On Wed, 16 Nov 2011 14:26:57 -0500, Timon Gehr timon.g...@gmx.ch
wrote:
On 11/16/2011 02:22 PM, Steven
On 11/16/2011 11:39 PM, Timon Gehr wrote:
I think this is a better solution:
void foo2(T: ParameterTypeTuple!foo[0])(T t){foo(t);}
Then it is just a matter of applying proper value range propagation for
IFTY:
void bar(T: short)(T t){...}
void main(){
bar(1); // ok
}
BTW, this already
On 11/15/2011 04:53 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 16:28:52 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/14/2011 09:39 PM, Steven Schveighoffer wrote:
Look at the code generated for enum a = [1, 2, 3]. using a is replaced
with a call to _d_arrayliteral
On 11/14/2011 01:02 AM, bearophile wrote:
Jonathan M Davis:
import std.algorithm;
void main() {
enum a = [3, 1, 2];
enum s = sort(a);
assert(equal(a, [3, 1, 2]));
assert(equal(s, [1, 2, 3]));
}
It's not a bug. Those an manifest constants. They're copy-pasted into whatever
On 11/14/2011 09:27 AM, Timon Gehr wrote:
On 11/14/2011 01:02 AM, bearophile wrote:
Jonathan M Davis:
import std.algorithm;
void main() {
enum a = [3, 1, 2];
enum s = sort(a);
assert(equal(a, [3, 1, 2]));
assert(equal(s, [1, 2, 3]));
}
It's not a bug. Those an manifest constants. They're
On 11/14/2011 10:20 AM, so wrote:
On Mon, 14 Nov 2011 10:27:21 +0200, Timon Gehr timon.g...@gmx.ch wrote:
It is the right design. Why should enum imply const or immutable? (or
inout, for that matter). They are completely orthogonal.
enum Enum{
opt1,
opt2,
}
void main(){
auto moo = Enum.opt1
On 11/14/2011 02:13 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 03:27:21 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/14/2011 01:02 AM, bearophile wrote:
Jonathan M Davis:
import std.algorithm;
void main() {
enum a = [3, 1, 2];
enum s = sort(a);
assert(equal(a, [3, 1, 2
On 11/14/2011 08:37 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 13:37:18 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/14/2011 02:13 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 03:27:21 -0500, Timon Gehr timon.g...@gmx.ch
wrote:
On 11/14/2011 01:02 AM, bearophile wrote
On 11/14/2011 09:39 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 14:59:50 -0500, Timon Gehr timon.g...@gmx.ch wrote:
On 11/14/2011 08:37 PM, Steven Schveighoffer wrote:
On Mon, 14 Nov 2011 13:37:18 -0500, Timon Gehr timon.g...@gmx.ch
wrote:
On 11/14/2011 02:13 PM, Steven
On 11/14/2011 11:25 PM, Johannes Totz wrote:
Hi!
I'm having trouble with named typed enums.
This works (unnamed):
enum : string
{
a = a,
b = b
}
int main(string[] argv)
{
writeln(a);
return 0;
}
But this does not:
enum X : string
{
a = a, // Error: Integer constan
t expression expected
On 11/11/2011 11:04 AM, Tobias Pankrath wrote:
I've written a Filter-Template, which implements the well-known function for
template arguments:
-
template Filter(alias SPred, E...)
{
static if(E.length == 0) {
alias TypeTuple!() Filter;
}
else
{
static
On 11/10/2011 06:24 PM, Simen Kjærås wrote:
I'm creating a Checked!T struct for integral values. The version
attached works
for the most part, but some parts confuse me, namely that the following
operations do not set the overflow flag:
uint.max + 1
ulong.max + 1
int.min - 1
uint.min - 1
On 11/10/2011 10:06 PM, Ruslan Mullakhmetov wrote:
Hi folks,
I need to create thread and pass to it array of objects wich will no
longer use in main thread.
The problem is that spawn only accepts immutables and i have no idea how
to tell him that i transfer full ownership of the data to child
On 11/10/2011 11:23 PM, Ali Çehreli wrote:
On 11/10/2011 01:57 PM, Ruslan Mullakhmetov wrote:
On 2011-11-11 01:21:09 +0400, Ali Çehreli said:
class Foo
{
}
void worker( shared(Foo)[] data )
{
//...
}
void main()
{
auto data = new shared(Foo)[10];
spawn( worker, data );
}
Thanks. I tried
On 11/10/2011 10:45 PM, Fabian wrote:
oh ... I see. Thank you ;)
++i is unidiomatic, and if the result is unused it means the same thing
as i++. So, I'd actually go with i++. The only reason why one would use
++i is because it is less efficient for C++ iterators, but D does not
have that
On 11/09/2011 02:16 PM, bearophile wrote:
This little D2 program, a pure function contains static variables initialized
with calls to not pure functions:
int foo() {
return 1;
}
pure int bar() {
enum int x1 = foo();
static immutable int x2 = foo();
return x1;
}
void main()
On 11/07/2011 12:26 AM, Jesse Phillips wrote:
I'm sure if this was changed there would be other interesting behavior,
such as arrays being consumed. And suggestions other than
for(S s; !s.empty, s.popFront())...
Example:
void main() {
S s;
foreach(i; s) {
On 11/05/2011 03:23 PM, bearophile wrote:
Tobias Pankrath:
I do like it, just it would be nice to have an alternative in phobos, iff there is
no other way I am not aware of.
Type tuples (that are allowed to contain more than just types) aren't Phobos
constructs, they are built-in in the
On 11/04/2011 05:28 PM, Justin Whear wrote:
I just use a templated struct.
struct GroupedTypes(T...)
{
alias T Types;
}
Then, if you need to something special with groups, you can create an
override:
//overriding previous Test template...
template Test(T: GroupedTypes!(S), S...)
{
}
On 11/03/2011 06:13 PM, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 12:35:36 -0400, Dmitry Olshansky
dmitry.o...@gmail.com wrote:
On 03.11.2011 19:34, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 10:02:22 -0400, Tobias Pankrath
tob...@pankrath.net wrote:
Dmitry Olshansky wrote:
And
On 11/03/2011 07:15 PM, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 13:47:28 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 11/03/2011 06:13 PM, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 12:35:36 -0400, Dmitry Olshansky
dmitry.o...@gmail.com wrote:
On 03.11.2011 19:34, Steven
On 11/03/2011 09:46 PM, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 14:50:31 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 11/03/2011 07:15 PM, Steven Schveighoffer wrote:
On Thu, 03 Nov 2011 13:47:28 -0400, Timon Gehr timon.g...@gmx.ch
wrote:
On 11/03/2011 06:13 PM, Steven
On 10/26/2011 07:38 PM, Ary Manzana wrote:
On 10/26/11 1:28 PM, Jonathan M Davis wrote:
On Wednesday, October 26, 2011 09:00 Dominic Jones wrote:
Also an plain array is a good stack. :)
I'd rather not use a plain array because (I assume) that when I push
or pop using arrays, a swap array is
On 10/25/2011 08:38 PM, Graham Fawcett wrote:
On Tue, 25 Oct 2011 13:11:20 -0400, bearophile wrote:
Dmitry Olshansky:
No, it's not a bug. It's the same as c++ STL remove - it operates on
range but not on container. To shrink container, update it's length.
Thank you for your answer, I
On 10/22/2011 09:28 AM, Nick Sabalausky wrote:
Is this a compiler bug?
struct Foo
{
int a;
}
Foo foo;
alias foo.a b;
void main()
{
b = 5; //-- Error
}
dmd test.d
test.d(11): Error: need 'this' to access member a
On 10/22/2011 11:03 PM, Nick Sabalausky wrote:
Timon Gehrtimon.g...@gmx.ch wrote in message
news:j7u9ld$i8t$1...@digitalmars.com...
alias has never worked for instance members, even if they are accessible
at compile time.
Any idea if it's supposed to work?
I do not know. But if it was
On 10/17/2011 08:04 AM, Jonathan M Davis wrote:
On Monday, October 17, 2011 00:29:30 Timon Gehr wrote:
On 10/16/2011 07:31 PM, Jonathan M Davis wrote:
On Sunday, October 16, 2011 19:13:09 Timon Gehr wrote:
I don't agree that 'old' is very difficult to implement. Just evaluate
what is inside
On 10/14/2011 09:43 PM, Jonathan M Davis wrote:
On Friday, October 14, 2011 15:29:17 Jay Norwood wrote:
Jonathan M Davis Wrote:
On Friday, October 14, 2011 11:30:25 Jay Norwood wrote:
Is it possible to overload array operations
Please be more specific. Are you asking whether a struct or
On 10/15/2011 01:12 AM, Jay Norwood wrote:
Jonathan M Davis Wrote:
On Friday, October 14, 2011 15:29:17 Jay Norwood wrote:
Jonathan M Davis Wrote:
On Friday, October 14, 2011 11:30:25 Jay Norwood wrote:
Is it possible to overload array operations
Please be more specific. Are you asking
On 10/13/2011 07:14 PM, Ali Çehreli wrote:
On Thu, 13 Oct 2011 09:18:46 -0700, Jonathan M Davis wrote:
On Thursday, October 13, 2011 05:35:52 bearophile wrote:
Davidson Corry:
Did D2 ever implement the Eiffel old construct?
At the moment there no prestate in D. I agree that prestate is an
On 10/13/2011 08:25 PM, Davidson Corry wrote:
On 10/13/2011 10:57 AM, bearophile wrote:
Jonathan M Davis:
I don't recall him ever saying anything about contract programming in
D being a failure in any way.
He said unittesting has changed the way you write code and has
significantly
On 10/13/2011 01:46 PM, Steven Schveighoffer wrote:
On Thu, 13 Oct 2011 06:57:09 -0400, Cheng Wei riverch...@gmail.com wrote:
== Quote from Steven Schveighoffer (schvei...@yahoo.com)'s article
On Wed, 12 Oct 2011 09:46:57 -0400, Trass3r u...@known.com wrote:
I believe that the primary
On 10/16/2011 07:31 PM, Jonathan M Davis wrote:
On Sunday, October 16, 2011 19:13:09 Timon Gehr wrote:
I don't agree that 'old' is very difficult to implement. Just evaluate
what is inside the 'old' before you enter the in contract, store
somewhere, maybe in hidden local variables, and make
On 10/02/2011 02:44 PM, Philippe Sigaud wrote:
On Sun, Oct 2, 2011 at 04:20, bearophilebearophileh...@lycos.com wrote:
This little program is a reduction of code recently shown around here:
template Spam(T, alias P) { enum Spam = P!T; }
template Foo(T, Preds...) {
enum bool Foo =
On 10/02/2011 08:48 PM, Philippe Sigaud wrote:
On Sun, Oct 2, 2011 at 19:12, Timon Gehrtimon.g...@gmx.ch wrote:
Types are symbols, so just using alias template arguments works.
Hmm, no.
template isSymbol(alias a)
{
enum isSymbol = true;
}
void main()
{
enum a = isSymbol!int;
}
On 10/02/2011 09:47 PM, bearophile wrote:
Sometimes in my code I have to find the first few smaller (or bigger) items of
an array, I don't know how many I will need, but I know in general I will need
only few of them, much less than the whole array.
Turnign the array into an heap is slow if I
On 10/01/2011 07:07 PM, ponce wrote:
Question 1:
assert can throw an AssertError in debug mode.
What happens when I mark as nothrow a function with assertions ?
The compiler accept it but I have a bad feeling about it.
nothrow means that a function won't throw an exception. They can still
On 09/29/2011 01:28 PM, Trass3r wrote:
Am 29.09.2011, 06:51 Uhr, schrieb Cheng Wei riverch...@gmail.com:
extern(C) {
struct ab;
}
ab*[int] map;
void main() {
map.clear();
}
Cannot be compiled. Why?
Thanks.
Just use void* for opaque pointers in D.
Or an empty struct.
struct ab{}
On 09/26/2011 10:55 PM, Christian Köstlin wrote:
Hi,
I have the problem, that I want to always construct a struct with a
parameter. To make this more comfortable (e.g. provide a default
parameter I have a factory function to create this struct).
struct S {
int i;
this(int i_) { i = i_; }
}
S
On 09/22/2011 04:17 AM, alex wrote:
Hi Y'all!! Just as a note, I am new to the news group, but slightly less
new to D =)
Back on topic:
I am unable to get multiple version specifications to work (from the
website)
sometihng like:
version (foo) {
version = bar;
version = baz;
}
version (bar)
On 09/21/2011 02:15 AM, Christophe wrote:
Timon Gehr , dans le message (digitalmars.D.learn:29641), a écrit :
Last point: WalkLength is not optimized for strings.
std.utf.count should be.
This short implementation of count was 3 to 8 times faster than
walkLength is a simple benchmark:
size_t
On 09/21/2011 12:37 PM, Dmitry Olshansky wrote:
On 21.09.2011 4:04, Timon Gehr wrote:
On 09/21/2011 01:57 AM, Christophe wrote:
Jonathan M Davis , dans le message (digitalmars.D.learn:29637), a
écrit :
On Tuesday, September 20, 2011 14:43 Andrej Mitrovic wrote:
On 9/20/11, Jonathan M
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar*, not a wchar[].
I am not familiar with
On 09/20/2011 08:06 PM, Dax wrote:
Hi!
I'm working on a library written in D.
After some tests I have discovered that my library leaks memory, those leaks
are caused by dynamics array that I use in my library.
Does it 'leak'? What is your exact setup, why isn't the GC collecting
that
On 09/20/2011 08:34 PM, Trass3r wrote:
Are you sure that the call requires the string to be null terminated?
I do not know that winapi function, but this might work:
bool test(HDC dc, string str, SIZE* s)
{
auto wstr = to!(wchar[])str;
GetTextExtentPoint32W(dc, wstr.ptr, wstr.length, s);
...
On 09/20/2011 08:24 PM, Timon Gehr wrote:
On 09/20/2011 08:07 PM, Andre wrote:
Am Tue, 20 Sep 2011 19:27:03 +0200 schrieb Trass3r:
bool test(HDC dc, string str, int len, SIZE* s)
{
wchar[] wstr = toUTFz!(wchar*)str;
GetTextExtentPoint32W(dc wstr.ptr, wstr.length, s);
toUTFz returns a wchar
On 09/18/2011 05:14 PM, Andrej Mitrovic wrote:
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
On 09/18/2011 06:55 PM, Ellery Newcomer wrote:
Just came across some old D code that does this:
version(linux){
extern(C):
}
Hundreds of OpenGL decls
in dmd 2.055, the extern(C) is not being applied to the OpenGL decls.
should it?
Yes they should be applied, unless they declare D
On 09/18/2011 08:57 PM, bearophile wrote:
I don't know what is the right design in this case. Intrinsics are useful because they
sometimes give more performance, but normal functions are sometimes more handy because
they allow more flexibility, like taking their address (first class
On 09/18/2011 10:08 PM, %u wrote:
does D compatibility with C restrict D from evolving ?
Binary compatibility as in extern(C) certainly does not. As to
source-level compatibility, the only guarantee that Ds design gives is
that C code will either compile as D code with identical semantics or
On 09/18/2011 10:46 PM, Ellery Newcomer wrote:
On 09/18/2011 01:02 PM, Timon Gehr wrote:
If you are asking, if the D compiler is wrong here: No, it is by design,
you can check with the D grammar.
Nah, just confirming that failure to apply the externs is a bug.
version(linux){
extern(C
On 09/19/2011 03:37 PM, Trass3r wrote:
Change it to the following, and you're golden.
extern(System):
Hundreds of OpenGL decls
That only fixes this particular issue.
I once had the following case that can't be done:
version(V1)
{
extern(System):
}
else
{
extern(C):
}
You could use the C
On 09/19/2011 11:20 PM, bearophile wrote:
A tiny puzzle I've shown on IRC. This is supposed to create an inverted array
of cards, but what does it print instead?
import std.stdio, std.algorithm, std.range;
void main() {
int[52] cards;
copy(iota(cards.length - 1, -1, -1), cards[]);
On 09/20/2011 12:50 AM, Adam Burton wrote:
Simen Kjaeraas wrote:
On Mon, 19 Sep 2011 23:20:47 +0200, bearophilebearophileh...@lycos.com
wrote:
A tiny puzzle I've shown on IRC. This is supposed to create an inverted
array of cards, but what does it print instead?
import std.stdio,
On 09/15/2011 10:24 PM, Andrej Mitrovic wrote:
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
On 09/14/2011 08:52 PM, simendsjo wrote:
Not sure if this is a bug or as intended.
import std.stdio;
void main() {
int i = 1;
switch(i) {
case 0:
writeln(case 0);
goto default; // needed here
default:
writeln(default);
// But always falls through here
aLabel:
writeln(a label);
}
}
This is as
On 09/14/2011 09:11 PM, bearophile wrote:
simendsjo Wrote:
Not sure if this is a bug or as intended.
The semantics of switch is a mess (example: see
http://d.puremagic.com/issues/show_bug.cgi?id=3820 ).
Mixing labels and switch cases seems a good way to create a bigger mess.
I think it is
On 09/14/2011 10:51 PM, bearophile wrote:
Timon Gehr:
I think it is a bit mean to say the whole semantics is a mess,
The original C design is a mess with several traps, and successive things added
in D to the switch have increased the mess, they were designed from very narrow
points
On 09/14/2011 04:12 AM, Timon Gehr wrote:
On 09/14/2011 03:34 AM, hdsh wrote:
this my try
int[] quickSort(int[] arr) {
int[] result = quickSort(filter!(arr arr[0])(arr)) ~ arr[0] ~
quickSort(filter!(arr arr[0])(arr));
}
but it fail to compile
Note that this approach is an inefficient way
On 09/12/2011 04:17 PM, Steven Schveighoffer wrote:
On Mon, 12 Sep 2011 10:10:35 -0400, Simen Kjaeraas
simen.kja...@gmail.com wrote:
On Mon, 12 Sep 2011 00:11:11 +0200, Timon Gehr timon.g...@gmx.ch wrote:
I think the fact that in for AAs returns a pointer is a mistake and
ugly in the first
On 09/12/2011 04:34 PM, Steven Schveighoffer wrote:
On Mon, 12 Sep 2011 10:24:52 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 09/12/2011 04:17 PM, Steven Schveighoffer wrote:
On Mon, 12 Sep 2011 10:10:35 -0400, Simen Kjaeraas
simen.kja...@gmail.com wrote:
On Mon, 12 Sep 2011 00:11:11 +0200
On 09/12/2011 05:16 PM, Steven Schveighoffer wrote:
On Mon, 12 Sep 2011 11:02:20 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 09/12/2011 04:34 PM, Steven Schveighoffer wrote:
On Mon, 12 Sep 2011 10:24:52 -0400, Timon Gehr timon.g...@gmx.ch
wrote:
On 09/12/2011 04:17 PM, Steven
On 09/11/2011 11:12 PM, Jonathan M Davis wrote:
On Sunday, September 11, 2011 14:00:55 Charles Hixson wrote:
On 09/11/2011 01:25 PM, Vladimir Panteleev wrote:
On Sun, 11 Sep 2011 23:02:37 +0300, Charles Hixson
charleshi...@earthlink.net wrote:
I can't figure it out from
On 09/12/2011 12:21 AM, Jonathan M Davis wrote:
On Monday, September 12, 2011 00:11:11 Timon Gehr wrote:
On 09/11/2011 11:12 PM, Jonathan M Davis wrote:
On Sunday, September 11, 2011 14:00:55 Charles Hixson wrote:
On 09/11/2011 01:25 PM, Vladimir Panteleev wrote:
On Sun, 11 Sep 2011 23:02:37
On 09/12/2011 12:28 AM, Charles Hixson wrote:
On 09/11/2011 02:12 PM, Jonathan M Davis wrote:
On Sunday, September 11, 2011 14:00:55 Charles Hixson wrote:
On 09/11/2011 01:25 PM, Vladimir Panteleev wrote:
On Sun, 11 Sep 2011 23:02:37 +0300, Charles Hixson
charleshi...@earthlink.net wrote:
I
On 09/12/2011 02:53 AM, Charles Hixson wrote:
On 09/11/2011 04:07 PM, Timon Gehr wrote:
How do you mean, instantiate it?
container.binaryOp(in)!(something I haven't figured out yet.
Template syntax doesn't make any sense to me yet. I'm just copying
examples and adapting them with a cut
On 09/09/2011 05:19 PM, teo wrote:
Here is an example of what I am after:
struct DATA
{
ubyte D1;
ubyte D2;
ubyte D3;
ubyte D4;
}
void main()
{
ubyte[16] a = [ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x01,
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 ];
auto b =
On 09/09/2011 10:25 PM, teo wrote:
On Fri, 09 Sep 2011 17:43:04 +0200, Timon Gehr wrote:
On 09/09/2011 05:19 PM, teo wrote:
Here is an example of what I am after:
struct DATA
{
ubyte D1;
ubyte D2;
ubyte D3;
ubyte D4;
}
void main()
{
ubyte[16] a = [ 0x01, 0x02, 0x03, 0x04
On 09/09/2011 11:42 PM, Jonathan M Davis wrote:
On Friday, September 09, 2011 17:37:26 bearophile wrote:
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
then.
Christophe wrote:
Justin Whear , dans le message (digitalmars.D.learn:29380), a écrit :
That'll work if you don't mind normal output being mixed with error
messages.
Timon Gehr wrote:
On 09/08/2011 07:26 PM, Justin Whear wrote:
The Posix solution is to use pipes. Basically, you'll want
On 09/07/2011 08:50 PM, Johannes Totz wrote:
On 06/09/2011 12:00, bearophile wrote:
malio:
Okay, thanks bearophile. But I currently doesn't exactly understand
what's the difference between ref and const ref/immutable
ref. If ref is syntactic sugar for pointers only (like your
first example),
On 09/06/2011 01:01 PM, Vladimir Panteleev wrote:
AddressInfo[] getAddressInfo(T...)(string node, string service = null, T
options)
TypeTuple!() emptyTuple;
AddressInfo[] getAddressInfo(T...)(string node, string service = null, T
options=emptyTuple) {}
Error: cannot implicitly convert
On 09/06/2011 11:03 PM, Vladimir Panteleev wrote:
What I'm trying to do:
struct S1 { int f; }
struct S2
{
S1 s1;
alias s1.f g;
}
This doesn't work. The declaration compiles, but attempts to access g
result in:
Error: struct test.S2 'f' is not a member
Error: struct test.S2 member f is not
On 09/05/2011 04:57 AM, Andrej Mitrovic wrote:
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 =
On 09/02/2011 02:45 AM, bearophile wrote:
Timon Gehr:
according to TDPL p53., that fact is defined. (unary minus: -x == ~x+1)
Uh.
Bye,
bearophile
For unsigned integers it is clearly defined:
1000... = 0111... = 1000...
And according to TDPL p53: This manipulation does not raise
On 09/02/2011 07:11 PM, Andrej Mitrovic wrote:
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 =
On 09/02/2011 08:46 PM, Andrej Mitrovic wrote:
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 = {
On 09/03/2011 01:13 AM, Andrej Mitrovic wrote:
On 9/3/11, Timon Gehrtimon.g...@gmx.ch 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.
So if I get you right, you made the templated version
On 09/01/2011 09:34 AM, Damian Ziemba wrote:
Greetings.
I've been playing around with opDispatch and toString methods and I found
strange behavior.
Example:
import std.stdio;
struct Test
{
string opDispatch( string key )()
{
On 09/01/2011 10:23 AM, David Nadlinger wrote:
It might well be that I'm missing something obvious in the emplace()
overload jungle, but what is the reason for std.range.zip to use
std.conv.emplace for assigning the range elements to the »output«
elements instead of just using the assignment
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, which would mean overflow is defined, but I cannot
find the respective part of the
On 09/02/2011 12:09 AM, Damian Ziemba wrote:
On Thu, 01 Sep 2011 13:59:29 +0200, Timon Gehr wrote:
static assert(isInputRange!Test);
static assert(isInputRange!Test2);
toString is not shadowed, but the implementation of writeln assumes that
your types are an InputRange (they provide
On 08/30/2011 03:20 AM, bearophile wrote:
Timon Gehr:
bar(array(map!((int[] a){return a;})(multi[])));
Simpler:
bar( array(map!q{ a[] }(multi[])) );
And buggy. It returns slices of a local stack frame, because static
arrays are value types.
Simpler still when we'll get amap:
bar( amap
On 08/30/2011 01:06 PM, bearophile wrote:
Timon Gehr Wrote:
On 08/30/2011 03:20 AM, bearophile wrote:
Timon Gehr:
bar(array(map!((int[] a){return a;})(multi[])));
Simpler:
bar( array(map!q{ a[] }(multi[])) );
And buggy. It returns slices of a local stack frame, because static
arrays
On 08/30/2011 01:19 PM, Jonathan M Davis wrote:
On Tuesday, August 30, 2011 07:08:32 bearophile wrote:
DMD 2.055head gives no compile-time errors on this, is this expected and
good/acceptable?
struct Foo {
int x;
this(int x_) { this.x = x_; }
}
void main() {
auto f1 = new
On 08/30/2011 01:29 AM, Andrej Mitrovic wrote:
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
//
On 08/26/2011 06:12 AM, Joel Christensen wrote:
On 26-Aug-11 10:20 AM, Timon Gehr wrote:
On 08/26/2011 12:19 AM, Timon Gehr wrote:
On 08/25/2011 11:34 PM, bellinom wrote:
whoops, this is better:
auto arr=to!(int[])(split(strip!(readln(;
Or,
auto arr2=to!(int[])( readln.strip.split
On 08/26/2011 05:45 AM, Joel Christensen wrote:
Hi,
Has anyone had much experience with multiple subtyping.
//Org: based on page 232 (6.13.1) in The D Programming Language book
//#save(); without storeShape does not work
import std.stdio;
class Shape {
void shape() {
writeln( Shape );
}
}
On 08/25/2011 01:11 PM, Steven Schveighoffer wrote:
On Wed, 24 Aug 2011 19:01:31 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 08/25/2011 12:47 AM, Mafi wrote:
Am 24.08.2011 21:04, schrieb Timon Gehr:
On 08/24/2011 08:04 PM, Andrej Mitrovic wrote:
Here's some code that iterates through
On 08/25/2011 05:31 PM, Steven Schveighoffer wrote:
On Thu, 25 Aug 2011 11:15:44 -0400, Jonathan M Davis
jmdavisp...@gmx.com wrote:
On Thursday, August 25, 2011 07:11:31 Steven Schveighoffer wrote:
On 08/25/2011 12:47 AM, Mafi wrote:
I'm not really sure if it's good for 'while'.
I'm
On 08/25/2011 10:51 PM, Steven Schveighoffer wrote:
On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr timon.g...@gmx.ch wrote:
I usually replace code like this:
x++;
if(x 100)
{
// use x
}
with this:
if(++x 100) {
// use x
}
so the logical mapping to while would map this:
x
On 08/25/2011 11:34 PM, bellinom wrote:
Thanks for that, I didn't realize they were that far out of date. I
use the latest
version of the compiler on my home PC, so I'd like to know the most
current ways
of reading from stdin.
Thanks
Currently what you get is readf and readln with
On 08/26/2011 12:19 AM, Timon Gehr wrote:
On 08/25/2011 11:34 PM, bellinom wrote:
Thanks for that, I didn't realize they were that far out of date. I
use the latest
version of the compiler on my home PC, so I'd like to know the most
current ways
of reading from stdin.
Thanks
Currently
On 08/26/2011 12:38 AM, Steven Schveighoffer wrote:
On Thu, 25 Aug 2011 17:31:26 -0400, Timon Gehr timon.g...@gmx.ch wrote:
On 08/25/2011 10:51 PM, Steven Schveighoffer wrote:
On Thu, 25 Aug 2011 12:21:19 -0400, Timon Gehr timon.g...@gmx.ch
wrote:
I usually replace code like this:
x
On 08/26/2011 02:00 AM, Ali Çehreli wrote:
On Thu, 25 Aug 2011 23:31:26 +0200, Timon Gehr wrote:
for(init; condition; statement){}
while(condition ){}
That's a very interesting way of looking at the question.
I bet that explains the other way around: there can't be a variable
On 08/24/2011 07:40 PM, Andrej Mitrovic wrote:
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
On 08/24/2011 07:54 PM, Steven Schveighoffer wrote:
On Wed, 24 Aug 2011 13:40:38 -0400, Andrej Mitrovic
andrej.mitrov...@gmail.com wrote:
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);
}
On 08/24/2011 08:04 PM, Andrej Mitrovic wrote:
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; }
}
701 - 800 of 838 matches
Mail list logo