Re: DConf 2013 on twitter

2013-04-30 Thread Gary Willoughby

On Tuesday, 30 April 2013 at 01:57:29 UTC, Ali Çehreli wrote:

On 04/29/2013 06:44 PM, Diggory wrote:
Just curious if there were any plans to put videos/slideshows 
from the

presentations online after the conference?


Yes, that's the plan.

Ali


Awesome! I really can't wait to watch these.


Re: DConf 2013 official car/room sharing thread

2013-04-30 Thread Manu
Bloody phone...
On 29 Apr 2013 19:01, Iain Buclaw ibuc...@ubuntu.com wrote:

 double post


 On 29 April 2013 18:57, Manu turkey...@gmail.com wrote:

 Haha, how do you intend to have a cooler-than-the-aloft club meetup
 there, when it's being presented by a cool aloft-er? ;)
 On 29 Apr 2013 16:35, Ali Çehreli acehr...@yahoo.com wrote:

 On 04/29/2013 04:10 PM, Adam Wilson wrote:

  *sigh* I'm not staying there either, but it does seem like all the cool
  kids are. Well, we'll just have to start our own Not Staying at Aloft
  Club for the cooler kids. :-D

 We can start the coolness by going to Manu's ACCU talk tomorrow in
 Mountain View: :)

   http://www.meetup.com/SFBay-**Association-of-C-C-Users/**
 events/115855342/http://www.meetup.com/SFBay-Association-of-C-C-Users/events/115855342/

 Ali




 --
 Iain Buclaw

 *(p  e ? p++ : p) = (c  0x0f) + '0';



Re: Formal Review of std.uni

2013-04-30 Thread Dmitry Olshansky

30-Apr-2013 04:12, Jonathan M Davis пишет:

On Tuesday, April 30, 2013 03:02:17 Dmitry Olshansky wrote:

29-Apr-2013 22:50, Jonathan M Davis пишет:

On Monday, April 29, 2013 22:13:09 Dmitry Olshansky wrote:

Technically these should be in std.string and are there but incorrect.


Then fix them there.


I think it will take a certain amount of leaked implementation details
to get it done at least half-decently. In particular to re-use the same
case-folding table as for case-insensitive matching.

Would be a strategic mistake IMHO to spread the internals across 2 modules.

Then std.string could provide a public alias(es) as it imports std.uni
anyway?

Going further if we are to preserve the status quo then std.uni will
declare them as package to not advertise their new location.


An alias would be one option. The primary issue I see is that the general
design of the modules has been that std.ascii and std.uni operate on
individual characters and not strings, whereas std.string operates on strings
(generally going with the unicode versions of things when there's a choice
rather than the ASCII ones). And having overloads in std.uni which operate on
strings doesn't follow that organizational model. Usually, std.string has
called the std.uni functions to do what it's needed, and no implementation
details have been leaked. I haven't looked at what you've done with std.uni
yet, so I don't know how well that would work. But toLower and toUpper are far
from them only functions which would be affected by something like this (icmp
would be another obvious one).


Unicode -- can't be done on character by character basis



But even if we decided to reorganize where some functionality or functions
live, we shouldn't have std.uni replacing std.string functions while leaving
the old functions in std.string. So, worst case, aliases should be used, but
if at all reasonable, I'd prefer to keep the module organizational structure
that we've had with regards to how characters and string functionality is
organized.


Aliases it is then.

--
Dmitry Olshansky


Re: 1 matches bool, 2 matches long

2013-04-30 Thread Steven Schveighoffer
On Mon, 29 Apr 2013 11:39:27 -0700, Walter Bright  
newshou...@digitalmars.com wrote:



On 4/29/2013 10:10 AM, Steven Schveighoffer wrote:


I think you are inventing a strawman problem that this bug solves.   
There is no
need for a Better scheme, partial ordering works great, and so do  
true and false.


bool isn't an integer.  It can implicitly cast to an integer, but  
that's it.
Once we implement that rule, everything falls into place.  If you want  
to pass a
true boolean literal, use true.  If you want to pass a false  
boolean literal
use false.  Using 1 and 0 may be convenient, and may also be valid, but  
when it

matches an integral type as well as bool, then it's ambiguous.


Carefully reading your statement, you are still arguing that matching 1  
to long should be better than matching it to bool.


Yes, just like it's better matching to long than string.

-Steve


Re: GDB support for multithreaded D application debugging

2013-04-30 Thread David
Am 29.04.2013 15:55, schrieb d coder:
 Greetings
 
 I just wanted to find out how good is the GDB support for debugging
 multithreaded code written in D language. I remember trying it sometimes
 back, but could not get it to work.
 
 Any suggestions?
 
 Regards
 - Puneet
 
I think GDB 7.5 is fully compatible to GDC produced debug-code. Maybe
try GDC anc GDB 7.5?


Re: trusted purity?

2013-04-30 Thread Walter Bright

On 4/29/2013 10:42 PM, monarch_dodra wrote:

Thanks. That (kinda) worked. I just had to add an alias, because the
compiler was complaining about: Error: fp_pure_t is used as a type


Yeah, I should have tested it before posting!



Re: 1 matches bool, 2 matches long

2013-04-30 Thread Rob T
On Tuesday, 30 April 2013 at 14:47:14 UTC, Steven Schveighoffer 
wrote:


Yes, just like it's better matching to long than string.

-Steve


More precise language is to state that there is no better match 
and long should simply not ever match with bool because long is 
not the same thing as bool, ie, bool should not be seen as an 
integral type because it clearly isn't because it does not behave 
like one and has a completely different purpose in the language 
otherwise there'd be no need for a bool to have special 
differences that the other integrals do not have.


How do we get the problem fixed? The sooner it is done the 
better, otherwise  we'll be forever stuck with subtle bugs and D 
programmers complaining about it for the rest of eternity.


--rt


Re: trusted purity?

2013-04-30 Thread monarch_dodra

On Tuesday, 30 April 2013 at 17:06:00 UTC, Walter Bright wrote:

On 4/29/2013 10:42 PM, monarch_dodra wrote:
Thanks. That (kinda) worked. I just had to add an alias, 
because the
compiler was complaining about: Error: fp_pure_t is used as a 
type


Yeah, I should have tested it before posting!


Oh, no problem, you gave me the right answer anyways, that's what
counts. Thanks.


Re: 1 matches bool, 2 matches long

2013-04-30 Thread Steven Schveighoffer

On Tue, 30 Apr 2013 10:43:01 -0700, Rob T al...@ucora.com wrote:


On Tuesday, 30 April 2013 at 14:47:14 UTC, Steven Schveighoffer wrote:


Yes, just like it's better matching to long than string.

-Steve


More precise language is to state that there is no better match and  
long should simply not ever match with bool because long is not the same  
thing as bool, ie, bool should not be seen as an integral type because  
it clearly isn't because it does not behave like one and has a  
completely different purpose in the language otherwise there'd be no  
need for a bool to have special differences that the other integrals do  
not have.


How do we get the problem fixed? The sooner it is done the better,  
otherwise  we'll be forever stuck with subtle bugs and D programmers  
complaining about it for the rest of eternity.


1. bool doesn't match to 1 or 0.
2. cast(bool)0 - false
3. cast(bool)(anything but 0) - true
4. true - (implicit cast) 1
5. false - (implicit cast) 0.

Then all that is left is to change any place where 1 or 0 implicitly casts  
to true or false to true and false.


The one casualty is any code that passes 1 or 0 to a function overloaded  
with long, short, or byte (or unsigned versions), and bool, will now  
silently switch to calling the integral version.  I would posit that this  
is extremely rare.


-Steve


Re: clear() causes crash?

2013-04-30 Thread Luís.Marques

On Monday, 29 April 2013 at 21:58:46 UTC, Jonathan M Davis wrote:

zeroes out the vtbl


Hmm, I was expecting that DMD, at least in -release mode, 
optimize foo() to a direct call, since there's no inheritance.


Re: clear() causes crash?

2013-04-30 Thread Dicebot

On Tuesday, 30 April 2013 at 18:54:45 UTC, Luís Marques wrote:
On Monday, 29 April 2013 at 21:58:46 UTC, Jonathan M Davis 
wrote:

zeroes out the vtbl


Hmm, I was expecting that DMD, at least in -release mode, 
optimize foo() to a direct call, since there's no inheritance.


It was discussed a lot of times in this newsgroup, you can google 
it quite easily. To sum up: it really can't, unless it is marked 
as final.


Re: 1 matches bool, 2 matches long

2013-04-30 Thread Paulo Pinto

Am 30.04.2013 20:50, schrieb Steven Schveighoffer:

On Tue, 30 Apr 2013 10:43:01 -0700, Rob T al...@ucora.com wrote:


On Tuesday, 30 April 2013 at 14:47:14 UTC, Steven Schveighoffer wrote:


Yes, just like it's better matching to long than string.

-Steve


More precise language is to state that there is no better match and
long should simply not ever match with bool because long is not the
same thing as bool, ie, bool should not be seen as an integral type
because it clearly isn't because it does not behave like one and has a
completely different purpose in the language otherwise there'd be no
need for a bool to have special differences that the other integrals
do not have.

How do we get the problem fixed? The sooner it is done the better,
otherwise  we'll be forever stuck with subtle bugs and D programmers
complaining about it for the rest of eternity.


1. bool doesn't match to 1 or 0.
2. cast(bool)0 - false
3. cast(bool)(anything but 0) - true
4. true - (implicit cast) 1
5. false - (implicit cast) 0.

Then all that is left is to change any place where 1 or 0 implicitly
casts to true or false to true and false.

The one casualty is any code that passes 1 or 0 to a function overloaded
with long, short, or byte (or unsigned versions), and bool, will now
silently switch to calling the integral version.  I would posit that
this is extremely rare.

-Steve


+1


Re: Formal Review of std.uni

2013-04-30 Thread Jonathan M Davis
On Tuesday, April 30, 2013 15:13:14 Dmitry Olshansky wrote:
 Unicode -- can't be done on character by character basis

Sure it can. It operates on dchar. I don't know what you've done with std.uni, 
but the way things have been laid out is that

std.ascii: Operates on dchars, doing ASCII operations, generally ignoring 
anything that's not ASCII.

std.uni: Operates on dchars, doing Unicode operations. The operations are 
generally the same as what you'd do with ASCII only with Unicode instead.

std.utf: Doing encoding related stuff with Unicode, so it operates on strings.

std.string: Operates on strings (almost always using Unicode)

So, with how it's been, std.uni would only be operating on dchars, and putting 
a function in there which operated on strings wouldn't make any sense. Maybe 
that doesn't work if you've done a bunch of grapheme stuff, and things will 
have to be adjusted, but it would be a definite shift to put anything in 
std.uni which operated on strings, and I think that it would need some definite 
justification (and there's a good chance that I'd be inclined to argue that it 
should still go in std.string, possibly using some internal modules if 
necessary).

But clearly I need to take the time to take a look at what you've actually 
done (I keep meaning to but haven't gotten around to it yet). It had been my 
impression that what you were doing was primarily a matter of improving the 
implementation, but it sounds like you're doing something beyond that.

- Jonathan M Davis


Re: clear() causes crash?

2013-04-30 Thread Jonathan M Davis
On Tuesday, April 30, 2013 20:59:17 Dicebot wrote:
 On Tuesday, 30 April 2013 at 18:54:45 UTC, Luís Marques wrote:
  On Monday, 29 April 2013 at 21:58:46 UTC, Jonathan M Davis
  
  wrote:
  zeroes out the vtbl
  
  Hmm, I was expecting that DMD, at least in -release mode,
  optimize foo() to a direct call, since there's no inheritance.
 
 It was discussed a lot of times in this newsgroup, you can google
 it quite easily. To sum up: it really can't, unless it is marked
 as final.

It pretty much comes down to the fact that the compiler can't possibly know 
that there's no inheritance, because it doesn't have the whole list of classes 
in the program and _can't_ have the whole list of classes (especially once 
shared libraries enter the mix).

- Jonathan M Davis


Re: clear() causes crash?

2013-04-30 Thread Mafi

On Monday, 29 April 2013 at 21:04:30 UTC, Luís Marques wrote:

This crashes in the last line of main:

class A
{
void foo() {}
}

void main()
{
A a = new A();
a.foo();
clear(a);
assert(a !is null);
a.foo();  // crashes
}

As far as I understand from TDPL book, this should not crash, 
but it does (DMD64 v2.062, OS X). Am I misunderstanding clear()?


BTW, why not make clear also change 'a' to null?


Hasn't 'clear' been renamed to 'destroy'?


Re: 1 matches bool, 2 matches long

2013-04-30 Thread Timothee Cour
+1 (and give a helpful compiler error with suggested modification)


Re: clear() causes crash?

2013-04-30 Thread Jonathan M Davis
On Tuesday, April 30, 2013 21:47:43 Mafi wrote:
 Hasn't 'clear' been renamed to 'destroy'?

Yes, but an alias to clear still exists, and TDPL talks about clear, not 
destroy, so anyone reading TDPL would still expect it to be clear.

- Jonathan M Davis


D frontend: Test suite online

2013-04-30 Thread Timon Gehr
For those who are interested, I have uploaded the test suite I use to 
guard my D frontend prototype against regressions to GitHub.


You may access it from: https://github.com/tgehr/___

(Note that this is still very much a work in progress.)
(dconf: David and deadalnix have received a binary.   )


Re: ARM targetting cross-toolchain with GDC

2013-04-30 Thread Timofei Bolshakoc
I was able to compile DGC to the Hello, World status for ARM 
using crosstools-ng 1.18 eglibc. uclibc would not work, it lack 
some of the functions in the library, context switching. There 
are several places I cheat ( to get Hello, World! ). Please 
advise:


../gcc-4.7.2/libphobos/libdruntime/core/sys/posix/ucontext.d:274: 
Error: static assert  Not implemented


../gcc-4.7.2/libphobos/libdruntime/core/thread.d:3409: Error: 
static assert  Not implemented


../gcc-4.7.2/libphobos/libdruntime/core/thread.d:4237: Error: 
static assert  Not implemented


I simply commented static asserts - and I do not think it will 
fly with any real multi threading program. All the places 
consider context switching and assembly-level register 
manipulation. Can somebody help me with that?


Re: ARM targetting cross-toolchain with GDC

2013-04-30 Thread Timofei Bolshakov

I was able to compile DGC to the Hello, World status for ARM
using crosstools-ng 1.18 eglibc. uclibc would not work, it lack
some of the functions in the library, context switching. There
are several places I cheat ( to get Hello, World! ). Please
advise:

../gcc-4.7.2/libphobos/libdruntime/core/sys/posix/ucontext.d:274:
Error: static assert  Not implemented

../gcc-4.7.2/libphobos/libdruntime/core/thread.d:3409: Error:
static assert  Not implemented

../gcc-4.7.2/libphobos/libdruntime/core/thread.d:4237: Error:
static assert  Not implemented

I simply commented static asserts - and I do not think it will
fly with any real multi threading program. All the places
consider context switching and assembly-level register
manipulation. Can somebody help me with that?


Re: DConf 2013 official car/room sharing thread

2013-04-30 Thread Daniel Murphy
Me too!  My phone is not cooperating though.

Zach the Mystic reachz...@gmail.com wrote in message 
news:tmigrwlhhlijoridd...@forum.dlang.org...
 On Monday, 29 April 2013 at 22:42:09 UTC, Tyro[17] wrote:
 Hi all, I'll be arriving tomorrow night. Will be in commuting from 
 Redwood City if anyone needs a ride.

 Andrew

 Hi! I'm also staying in Redwood City. Mike Parker is too, and I'm in touch 
 with him already. But my phone is five-one-oh three-seven-four oh-eight 
 six three, if you want to call or text when you get in.
 




How to dump the defaults version and debug names

2013-04-30 Thread cbleser
I would like to know if there is a way to dump the default 
version and debug names.


Like listing default macros in gcc
echo int main(){return 0;} | gcc -E -dM -

I am missing the version values name of the compiler release 
(like dmd-2.060).


Thank you.


Re: 1 matches bool, 2 matches long

2013-04-30 Thread MattCoder

On Monday, 29 April 2013 at 18:39:27 UTC, Walter Bright wrote:

On 4/29/2013 10:10 AM, Steven Schveighoffer wrote:
On Sat, 27 Apr 2013 13:27:39 -0700, Walter Bright 
newshou...@digitalmars.com

wrote:
.
. .
bool isn't an integer.  It can implicitly cast to an integer, 
but that's it.
Once we implement that rule, everything falls into place.  If 
you want to pass a
true boolean literal, use true.  If you want to pass a 
false boolean literal
use false.  Using 1 and 0 may be convenient, and may also be 
valid, but when it

matches an integral type as well as bool, then it's ambiguous.


Carefully reading your statement, you are still arguing that 
matching 1 to long should be better than matching it to bool.



Walter, Don't you agree that the current way can be confusing?

For example, the following code generates 2 differents 
results/output:


import std.stdio;

void foo(bool b) { writeln(bool); }
void foo(long l) { writeln(long); }

void main()
{
long num = 0;

foo(num);
foo(0);
foo(2);
}

output:

long
bool
long

Regardless the fact that num is a variable (long), the first 2 
foo calls in my perspective means foo(0), and should generate the 
same output. Don't you agree with that?


Removing the int foo[]; syntax

2013-04-30 Thread Brian Schott
It complicates the grammar and doesn't fit with D's style of 
declaraing variables. (type then identifier) I realize that it 
was left in to make C programmers happy, but it doesn't even work 
like it does in C:


int a[10];
int b[10], b[10];
int[10] c, d;
int e[string];
int f[string], g[string];

test.d(2): Error: multiple declarations must have the same type, 
not int[10] and int[10]
test.d(5): Error: multiple declarations must have the same type, 
not int[string] and int[string]




Appending char[] to char[][] has unexpected results

2013-04-30 Thread Tim Keating
Not sure whether this is a bug, or perhaps I'm misunderstanding 
something, but it seems like this should work:


void main()
{
char[][] outBuf;
auto f = File(testData.txt, r);
char[] buf;

writeln(\n RAW OUTPUT *);

while (f.readln(buf))
{
write(buf);
outBuf ~= buf;
}

writeln(\n BUFFERED OUTPUT *);

foreach (line; outBuf)
{
write(line);
}
}

testData.txt is just a couple of lines of miscellaneous text. The 
expectation is that the raw output and the buffered output should 
be exactly the same... but they are not. (If anyone would like to 
see this for themselves, I stuck it in github: 
https://github.com/MrTact/CharBug.)


Changing the types of outBuf and buf to dchar works as expected. 
Changing outBuf to a string[] and appending buf.idup does as well.


Re: Appending char[] to char[][] has unexpected results

2013-04-30 Thread anonymous

On Wednesday, 1 May 2013 at 03:54:23 UTC, Tim Keating wrote:
Not sure whether this is a bug, or perhaps I'm misunderstanding 
something, but it seems like this should work:


void main()
{
char[][] outBuf;
auto f = File(testData.txt, r);
char[] buf;

writeln(\n RAW OUTPUT *);

while (f.readln(buf))
{
write(buf);
outBuf ~= buf;
}

writeln(\n BUFFERED OUTPUT *);

foreach (line; outBuf)
{
write(line);
}
}

testData.txt is just a couple of lines of miscellaneous text. 
The expectation is that the raw output and the buffered output 
should be exactly the same... but they are not. (If anyone 
would like to see this for themselves, I stuck it in github: 
https://github.com/MrTact/CharBug.)


Changing the types of outBuf and buf to dchar works as 
expected. Changing outBuf to a string[] and appending buf.idup 
does as well.


Just outBuf ~= buf.dup; works, too. Without .dup you're 
overwriting and appending the same chunk of memory again and 
again.

From the documentation on File.readln
(http://dlang.org/phobos/std_stdio#readln): Note that reusing 
the buffer means that the previous contents of it has to be 
copied if needed.

I'm a bit puzzled as for why it behaves differently with dchar.


Re: debugging on Mac OSX

2013-04-30 Thread Jacob Carlborg

On 2013-04-30 02:01, Timothee Cour wrote:


C) stacktraces on OSX with some modifications I did involving wrapping
atos, etc: {

shows function name, full file, line numbers, and catches segfaults.
0  file: exception.d:356 pure @safe bool
std.exception.enforce!(bool).enforce(bool, lazy const(char)[],
immutable(char)[], ulong)
1  file: path/som_file.d:100 void util.some_function(int x)
...

Some problems:
in case of segfault, the very latest stack frame is missing (so we
only have the parent of the parent of the function that caused the
segfault, plus anything older).

in some rare cases we only have the file name but no file path
information.

}


How did you get this working?

--
/Jacob Carlborg


Re: debugging on Mac OSX

2013-04-30 Thread Jacob Carlborg

On 2013-04-29 20:49, Dan wrote:


Thanks. What is the takeaway? That it does not work and can not work
until these two bugs are fixed? A simple I don't think you can get
there from here?


At least these bugs need to be fixed to get demangled symbol names.

--
/Jacob Carlborg


Re: Arrays of functions, function signatures and template instantiation

2013-04-30 Thread JR

On Tuesday, 30 April 2013 at 02:38:27 UTC, anonymous wrote:

To get rid of the cast:

[...]

Instantiating the template with a function parameter causes a 
compilation error when actually calling the function;


--
  asdf.d:13: Error: variable asdf.MatrixWalker!(@system 
void(string major, uint minor, void function(string, uint) func), 
void function(string, uint)[uint][string]).applyFunc.func cannot 
be declared to be a function
  asdf.d:16: Error: function expected before (), not func of type 
_error_

--

I have a vague feeling I had it working like that at one point 
but I cannot recall with any degree of certainty.


Re: Arrays of functions, function signatures and template instantiation

2013-04-30 Thread anonymous

On Tuesday, 30 April 2013 at 08:42:57 UTC, JR wrote:

On Tuesday, 30 April 2013 at 02:38:27 UTC, anonymous wrote:

To get rid of the cast:

[...]

Instantiating the template with a function parameter causes a 
compilation error when actually calling the function;


--
  asdf.d:13: Error: variable asdf.MatrixWalker!(@system 
void(string major, uint minor, void function(string, uint) 
func), void function(string, 
uint)[uint][string]).applyFunc.func cannot be declared to be a 
function
  asdf.d:16: Error: function expected before (), not func of 
type _error_

--

I have a vague feeling I had it working like that at one point 
but I cannot recall with any degree of certainty.


Don't know what's going wrong there. It works for me:
http://dpaste.dzfl.pl/5c71f80e


Re: Arrays of functions, function signatures and template instantiation

2013-04-30 Thread JR

On Tuesday, 30 April 2013 at 09:18:56 UTC, anonymous wrote:

On Tuesday, 30 April 2013 at 08:42:57 UTC, JR wrote:

On Tuesday, 30 April 2013 at 02:38:27 UTC, anonymous wrote:



Don't know what's going wrong there. It works for me:
http://dpaste.dzfl.pl/5c71f80e


My bad, I switched the wrong runner/runner and in the wrong 
direction. Thanks!


Any other protips?

For instance, is it possible to have MatrixWalker's F type to 
have a default value of a NOP void function(), have the innermost 
foreach loop check if the element is a function, and if so call 
it directly without needing FuncRunner at all?


Also, is there a clever approach to have MatrixWalker call its 
passed function variadically with only the arguments that its 
signature allows? As in;


-

import std.stdio;
import std.concurrency;

struct Event { /* ... type, sender, target, content and friends 
... */ };


template MatrixWalker(F,E: E[I][T],I,T) {
// note addition of Event below
void applyFunc(ref Event evt, F func, E[I][T] matrix) {
/* ... Inception foreach ... */
func(evt, /* only the arguments of E, I and/or T that 
type F accepts */);

}
}

const alias Blaawp MAJOR;
const alias Oorgle MINOR;
static void function(ref Event, MINOR)[MINOR][MAJOR] 
funcyMatrix;

// note no MAJOR in func sig

void populate() {
/* ... */
}

void traverse() {
sendMessageAdapter = void function(ref Event evt, Tid) {
std.concurrency.send(tid, evt);
};

alias 
MatrixWalker!(typeof(sendMessageAdapter),typeof(funkyMatrix)).applyFunc 
apply;


writeln(Traversing funcy matrix);
apply(sendMessageAdapter, funkyMatrix);
}

void main(string[] args) {
populate();
traverse();
}

-

That sounds too good to be true, but it would make me warm and 
fuzzy inside if I didn't have to resort to keeping a dozen 
adapter/shim functions around.


Re: Arrays of functions, function signatures and template instantiation

2013-04-30 Thread anonymous

On Tuesday, 30 April 2013 at 10:02:07 UTC, JR wrote:
[...]
For instance, is it possible to have MatrixWalker's F type to 
have a default value of a NOP void function(), have the 
innermost foreach loop check if the element is a function, and 
if so call it directly without needing FuncRunner at all?


Let's start by turning MatrixWalker into a function template 
(fixing the matrix template parameter on the way):

---
void walkMatrix(F,M: E[I][T],E,I,T)(F func, M matrix) {
/* those foreaches */
}
---

This way it can be called without explicitly instantiating the 
template:

---
walkMatrix(runner, funcyMatrix);
---

Now add an overload for callable elements:
---
void walkMatrix(M: E[I][T],E,I,T)(M matrix) 
if(is(typeof(FuncRunner!M.run))) {

walkMatrix(FuncRunner!M.run, matrix);
}
---

A call:
---
walkMatrix(funcyMatrix);
---

Of course, FuncRunner is now only needed by that overload, so you 
could move its implementation in there.


Also, is there a clever approach to have MatrixWalker call its 
passed function variadically with only the arguments that its 
signature allows? As in;


-

import std.stdio;
import std.concurrency;

struct Event { /* ... type, sender, target, content and 
friends ... */ };


template MatrixWalker(F,E: E[I][T],I,T) {
   // note addition of Event below
   void applyFunc(ref Event evt, F func, E[I][T] matrix) {
   /* ... Inception foreach ... */
   func(evt, /* only the arguments of E, I and/or T that 
type F accepts */);

   }
}

const alias Blaawp MAJOR;
const alias Oorgle MINOR;
static void function(ref Event, MINOR)[MINOR][MAJOR] 
funcyMatrix;

// note no MAJOR in func sig

void populate() {
   /* ... */
}

void traverse() {
   sendMessageAdapter = void function(ref Event evt, Tid) {
   std.concurrency.send(tid, evt);
   };

   alias 
MatrixWalker!(typeof(sendMessageAdapter),typeof(funkyMatrix)).applyFunc 
apply;


   writeln(Traversing funcy matrix);
   apply(sendMessageAdapter, funkyMatrix);
}

void main(string[] args) {
   populate();
   traverse();
}

-

That sounds too good to be true, but it would make me warm and 
fuzzy inside if I didn't have to resort to keeping a dozen 
adapter/shim functions around.


I don't have a clever solution for that.


Re: how hash_t toHash() works?

2013-04-30 Thread gedaiu

On Monday, 29 April 2013 at 16:01:15 UTC, Ivan Kazmenko wrote:

one more question
What is the type of cont?

auto cont = redBlackTree !(a.key  b.key, true, MyRecord) ();

I want to use this as a property in a class and i can't use 
there auto keyword... I tried different types but it did not 
work.


For me, the following declaration works:

-
import std.functional;
...
RedBlackTree !(MyRecord, binaryFun!a.key  b.key, true) cont;
...
cont = redBlackTree !(a.key  b.key, true, MyRecord) ();
-

I admit it could have been easier to figure out.  For example, 
writeln (typeof (cont).stringof); just prints RedBlackTree 
which is not enough for a proper declaration.  I've inferred 
the right declaration from the following lines in container.d:


-
/++ Ditto +/
auto redBlackTree(alias less, bool allowDuplicates, E)(E[] 
elems...)

if(is(typeof(binaryFun!less(E.init, E.init
{
//We shouldn't need to instantiate less here, but for some 
reason,
//dmd can't handle it if we don't (even though the template 
which

//takes less but not allowDuplicates works just fine).
return new RedBlackTree!(E, binaryFun!less, 
allowDuplicates)(elems);

}
-


Error: template instance RedBlackTree!(ValueRecord, binaryFun, 
true) RedBlackTree!(ValueRecord, binaryFun, true) does not match 
template declaration RedBlackTree(T, alias less = a  b, bool 
allowDuplicates = false) if (is(typeof(binaryFun!(less)(T.init, 
T.init
Error: RedBlackTree!(ValueRecord, binaryFun, true) is used as a 
type


Do you know what this error means?

Thank,
Bogdan


starting with GUI

2013-04-30 Thread Carlos

I;m trying to add a Entry but I get the following error:

mywindow.d(12): Error: undefined identifier Entry

Here is my code :

window.add(new Entry(Minsit));

I'm just guessing to see if everything is that simple. So I have 
to define the Entry. How do I do that ? ( Any tutorials from the 
web are welcome )


I'm trying to make a program that calculates two numbers and then 
adds them together to give a result.


Here is the CLI version :

import std.stdio;
import std.c.stdlib;
void main()
{
immutable sitc = 1.66, sleepc = 1.08;
float tcsleep, tcsit, tc;
int minsleep, minsit;
write(Input number of minutes sleep and sit : \n);
readf( %s , minsleep);
readf( %s , minsit);
write(Thanks!\n);
tcsit = minsleep*sleepc;
tcsleep = minsit*sitc;
tc = (tcsleep + tcsit);
writeln(Your total burned calories is : , tc);
}


I'm using this GTK for the GUI :

http://www.dsource.org/projects/gtkd/wiki/DebianPackages;
 and this compiles fine with the following :

dmd $(pkg-config --cflags --libs gtkd-2) mywindow.d

This is the code I compiled with GTKD :

import gtk.MainWindow;
import gtk.Label;
import gtk.Main;

void main (string[] args)
{
Main.init(args);
auto window = new MainWindow(My Window);
window.show();
window.setDefaultSize(200, 100);
window.add(new Label(Hello!));
window.showAll();
Main.run;
}


So basicly what I'm missing is a good way on learning to use this 
GTKD but for the moment I only want to define a Entry.

THank you for your time.


Re: starting with GUI

2013-04-30 Thread Carlos
Another version of the CLI which tries to keep 1440 minutes for a 
complete day ( this is desired on the GUI ) is :



import std.stdio;
import std.c.stdlib;
void main()
{
immutable sitc = 1.66;
immutable sleepc = 1.08;
float tcsleep, tcsit, tc;
int minsleep, minsit;
write(Input minutes sit : \n);
readf( %d, minsit);
write(Input minutes sleep : \n);
readf( %d, minsleep);
while (minsit+minsleep != 1440){
write(Error 1 \n);
write(Input minutes sit : \n);
readf( %d, minsit);
write(Input minutes sleep : \n);
readf( %d, minsleep);
}
if (minsit+minsleep == 1440){
tcsit = minsleep*sleepc;
tcsleep = minsit*sitc;
tc = (tcsleep + tcsit);
write(Your calories per day is : , tc, \n);
exit (0);
}
}



Re: starting with GUI

2013-04-30 Thread anonymous

On Tuesday, 30 April 2013 at 17:03:07 UTC, Carlos wrote:

I;m trying to add a Entry but I get the following error:

mywindow.d(12): Error: undefined identifier Entry

Here is my code :

window.add(new Entry(Minsit));

I'm just guessing to see if everything is that simple. So I 
have to define the Entry. How do I do that ? ( Any tutorials 
from the web are welcome )



[...]


This is the code I compiled with GTKD :

import gtk.MainWindow;
import gtk.Label;
import gtk.Main;

void main (string[] args)
{
Main.init(args);
auto window = new MainWindow(My Window);
window.show();
window.setDefaultSize(200, 100);
window.add(new Label(Hello!));
window.showAll();
Main.run;
}


So basicly what I'm missing is a good way on learning to use 
this GTKD but for the moment I only want to define a Entry.

THank you for your time.


A wild guess: import gtk.Entry;


Re: starting with GUI

2013-04-30 Thread Carlos

A wild guess: import gtk.Entry;
Thank you I just did that some minutes ago ( a good guess ). Now 
I'm trying to work on the layout so I can finally enter in 
signals if that's how GTKD works.


Re: how hash_t toHash() works?

2013-04-30 Thread Ivan Kazmenko

-
import std.functional;
...
	RedBlackTree !(MyRecord, binaryFun!a.key  b.key, true) 
cont;

...
cont = redBlackTree !(a.key  b.key, true, MyRecord) ();
-


Error: template instance RedBlackTree!(ValueRecord, binaryFun, 
true) RedBlackTree!(ValueRecord, binaryFun, true) does not 
match template declaration RedBlackTree(T, alias less = a  
b, bool allowDuplicates = false) if 
(is(typeof(binaryFun!(less)(T.init, T.init
Error: RedBlackTree!(ValueRecord, binaryFun, true) is used as a 
type


I am able to reproduce it if I write
RedBlackTree !(MyRecord, binaryFun, true)
instead of
RedBlackTree !(MyRecord, binaryFun!a.key  b.key, true)

If you are using a plain regular function instead of a.key  
b.key there, consider the following form:


-
bool less (T) (auto ref T a, auto ref T b)
{
return a.key  b.key;
}
...
RedBlackTree !(MyRecord, less, true) cont;
...
cont = redBlackTree !(less, true, MyRecord) ();
-

Note that the straightforward notation does *not* work yet in 
2.062 if you want ref parameters:


-
bool less (ref MyRecord a, ref MyRecord b)
{
return a.key  b.key;
}
-

The current condition of binaryFun is too tight.  So, for now, we 
have to create a non-ref version too to pass it.  See (and 
perhaps comment) the following issue in BugZilla:  
http://d.puremagic.com/issues/show_bug.cgi?id=9513


Ivan Kazmenko.


Re: WinAPI callbacks and GC

2013-04-30 Thread Sean Kelly
On Apr 23, 2013, at 2:21 PM, Jack Applegame jappleg...@gmail.com wrote:
 
 According WinAPI documentation, CtrlHandler will be called in new additional 
 thread. Is it safe to allocate GC memory in NOT Phobos threads?
 If not, how to make it safe? I'm trying call thread_attachThis() at the 
 beginning of CtrlHandler fucntion, but it doesn't compile because 
 thread_attachThis() is not no throw.


thread_attachThis should probably just be labeled nothrow.  I don't think 
there's anything in that function that can throw an Exception.

[Issue 10011] New: Invalid UTF-8 sequence in generated JSON file in init property

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10011

   Summary: Invalid UTF-8 sequence in generated JSON file in
init property
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: json
  Severity: major
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: verylonglogin@gmail.com


--- Comment #0 from Denis Shelomovskij verylonglogin@gmail.com 2013-04-30 
12:34:17 MSD ---
This variable produces invalid UTF-8 sequence in generated JSON file in init
property thus making the whole file broken:
---
const Object c = new Object();
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10012] New: [2.063 beta] pure constructors taking POD structs should be allowed for shared/immutable construction

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10012

   Summary: [2.063 beta] pure constructors taking POD structs
should be allowed for shared/immutable construction
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: slud...@outerproduct.org


--- Comment #0 from S�nke Ludwig slud...@outerproduct.org 2013-04-30 02:04:08 
PDT ---
The following snippet errors out:

---
struct S { }
class Test2 { this(S) pure {} }

void main()
{
auto test2 = new shared Test2(S());
auto test3 = new immutable Test2/(S());
}
---

test_shared.d(7): Error: mutable method test_shared.Test2.this is not callable
u
sing a immutable object
test_shared.d(7): Error: incompatible types for ((new immutable(Test2)) /
(S()))
: 'immutable(Test2)' and 'S'

However, since any instance of S is an independent copy, the resulting object
is still unique and thus should be liable for immutable or shared object
construction. Also, in addition to POD types, types containing only immutable
references should be allowed.

Finally, shared references can also be allowed when constructing a shared
object, but this is a different kind of unique or isolated concept - I call
it weakly isolated in my library implementation [1] following the weakly
pure nomenclature - so this may need some bigger changes.

[1]
https://github.com/rejectedsoftware/vibe.d/blob/6c9efa2fdcef1797c84e58483410f262a2a82d67/source/vibe/core/concurrency.d#L958

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10012] [2.063 beta] pure constructors taking POD structs should be allowed for shared/immutable construction

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10012



--- Comment #1 from Kenji Hara k.hara...@gmail.com 2013-04-30 02:13:44 PDT ---
(In reply to comment #0)
 auto test3 = new immutable Test2 / (S());   // unnecessary '/'
  auto test3 = new immutable Test2(S());   

After the fix, the code would work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10012] [2.063 beta] pure constructors taking POD structs should be allowed for shared/immutable construction

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10012



--- Comment #2 from S�nke Ludwig slud...@outerproduct.org 2013-04-30 02:24:01 
PDT ---
Sorry, I was blind while preparing the test case. This is the correct one:

---
struct S { string str; }
class Test { S _s; this(S s) pure { _s = s; } }

void main()
{
auto test2 = new shared Test(S());
auto test3 = new immutable Test(S());
}
---

So POD indeed works right, but immutable (and shared) references are seemingly
disallowed.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9044] dmd sometimes produces object files with multiple definitions

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9044



--- Comment #24 from Denis Shelomovskij verylonglogin@gmail.com 
2013-04-30 16:07:00 MSD ---
Any plans on fixing this? In my unlucky hands even VisualD's cpp2d fails to
build in debug mode because of the issue...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10013] New: `inout` constructor sometimes fails to create immutable object

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10013

   Summary: `inout` constructor sometimes fails to create
immutable object
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: verylonglogin@gmail.com


--- Comment #0 from Denis Shelomovskij verylonglogin@gmail.com 2013-04-30 
16:34:45 MSD ---
---
class C
{
this() inout { }
this(inout int[]) inout {  }
}

void main()
{
auto c0 = new immutable C(cast(immutable int[]) null); // OK
auto c1 = new immutable C(); // Error (line 10)
auto c2 = new immutable C(null); // Error (line 11)
}
---

dmd output:
---
main.d(10): Error: inout constructor main.C.this creates inout object, not
immutable
main.d(11): Error: inout constructor main.C.this creates mutable object, not
immutable
---

Partial workaround:
Mark constructor as `pure` or `immutable` if possible.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10014] New: `__traits(parent, ...)` isn't parsed as type

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10014

   Summary: `__traits(parent, ...)` isn't parsed as type
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: rejects-valid
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: verylonglogin@gmail.com


--- Comment #0 from Denis Shelomovskij verylonglogin@gmail.com 2013-04-30 
18:13:49 MSD ---
---
class C { int i; }

static assert(is(__traits(parent, C.i) == C)); // Error (line 3)

template Id(T){ alias Id = T; }
static assert(is(Id!(__traits(parent, C.i)) == C)); // OK
---

dmd output:
---
main.d(3): Error: basic type expected, not __traits
main.d(3): Error: found '__traits' when expecting ')'
main.d(3): Error: found ')' when expecting ';'
---

Workaround:
Use `Id` template.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10014] `__traits(parent, ...)` isn't parsed as type

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10014



--- Comment #1 from Denis Shelomovskij verylonglogin@gmail.com 2013-04-30 
18:15:50 MSD ---
Another workaround is to use `init` property: `typeof(__traits(parent,
C.i).init)`

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10015] New: Segfault on forward referencing a variable of templated struct

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10015

   Summary: Segfault on forward referencing a variable of
templated struct
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Keywords: ice
  Severity: normal
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: verylonglogin@gmail.com


--- Comment #0 from Denis Shelomovskij verylonglogin@gmail.com 2013-04-30 
18:39:13 MSD ---
---
struct S(T) { alias X = int; }

alias Y = s.X;
S!int s;
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10016] New: 2.062 - 2.063 Out of memory using RefCounted

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10016

   Summary: 2.062 - 2.063 Out of memory using RefCounted
   Product: D
   Version: D2
  Platform: All
OS/Version: All
Status: NEW
  Severity: regression
  Priority: P2
 Component: DMD
AssignedTo: nob...@puremagic.com
ReportedBy: henn...@still-hidden.de


--- Comment #0 from Henning Pohl henn...@still-hidden.de 2013-04-30 08:44:17 
PDT ---
struct RefCounted(T) {
struct RefCountedStore {
struct Impl {
T _payload;
}
Impl* _store;
}
RefCountedStore _refCounted;

void opAssign(typeof(this)) { }

void opAssign(T) { }

@property refCountedPayload() {
return _refCounted._store._payload;
}
alias refCountedPayload this;
}


struct S {
int i = malloc;
}

class C {
}

class N {
this(C) {
}

C c() {
return null;
}
}

class D : N {
this() {
super(c);
}

RefCounted!S _s;
}

2.063:
-
Fatal Error: Out of memory
-

2.062:
-
main.d(22): Error: undefined identifier malloc
main.d(42): Error: template instance main.RefCounted!(S) error instantiating
-

DustMite did a good job :]

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 10016] 2.062 - 2.063 Out of memory using RefCounted

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=10016



--- Comment #1 from Henning Pohl henn...@still-hidden.de 2013-04-30 09:43:35 
PDT ---
You can replace malloc with someRandomUnknownIdentifier.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 9656] Built-in dup result should behave as like unique array, if it is possible.

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=9656



--- Comment #5 from bearophile_h...@eml.cc 2013-04-30 09:48:13 PDT ---
(In reply to comment #4)
 But maybe we should have a language-level way (like an
 annotation) to denote some reference data as unique.

I am ignorant regarding the compiler, but ,aybe in the meantime it's enough to
have an invisible unique attribute used just by the compiler-front end, like
the various PUREimpure, PUREfwdref, etc used in the compiler.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---


[Issue 1631] Bundled documentation requires connection to digitalmars.com

2013-04-30 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=1631



--- Comment #3 from Eugene Ossintsev dl...@eugoss.eml.cc 2013-04-30 21:15:23 
PDT ---
Sorry, Yao, speaking of Google Ads, you're right. They are still there.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---