Re: std.experimental.testing PR review

2015-04-21 Thread Jacob Carlborg via Digitalmars-d

On 2015-04-20 16:29, Atila Neves wrote:


I saw links to PRs past with generated docs but have/had no
idea how to get a similar result. Besides the html make target,
what is it a person has to do exactly? I'm going to edit the wiki
with this information as well.


Some developer use Ddox [1], some use the same way as Phobos uses. I 
think it's enough to add you're files to Phobos (including the 
makefiles) and the generate the documentation using make in the 
dlang.org repository.


[1] https://github.com/rejectedsoftware/ddox

--
/Jacob Carlborg


Re: druntime unit test failures on FreeBSD

2015-04-21 Thread Jonathan M Davis via Digitalmars-d
In any case, I just reported the bug:

https://issues.dlang.org/show_bug.cgi?id=14476

I guess that the fact that it wasn't found sooner just goes to show that not
many druntime developers are using FreeBSD (though that's not exactly
surprising).

- Jonahan M Davis



Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote:

On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:

On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all opIndex and 
opSlice overloads?


Further, this is slightly related to a way to query the 
dimensions of a data-type. If possible I would like to have a 
type trait for this. This type-trait could then be used both for 
this challenge but also for figuring out how to create randomized 
instances of multi-dimensional structures. This can be used for 
automatic generation of data instances of parameters in algorithm 
testing and benchmarking.


Re: C++/C mangleof inconsistency for OS X

2015-04-21 Thread Jacob Carlborg via Digitalmars-d

On 2015-04-20 18:33, Dan Olson wrote:

An observation on OSX w/ 2.067: mangleof for C++ (and D) names produces
the actual object file symbol while mangleof for C names strips a
leading underscore.

Is this intended?  If so what is rationale?


I don't think it's intentional. The point of mangleof is to evaluate 
to the actual mangled name, as it appears in the object file.


--
/Jacob Carlborg


Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn

On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:

On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all opIndex and 
opSlice overloads?


Ideally you don't want to have to do that. You'd have to 
consider alias this and inheritance.


How do you plan on overriding the behaviour of opIndex and 
opSlice with alias this and inheritance?


We don't want to limit this classes only.

Fixed-dimensional matrices (in 2D/3D graphics) is a typically 
example of where we want to use structs instead.


Typical use case is a Matrix class having index dimension 
RowIndex and ColumnIndex.


[Issue 14476] New: core.thread unit tests failing on FreeBSD 9+

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14476

  Issue ID: 14476
   Summary: core.thread unit tests failing on FreeBSD 9+
   Product: D
   Version: unspecified
  Hardware: All
OS: FreeBSD
Status: NEW
  Severity: major
  Priority: P1
 Component: druntime
  Assignee: nob...@puremagic.com
  Reporter: issues.dl...@jmdavisprog.com

I am consistently seeing this when I try and run druntime's unit tests on
FreeBSD for either 2.067 or master (2.068 alpha):

0.000s PASS release64 object
0.000s PASS release64 core.atomic
0.008s PASS release64 core.bitop
0.000s PASS release64 core.checkedint
0.000s PASS release64 core.demangle
0.000s PASS release64 core.exception
0.000s PASS release64 core.math
0.000s PASS release64 core.memory
posix.mak:230: recipe for target 'obj/64/core/thread' failed
gmake: *** [obj/64/core/thread] Illegal instruction
gmake: *** Deleting file 'obj/64/core/thread'

The druntime unit tests for 2.066 run just fine, so whatever the problem is was
either introduced in 2.067, or a new test that triggers it was introduced.

I'm running the latest PC-BSD on x86_64 (so FreeBSD 10.1), and someone else in
the newsgroup sees the same thing on their 9.1 i386 machine:
http://forum.dlang.org/post/koxlbjptuyccdygvk...@forum.dlang.org

The autotester is not hitting this problem, so clearly, it doesn't exist on all
FreeBSD systems However, apparently, the autotester is currently running
FreeBSD 8.4, so that would imply that the problem only exists in FreeBSD 9+. I
narrowed it down to the last test in core.thread:

unittest
{
auto thr = new Thread(function{}, 10).start();
thr.join();
}

And if I remove the , 10 from the constructor call, then it works - but then
the druntime unit test build fails later:

Testing link
Testing load
Testing linkD
Testing linkDR
Testing loadDR
Testing host
Testing finalize
Testing link_linkdep
Makefile:28: recipe for target 'obj/freebsd/64/link_linkdep.done' failed
gmake[1]: *** [obj/freebsd/64/link_linkdep.done] Segmentation fault
gmake[1]: Leaving directory
'/usr/home/jmdavis/Programming/github/druntime/test/shared'
posix.mak:242: recipe for target 'test/shared/.run' failed
gmake: *** [test/shared/.run] Error 2

I have no idea if it's a related problem or not, but if it isn't, then another
problem was introduced in 2.067 which only exists on FreeBSD 9+. But
regardless, something about setting the stack size for threads isn't working
properly on FreeBSD 9+.

--


Re: Converting Java code to D

2015-04-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-04-20 20:05, Steven Schveighoffer wrote:


enum LineStyle : string {
NONE = None,
SOLID = Solid,
... // etc
}

Used like this:

funcThatTakesString(LineStyle.NONE);

LineStyle ls = LineStyle.SOLID;

funcThatTakesLineStyle(ls);

I'm not a Java programmer, and my time with Java was before enums. But
this is how I would do it.


This is probably the best translation, depending on if the Java API 
needs to be retained or not. label is not included in this 
translation, assuming you can access that in Java.


--
/Jacob Carlborg


Re: Updating ddoc to support modern HTML tags

2015-04-21 Thread Jakob Ovrum via Digitalmars-d

On Monday, 20 April 2015 at 19:42:43 UTC, Gary Willoughby wrote:
I've just done a little bit of work on the ddoc documentation 
and it was brought to my attention that the HTML output of ddoc 
is actually quite old. Some of the current tags are deprecated. 
I've raised this as an issue here:


https://issues.dlang.org/show_bug.cgi?id=14473

Before starting on any work however, I thought there should be 
a discussion on what impact this would have and what tags 
should be used instead.


Here's a list of the current ddoc symbols (and tag output) that 
IMHO would need updating:


https://gist.github.com/nomad-software/333cd658ad88090dcb0a

and here are some proposed substitutions:

https://gist.github.com/nomad-software/20d2ab1f7d4c9e55a343

The changes seem quite simple but I'm wondering what knock on 
effect this would have on anything else? Can you see any 
problems this might create? Any comments on the new tags used?


It's possible that some of the dlang.org CSS would need to be 
updated too, but I like it. Always irked me to see b and such 
everywhere. It's still a long road before we even output correct 
HTML, but this is a nice low-effort (relatively) enhancement.


It would have to be mentioned clearly in the changelog so 
third-party users of DDoc can update their CSS and possibly 
JavaScript (although I don't expect any breakages in practice; 
good practice entails using classes).



The following files would need updating:
https://github.com/D-Programming-Language/dmd/blob/master/src/doc.c#L143-L186
https://github.com/D-Programming-Language/dlang.org/blob/master/ddoc.dd#L687-L720


Also http://dlang.org/ddoc (Section Predefined Macros)


Re: Trial migration of Dsource bindings project to Github

2015-04-21 Thread Jacob Carlborg via Digitalmars-d-announce

On 2015-04-21 01:42, Vladimir Panteleev wrote:


Committing is a local (non-network) operation in git, so you must have
pushed them afterwards, or your GUI has done this for you.


Just for the record, it is possible to use SVN to interact with 
repositories on Github [1], including committing.


https://help.github.com/articles/support-for-subversion-clients/

--
/Jacob Carlborg


[Issue 8207] OS X: Should extern(D) symbols include another underscore?

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8207

Dan Olson go...@comcast.net changed:

   What|Removed |Added

 CC||go...@comcast.net

--- Comment #2 from Dan Olson go...@comcast.net ---
I would think yes, D symbols emitted to the object file on OS X should have
extra underscore.  And .mangleof should produce the symbol without the extra
underscore as it does today. 

extern(C++) has opposite problem.  The extra underscore is present in object
file (correct) but is also present in .mangleof symbol.  It should be stripped
from the .mangleof symbol.  Note: ldc merge-2.067 does this now which caused
test compilable/test7030.d to fail, which is how I got here.  I think LDC is
correct.

-- demo --
void dfun(int);
extern(C++) void cxxfun(int);
extern (C) void cfun(int);

pragma(msg, dfun.mangleof);
pragma(msg, cxxfun.mangleof);
pragma(msg, cfun.mangleof);

dmd 2.067 produces:
_D10showmangle4dfunFiZv
__Z6cxxfuni
cfun

where obj file has these symbols:
 U _D10showmangle4dfunFiZv
 U __Z6cxxfuni
 U _cfun

--


Re: SDC needs you -- redux

2015-04-21 Thread deadalnix via Digitalmars-d

On Monday, 20 April 2015 at 20:01:17 UTC, Johan Engelen wrote:

On Saturday, 18 April 2015 at 20:39:56 UTC, weaselcat wrote:
On Saturday, 18 April 2015 at 17:21:28 UTC, Shammah Chancellor 
wrote:

...


Are there any plans for the LDC and SDC team to work together 
once SDC matures?


I recently joined the LDC team, and I am a bit at a loss...
Should I join SDC so that I can have fun writing in D?  How big 
is the duplication of effort between SDC and LDC? Could LDC and 
SDC perhaps share druntime? (LDC has many custom changes to 
druntime to either use LLVM intrinsics, or rewriting of 
assembly routines that (I think) really only work for DMD)


-Johan


I'm actually looking at how things are done in LDC runtime on a 
regular basis. That is great source of help.


Right now, thing are reimplemented in SDC, but the actual runtime 
is very slim. I reimplemented exceptions as I was not satisfied 
by the way C++ exception are handled by LDC and I want to 
leverage type qualifier to improve the GC, which makes for an 
incompatible GC API at runtime level for SDC (so reimplementation 
is going on here).


I'm not opposed to sharing work with LDC, and vast part of SDC's 
runtime are stupid stubs that fake it (till hopefully we can make 
it) and I'm sure sharing with LDC is an option for some of them.


Re: Example for Documentation?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d

On 4/21/15 2:06 PM, Chris wrote:


multiSort should at least be added to the cheat sheet in
std.algorithm.sorting.


This I can agree with. Can you add a pull request for it?

-Steve


Re: Structural exhaustive matching

2015-04-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2015-04-21 17:36, Jadbox wrote:

What's the best equivalent to Rust's structural enum/pattern (match)ing?
Is it also possible to enforce exhaustive matches? Basically, I'm
curious on what the best way to do ADTs in D.


There's something call castSwitch [1], perhaps not what you're looking 
for.


[1] http://dlang.org/phobos/std_algorithm_comparison.html#.castSwitch

--
/Jacob Carlborg


Re: C++/C mangleof inconsistency for OS X

2015-04-21 Thread Jacob Carlborg via Digitalmars-d

On 2015-04-21 19:01, Dan Olson wrote:


Hmmm, I can see another point of view where mangleof should produce the
equivalent extern(C) symbol.  My gut says this is the way it should
work.


That makes sense.


If I want to call a C function void debug(const char*) from a C library,
I would do this because of D debug keyword:

   pragma(mangle, debug)
   extern (C) void debug_c(const(char*));

Now I would think debug_c.mangleof - debug
(and that is indeed what dmd produces even on OS X).


Are there use cases where one would want to use some other mangling than 
C? I mean, D is a system programing language.



On systems which prepend an underscore, we want compiler to take care of
this so code is portable, otherwise code must do this:

version (OSX)
   pragma(mangle, _debug) extern (C) void debug_c(const(char*));
else
   pragma(mangle, debug) extern (C) void debug_c(const(char*));


These are all good points.

--
/Jacob Carlborg


Re: Example for Documentation?

2015-04-21 Thread John Colvin via Digitalmars-d
On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer 
wrote:
for example, RedBlackTree!(int, a  b) is not compatible with 
RedBlackTree!(int, ab), even though they are identical.


I'm pretty sure this can and should be fixed. Removing whitespace 
before creating the function would be start.


Re: I need dmd2's Arm platform compile.

2015-04-21 Thread Kai Nacke via Digitalmars-d

On Sunday, 19 April 2015 at 18:45:26 UTC, Brian wrote:
I need to use DMD compilation arm or arm64 version, don't know 
DMD now support for the arm.


I think it is very important to the arm of a structure, such as 
rust/go is good enough to support the architecture.


I hope we can improve in arm.


See here for a solution: 
http://forum.dlang.org/post/ycmpuxtbeybrfjdtm...@forum.dlang.org


Regards,
Kai


Found on Reddit: It's time for D to own up

2015-04-21 Thread Ali Çehreli via Digitalmars-d-announce


http://www.reddit.com/r/programming/comments/33dccx/its_time_for_d_to_own_up/

Ali


Re: Example for Documentation?

2015-04-21 Thread Meta via Digitalmars-d
On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer 
wrote:
quoted lambdas are indeed shorter, but the issue with them is 
that ab instantiates a different template than a  b, 
whereas the lambda does not.


In fact, that is why we added shorthand lambdas to the 
language. Note that in this case, it's just wasted code space 
and not a real issue. but for example, RedBlackTree!(int, a  
b) is not compatible with RedBlackTree!(int, ab), even 
though they are identical.


I'm not saying we shouldn't allow string lambdas, just that we 
shouldn't encourage them as proper D code.


Unfortunately, it doesn't work at all for lambdas.

RedBlackTree!(int, (a, b) = a  b) tree1;
RedBlackTree!(int, (a, b) = a  b) tree2;

//Fails
assert(is(typeof(tree1) == typeof(tree2)));


[Issue 14079] Variable templates' documentation not generated.

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14079

Gary Willoughby d...@nomad.so changed:

   What|Removed |Added

   Keywords||pull
 CC||d...@nomad.so

--- Comment #1 from Gary Willoughby d...@nomad.so ---
https://github.com/D-Programming-Language/phobos/pull/3212

--


Re: Example for Documentation?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d

On 4/21/15 2:53 PM, Justin Whear wrote:

On Tue, 21 Apr 2015 18:34:35 +, Chris wrote:

Yeah, but I have to ask a stupid question. How do I add a PR? I've never
done it before.


This wiki page will walk you through it:
http://wiki.dlang.org/Pull_Requests



Just FYI, the thing you want to fork is phobos.

And I would, at this point, just avoid trying to build the whole thing. 
This isn't a very complex change. But you can try if you want. Building 
the docs is a pain, and trying to get it to build with what you checked 
out instead of it trying to get it from github is not exactly 
straightforward.


-Steve


Re: Example for Documentation?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d

On 4/21/15 3:00 PM, Meta wrote:

On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer wrote:

quoted lambdas are indeed shorter, but the issue with them is that
ab instantiates a different template than a  b, whereas the
lambda does not.

In fact, that is why we added shorthand lambdas to the language. Note
that in this case, it's just wasted code space and not a real issue.
but for example, RedBlackTree!(int, a  b) is not compatible with
RedBlackTree!(int, ab), even though they are identical.

I'm not saying we shouldn't allow string lambdas, just that we
shouldn't encourage them as proper D code.


Unfortunately, it doesn't work at all for lambdas.

RedBlackTree!(int, (a, b) = a  b) tree1;
RedBlackTree!(int, (a, b) = a  b) tree2;

//Fails
assert(is(typeof(tree1) == typeof(tree2)));


What? I thought this was the entire point of these?

Hm... let me dig it up.

https://issues.dlang.org/show_bug.cgi?id=10819

http://forum.dlang.org/post/jnlqesrwxfekdsxje...@forum.dlang.org

Looks like that's not solved :(

I was sure we introduced this to fix this string quirkiness problem, but 
I am wrong. I can't find the discussion I remember about this triggering 
the new syntax.


Is there any possibility to move towards a solution where two identical 
context-free lambdas are equivalent when generating a template?


There were also some pretty good ideas in that thread I referenced that 
never got fleshed out.


-Steve


[Issue 14469] file.readText on Win64 doesn't work for files 4GB.

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14469

--- Comment #1 from Kenny Alive artemal...@gmail.com ---
Additionally since ReadFile (and ReadFileEx too) can read file in chunks not
larger than 4GB the file reading code should be updated to something like this:

ulong totalNumRead = 0;
while (totalNumRead != size)
{
uint chunkSize = (size - totalNumRead)  0x;
DWORD numRead = void;
cenforce(ReadFile(hFile, cast(ubyte*)lpBuffer + totalNumRead,
chunkSize, numRead, null) != 0
 numRead == chunkSize, name);
totalNumRead += chunkSize;
}

--


Re: CT-String as a Symbol

2015-04-21 Thread Nordlöw

On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:

Then you throw in some more stuff to detect 1-dimensional cases.


Could you please elaborate a bit?


Re: Example for Documentation?

2015-04-21 Thread Chris via Digitalmars-d
On Tuesday, 21 April 2015 at 17:30:08 UTC, Steven Schveighoffer 
wrote:
On 4/21/15 11:25 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= 
schue...@gmx.net wrote:
On Tuesday, 21 April 2015 at 14:25:29 UTC, Steven 
Schveighoffer wrote:

On 4/21/15 10:07 AM, Chris wrote:

Here's bearophile's version of sorting an AA by value [1]

void main() {
   import std.stdio: writeln;
   import std.algorithm.sorting: multiSort;
   import std.array: array;

   const size_t[string] wCount = [
   hamster: 5,
   zorro: 80,
   troll: 90,
   algorithm: 80,
   beer: 80
   ];

   auto pairs = wCount.byKeyValue.array;
   assert(wCount.length == pairs.length);
   pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
   assert(pairs[2].key == beer);
   foreach (const ref it; pairs)
   writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. 
http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort

2. http://dlang.org/hash-map.html


We should not be promoting string-based lambdas:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key 
 b.key);




I find the strings to be more readable, simply because they 
are shorter.

I would probably even prefer normal  quotes.


quoted lambdas are indeed shorter, but the issue with them is 
that ab instantiates a different template than a  b, 
whereas the lambda does not.


In fact, that is why we added shorthand lambdas to the 
language. Note that in this case, it's just wasted code space 
and not a real issue. but for example, RedBlackTree!(int, a  
b) is not compatible with RedBlackTree!(int, ab), even 
though they are identical.


I'm not saying we shouldn't allow string lambdas, just that we 
shouldn't encourage them as proper D code.


I think this would be a perfect addition for the disqus forum 
of that
function (once ddox gets to be the default). I don't want to 
get into
adding sample usages for every use case on every function to 
the

documentation.


Not for every possible use case, but I'd prefer examples 
demonstrating
an actual, practical application to ones that were just made 
up for the

sake of documentation.


This use case seems niche to me. I haven't ever had the need to 
sort an AA, and if I did, I would use a RedBlackTree.


Not discounting it, or saying it's not valid or useful, just 
that it's not such a perfect example that it needs to unseat 
the current example (sorting points by x and y).


It definitely does not belong in the AA documentation.

-Steve


It's not meant to unseat the existing example, but it could be 
added as an additional use case. I agree, I don't need AA.value 
sort everyday, but when you need it, it should be fast and easy 
to implement. I needed it, because I was grinding data in various 
ways (like you would in a spread sheet). It came in handy there.


multiSort should at least be added to the cheat sheet in 
std.algorithm.sorting.


[Issue 6032] wstring literals cannot be implicitly converted to const(wchar)*

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6032

Elie Morisse syniu...@gmail.com changed:

   What|Removed |Added

 CC||syniu...@gmail.com

--- Comment #3 from Elie Morisse syniu...@gmail.com ---
   const(char)* s = fooc; // fails too 

Any rationale behind this?

--


Re: how does isInputRange(T) actually work?

2015-04-21 Thread anonymous via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 19:17:56 UTC, kevin wrote:

On Tuesday, 21 April 2015 at 19:13:34 UTC, Meta wrote:

On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:

On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:

enum bool isInputRange = is(typeof(
 (inout int = 0)
 {
 R r = R.init; // can define a range object
 if (r.empty) {}   // can test for empty
 r.popFront(); // can invoke popFront()
 auto h = r.front; // can get the front of the range
 }));

[...]

Don't lambdas need a = token?


No, D has two variants of function/delegate literal or lambda 
syntax:


1) with =: parameters = expression
Some examples:
(int a) = a + 2
a = a + 2
(a, b) = a + b
() = 2

2) with braces: (parameters) {statements}
Same examples as above:
(int a) {return a + 2;}
(a) {return a + 2;}
(a, b) {return a + b;}
{return 2;}

As you can see, a lot is optional there.

In the spec: http://dlang.org/expression.html#FunctionLiteral

Also, what is the purpose of typeof? I would have expected a 
simple is() to work just fine.


(In this most simple form,) `is` evaluates to true if the 
argument is a valid type. A function/delegate literal isn't a 
type.


If you passed the lambda expression itself to `is`, the result 
would always be false. As it is, the result is true when the 
lambda expression compiles (so it has a valid type).


More about the IsExpression: 
http://dlang.org/expression.html#IsExpression


oversight with input ranges

2015-04-21 Thread ketmar via Digitalmars-d
here's the interesting oversight for isInputRange:
https://issues.dlang.org/show_bug.cgi?id=14478

so be careful: ranges with non-copyable elements aren't input ranges for 
now. ;-)

signature.asc
Description: PGP signature


Re: Example for Documentation?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d
On 4/21/15 11:25 AM, Marc =?UTF-8?B?U2Now7x0eiI=?= schue...@gmx.net 
wrote:

On Tuesday, 21 April 2015 at 14:25:29 UTC, Steven Schveighoffer wrote:

On 4/21/15 10:07 AM, Chris wrote:

Here's bearophile's version of sorting an AA by value [1]

void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort
2. http://dlang.org/hash-map.html


We should not be promoting string-based lambdas:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key  b.key);



I find the strings to be more readable, simply because they are shorter.
I would probably even prefer normal  quotes.


quoted lambdas are indeed shorter, but the issue with them is that ab 
instantiates a different template than a  b, whereas the lambda does not.


In fact, that is why we added shorthand lambdas to the language. Note 
that in this case, it's just wasted code space and not a real issue. but 
for example, RedBlackTree!(int, a  b) is not compatible with 
RedBlackTree!(int, ab), even though they are identical.


I'm not saying we shouldn't allow string lambdas, just that we shouldn't 
encourage them as proper D code.



I think this would be a perfect addition for the disqus forum of that
function (once ddox gets to be the default). I don't want to get into
adding sample usages for every use case on every function to the
documentation.


Not for every possible use case, but I'd prefer examples demonstrating
an actual, practical application to ones that were just made up for the
sake of documentation.


This use case seems niche to me. I haven't ever had the need to sort 
an AA, and if I did, I would use a RedBlackTree.


Not discounting it, or saying it's not valid or useful, just that it's 
not such a perfect example that it needs to unseat the current example 
(sorting points by x and y).


It definitely does not belong in the AA documentation.

-Steve


how does isInputRange(T) actually work?

2015-04-21 Thread kevin via Digitalmars-d-learn

enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}));


... is the current implementation in Phobos. But I can't seem to 
understand this syntax. What is (inout int = 0)? Why can a block 
follow it?


My guess is that this is declaring some sort of function and 
testing if it is syntactically valid, but this is still strange 
to me.


Re: how does isInputRange(T) actually work?

2015-04-21 Thread kevin via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 19:13:34 UTC, Meta wrote:

On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:

On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:

enum bool isInputRange = is(typeof(
  (inout int = 0)
  {
  R r = R.init; // can define a range object
  if (r.empty) {}   // can test for empty
  r.popFront(); // can invoke popFront()
  auto h = r.front; // can get the front of the range
  }));


... is the current implementation in Phobos. But I can't seem 
to understand this syntax. What is (inout int = 0)? Why can a 
block follow it?


My guess is that this is declaring some sort of function and 
testing if it is syntactically valid, but this is still 
strange to me.


It's defining a lambda function and checking that it is 
*semantically* valid.


No idea what the `(inout int = 0)` is there for, I would have 
thought it would be fine without it.


`inout int = 0` is just `inout int n = 0` without the variable 
name, which is just `inout int n` with a default argument of 0.


Thanks for your responses. Don't lambdas need a = token? Also, 
what is the purpose of typeof? I would have expected a simple 
is() to work just fine.


Re: SDC needs you -- redux

2015-04-21 Thread deadalnix via Digitalmars-d

On Monday, 20 April 2015 at 22:40:11 UTC, Brian Schott wrote:

On Sunday, 19 April 2015 at 06:01:14 UTC, weaselcat wrote:
gofmt, much like python's standardized formatting, made 
contributing to go projects much easier IMO. While the same 
can't be done for D, hopefully dfmt becomes a standard tool 
and each dub project can just include a dfmt.conf or something 
to make contributing easier.


dfmt options go in .editorconfig with the rest of your 
project's style decisions like tabs/spaces and line length.


I agree with the OP on the tooling point, just look at C++. 
C++ had historically zero(okay, some - but it sucked! ctags 
were awful, etc.) tooling before clang hit the scene. IMO 
clang/LLVM was a complete game changer for C++ tooling, and I 
hope D can do the same.


For what it's worth, D-Scanner can output ctags information for 
D files.



Clang has a static analyzer, a formatter, a modernizer...
Hell, clang(and obv. libclang) can dump the AST right from its 
driver, and even has autocompletion built into 
it(-code-completion-at)


We now have a formatter. D-Scanner can perform some static 
analysis and dump an AST from its parser, DCD provides 
autocompletion. dfix can perform syntax upgrades.


I think your work is very valuable, but SDC is still necessary. D 
a very meta programming language, which makes having a fully 
featured front end necessary for various tooling.


Your approach certainly yield result faster, and is sufficient 
for some tooling. I see your work and SDC as complementary rather 
than stepping on each other. This is why I put tools like REPL or 
test runner in the list rather than tools like formatting, which 
you approach can already provide.


[Issue 14478] New: isInputRange failed to recognize some ranges

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14478

  Issue ID: 14478
   Summary: isInputRange failed to recognize some ranges
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: major
  Priority: P1
 Component: Phobos
  Assignee: nob...@puremagic.com
  Reporter: ket...@ketmar.no-ip.org

assume we have this code:

import std.range;
import std.stdio;

struct S {
  int n;
  @disable this (this);
}


void main () {
  S[2] s0, s1;
  foreach (ref el; chain(s0[], s1[])) writeln(el.n);
}


if we try to compile it, we got error:
(12): Error: template std.range.chain cannot deduce function from argument
types

yet if we will remove `@disable this (this);`, everything is working fine.

the bug is in `isInputRange` template:

template isInputRange(R)
{
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range (HERE!)
}));
}

line `auto h = r.front;` causes the bug. althru `front` returning ref here, we
can't declare ref variables, so `h` looses `ref` and thus requires copying. yet
we explicitly disabled copying for our struct, so `isInputRange` is failing.

here is the proposed fix:

template isInputRange(R)
{
enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
static void testfront(T) (auto ref T n) {} testfront(r.front);
}));
}

here we using nested function with `auto ref` to not loose `ref` from `front`.

it would be good to check if some other templates requires such fix too.

p.s. with the proposed fix sample code works like a charm.

--


[Issue 14477] New: Nullable does not work with structs with default constructor disabled

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14477

  Issue ID: 14477
   Summary: Nullable does not work with structs with default
constructor disabled
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: Phobos
  Assignee: nob...@puremagic.com
  Reporter: jus...@economicmodeling.com

The following simple code does not compile:
--
import std.typecons;
struct Foo
{
int x;
@disable this();
this(int value) { x=value; }
}

void main()
{
Nullable!Foo foo;
}
--
test.d(14): Error: variable test.main.foo default construction is disabled for
type Nullable!(Foo)

Of course, one of the major use-cases for Nullable is to provide a way to
default-initialize such a struct to a null state.

--


DMD Copyright string

2015-04-21 Thread Colin via Digitalmars-d

I notice when you run dmd with no args, it will print:
DMD64 D Compiler v2.067.0
Copyright (c) 1999-2014 by Digital Mars written by Walter Bright


Surely that's meant to be 2015?
Walter should prob fix that. Someone could steal D!


Re: Example for Documentation?

2015-04-21 Thread Chris via Digitalmars-d
On Tuesday, 21 April 2015 at 18:10:25 UTC, Steven Schveighoffer 
wrote:

On 4/21/15 2:06 PM, Chris wrote:


multiSort should at least be added to the cheat sheet in
std.algorithm.sorting.


This I can agree with. Can you add a pull request for it?

-Steve


Yeah, but I have to ask a stupid question. How do I add a PR? 
I've never done it before.


Re: SDC needs you -- redux

2015-04-21 Thread Atila Neves via Digitalmars-d

On Tuesday, 21 April 2015 at 15:01:59 UTC, Dan Olson wrote:

Brian Schott briancsch...@gmail.com writes:
For what it's worth, D-Scanner can output ctags information 
for D

files.


Brian, how about etags for emacs?


Better:

https://github.com/atilaneves/ac-dcd

Atila


[Issue 14478] isInputRange failed to recognize some ranges

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14478

--- Comment #1 from Ketmar Dark ket...@ketmar.no-ip.org ---
seems that `isBidirectionalRange` can be affected too.

--


[Issue 14477] Nullable does not work with structs with default constructor disabled

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14477

Justin Whear jus...@economicmodeling.com changed:

   What|Removed |Added

   Keywords||pull
 Status|NEW |ASSIGNED
URL||https://github.com/D-Progra
   ||mming-Language/phobos/pull/
   ||3213

--


Re: Example for Documentation?

2015-04-21 Thread Justin Whear via Digitalmars-d
On Tue, 21 Apr 2015 18:34:35 +, Chris wrote:
 Yeah, but I have to ask a stupid question. How do I add a PR? I've never
 done it before.

This wiki page will walk you through it:
http://wiki.dlang.org/Pull_Requests


Re: how does isInputRange(T) actually work?

2015-04-21 Thread John Colvin via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:

enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}));


... is the current implementation in Phobos. But I can't seem 
to understand this syntax. What is (inout int = 0)? Why can a 
block follow it?


My guess is that this is declaring some sort of function and 
testing if it is syntactically valid, but this is still strange 
to me.


It's defining a lambda function and checking that it is 
*semantically* valid.


No idea what the `(inout int = 0)` is there for, I would have 
thought it would be fine without it.


Re: how does isInputRange(T) actually work?

2015-04-21 Thread Meta via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 19:11:43 UTC, John Colvin wrote:

On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:

enum bool isInputRange = is(typeof(
   (inout int = 0)
   {
   R r = R.init; // can define a range object
   if (r.empty) {}   // can test for empty
   r.popFront(); // can invoke popFront()
   auto h = r.front; // can get the front of the range
   }));


... is the current implementation in Phobos. But I can't seem 
to understand this syntax. What is (inout int = 0)? Why can a 
block follow it?


My guess is that this is declaring some sort of function and 
testing if it is syntactically valid, but this is still 
strange to me.


It's defining a lambda function and checking that it is 
*semantically* valid.


No idea what the `(inout int = 0)` is there for, I would have 
thought it would be fine without it.


`inout int = 0` is just `inout int n = 0` without the variable 
name, which is just `inout int n` with a default argument of 0.


Re: SDC needs you -- redux

2015-04-21 Thread Brian Schott via Digitalmars-d

On Tuesday, 21 April 2015 at 15:01:59 UTC, Dan Olson wrote:

Brian Schott briancsch...@gmail.com writes:
For what it's worth, D-Scanner can output ctags information 
for D

files.


Brian, how about etags for emacs?


Because the documentation for etags consists of a Wikipedia 
article and a Stack Overflow post. I'm far too lazy to 
reverse-engineer Emacs' source code.


https://github.com/Hackerpilot/Dscanner/issues/223


Re: how does isInputRange(T) actually work?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/21/15 3:11 PM, John Colvin wrote:

On Tuesday, 21 April 2015 at 19:06:39 UTC, kevin wrote:

enum bool isInputRange = is(typeof(
(inout int = 0)
{
R r = R.init; // can define a range object
if (r.empty) {}   // can test for empty
r.popFront(); // can invoke popFront()
auto h = r.front; // can get the front of the range
}));


... is the current implementation in Phobos. But I can't seem to
understand this syntax. What is (inout int = 0)? Why can a block
follow it?

My guess is that this is declaring some sort of function and testing
if it is syntactically valid, but this is still strange to me.


It's defining a lambda function and checking that it is *semantically*
valid.

No idea what the `(inout int = 0)` is there for, I would have thought it
would be fine without it.


inout has a rule that you can't declare a type of inout as a local 
variable unless there is an inout parameter/return. I'm not sure if this 
rule still exists (it causes weird shit like the above to be required). 
I know some inout rules that I devised have been relaxed for the benefit 
of generic function sanity.


The inout int = 0 gives the lambda an inout parameter, in case you are 
doing isInputRange!(inout(int)[]), then you can validly declare a range 
of type R inside your function.


Alternatively, you could have the lambda take an R as a parameter. Or 
fix the semantics so that inout local variable acts like immutable 
inside a non-inout function.


-Steve


Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 07:01:27 UTC, Per Nordlöw wrote:

On Tuesday, 21 April 2015 at 06:56:33 UTC, Per Nordlöw wrote:

On Monday, 20 April 2015 at 13:49:41 UTC, John Colvin wrote:

On Thursday, 16 April 2015 at 18:12:35 UTC, Nordlöw wrote:
Is there a way to CT-query the arity of all opIndex and 
opSlice overloads?


Further, this is slightly related to a way to query the 
dimensions of a data-type. If possible I would like to have a 
type trait for this. This type-trait could then be used both 
for this challenge but also for figuring out how to create 
randomized instances of multi-dimensional structures. This can 
be used for automatic generation of data instances of 
parameters in algorithm testing and benchmarking.


template dimensionality (S) {
  template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
  enum count_dim = count_dim!(i+1);
else enum count_dim = i;
  }

  alias dimensionality = count_dim!();
}

Then you throw in some more stuff to detect 1-dimensional cases.


std.net.curl.get failing to resolve google.com

2015-04-21 Thread Jakob Ovrum via Digitalmars-d-learn

test.d

---
void main()
{
import std.net.curl;
import std.stdio;

writeln(get(http://google.com;));
}
---

rdmd -g test.d

---
std.net.curl.CurlException@std\net\curl.d(3691): couldn't resolve 
host name on handle 26B4878


0x0040572A in pure @safe void 
std.exception.bailOut!(std.net.curl.CurlException).bailOut(immutable(char)[], 
uint, const(char[])) at 
d:\Programming\D\dmd.2.067.0.windows\dmd2\windows\bin\..\..\src\phobos\std\exception.d(400)
0x004056D2 in pure @safe bool 
std.exception.enforce!(std.net.curl.CurlException, 
bool).enforce(bool, lazy const(char)[], immutable(char)[], uint) 
at 
d:\Programming\D\dmd.2.067.0.windows\dmd2\windows\bin\..\..\src\phobos\std\exception.d(352)

0x00431356 in void std.net.curl.Curl._check(int)
0x004064F6 in char[] std.net.curl.get!(std.net.curl.HTTP, 
char).get(const(char)[], std.net.curl.HTTP) at 
d:\Programming\D\dmd.2.067.0.windows\dmd2\windows\bin\..\..\src\phobos\std\net\curl.d(405)
0x004020A4 in char[] std.net.curl.get!(std.net.curl.AutoProtocol, 
char).get(const(char)[], std.net.curl.AutoProtocol) at 
d:\Programming\D\dmd.2.067.0.windows\dmd2\windows\bin\..\..\src\phobos\std\net\curl.d(419)

0x0040202A in _Dmain
0x00423C0A in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x00423BDF in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()

0x00423AF7 in _d_run_main
0x004237A0 in main
0x0046E025 in mainCRTStartup
0x76D0338A in BaseThreadInitThunk
0x77269F72 in RtlInitializeExceptionChain
0x77269F45 in RtlInitializeExceptionChain
---

Using DMD32 D Compiler v2.067.0 (release version) on Windows.

google.com resolves fine when using ping or a browser, so what 
could be causing this?


It happens with every other host name I've tried, too.


Re: multiSort for sorting AA by value

2015-04-21 Thread bearophile via Digitalmars-d-learn

Chris:

I'm happy with it, but maybe there is a more concise 
implementation?


This is a bit shorter and a bit better (writefln is not yet able 
to format tuples nicely):



void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}


Bye,
bearophile


[Issue 14080] No mention of documented unittests on ddoc's page

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14080

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dlang.org

https://github.com/D-Programming-Language/dlang.org/commit/738506db345b483657cd11c63ad49ba1b566d5a5
Fix issue 14080

https://github.com/D-Programming-Language/dlang.org/commit/98c8d8146dac68a2fdd2d04a9596011c2ef7d187
Merge pull request #971 from nomad-software/issue_14080

Issue 14080 - No mention of documented unittests on ddoc's page

--


std.datetime.parseRFC822DateTime

2015-04-21 Thread Jakob Ovrum via Digitalmars-d-learn
std.datetime contains parseRFC822DateTime to convert from an 
RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19 
-0800) to a SysTime.


Does it contain anything for the converse - converting from a 
SysTime to Sat, 6 Jan 1990 12:14:19 -0800?


If not, should it?


Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn
As an aside, I've put a bit of work into the generic 
multidimensional containers problem lately and have an interface 
generating library as a result.


https://github.com/evenex/autodata

It's still in the nascent stages but contains a lot of tools for 
working with multidimensional structures.


You can take a look at the definition in the spaces/ and 
topology/ folder (and the unittests in operators/) to get an idea 
of how it works - basically generates all the opIndex/opSlice 
stuff (with safety checks) under a unified system; end result 
being that you just write the business logic for your types, 
mixin the operators, and they will all interoperate with uniform 
semantics.


The definitions for the types themselves tend to be very short 
and to-the-point as a result. I've taken old containers of mine 
whose defs were pushing 300 lines and reimplemented them in ~50 
using the autodata operators.


A full set of traits and multidim range compositions (map, zip, 
take, cycle, repeat) are present as well. A lot of them are full 
or partial reimplementations of Phobos stuff.


It's pretty poorly documented (for now) but I'm happy to answer 
questions (and make documentation based on that) if you decide to 
check it out.


Re: D vs nim

2015-04-21 Thread Chris via Digitalmars-d

On Tuesday, 21 April 2015 at 08:29:11 UTC, Russel Winder wrote:
On Mon, 2015-04-20 at 13:05 -0700, Parke via Digitalmars-d 
wrote:



[…]

Nim includes an install.sh script.  It worked for me.


install.sh calls koch, both of these are created by running 
build.sh.


Running koch builds the executable for installation which 
requires extra
compilations one critical part of which does not happen. So the 
built

system is fine but the installable version will not build.

According to the Nim docs ( http://nim-lang.org/download.html 
) There
are other ways to install Nim (like using the install.sh 
script), but

these tend to cause more problems.  I am not sure what these
unspecified problems are.  I used Nim only briefly, so perhaps 
there

problems are lurking and I just did not encounter them.


The Nim developers seem disinterested in fixing things for 
early adopters,

which is sad.


Neither is it a good strategy. How are they supposed to build up 
a user base (and get input), if they don't care for potential 
users, especially now that they are going on about how great the 
language is.


Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn
Maybe something like bearophile's example should go into the 
documentation of std.algorithm.sorting.multiSort. It's a common 
enough thing in programming.


Re: std.experimental.testing PR review

2015-04-21 Thread Atila Neves via Digitalmars-d
On Tuesday, 21 April 2015 at 08:17:37 UTC, Robert burner Schadek 
wrote:

On Monday, 20 April 2015 at 14:29:33 UTC, Atila Neves wrote:

I saw links to PRs past with generated docs but have/had no
idea how to get a similar result. Besides the html make target,
what is it a person has to do exactly? I'm going to edit the 
wiki


http://wiki.dlang.org/Building_DMD#Building_the_Docs


This part I'd figured out; it's the getting it online for others 
to see (and the need to do this as part of the PR) I had troubles 
with.


I did a lot of google searches for site:dlang.org 
std.experimental.logger ;)


Atila


Re: Today's programming challenge - How's your Range-Fu ?

2015-04-21 Thread John Colvin via Digitalmars-d

On Tuesday, 21 April 2015 at 13:06:22 UTC, JohnnyK wrote:

On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:

On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need 
the number of graphemes. (d|)?string.length gives you the 
number of code units.


Even that's not really true.


Why? Doesn't string.length give you the byte count?


I was talking about the you'll need the number of graphemes. 
s.length returns the number of elements in the slice, which in 
the case of D's string types gives is the same as the number of 
code units.



I think what you are looking for is string.sizeof?

From the D reference

.sizeof	Returns the array length multiplied by the number of 
bytes per array element.
.length	Returns the number of elements in the array. This is a 
fixed quantity for static arrays. It is of type size_t.


That is for static arrays only. .sizeof for slices is just 
size_t.sizeof + T*.sizeof i.e. 8 on 32 bit, 16 on 64 bit.


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-21 Thread Atila Neves via Digitalmars-d

On Tuesday, 21 April 2015 at 02:00:49 UTC, JT wrote:

On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:

...
maybe(userManager).CurrentUser.GetRole().Name ?
...


Where can I find this maybe monad implementation?


In the Haskell prelude? :P

There was a blog post about monads in D I can no longer find. 
Other than that the only other one I know of is the gist I posted.


Atila


Re: Today's programming challenge - How's your Range-Fu ?

2015-04-21 Thread JohnnyK via Digitalmars-d

On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:

On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need 
the number of graphemes. (d|)?string.length gives you the 
number of code units.


Even that's not really true.


Why? Doesn't string.length give you the byte count?


I think what you are looking for is string.sizeof?

From the D reference

.sizeof	Returns the array length multiplied by the number of 
bytes per array element.
.length	Returns the number of elements in the array. This is a 
fixed quantity for static arrays. It is of type size_t.



Isn't a string type an array of characters (char[] string UTF-8, 
wchar[] string UTF-16, and dchar[] string UTF-32) and not 
arbitrary bytes?


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-21 Thread Atila Neves via Digitalmars-d

On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:

On Monday, 20 April 2015 at 15:37:02 UTC, Atila Neves wrote:

On Monday, 20 April 2015 at 12:16:21 UTC, Jakob Ovrum wrote:

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement 
the same thing in nim in 2 lines of code


template `?.`(a, b): expr =
if a != nil: a.b else: nil

template `??`(a, b): expr =
if a != nil: a else: b


This is what I came up with for D:

  https://gist.github.com/JakobOvrum/7e3a7bc130ab7db28de3

Meh.


Here's mine:

https://gist.github.com/atilaneves/727d63f0a7029032d7ac



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, 
GetRole, Name);


D (Atila):
auto roleName = ?


I was trying to write a Maybe monad in D, not make it easy to use.
An easy to use solution would probably make use of opDispatch. 
But...:


auto roleName = userManager.bind!(a = a.CurrentUser.bind!(b = 
b.GetRole.bind!(c = c.Name);

//roleName's type is Maybe!string.

The only reason monads are readable in Haskell is due to do 
syntax sugar.


Re: Trial migration of Dsource bindings project to Github

2015-04-21 Thread John Colvin via Digitalmars-d-announce
On Monday, 20 April 2015 at 23:42:54 UTC, Vladimir Panteleev 
wrote:

On Monday, 20 April 2015 at 22:57:51 UTC, Stewart Gordon wrote:
I committed some updates the other day and they seem they have 
gone straight into the online repository.


Committing is a local (non-network) operation in git, so you 
must have pushed them afterwards, or your GUI has done this for 
you.


I think he's using github's svn support The repository is still a 
git repository.


Re: Updating ddoc to support modern HTML tags

2015-04-21 Thread Jakob Ovrum via Digitalmars-d

On Tuesday, 21 April 2015 at 07:34:19 UTC, Walter Bright wrote:

On 4/20/2015 11:39 PM, Jakob Ovrum wrote:

It's still a long road before we even output correct HTML,


??


Have you ever tried validating the HTML output for dlang.org? 
It's a mess, see this PR for some details[1].


[1] https://github.com/D-Programming-Language/dlang.org/pull/96


Re: Updating ddoc to support modern HTML tags

2015-04-21 Thread Walter Bright via Digitalmars-d

On 4/20/2015 11:39 PM, Jakob Ovrum wrote:

It's still a long road before we even output correct HTML,


??


Re: CT-String as a Symbol

2015-04-21 Thread via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:

template dimensionality (S) {
  template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
  enum count_dim = count_dim!(i+1);
else enum count_dim = i;
  }

  alias dimensionality = count_dim!();
}

Then you throw in some more stuff to detect 1-dimensional cases.


Great! I guess a template restriction on opSlice would be in 
Place aswell.


One thing: Why aren't you using opIndex instead? If there are 
types that have opIndex but not opSlice defined then 
dimensionality() could cover more types, right?


Re: D vs nim

2015-04-21 Thread Russel Winder via Digitalmars-d
On Mon, 2015-04-20 at 13:05 -0700, Parke via Digitalmars-d wrote:
 
[…]
 Nim includes an install.sh script.  It worked for me.

install.sh calls koch, both of these are created by running build.sh.

Running koch builds the executable for installation which requires extra
compilations one critical part of which does not happen. So the built
system is fine but the installable version will not build.

 According to the Nim docs ( http://nim-lang.org/download.html ) There
 are other ways to install Nim (like using the install.sh script), but
 these tend to cause more problems.  I am not sure what these
 unspecified problems are.  I used Nim only briefly, so perhaps there
 problems are lurking and I just did not encounter them.

The Nim developers seem disinterested in fixing things for early adopters,
which is sad.
-- 
Russel.
=
Dr Russel Winder t:+44 20 7585 2200   voip:sip:
russel.win...@ekiga.net
41 Buckmaster Road   m:+44 7770 465 077   xmpp:rus...@winder.org.uk
London SW11 1EN, UK  w: www.russel.org.uk skype:russel_winder


signature.asc
Description: This is a digitally signed message part


[Issue 12920] ICE: Internal error: backend/symbol.c 1035

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12920

--- Comment #3 from Marc Schütz schue...@gmx.net ---
Is it really a duplicate? The code in the other bug is clearly invalid, but
this one should work IMO.

--


[Issue 14476] core.thread unit tests failing on FreeBSD 9+

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14476

--- Comment #1 from Joakim db...@joakim.fea.st ---
I can confirm that that last unittest is the one causing the problem on i386
also, as commenting it out gets core.thread to pass and the tests to fail here
instead:

Testing link
Testing load
Testing linkD
Testing linkDR
Testing loadDR
Testing host
gmake[1]: *** [obj/freebsd/32/host.done] Segmentation fault: 11 (core dumped)

This is with dmd/druntime HEAD on FreeBSD 9.1 stable from a couple years ago
running in a VM.

--


Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 08:09:38 UTC, Per Nordlöw wrote:

On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:

template dimensionality (S) {
 template count_dim (uint i = 0) {
   static if (is (typeof(S.init.opSlice!i (0,0
 enum count_dim = count_dim!(i+1);
   else enum count_dim = i;
 }

 alias dimensionality = count_dim!();
}

Then you throw in some more stuff to detect 1-dimensional 
cases.


Great! I guess a template restriction on opSlice would be in 
Place aswell.


One thing: Why aren't you using opIndex instead? If there are 
types that have opIndex but not opSlice defined then 
dimensionality() could cover more types, right?


So, if the type is multidimensional, that means its using the new 
opIndex/opSlice syntax that was designed for multidimensional 
structures. So I know that, if dim  1, opSlice!i must be 
defined, and (assuming we are only working with integral indices 
here) I can instantiate it with opSlice!i (0,0).


For other types, you would throw in a test for a length member, 
or for front, and know that you have a 1-dimensional type.


Alternatively, if we're assuming only integral indices, a 
recursive attempt to get the typeof(opIndex (Repeat!(i, 0))) 
would probably handle all the opIndex-but-not-opSlice cases (but 
you still need to handle non-indexed ranges and D arrays 
specially).


Re: std.experimental.testing PR review

2015-04-21 Thread Robert burner Schadek via Digitalmars-d

On Monday, 20 April 2015 at 14:29:33 UTC, Atila Neves wrote:

I saw links to PRs past with generated docs but have/had no
idea how to get a similar result. Besides the html make target,
what is it a person has to do exactly? I'm going to edit the 
wiki


http://wiki.dlang.org/Building_DMD#Building_the_Docs


[Issue 14468] [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14468

Kenji Hara k.hara...@gmail.com changed:

   What|Removed |Added

   Keywords||pull, rejects-valid

--- Comment #3 from Kenji Hara k.hara...@gmail.com ---
https://github.com/D-Programming-Language/dmd/pull/4603

--


Re: Calypso: Direct and full interfacing to C++

2015-04-21 Thread Elie Morisse via Digitalmars-d-announce

On Thursday, 16 April 2015 at 06:43:25 UTC, Suliman wrote:
Could anybody wrote very simple tutorial, that show how to use 
any popular C/C++ lib without binding? I mean step by step 
manual.


Also it would be nice to get binary builds for Windows to test.


Sorry for the wait.

So Calypso still can't load the MSVC C++ standard lib. I thought 
Kelly managed to build some STL examples but actually it's not 
remotely possible yet. The main blocker is that template 
instances often depend on each other (but not in their entirety) 
which cause forward reference errors in DMD.


However it works with MinGW-w64, but this wasn't remotely 
straightforward either, I had to modify Clang to make it detect 
correctly the MinGW paths (which are hardcoded in Clang and 
obsolete):


 - install mingw-w64, in the installer choose 4.9.2, DWARF 
exceptions and POSIX threads

 - download http://homo-nebulus.fr/dlang/Calypso_mingw-w64.7z
 - extract the archive over the MinGW root directory (where the 
bin/, etc/, etc. folders lie)

 - correct the paths in /etc/ldc.conf
 - add Z:\path\to\MingW\bin to your PATH environment variable in 
your System settings (e.g follow: 
http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx)


Then you can build the examples in tests/


Re: C++/C mangleof inconsistency for OS X

2015-04-21 Thread Dan Olson via Digitalmars-d
Jacob Carlborg d...@me.com writes:

 On 2015-04-20 18:33, Dan Olson wrote:
 An observation on OSX w/ 2.067: mangleof for C++ (and D) names produces
 the actual object file symbol while mangleof for C names strips a
 leading underscore.

 Is this intended?  If so what is rationale?

 I don't think it's intentional. The point of mangleof is to evaluate
 to the actual mangled name, as it appears in the object file.

Thanks Jacob.

In that case, mangleof for extern(C) names on OS X and other systems
that add a leading underscore should include the underscore.

extern(C) int x;
version(linux) pragma(msg, foo.mangleof); // x
version(OSX) pragma(msg, foo.mangleof);   // _x

I'm trying to understand because ldc is different than dmd, and it is
related to proper debugging on systems with leading underscores.
pragma(mangle, name) is wrapped up in this too.  This needs to be right
to help D expand to other systems.
-- 
Dan


Re: std.experimental.testing PR review

2015-04-21 Thread Jacob Carlborg via Digitalmars-d

On 2015-04-21 15:56, Robert burner Schadek wrote:


I did use github pages https://pages.github.com/


I have used dropbox.

--
/Jacob Carlborg


Re: SDC needs you -- redux

2015-04-21 Thread Dan Olson via Digitalmars-d
Brian Schott briancsch...@gmail.com writes:
 For what it's worth, D-Scanner can output ctags information for D
 files.

Brian, how about etags for emacs?


[Issue 12920] ICE: Internal error: backend/symbol.c 1035

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12920

Martin Krejcirik m...@krej.cz changed:

   What|Removed |Added

 CC||m...@krej.cz
   Hardware|x86_64  |All
 OS|Linux   |All

--- Comment #4 from Martin Krejcirik m...@krej.cz ---
(In reply to Marc Schütz from comment #3)
 Is it really a duplicate? The code in the other bug is clearly invalid, but
 this one should work IMO.

In this example 'v' is a runtime variable and as such it cannot be a case
variable.

If a,b,c were enums, it would compile. 

But I don't understand why uint a,b,c gives error message
Error: variable v cannot be read at compile time

but int a,b,c does not. So maybe it's a different bug.

--


Re: Reuse object memory?

2015-04-21 Thread via Digitalmars-d-learn

On Monday, 20 April 2015 at 21:36:35 UTC, Ali Çehreli wrote:

final class Foo {
uint id;

@nogc
this(uint id) {
this.id = id;
}
}

C reuse(C, T...)(ref C old, T ctorParams)
{
import std.conv;
import std.typetuple;

enum objectSize = __traits(classInstanceSize, C);

void* oldPlace = cast(void*)old;


It's probably better to call the destructor here before calling 
emplace, to complete the lifecycle of the old object.


C newObject = emplace!C(oldPlace[0..objectSize], 
ctorParams);


old = null;

return newObject;
}

void main()
{
Foo f = new Foo(42);

auto f2 = f.reuse(43);

assert(f is null);
assert(f2.id == 43);
}

Ali




Re: std.experimental.testing PR review

2015-04-21 Thread Robert burner Schadek via Digitalmars-d

On Tuesday, 21 April 2015 at 13:18:59 UTC, Atila Neves wrote:


This part I'd figured out; it's the getting it online for 
others to see (and the need to do this as part of the PR) I had 
troubles with.


I did use github pages https://pages.github.com/



Re: User defined properties signatures

2015-04-21 Thread via Digitalmars-d-learn

On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis wrote:
There may be languages out there which take the the return type 
into account

when overloading, but I've never seen one.


Rust does, as far as I know.

I don't think that the ambiguities are an insurmountable 
obstacle. It's probably sufficient to error out when a call is 
ambiguous in its context, as can already happen during 
overloading.


Also note that, as Ali pointed out, with multiple alias this we 
will be able to implement this indirectly. Which means that the 
compiler needs to deal with exactly the same ambiguities anyway. 
Might as well just take the return type into consideration 
directly.


Re: User defined properties signatures

2015-04-21 Thread Dicebot via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 13:27:48 UTC, Marc Schütz wrote:
On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis 
wrote:
There may be languages out there which take the the return 
type into account

when overloading, but I've never seen one.


Rust does, as far as I know.


And this is incredibly frustrating approach that harms both 
readability and maintainability (you can't cut/paste RHS of an 
expression anymore without additional changes to the context). I 
have actually mentioned that when doing first impressions post 
about Rust.


Example for Documentation?

2015-04-21 Thread Chris via Digitalmars-d

Here's bearophile's version of sorting an AA by value [1]

void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort
2. http://dlang.org/hash-map.html

I think it's quite a common task and people will duckduckgo or 
google for it.



[1] 
http://forum.dlang.org/thread/jhcmegyrasivotqfm...@forum.dlang.org#post-flvdtewuyehvdetoxjrw:40forum.dlang.org


Re: Example for Documentation?

2015-04-21 Thread Steven Schveighoffer via Digitalmars-d

On 4/21/15 10:07 AM, Chris wrote:

Here's bearophile's version of sorting an AA by value [1]

void main() {
 import std.stdio: writeln;
 import std.algorithm.sorting: multiSort;
 import std.array: array;

 const size_t[string] wCount = [
 hamster: 5,
 zorro: 80,
 troll: 90,
 algorithm: 80,
 beer: 80
 ];

 auto pairs = wCount.byKeyValue.array;
 assert(wCount.length == pairs.length);
 pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
 assert(pairs[2].key == beer);
 foreach (const ref it; pairs)
 writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort
2. http://dlang.org/hash-map.html


We should not be promoting string-based lambdas:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key  b.key);

I think this would be a perfect addition for the disqus forum of that 
function (once ddox gets to be the default). I don't want to get into 
adding sample usages for every use case on every function to the 
documentation.


-Steve


[Issue 14048] std.container documentation issues

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14048

Gary Willoughby d...@nomad.so changed:

   What|Removed |Added

 CC||d...@nomad.so

--- Comment #1 from Gary Willoughby d...@nomad.so ---
This looks like this has been fixed.

--


Re: std.datetime.parseRFC822DateTime

2015-04-21 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via Digitalmars-d-learn wrote:
 std.datetime contains parseRFC822DateTime to convert from an
 RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19
 -0800) to a SysTime.

 Does it contain anything for the converse - converting from a
 SysTime to Sat, 6 Jan 1990 12:14:19 -0800?

 If not, should it?

No, it does not contain the reverse. It was added specifically for the
installer. If it weren't for that, std.datetime wouldn't support it at all.
It's a horrible format that should just die. The only reason to use it is
because the e-mail spec (and thus specs like HTTP) unfortunately uses it.
However, anyone that's going to need to generate the format for anything
like that is going to need a lot more than that that Phobos doesn't provide
anyway, so I really don't think that it's much of a loss. Regardless, I'm
strongly of the opinion that anything dealing with that format should be
restricted to a library for e-mail or HTTP, and if it weren't for the fact
that the installer needed to be able to read it (I forget why), I would have
argued strongly against adding parseRFC822DateTime to Phobos.

- Jonathan M Davis



Re: std.datetime.parseRFC822DateTime

2015-04-21 Thread Jakob Ovrum via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 10:28:32 UTC, Jonathan M Davis wrote:
On Tuesday, April 21, 2015 08:14:10 Jakob Ovrum via 
Digitalmars-d-learn wrote:

std.datetime contains parseRFC822DateTime to convert from an
RFC822/RFC5322 formatted string (ala Sat, 6 Jan 1990 12:14:19
-0800) to a SysTime.

Does it contain anything for the converse - converting from a
SysTime to Sat, 6 Jan 1990 12:14:19 -0800?

If not, should it?


No, it does not contain the reverse. It was added specifically 
for the
installer. If it weren't for that, std.datetime wouldn't 
support it at all.
It's a horrible format that should just die. The only reason to 
use it is
because the e-mail spec (and thus specs like HTTP) 
unfortunately uses it.
However, anyone that's going to need to generate the format for 
anything
like that is going to need a lot more than that that Phobos 
doesn't provide
anyway, so I really don't think that it's much of a loss. 
Regardless, I'm
strongly of the opinion that anything dealing with that format 
should be
restricted to a library for e-mail or HTTP, and if it weren't 
for the fact
that the installer needed to be able to read it (I forget why), 
I would have

argued strongly against adding parseRFC822DateTime to Phobos.

- Jonathan M Davis


I needed it for the If-Modified-Since HTTP header, through 
std.net.curl.HTTP.addRequestHeader.


Phobos has HTTP support and this is the preferred date format 
according to spec. Phobos should support it.


Re: multiSort for sorting AA by value

2015-04-21 Thread Chris via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 11:46:24 UTC, bearophile wrote:

Chris:

I'm happy with it, but maybe there is a more concise 
implementation?


This is a bit shorter and a bit better (writefln is not yet 
able to format tuples nicely):



void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}


Bye,
bearophile


Nice!


[Issue 14048] std.container documentation issues

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14048

grogan.co...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #2 from grogan.co...@gmail.com ---
Yep, it has!

--


Structural exhaustive matching

2015-04-21 Thread Jadbox via Digitalmars-d-learn
What's the best equivalent to Rust's structural enum/pattern 
(match)ing? Is it also possible to enforce exhaustive matches? 
Basically, I'm curious on what the best way to do ADTs in D.


Re: Structural exhaustive matching

2015-04-21 Thread bearophile via Digitalmars-d-learn

Jadbox:


I'm curious on what the best way to do ADTs in D.


Sometimes there's no best way, there are several alternative ways 
with different tradeoffs. D isn't a functional language and 
there's no really good way to do ADTs in D. You can use plus a 
final switch. Or you can use Algebraic from Phobos. Sometimes 
you can use another Phobos function that simulates an improved 
switch. Or often you can just give up at using ADTs in D and use 
what other solutions D offers you (like OOP).


Bye,
bearophile


Re: Example for Documentation?

2015-04-21 Thread bachmeier via Digitalmars-d
On Tuesday, 21 April 2015 at 14:25:29 UTC, Steven Schveighoffer 
wrote:

On 4/21/15 10:07 AM, Chris wrote:

Here's bearophile's version of sorting an AA by value [1]

void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. 
http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort

2. http://dlang.org/hash-map.html


We should not be promoting string-based lambdas:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key  
b.key);


I think this would be a perfect addition for the disqus forum 
of that function (once ddox gets to be the default). I don't 
want to get into adding sample usages for every use case on 
every function to the documentation.


-Steve


What about putting it on the wiki and then providing a link with 
a label like View other examples on the wiki. That would (a) be 
available now, and (b) let users know it's there, as few would 
know to look on the wiki. As I recall, the plan with Discus is to 
have something like PHP's documentation, and that's not a great 
solution.


Re: Example for Documentation?

2015-04-21 Thread via Digitalmars-d
On Tuesday, 21 April 2015 at 14:25:29 UTC, Steven Schveighoffer 
wrote:

On 4/21/15 10:07 AM, Chris wrote:

Here's bearophile's version of sorting an AA by value [1]

void main() {
import std.stdio: writeln;
import std.algorithm.sorting: multiSort;
import std.array: array;

const size_t[string] wCount = [
hamster: 5,
zorro: 80,
troll: 90,
algorithm: 80,
beer: 80
];

auto pairs = wCount.byKeyValue.array;
assert(wCount.length == pairs.length);
pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
assert(pairs[2].key == beer);
foreach (const ref it; pairs)
writeln(it.key, : , it.value);
}

Should we add it to the documentation of

1. 
http://dlang.org/phobos/std_algorithm_sorting.html#.multiSort

2. http://dlang.org/hash-map.html


We should not be promoting string-based lambdas:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key  
b.key);




I find the strings to be more readable, simply because they are 
shorter. I would probably even prefer normal  quotes.


Compare:

pairs.multiSort!((a, b) = a.value  b.value, (a, b) = a.key  
b.key);

pairs.multiSort!(q{a.value  b.value}, q{a.key  b.key});
pairs.multiSort!(a.value  b.value, a.key  b.key);

I think this would be a perfect addition for the disqus forum 
of that function (once ddox gets to be the default). I don't 
want to get into adding sample usages for every use case on 
every function to the documentation.


Not for every possible use case, but I'd prefer examples 
demonstrating an actual, practical application to ones that were 
just made up for the sake of documentation.


[Issue 7392] ICE(symbol.c) on invalid nested case statement

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=7392

Martin Krejcirik m...@krej.cz changed:

   What|Removed |Added

 CC||m...@krej.cz

--


[Issue 14479] isInputRange returns false on a slice of noncopyables.

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14479

Brian Smith block8...@gmail.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #1 from Brian Smith block8...@gmail.com ---


*** This issue has been marked as a duplicate of issue 14478 ***

--


[Issue 14478] isInputRange failed to recognize some ranges

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14478

Brian Smith block8...@gmail.com changed:

   What|Removed |Added

 CC||block8...@gmail.com

--- Comment #2 from Brian Smith block8...@gmail.com ---
*** Issue 14479 has been marked as a duplicate of this issue. ***

--


Re: CT-String as a Symbol

2015-04-21 Thread Nordlöw

On Tuesday, 21 April 2015 at 20:30:00 UTC, Vlad Levenfeld wrote:
Should work for any case I can think of (assuming integral 
indices).


Thanks.


[Issue 14006] Contribute button/option on the main site and sitemap

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14006

Gary Willoughby d...@nomad.so changed:

   What|Removed |Added

   Keywords||pull
 CC||d...@nomad.so

--- Comment #1 from Gary Willoughby d...@nomad.so ---
https://github.com/D-Programming-Language/dlang.org/pull/972

--


Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn

template dimensionality (S) {
  template count_dim (uint i = 0) {
static if (is (typeof(S.init.opSlice!i (0,0
  enum count_dim = count_dim!(i+1);
else static if (i == 0  (isInputRange!S || is 
(typeof(S.init[0])))

  enum count_dim = 1;
else enum count_dim = i;
  }

  alias dimensionality = count_dim!();
}

Should work for any case I can think of (assuming integral 
indices).


Re: CT-String as a Symbol

2015-04-21 Thread Vlad Levenfeld via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 19:46:03 UTC, Nordlöw wrote:

On Tuesday, 21 April 2015 at 07:46:03 UTC, Vlad Levenfeld wrote:
Then you throw in some more stuff to detect 1-dimensional 
cases.


Could you please elaborate a bit?


Well assuming the type is not multidimensional (does not define 
opSlice!i) then testing for input range primitives or opIndex(0) 
is probably enough to conclude that a type is 1d.


Re: C++/C mangleof inconsistency for OS X

2015-04-21 Thread Michel Fortin via Digitalmars-d

On 2015-04-21 18:29:36 +, Jacob Carlborg d...@me.com said:


On 2015-04-21 19:01, Dan Olson wrote:


If I want to call a C function void debug(const char*) from a C library,
I would do this because of D debug keyword:

   pragma(mangle, debug)
   extern (C) void debug_c(const(char*));

Now I would think debug_c.mangleof - debug
(and that is indeed what dmd produces even on OS X).


Are there use cases where one would want to use some other mangling 
than C? I mean, D is a system programing language.


Apple does this in many of its own C headers. Lookup the definition of 
pthread_join for instance, you'll see the __DARWIN_ALIAS macro which 
when expanded under certain circumstances adds a suffix to the symbol 
name in a similar way to pragma(mangle) in D. This allows some fixes to 
only apply to code compiled with newer SDKs. (Also note that the 
underscore is explicitly put there by the macro.)


--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca



[Issue 14468] [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14468

--- Comment #4 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9c728ce3a8757050cc50407df34eb3f4d0bbceed
fix Issue 14468 - overload mismatch for template instance with typesafe
variadic parameter

https://github.com/D-Programming-Language/dmd/commit/2c102ce5d55cea1259a27e3e32c850cc39f53d6b
Merge pull request #4603 from 9rnsr/fix14468

[REG2.068a] Issue 14468 - overload mismatch for template instance with typesafe
variadic parameter

--


[Issue 14468] [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14468

github-bugzi...@puremagic.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--


[Issue 14183] Updates to groupBy

2015-04-21 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14183

--- Comment #4 from github-bugzi...@puremagic.com ---
Commit pushed to stable at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/afd30b41b09b9298f56ccba19068f1fbcab6fbb5
Merge pull request #3005 from Poita/Issue14183

Fix Issue 14183 - Changes to groupBy

--


Re: C++/C mangleof inconsistency for OS X

2015-04-21 Thread Michel Fortin via Digitalmars-d

On 2015-04-21 17:01:51 +, Dan Olson zans.is.for.c...@yahoo.com said:


Dan Olson zans.is.for.c...@yahoo.com writes:


Jacob Carlborg d...@me.com writes:


On 2015-04-20 18:33, Dan Olson wrote:

An observation on OSX w/ 2.067: mangleof for C++ (and D) names produces
the actual object file symbol while mangleof for C names strips a
leading underscore.

Is this intended?  If so what is rationale?


I don't think it's intentional. The point of mangleof is to evaluate
to the actual mangled name, as it appears in the object file.


Thanks Jacob.

In that case, mangleof for extern(C) names on OS X and other systems
that add a leading underscore should include the underscore.

extern(C) int x;
version(linux) pragma(msg, foo.mangleof); // x
version(OSX) pragma(msg, foo.mangleof);   // _x

I'm trying to understand because ldc is different than dmd, and it is
related to proper debugging on systems with leading underscores.
pragma(mangle, name) is wrapped up in this too.  This needs to be right
to help D expand to other systems.


Hmmm, I can see another point of view where mangleof should produce the
equivalent extern(C) symbol.  My gut says this is the way it should
work.

If I want to call a C function void debug(const char*) from a C library,
I would do this because of D debug keyword:

  pragma(mangle, debug)
  extern (C) void debug_c(const(char*));

Now I would think debug_c.mangleof - debug
(and that is indeed what dmd produces even on OS X).

On systems which prepend an underscore, we want compiler to take care of
this so code is portable, otherwise code must do this:

version (OSX)
  pragma(mangle, _debug) extern (C) void debug_c(const(char*));
else
  pragma(mangle, debug) extern (C) void debug_c(const(char*));


I think if you specify the mangling most of the time it's because you 
don't want the compiler to do it for you. But you should consider doing 
this:


string mangleC(string name) {
version (OSX) return _ ~ name;
else return name;
}

pragma(mangle, mangleC(debug)) extern (C) void debug_c(const(char*));

--
Michel Fortin
michel.for...@michelf.ca
http://michelf.ca



Re: how does isInputRange(T) actually work?

2015-04-21 Thread Ali Çehreli via Digitalmars-d-learn

On 04/21/2015 12:06 PM, kevin wrote:

enum bool isInputRange = is(typeof(
 (inout int = 0)
 {
 R r = R.init; // can define a range object
 if (r.empty) {}   // can test for empty
 r.popFront(); // can invoke popFront()
 auto h = r.front; // can get the front of the range
 }));


... is the current implementation in Phobos. But I can't seem to
understand this syntax. What is (inout int = 0)? Why can a block follow it?

My guess is that this is declaring some sort of function and testing if
it is syntactically valid, but this is still strange to me.


I try to explain that syntax here:


http://ddili.org/ders/d.en/templates_more.html#ix_templates_more.named%20template%20constraint

Ali



Re: dsource.org moved

2015-04-21 Thread Stewart Gordon via Digitalmars-d-announce

On 21/04/2015 00:35, Vladimir Panteleev wrote:
snip

In the other thread I referred to this
http://stackoverflow.com/questions/5010754/github-collaborators-have-commit-access
which makes it sound as though it's possible to do the same thing in GitHub.  
Is that
page wrong?


This question pertains to private GitHub repositories (a feature of paid plans).


One of the comments there: Or you make your repository public, then everyone (who is not 
a collaborator) has read-only access


And everyone who _is_ a collaborator has what?


Regardless, I do not recommend attempting to shoehorn your previous SVN 
workflow into git
and GitHub. The usual way contributions are done with GitHub is that anyone 
with a GitHub
account can create a pull request (a series of commits, initially published on 
their own
fork of the repository), which the repository owner (or collaborators) can then 
accept
(merge) into the main repository.


https://en.wikipedia.org/wiki/Fork_%28software_development%29
implies that a fork is a divergent development branch - a separate copy of the project 
that has no ongoing link to the original.  Is the Git concept of a fork different?



Instead of designating a group of committers as in SVN,
you would simply need to review pull requests and click the merge button to 
accept them.
If you do not foresee yourself being available often enough to review/accept 
pull
requests, you can designate a few collaborators who can do it as well.


Maybe I'll do that.  Most of the time I should be available enough, but there's always the 
chance that I'll be away for a week every now and again (possibly longer if I'm lucky).


Stewart.

--
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


  1   2   >