Re: Recommend: IDE and GUI library

2017-03-01 Thread thedeemon via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 23:44:47 UTC, XavierAP wrote:
Still I want to be able to be  able to work and debug from 
Visual Studio.


The way I did on Windows:
1) get dlangui via dub
2) go to its folder in AppData\roaming\dub\packages and edit 
dub.json:

 * find "minimal" configuration
 * add "USE_WIN32" to "versions-windows",
 * remove mentions of "derelict-sdl2" and "derelict-gl3" from 
"dependencies"

 * remove "ForceLogs" from "versions" (just to avoid logspamming)
3) run "dub build --build=release --config=minimal"
4) use the result .lib file from my VisualD project

This way no dependency on OpenGL which causes problems for you.


Why opDispatch uses SFINAE implicitly?

2017-03-01 Thread Dukc via Digitalmars-d
If I define an opDispatch for something, but the call does not 
compile, the compiler currently behaves as if the opDispatch 
didn't exist at all. Just like C++ templates as  far as I know. 
Why is this? I think it would be better if it acted like other D 
templates: Compilation failure is always an error, but you can 
use preconditions if you want the "substitution failure is not an 
error"-idiom. This would be better to detect errors.


Is there any way to define a dispatching type so that it errs or 
at least announces if the call does not compile?


Re: Recommend: IDE and GUI library

2017-03-01 Thread Patrick Schluter via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 23:44:47 UTC, XavierAP wrote:

On Wednesday, 1 March 2017 at 20:00:32 UTC, thedeemon wrote:

For this I found out how to clone the dependencies, sorry about 
that... (Only from the command line... Anyone recommends better 
free Windows Git gui clients than GitHub Desktop?) Import paths 
seem correctly setup in the project files from the repo, as I 
would expect. And once the dependency code is in its place it 
does build, both the library and the example applications.


Here [1] is the official git page listing all GUI clients for 
different plartforms.
I use GitExtensions[2] and I like it a lot. It works very well 
and all the complicated stuff can be done from the GUI interface 
and also from command line.



[1]=https://git-scm.com/download/gui/win
[2]=https://gitextensions.github.io/


Re: Getting underlying struct for parseJSON

2017-03-01 Thread Alexey H via Digitalmars-d-learn

On Tuesday, 28 February 2017 at 21:21:30 UTC, Adam D. Ruppe wrote:

On Tuesday, 28 February 2017 at 20:27:25 UTC, Alexey H wrote:

[...]


It doesn't actually generate one, it just returns a tagged 
union (a kind of dynamic type).


[...]


Superb, Adam, thank you! I need to check out inspector.

The std.json will be used solely to generate proper structs.
I expect to do all the heavy stuff via 
http://code.dlang.org/packages/jsonserialized
since it uses vibe.d's JSON implementation, my expectations are 
that it would be faster.


Re: Mixing libraries

2017-03-01 Thread Mike Parker via Digitalmars-d-learn

On Thursday, 2 March 2017 at 02:27:03 UTC, Jordan Wilson wrote:



Ah yes, I think you explain the difference between 
wrapper/binding in one of the Derelict docs.


I'm currently working through a ebook on Game Dev with 
SFML...the examples are all C++.
I don't have any trouble translating it to the equivalent C 
bindings (so far anyway), but perhaps in the long run using 
dsfml will be easier (for example, I found using Iup4d easier 
than the straight C Iup bindings).


Yes, that's what wrappers are for :-) Plenty of people have built 
wrappers on top of the Derelict bindings. I have my own little 
SDL and GLFW wrappers I use for throw away projects. Makes the 
code cleaner and easier on the eyes (C APIs can be ugly).


Jeremy did a great job with DSFML. When I first implemented 
DerelictSFML, there was a DMD bug on Linux 64-bit that caused 
crashes when passing structs to functions by value, which bits of 
the CSFML API require. That made the binding effectively unusable 
on Linux. Jeremy implemented his own C binding (DSFML-C) which 
eliminated the pass-by-value bits and then built DSFML on top of 
that. IIRC the bug has been fixed since then, so I don't know if 
DSFML is using CSFML directly now or not.


Re: DConf 2017 Hotel - book now!

2017-03-01 Thread Walter Bright via Digitalmars-d-announce

On 3/1/2017 6:49 PM, Nicholas Wilson wrote:

Any idea when the speaker list will be published?


I hope soon.


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Adam D. Ruppe via Digitalmars-d

On Thursday, 2 March 2017 at 00:06:17 UTC, Adam D. Ruppe wrote:
Though it is important to note that adrdox does NOT support 
user-defined ddoc macros


But, it DOES now support a footnote kind of thing. Behold:

http://dpldocs.info/experimental-docs/test.html#footnotes

In ddoc, I was tempted to define a $(RANGE_CONCEPT Input) macro 
or something like that, which would expand do $(REF 
std,range,primitives,is$1Range, $1 range) or something along 
those lines (of course, ddoc is so underpowered that wouldn't 
even be that good..) because right now we repeat those references 
a LOT.


(Actually, I don't love linking to isInputRange's function 
definition. I'd prefer a higher-level overview of ranges when we 
link it, but isInputRange is the best we have written right now 
outside our various books.)


adrdox makes it a bit nicer, `[isInputRange|input range]` will do 
what's needed, as long as `std.range.primitives` is imported in 
scope (which it typically is for the constraint anyway), but what 
if we write a new conceptual article and want to change the links?


That's what led me to the Link_References idea. By defining:

concept_input_range = [isInputRange|input range]

we can just reference text like `It must be an 
[concept_input_range]` and be a bit more DRY (and btw 
concept_input_range is easier on my autocomplete algorithms than 
isInputRange|input range... and infinitely better than the ddoc 
macro mess.)


So, I went ahead and implemented that today. And footnotes, 
images, and popup text is easy to do in the same framework and 
sometimes useful too, so I just did it all together.



My generator isn't just about reading more semantics out of D, it 
is also about making something easier to use than ddoc.


Re: DCV v0.2.0 - adaptation to the new ndslice

2017-03-01 Thread jmh530 via Digitalmars-d-announce

On Wednesday, 1 March 2017 at 21:48:27 UTC, Faux Amis wrote:

Nice!

Question, do you know of any (plans to make a) deep learning 
framework in D? (like: http://caffe.berkeleyvision.org)




I only recall a previous discussion on this thread
http://forum.dlang.org/post/iejpbjeelnubtzhoz...@forum.dlang.org

As noted on that thread, it's a lot of work, but if you're 
interested in it there's no reason you can't help make 
contributions of some kind or another. Rather than think about 
the whole library, you could think about what would be precursors 
to a good machine learning library. Integration between Mir GLAS 
and Dcompute is pretty obvious as machine learning libraries are 
pretty computationally intensive. Along the same lines, an 
autodiff library would be very helpful. I would expect that D 
would provide a good framework for building one, especially given 
Ilya's success with GLAS. Machine learning libraries also make 
heavy use of graphs. I see that there is a Dgraph, but the dub 
page says it is still experimental. I'm sure there's a bunch of 
other things that I haven't even thought of.


Re: CTFE Status 2

2017-03-01 Thread Stefan Koch via Digitalmars-d

On Thursday, 2 March 2017 at 03:09:56 UTC, Stefan Koch wrote:
On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch 
wrote:

[ ... ]


Hi Guys,

The implementation of ref parameters by itself was successful.
However they hey have one bug, which is a consquence of newCTFE 
not touching dmd's state.
They cannot modify an outer parameter. (where outer means that 
the parameter does not originate from a ctfe-evaluation further 
up the call stack)


Cheers,
Stefan



It turn out that this was not the problem.
It was rather old code in the byte-code evaluator that dated from 
a time where parameters were not considered stack values.

causing that code to copy the parameters into a temporary.
When I removed the distinction between parameters and normal 
stack values I deleted the code that kept track of the parameters 
that were copied into temporaries.


Since I forgot to remove the creation of those temporaries.
We ended up with the situation described above.


[Issue 17229] File.byChunk (ubyte) w/ stdout.lockingTextWriter corrupts utf-8 data (and is very slow)

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17229

Steven Schveighoffer  changed:

   What|Removed |Added

   Keywords||pull
   Hardware|x86 |All
 OS|Mac OS X|All
   Severity|enhancement |major

--- Comment #7 from Steven Schveighoffer  ---
PR: https://github.com/dlang/phobos/pull/5229

--


Re: CTFE Status 2

2017-03-01 Thread Stefan Koch via Digitalmars-d

On Thursday, 2 March 2017 at 03:09:56 UTC, Stefan Koch wrote:
On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch 
wrote:

[ ... ]





uint add8ret3(ref uint a) {a += 8; return 3;}

pragma (msg, (uint outer) { outer += add8ret3(a); return 
outer;}(1)); // will print 4


was supposed to say:
pragma (msg, (uint outer) { outer += add8ret3(outer); return 
outer;}(1)); // will print 4




Re: CTFE Status 2

2017-03-01 Thread Stefan Koch via Digitalmars-d

On Thursday, 16 February 2017 at 21:05:51 UTC, Stefan Koch wrote:

[ ... ]


Hi Guys,

The implementation of ref parameters by itself was successful.
However they hey have one bug, which is a consquence of newCTFE 
not touching dmd's state.
They cannot modify an outer parameter. (where outer means that 
the parameter does not originate from a ctfe-evaluation further 
up the call stack)


uint add8ret3(ref uint a) {a += 8; return 3;}

pragma (msg, (uint outer) { outer += add8ret3(a); return 
outer;}(1)); // will print 4


pragma (msg, (uint outer) { uint inner = outer; inner += 
add8ret3(inner); return inner; }(1)); // will print 12 as 
expected.


There are two options I could take:
The first one is to disallow having refs of outer parameters 
taken.

(and bailing out in this case)
The second option is to implement the logic necessary to modify 
these expression nodes.


Both options require me to detect if we have an outer ref 
parameter. but that should be easy to do.


Cheers,
Stefan


Re: DConf 2017 Hotel - book now!

2017-03-01 Thread Nicholas Wilson via Digitalmars-d-announce

On Thursday, 2 March 2017 at 02:24:50 UTC, Walter Bright wrote:

http://www.ibis.com/gb/hotel-5694-ibis-berlin-neukoelln/index.shtml

Last year, some people booked late and it was full and they had 
to stay at another hotel.


Thanks for the heads up. Any idea when the speaker list will be 
published?


Re: Recommend: IDE and GUI library

2017-03-01 Thread evilrat via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 23:44:47 UTC, XavierAP wrote:


For this I found out how to clone the dependencies, sorry about 
that... (Only from the command line... Anyone recommends better 
free Windows Git gui clients than GitHub Desktop?)




TortoiseGIT maybe?


Re: Mixing libraries

2017-03-01 Thread Jordan Wilson via Digitalmars-d-learn

On Thursday, 2 March 2017 at 01:02:39 UTC, Mike Parker wrote:

On Wednesday, 1 March 2017 at 16:12:06 UTC, bauss wrote:



There is a better binding.

dsfml.

You can find it here: http://dsfml.com/


DSFML technically is not a binding (even though it says such on 
the web site). It's a wrapper that D-ifies the SFML API. The 
SFML functions are not callable directly, as they are all 
declared privately. DerelictSFML is strictly a binding, with no 
attempt to wrap anything. A wrapper like DSFML could be 
implemented on top of DerelictSFML.


So yes, it's better if what you really want is a wrapper.


Ah yes, I think you explain the difference between 
wrapper/binding in one of the Derelict docs.


I'm currently working through a ebook on Game Dev with SFML...the 
examples are all C++.
I don't have any trouble translating it to the equivalent C 
bindings (so far anyway), but perhaps in the long run using dsfml 
will be easier (for example, I found using Iup4d easier than the 
straight C Iup bindings).


DConf 2017 Hotel - book now!

2017-03-01 Thread Walter Bright via Digitalmars-d-announce

http://www.ibis.com/gb/hotel-5694-ibis-berlin-neukoelln/index.shtml

Last year, some people booked late and it was full and they had to stay at 
another hotel.


[Issue 17237] Wrong alignment of 256-bit and 512-bit vectors

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17237

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

   What|Removed |Added

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

--


[Issue 17237] Wrong alignment of 256-bit and 512-bit vectors

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17237

--- Comment #2 from github-bugzi...@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/10eba509d6a5dfbe509fa1ffe7f4c3962a58a490
fix Issue 17237 - Wrong alignment for 256-bit vectors.

https://github.com/dlang/dmd/commit/25f8bc5bbb2e843fb3ab381d13f4ce919eae0958
Merge pull request #6582 from ibuclaw/issue17237

fix Issue 17237 - Wrong alignment for 256-bit vectors.

--


[Issue 17238] r.lookaround!(a, b) returns a range derived from r that allows a elements of lookahead and b elements of lookback

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17238

--- Comment #2 from Andrei Alexandrescu  ---
(In reply to greenify from comment #1)
> A couple of questions to clarify:
> 
> 1) popFront/popBack will move the fixed-size buffer, right?
> For example:
> 
> 10.iota.ahead(3).drop(2).writeln; // [2, 3, 4]

ahead(k) returns the kth element ahead of front, not a range.

> 2)
> > it embeds a fixed-size buffer and moves through it with minimal effort.
> 
> It's assumed are only shallow which can change?

Affirmative.

--


Range with lookaround

2017-03-01 Thread Andrei Alexandrescu via Digitalmars-d
May be worth discussing in here: 
https://issues.dlang.org/show_bug.cgi?id=17238 -- Andrei


[Issue 17238] r.lookaround!(a, b) returns a range derived from r that allows a elements of lookahead and b elements of lookback

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17238

greenify  changed:

   What|Removed |Added

 CC||greeen...@gmail.com
   Assignee|nob...@puremagic.com|greeen...@gmail.com

--- Comment #1 from greenify  ---
A couple of questions to clarify:

1) popFront/popBack will move the fixed-size buffer, right?
For example:

10.iota.ahead(3).drop(2).writeln; // [2, 3, 4]

2)
> it embeds a fixed-size buffer and moves through it with minimal effort.

It's assumed are only shallow which can change?

auto arr = 10.iota.ahead(3);
auto a = arr[1..$]; // [1, 2]
arr.popFront;
auto b = arr[1..$]; // [2, 3]

With "minimal effort" a would be [2, 3] as well.

3) Should there be ahead!3 to allow using a static array as buffer in order to
avoid allocation?

4) Should there be support for providing your custom allocator for the runtime
flag to allow GC-free behavior?

--


Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Cecil Ward via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 22:15:59 UTC, Iain Buclaw wrote:

On Wednesday, 1 March 2017 at 19:09:24 UTC, Johan Engelen wrote:

On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote:


Simple test case would be:

struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);


With explicit align(32), it works:
https://godbolt.org/g/3GjOHW

- Johan


Well obviously, because it adheres to explicit alignment.  The 
compiler just has the wrong idea of how default alignment 
should work.


Raised bug here, and I'm raising a PR now also. 
https://issues.dlang.org/show_bug.cgi?id=17237


In a dream world where engineers have nothing better to do, it 
would of course be better to effectively delete the inner 
anonymous struct so that the two bools could be packed together 
adjacently. I presume that that is theoretically ok? In contrast, 
if the sub-struct were named, you could presumably take the 
address of the entire sub-struct, so the space-inefficient offset 
to it is something you are just stuck with of course.


A noob question: is it illegal to reorder the fields in a struct? 
(e.g. so as to optimise packing as far as correct alignment 
allows) - (C compatibility? Would perhaps need to be an _option_?)


[Issue 17238] New: r.lookaround!(a, b) returns a range derived from r that allows a elements of lookahead and b elements of lookback

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17238

  Issue ID: 17238
   Summary: r.lookaround!(a, b) returns a range derived from r
that allows a elements of lookahead and b elements of
lookback
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: and...@erdani.com

Inspired by https://github.com/dlang/phobos/pull/5153, a great range type would
be one that offers fixed lookaround. It works like any other range but has
supplemental functions for lookahead and lookback.

r.lookahead!(a, b) yields a range looking up to a elements ahead and up to b
elements back. These are accessible through two new APIs, e.g. ahead(k) and
behind(k).

If r is a random-access range, the resulting range does NOT copy any elements
and simply provides APIs on top of the random access primitives.

If r is weaker than random-access, it embeds a fixed-size buffer and moves
through it with minimal effort.

--


Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Cecil Ward via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 22:15:59 UTC, Iain Buclaw wrote:

On Wednesday, 1 March 2017 at 19:09:24 UTC, Johan Engelen wrote:

On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote:


Simple test case would be:

struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);


With explicit align(32), it works:
https://godbolt.org/g/3GjOHW

- Johan


Well obviously, because it adheres to explicit alignment.  The 
compiler just has the wrong idea of how default alignment 
should work.


Raised bug here, and I'm raising a PR now also. 
https://issues.dlang.org/show_bug.cgi?id=17237


Thanks for your help Iain. And many thanks btw for all the 
general good work which is very much appreciated by this 
particular geriatric asm programmer.


I checked the case of XMM alignment, and it's fine.

I presume D does not yet support 512-bit zmm vector objects? (I 
have seen GDC doing a nice job generating auto-vectorised AVX512 
code though - thanks.) The same bug would presumably bite again 
in that case otherwise?


Re: Mixing libraries

2017-03-01 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 16:12:06 UTC, bauss wrote:



There is a better binding.

dsfml.

You can find it here: http://dsfml.com/


DSFML technically is not a binding (even though it says such on 
the web site). It's a wrapper that D-ifies the SFML API. The SFML 
functions are not callable directly, as they are all declared 
privately. DerelictSFML is strictly a binding, with no attempt to 
wrap anything. A wrapper like DSFML could be implemented on top 
of DerelictSFML.


So yes, it's better if what you really want is a wrapper.


[Issue 12564] std.range.backWalk, std.range.backWalkMaybe

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12564

greenify  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||greeen...@gmail.com
 Resolution|--- |WONTFIX

--- Comment #1 from greenify  ---
Due to the discussion at https://github.com/dlang/phobos/pull/5153, I am
closing this as WONTFIX as it can be done easily with:

```
auto last = r.fold!((a, b) => b);
```

For Maybe have a look at this PR:

https://github.com/dlang/phobos/pull/5154

It allows the following

range.orElse(seed).fold!`b`

--


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 1 March 2017 at 23:21:14 UTC, Seb wrote:

https://github.com/dlang/phobos/pulls?utf8=%E2%9C%93=is%3Apr%20label%3Adocumentation%20

Most of these changes are independent from 
Ddoc/Ddox/Adrdox/..., so everyone should be able to enjoy 
cleaner documentation soon.


Actually, almost none of that affects me! (Except perhaps causing 
more merge conflicts for me when I pull, alas, but that's the 
downside of doing a fork. I already killed most the LUCKY links, 
for example, and the booktables are redundant (though basically 
harmless) with my automatically generated listings.


My diff from upstream is now over 5300 lines long, including a 
mix of formatting, syntax, linking, and some content changes...



@Adam: I like your docs as well!
Have you ever considered adding vibe.d to them?


Once I'm happy with it, I might scrape code.dlang.org and pull it.

Though it is important to note that adrdox does NOT support 
user-defined ddoc macros, so not everything with ddoc will just 
work. I hardcoded a bunch of the common Phobos ones, but my goal 
ideally is to eliminate most macros in favor of things taking 
care of themselves with lightweight syntax (which ironically, was 
part of ddoc's original charter!)


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread lobo via Digitalmars-d

On Wednesday, 1 March 2017 at 06:19:30 UTC, lobo wrote:

On Wednesday, 1 March 2017 at 05:18:59 UTC, Adam D. Ruppe wrote:
I stumbled across std.typecons.Unique in my doc website today 
and realized there was a postblit in the source, but I didn't 
display the documentation comment.


[...]


Is it possible to use your tool to generate the docs for my own 
code?


Thanks,
lobo


Thanks, I'll give it a try.

lobo


Re: Recommend: IDE and GUI library

2017-03-01 Thread XavierAP via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 20:00:32 UTC, thedeemon wrote:
If you're building your app with VisualD (as opposed to 
invoking dub externally), make sure you've set up import paths 
in project settings properly.


Thanks. With dub everything works straight forward. I just call 
it blindly since it's the first time I use dub and I'm not sure 
everything it's supposed to do. Still I want to be able to be 
able to work and debug from Visual Studio.


For this I found out how to clone the dependencies, sorry about 
that... (Only from the command line... Anyone recommends better 
free Windows Git gui clients than GitHub Desktop?) Import paths 
seem correctly setup in the project files from the repo, as I 
would expect. And once the dependency code is in its place it 
does build, both the library and the example applications.


The problem I was having after all this was a runtime exception, 
but it happens only on 32-bit. Switching to 64-bit building and 
debugging works out of the box (after having cloned the 
subrepos). Here I have no idea if I have a drive issue, in any 
case 64-bit is enough for me.

BTW the exception is:
"derelict.util.exception.SymbolLoadException Failed to load 
OpenGL symbol [glEnableClientStateiEXT] "


Also, if you use "minimal" configuration of DLangUI (which I 
recommend) you can remove mentions of SDL and GL from its 
dependencies in its dub.json, this way there are less things 
for compiler and VisualD to look for.


I understand that in order to do this from Visual Studio, 
according to the instructions at github.com/buggins/dlangui, I 
should use configurations DebugMinimal instead of Debug, etc. But 
these configurations are not defined; I wonder if this 
documentation is out of sync with the current code. Otherwise I 
also though OpenGL wouldn't be used unless the version identifier 
USE_OPENGL was defined, but apparently it is not in VS as far as 
I can see?


So in the end I'm not very sure whether OpenGL is kicking in in 
64-bit when it works, or in general how to disable it (from 
Visual Studio instead of dub) -- or what are the consequences for 
performance or whatever. For now I can work like this and if I 
have additional problems that prevent me from advancing I will 
research it further...


Thanks also @aberba and everyone.


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Seb via Digitalmars-d

On Wednesday, 1 March 2017 at 20:10:35 UTC, Adam D. Ruppe wrote:

On Wednesday, 1 March 2017 at 12:05:33 UTC, bachmeier wrote:
If by "surrender", you mean adopt your system for the official 
documentation, well I sure hope not. That's a fast way to kill 
progress on anything related to this language.


Yeah, I'd prolly have to continue working on it myself but they 
could fork off a stable version to use on the website.


Regardless though, I'd also be happy if the competitive 
pressure leads to improvements on the main site (while I 
continue to be streets ahead on my own site).


Hehe, well for those who haven't been following closely. Jack and 
I are putting some effort into improving the "official" 
documentation:


https://github.com/dlang/phobos/pulls?utf8=%E2%9C%93=is%3Apr%20label%3Adocumentation%20

Most of these changes are independent from Ddoc/Ddox/Adrdox/..., 
so everyone should be able to enjoy cleaner documentation soon.


@Adam: I like your docs as well!
Have you ever considered adding vibe.d to them?


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Adam D. Ruppe via Digitalmars-d
Seeing ddmd coming to dlang.org 
, just for 
fun I ran my doc generator over the dmd source code too: 
http://dpldocs.info/experimental-docs/ddmd.html I didn't enable 
search over it but you can browse to the extent that there are 
ddoc comments in there.


This is an interesting case to look at because dmd is pretty 
class-heavy... and my class handling is OK, but not great.


Like here, it shows inherited members from Declaration, but not 
from Dsymbol.


http://dpldocs.info/experimental-docs/ddmd.declaration.AliasDeclaration.html

but hey at least you can navigate up the tree with just a few 
clicks anyway.


Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Iain Buclaw via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 19:09:24 UTC, Johan Engelen wrote:

On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote:


Simple test case would be:

struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);


With explicit align(32), it works:
https://godbolt.org/g/3GjOHW

- Johan


Well obviously, because it adheres to explicit alignment.  The 
compiler just has the wrong idea of how default alignment should 
work.


Raised bug here, and I'm raising a PR now also. 
https://issues.dlang.org/show_bug.cgi?id=17237


[Issue 17237] Wrong alignment of 256-bit and 512-bit vectors

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17237

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #1 from Iain Buclaw  ---
On a mild ranting note, this is the offender in the frontend.

---
// AggregateDeclaration.placeField (aggregate.d)

if ((global.params.is64bit || global.params.isOSX) && memalignsize == 16)
{
}
else if (8 < memalignsize)
memalignsize = 8;

---

For DMD - you seem to have forgotten that you support 256-bit vectors.

For GDC, you're ignoring the target-specific alignment of fields that we
return, instead enforcing that everything must fit your x86 view of ABI.

This piece of code should be moved to Target::fieldalign where it deservedly
belongs.

--


[Issue 17237] New: Wrong alignment of 256-bit and 512-bit vectors

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17237

  Issue ID: 17237
   Summary: Wrong alignment of 256-bit and 512-bit vectors
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: ibuc...@gdcproject.org

Target field alignment returned by GDC (and probably LDC too) is being
overwritten/ignored by the frontend if it considers it wrong from an x86
standpoint.

Here's one example that affects both DMD and GDC for different reasons.

---
struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32); // Fails, offset == 8
static assert(vec_struct.field.offsetof == 64); // Fails, offset == 40 !!!
---

--


Re: DCV v0.2.0 - adaptation to the new ndslice

2017-03-01 Thread Faux Amis via Digitalmars-d-announce

On 2017-03-01 18:10, Relja Ljubobratovic wrote:

Hi everyone,

I wanted to let you know that we've released new version of DCV[1], an
open source computer vision library, written in D programming language,
with goal to provide tools for solving most common computer vision
problems - various image processing tasks, feature detection and
tracking, camera calibration, stereo etc.



Nice!

Question, do you know of any (plans to make a) deep learning framework 
in D? (like: http://caffe.berkeleyvision.org)


Something which could maybe be used on top of DCV for computer vision?



[Issue 17236] New: DMD doesn't build on debian anymore

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17236

  Issue ID: 17236
   Summary: DMD doesn't build on debian anymore
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: deadal...@gmail.com

make[1]: Entering directory '/home/deadalnix/d/dmd/src'
no cpu specified, assuming X86
CC=c++ dmd -of../generated/linux/release/64/idgen ddmd/idgen.d
/usr/bin/ld: ../generated/linux/release/64/idgen.o: relocation R_X86_64_32
against `.rodata' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
Error: linker exited with status 1
posix.mak:414: recipe for target '../generated/linux/release/64/idgen' failed
make[1]: *** [../generated/linux/release/64/idgen] Error 1
make[1]: Leaving directory '/home/deadalnix/d/dmd/src'
posix.mak:8: recipe for target 'all' failed
make: *** [all] Error 2

--


Re: Recommend: IDE and GUI library

2017-03-01 Thread aberba via Digitalmars-d-learn

On Friday, 24 February 2017 at 22:44:55 UTC, XavierAP wrote:
Hi I've looked at wiki.dlang.org/IDEs, and I see that Visual D 
is linked from dlang.org/download.html. Still I was looking for 
personal opinions and experiences beyond hard specs, I wonder 
if one of the IDEs is already dominant at least for each OS for 
any good reason.


My requirements are quite ordinary: make x64, debug, go to 
definition, manage projects, code completion. My platform is 
Windows; interested if the choice would be different for Linux, 
if the same nice, otherwise I'd prefer to use whatever is best 
on each OS.


And second question, is DWT the de facto standard for creating 
GUIs? Or are there good competitors.


Sorry if I'm asking something too obvious, though I've looked 
around for answers before. And I've also searched the forum but 
really equivalent questions were over 2 years old and many 
things may have changed.

Thanks!


Gtkd is obviously defacto for Linux ONLY, dlangui for cross 
platform app without native feel. But if you want something easy 
and flexible with native look and feel on all platforms, well 
tested, use LibUI (http://code.dlang.org/packages/libuid). Look 
inside the "examples" folder in their Github repository to see 
example usage.


More like:
 auto hbox = new Box(false).setPadded(1);
 vbox.append(hbox);

hbox.append(new Button("Button"))
.append(new Checkbox("Checkbox"))
...

Examples:
https://github.com/mogud/libuid/blob/master/examples/example1.d
https://github.com/mogud/libuid/blob/master/examples/example2.d





Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread aberba via Digitalmars-d

On Wednesday, 1 March 2017 at 18:34:22 UTC, bachmeier wrote:
On Wednesday, 1 March 2017 at 17:09:51 UTC, Jared Jeffries 
wrote:


I think it should instead be advertised as the perfect 
language to learn programming and web development, because 
that's where it really shines, IMHO.


I agree, but we need an intro to programming class using D as 
the language in order to do that. Most of the materials for the 
language assume you have programming experience. You can't just 
say that D allows you to use pointers and other low-level 
constructs, you have to explain what a pointer is and what you 
do with it. The same goes for functional programming, OOP, 
contracts, compile time, and so on. That's a big task. Ali's 
book is great as an introduction to the language, but not 
really sufficient as a beginning programming tutorial.


Thats the gab I'm trying to fill 
https://github.com/aberba/learn-coding


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 1 March 2017 at 12:05:33 UTC, bachmeier wrote:
If by "surrender", you mean adopt your system for the official 
documentation, well I sure hope not. That's a fast way to kill 
progress on anything related to this language.


Yeah, I'd prolly have to continue working on it myself but they 
could fork off a stable version to use on the website.


Regardless though, I'd also be happy if the competitive pressure 
leads to improvements on the main site (while I continue to be 
streets ahead on my own site).


Re: Recommend: IDE and GUI library

2017-03-01 Thread thedeemon via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 17:37:02 UTC, XavierAP wrote:
I'm trying now DlangUI on Visual D. I'm getting different 
errors from missing Derelict library dependencies...


If you're building your app with VisualD (as opposed to invoking 
dub externally), make sure you've set up import paths in project 
settings properly. Two paths must be there: one like

C:\Users\...\AppData\Roaming\dub\packages\dlangui-0.9.46\dlangui\src\
and the other like
C:\Users\...\AppData\Roaming\dub\packages\dlangui-0.9.46\dlangui\3rdparty\
and in linker tab of project settings make sure you link to the 
dlangui.lib you should have built beforehand.
Also, if you use "minimal" configuration of DLangUI (which I 
recommend) you can remove mentions of SDL and GL from its 
dependencies in its dub.json, this way there are less things for 
compiler and VisualD to look for.


Re: foreach for string[string]AA

2017-03-01 Thread Mike Wey via Digitalmars-d-learn

On 02/28/2017 07:16 PM, Anton Pastukhov wrote:

On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák wrote:

V Tue, 28 Feb 2017 15:15:00 +
Anton Pastukhov via Digitalmars-d-learn
 napsáno:


I can't see the logic in AA foreach order. Consider this code:
...
Output:
three
two
one
four

I was sure output should be
one
two
three
four


https://forum.dlang.org/post/xbanhtkvrizyqjcib...@forum.dlang.org


Thank you for the link, it was informative reading. It's a pity that
still there is no ordered AA at least as a library type.


I had the same use case in the generator for GtkD, i needed fast lookup 
while iteration needed to preserve the insertion order. I opted for 
storing nodes of a linked list in the build in AA.


The implementation[1] is currently LGPL to match the rest of the 
library, but if anyone would find it useful it can be changed to 
something else.


[1] 
https://github.com/gtkd-developers/GtkD/blob/master/wrap/utils/LinkedHasMap.d


--
Mike Wey


Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Johan Engelen via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 18:34:16 UTC, Iain Buclaw wrote:


Simple test case would be:

struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);


With explicit align(32), it works:
https://godbolt.org/g/3GjOHW

- Johan


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 03/01/2017 12:25 PM, Jack Stouffer wrote:

I agree. We have a lot to improve in terms of marketing.

Mainly our messaging is jumbled.

Rust = memory safety
Go = the best runtime around
D = everything I guess?

And the problem is that D is good at everything (IMO), so how do we go
about marketing to everyone without getting our messages mixed up in the
public's view.


Yea, its kinda depressing that programmers will be cold towards D, and 
admit flat-out it's because D *isn't* a one-trick pony centered around 
once single gimmick. (I've encountered that myself. Such a facepalm 
inducer. "Polyglot programming" has rotted people's brains.)




Libharu D binding harud unicode support

2017-03-01 Thread Erdem via Digitalmars-d-learn
How should one use libharu d binding in unicode mode. Consider 
this basic example.


import std.stdio;

import harud;
import harud.c;

void main()
{
   void  errorCallback(uint error_number, uint detail_number)
   {
  writefln("err %x, %s, (num %x)"
, error_number
, getErrorDescription(error_number),
detail_number);
   }

   Doc pdf = new Doc();   ///  New pdf document
   Font helvetica = pdf.getFont("Helvetica");
   writeln("build font");

   Page page = pdf.addPage(); /// Add a new page to the document

   writeln("page width:", page.width);

   auto status = page.setFontAndSize(helvetica, 60);   /// Set 
the current font and size for the page

   writeln("set font width:", 60, " status", status);

   status = page.beginText(); /// Begin text mode
   writeln("begin ", status);

   status = page.showText("üçÇÜÖöĞğIı"); /// Print text to the 
page

   writeln("show ", status);

   page.endText(); /// End text mode

   pdf.saveToFile("./hello.pdf"); /// Write to disk
}

As you'd see I'd like to be able to write some Turkish characters 
to pdf file using libharu D binding.(a.k.a. harud)


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread bachmeier via Digitalmars-d

On Wednesday, 1 March 2017 at 17:09:51 UTC, Jared Jeffries wrote:

I think it should instead be advertised as the perfect language 
to learn programming and web development, because that's where 
it really shines, IMHO.


I agree, but we need an intro to programming class using D as the 
language in order to do that. Most of the materials for the 
language assume you have programming experience. You can't just 
say that D allows you to use pointers and other low-level 
constructs, you have to explain what a pointer is and what you do 
with it. The same goes for functional programming, OOP, 
contracts, compile time, and so on. That's a big task. Ali's book 
is great as an introduction to the language, but not really 
sufficient as a beginning programming tutorial.


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 03/01/2017 08:35 AM, Craig Dillabaugh wrote:


However the forum does often answer some highly important and relevant
questions.  My favorite so far was the "If I wanted to jump from an
airplane flying at 30,000 feet with nothing but bubble wrap for
protection, how much would I need?"


Since you are no doubt curious, I believe the answer was you would need
to be wrapped in a ball about 4m in radius.  They never explained how
you would get that on the plane though.


Hah :) Sounds very xkcd.


Re: Alignment of struct containing SIMD field - GDC

2017-03-01 Thread Iain Buclaw via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 06:04:32 UTC, Cecil Ward wrote:

struct vec_struct {
alias field this;
bool b;
int8 field;
}

In this code when you look at the generated x64 code output by 
GDC it seems to be doing a nice job, because it has got the 
offset right for the 256-bit YMM 'field' correct.


Does D automatically propagate the alignment restrictions on 
the field to the allocation of static structs or structs on the 
stack?


In this case:

struct vec_struct {
bool b2;
struct {
alias field this;
bool b;
int8 field;
}
}
it appears that the offset to 'field' is no longer aligned 
correctly - offset is 40 bytes in GDC. I don't suppose the 
compiler will use solely unaligned instructions? In any event, 
I could take the address of field and then pass that to someone 
expecting to pick up something with guaranteed correct 
alignment, if I have understood the D docs.




Yeah, it looks like the semantic analysis pass is defeating us 
here.  It's adding the anonymous struct offset to the aligned 
field, ignoring completely the original alignment.


Or... the anonymous struct alignment != largest field alignment, 
which probably is the more likely scenario.


Please raise a bug against DMD.

Simple test case would be:

struct vec_struct {
bool b2;
struct {
bool b;
int8 field;
}
}

static assert(vec_struct.b.offsetof == 32);
static assert(vec_struct.field.offsetof == 64);




Noob q: I notice that the GDC opcodes look a bit odd, for 
example the compiler generates a 256-bit unaligned fetch 
followed by an aligned binary operation (I think), eg a movdqu 
followed by a vpaddd r, ymm ptr blah - is the latter 
aligned-only? Apologies if I have got this wrong, need to read 
up. Would someone sanity-check me?


The x86 allows unaligned loads.  But if this is referencing the 
above data structure, you shouldn't be seeing this if the fields 
were correctly aligned.




Re: It's alive! D building D building D, all on Android

2017-03-01 Thread Andre Pany via Digitalmars-d-announce

On Monday, 27 February 2017 at 17:08:26 UTC, Joakim wrote:


Piping hot builds of the upcoming ldc 1.1.1 release available 
as both a linux/x64 -> Android/ARM cross-compiler and a native 
Android/ARM compiler, that you can run on your own phone or 
tablet:


https://github.com/joakim-noah/android/releases

I finally spent some time tracking down that touch bug in the 
sample Teapot app, think I know where it's coming from now, 
just need to fix it.


Also Dockerfile is updated and using now this new version.
More info 
https://wiki.dlang.org/Build_Android_Apps_using_LDC_in_a_Container


Kind regards
André


Re: WebAssembly design is done?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 03/01/2017 05:15 AM, Ola Fosheim Grøstad wrote:


So, maybe the conclusion is: don't let corporations create technology
standards in their main domain, because then they try to create
monopolies and start misbehaving. Browsers is  a side-line tech, so...
this might have a chance..?



Well, it's Google's main domain, and they've kinda already settled into 
a pattern of making decisions more on self-serving grounds than for the 
good of the product/users. "Don't be evil" doesn't exactly set a very 
high bar.


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Meta via Digitalmars-d

On Wednesday, 1 March 2017 at 17:25:07 UTC, Jack Stouffer wrote:

I agree. We have a lot to improve in terms of marketing.

Mainly our messaging is jumbled.

Rust = memory safety
Go = the best runtime around
D = everything I guess?

And the problem is that D is good at everything (IMO), so how 
do we go about marketing to everyone without getting our 
messages mixed up in the public's view.


To me, D's key marketing feature has always been it's incredible 
static introspection and metaprogramming abilities.


Re: rdmd with a file with no extension

2017-03-01 Thread XavierAP via Digitalmars-d-learn

On Wednesday, 1 March 2017 at 16:06:20 UTC, Colin wrote:
When running a small D program through rdmd, it seems the file 
needs a .d extension to work.


It looks like the file extension is enforced:
https://dlang.org/dmd-windows.html#switches

Looks like a feature rather than a bug... At the command line, 
both "file" or "file.d" make the compiler look for "file.d". Even 
"file.c" is understood as "file.c.d"


Re: Recommend: IDE and GUI library

2017-03-01 Thread XavierAP via Digitalmars-d-learn

On Tuesday, 28 February 2017 at 06:16:08 UTC, thedeemon wrote:
For me Visual-D served well for years, and for GUI on Windows 
I've used DFL successfully (quite nice lib, very WinForms-like, 
with a visual editor) and now mostly use DLangUI (on both 
Windows and Linux).


I'm trying now DlangUI on Visual D. I'm getting different errors 
from missing Derelict library dependencies... I see at github.com 
these are "subrepos" but after cloning the subrepo directories 
are still empty. Sorry this is my first time using Git/GitHub 
(used Mercurial and TortoiseHg at work, which I think would have 
cloned the subrepos without additional action). What am I missing?


Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, March 01, 2017 17:02:37 Dukc via Digitalmars-d-learn wrote:
> On Wednesday, 1 March 2017 at 16:43:41 UTC, Jonathan M Davis
>
> wrote:
> > Assert is for program invariants. If the condition is true,
> > your program is outright broken.
>
> Error: He meant that if the condition is FALSE, the program is
> faulty.

LOL. True. Sorry about that. Invariants must be true, not false. I should
have caught that.

- Jonathan M Davis



Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Joakim via Digitalmars-d

On Wednesday, 1 March 2017 at 17:09:51 UTC, Jared Jeffries wrote:
I'm not talking especially about Quora, even if I admit that 
it's on this forum that somebody advised me to learn D to 
improve my object oriented programming skills.


[...]
I think it should instead be advertised as the perfect language 
to learn programming and web development, because that's where 
it really shines, IMHO.


Why do you believe this?  Don't tell me here: write it up as a 
post on your blog and link it on those fora.  That will help 
advertise the language.


Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread XavierAP via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 09:19:53 UTC, Christian Köstlin 
wrote:

On 01/03/2017 00:09, Joseph Rushton Wakeling wrote:

if (!__ctfe) assert(false);

... might be the best option.  That shouldn't be compiled out 
even in -release builds.
thats a nice idea! is this happening because of assert(false) 
being always part of release builds (as mentioned here: 
https://dlang.org/spec/contracts.html#assert_contracts) or 
because the if would have no instructions anymore if this is 
removed.


Yes assert(false) or assert(0) is a special case according to the 
specification. At least in the DMD implementation it is not 
removed for -release. If reached it throws an "object.Error@(0): 
assert(0) or HLT instruction" instead of 
core.exception.AssertError


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Jack Stouffer via Digitalmars-d

On Wednesday, 1 March 2017 at 17:09:51 UTC, Jared Jeffries wrote:
I'm not talking especially about Quora, even if I admit that 
it's on this forum that somebody advised me to learn D to 
improve my object oriented programming skills.


I'm just saying that I think that D is de facto one of the best 
languages for beginners like me.


A lot better than most mainstream language these forum are 
always promoting as the best starting programming language.


So it's sad that D is ignored by so many young programmers, 
because when they do some research on google, like I did, there 
are too little chance they will find this advice.


D is mainly known as a system programming language because it's 
indeed "C++ done well". But that's probably not enough to 
convince C++ addicts to try D, especially because of the 
garbage collector.


But D is a great alternative to mainstream garbage collected 
languages like Java, C#, Javascript, PHP, etc.


I think it should instead be advertised as the perfect language 
to learn programming and web development, because that's where 
it really shines, IMHO.


I agree. We have a lot to improve in terms of marketing.

Mainly our messaging is jumbled.

Rust = memory safety
Go = the best runtime around
D = everything I guess?

And the problem is that D is good at everything (IMO), so how do 
we go about marketing to everyone without getting our messages 
mixed up in the public's view.


DCV v0.2.0 - adaptation to the new ndslice

2017-03-01 Thread Relja Ljubobratovic via Digitalmars-d-announce

Hi everyone,

I wanted to let you know that we've released new version of 
DCV[1], an open source computer vision library, written in D 
programming language, with goal to provide tools for solving most 
common computer vision problems - various image processing tasks, 
feature detection and tracking, camera calibration, stereo etc.


Major change in this one is the integration of new ndslice 
package[2], Ilya Yaroshenko has been working on for past couple 
of months.


These major API braking changes have initiated following 
refactoring of the library[3]. We've recognized some critical 
design errors, and until those are sorted out, we've paused the 
implementation of new features. But, with help of more 
experienced colleagues at libmir org[4], hopefully we'll soon 
have a stable API, upon which we'll safely build new computer 
vision algorithms.


Best regards,
Relja

[1] https://github.com/libmir/dcv
[2] https://github.com/libmir/mir-algorithm
[3] https://github.com/libmir/dcv/issues/87
[4] https://github.com/libmir


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Jared Jeffries via Digitalmars-d
I'm not talking especially about Quora, even if I admit that it's 
on this forum that somebody advised me to learn D to improve my 
object oriented programming skills.


I'm just saying that I think that D is de facto one of the best 
languages for beginners like me.


A lot better than most mainstream language these forum are always 
promoting as the best starting programming language.


So it's sad that D is ignored by so many young programmers, 
because when they do some research on google, like I did, there 
are too little chance they will find this advice.


D is mainly known as a system programming language because it's 
indeed "C++ done well". But that's probably not enough to 
convince C++ addicts to try D, especially because of the garbage 
collector.


But D is a great alternative to mainstream garbage collected 
languages like Java, C#, Javascript, PHP, etc.


I think it should instead be advertised as the perfect language 
to learn programming and web development, because that's where it 
really shines, IMHO.


Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Dukc via Digitalmars-d-learn
On Wednesday, 1 March 2017 at 16:43:41 UTC, Jonathan M Davis 
wrote:
Assert is for program invariants. If the condition is true, 
your program is outright broken.


Error: He meant that if the condition is FALSE, the program is 
faulty.





Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, February 28, 2017 09:16:47 sarn via Digitalmars-d-learn wrote:
> On Tuesday, 28 February 2017 at 07:41:36 UTC, Christian Köstlin
>
> wrote:
> > As I understand the only difference between assert and enforce
> > is, that
> > assert is not compiled into releases?
> >
> > Thanks!
> > Christian
>
> Pretty much so.  The intention is that assert means something
> that's supposed to be true (and can be assumed in release) while
> enforce means something you want to be true (but can't guarantee).
>
> E.g., you can assert that a list is sorted after running heapsort
> on it, but you need to enforce that a file is in the correct
> format.

I'd put it more strongly than that. assert is for program invariants. If the
condition is true, your program is outright broken. For performance reasons,
assertions are removed in release builds, but many folks think that they
should be left in and kill our program if they fail in release (and would be
why some folks won't compile with -release even in production). assert(0)
_does_ stay in your program in release mode and could be used in conjuction
with an if statement (since it doesn't have a condition to test), but it's
intended for unreachable code. Normally, assert throws an AssertError on
failure (assert(0) becomes an HLT instruction in release), and types derived
from Error are intended to kill your program on failure, precisely because
they indicate a bug in your program and if they fail, it means that your
program is in an undefined state (RangeError, which is use a failed bounds
check for an array would be another example of an Error).

Exceptions - specifically Exception or any type derived from it - are for
general error conditions that occur while a program is running but do not
necessarily indicate a bug in the program. Bad user input, stuff on disk,
anything in the environment, etc. - i.e. anything over which you have no
control -  generally would be the sort of thing that triggers an exception
when the program hits them. Exceptions are part of the normal operation of
your program and are expected to be recoverable (though a typical program
that hits no bad input would typically never need to throw an exception).

In general, the distinction between assertions and exceptions should be very
clear: assertions are for program invariants and exceptions are for when
your program encounters bad input or any other error condition that does not
indicate a bug in your program. Unfortunately however, the fact that enforce
looks the same as assert does seem to confuse some folks.

The only place that gets a bit debatable is testing arguments to a function,
and that really depends on the function's contract. If the function requires
that its input meet some conditions, and it's a bug if the caller does not
meet them, then an assertion should be used, whereas if it's not a bug in
the program if the caller provides bad input, then an exception is
appropriate. And when it should be considered a program bug and when it
should just be considered normal program execution depends on exactly what
the function is doing as well as your programming style (e.g. some folks
prefer that the caller be required to verify the correct input, whereas
others prefer that the callee do that; there are pros and cons to both). So,
that can get subjective. But ultimately, assertions are still for program
bugs, whereas exceptions are for normal error conditions that do not
indicate a bug in the program.

- Jonathan M Davis




Re: Mixing libraries

2017-03-01 Thread bauss via Digitalmars-d-learn

On Tuesday, 28 February 2017 at 20:08:25 UTC, Jordan Wilson wrote:

Hello,

Been trying to learn the Simple Fast Multimedia Library (SFML) 
using the Derelict bindings, and noticed some functionality is 
offered by both SFML and the std library (for example, sfClock 
and sfMutex).


Is there a general design principle of, say, use the std 
library whenever possible and only SFML when I have too? Or 
should I try to be consistent and use SFML library whenever 
possible?


Thanks,

Jordan


There is a better binding.

dsfml.

You can find it here: http://dsfml.com/


rdmd with a file with no extension

2017-03-01 Thread Colin via Digitalmars-d-learn
When running a small D program through rdmd, it seems the file 
needs a .d extension to work.


```
$ ./testscript2
Error: module testscript2 is in file './testscript2.d' which 
cannot be read


$ cat testscript2
#!/usr/bin/env rdmd

void main(string[] args){
import std.stdio;

writeln(args);
}

```

Trying the above on OSX if that makes a difference.

Any way to get these to work short of renaming it testscript2.d?


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Jack Stouffer via Digitalmars-d
On Tuesday, 28 February 2017 at 23:29:24 UTC, Jared Jeffries 
wrote:
I've read the answer to questions like "Which is the best 
programming language to learn in 2017?".


Nobody was telling anything about D, which is really sad, 
because in my opinion D could be one of the best answers to 
this question.


I've answered this question. Better late than never.

I suggest that other "happy users" of this language do the 
same...


There's a reason stackoverflow and 
softwareengineering.stackexchange delete these kinds of 
questions: they're counter productive and can't actually be 
answered.


The question "Which is the best programming language to learn in 
2017" is one such question. It comes down strictly to opinion and 
circumstance. Because of this, the "answers" are either answering 
a different question or just ads for the user's favorite 
language. It seems most of the top answers in that thread took 
the question to mean "Which language would be most likely to get 
me a job in 2017", which isn't the same.


Programming questions on Quora are the dumping ground for bad SO 
questions.


Most D power users spend their time either on the IRC or on SO.


[Issue 17229] File.byChunk (ubyte) w/ stdout.lockingTextWriter corrupts utf-8 data (and is very slow)

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17229

--- Comment #6 from Steven Schveighoffer  ---
(In reply to anonymous4 from comment #5)
> static assert(is(ubyte:dchar));
> This assert succeeds. Is it intended? It's why LockingTextWriter accepts
> bytes event though it's a text writer.

Yes, in the compiler, ubyte and dchar are fundamentally unsigned integer types.
You can implicitly convert via integer promotion.

Technically, char can integer promote to dchar as well. However, foreach(dchar
d; someCharArray) is specialized in the compiler to go through auto decoding.

The forums contain volumes of battles on auto-decoding and how the choice has
affected D, I don't think we need to rehash it here. What we need to do is make
it so obviously wrong code is not accepted for this function. I'll try and get
a PR together.

--


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 1 March 2017 at 06:19:30 UTC, lobo wrote:
Is it possible to use your tool to generate the docs for my own 
code?


Yes, but I don't actually support it yet (you can grab the code 
from the link rikki gave but you're on your own).


I work on this in between the other million things I have to do, 
so we are probably still a bit away from this, but once I'm happy 
with the feature set, I'll call it "beta" in the header and start 
supporting it for other people, through a download of the 
generator or probably an upload to my site of a zip of your 
project.


My ideal end goal is to have a combined search too btw, so you 
can find docs for anything from the dpldocs.info homepage.


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Mike Parker via Digitalmars-d

On Wednesday, 1 March 2017 at 10:20:45 UTC, Jared Jeffries wrote:



I suggest that D lovers answer as often as possible to these 
kind of questions on these websites.


Plenty of people do, particularly on reddit, StackOverflow, 
Hacker News, and whatever forums & communities they tend to hang 
out at (e.g. gamedev.net). If there's an absence of such at 
Quora, it's just because none of the vocal D users are using it.


Project Highlight: vibe.d

2017-03-01 Thread Mike Parker via Digitalmars-d-announce
Most of us here are already familiar with vibe.d. In this post, 
Sönke talks a bit about why he started it and why & how he's 
breaking it up into independent packages.


Post:
https://dlang.org/blog/2017/03/01/project-highlight-vibe-d/

Reddit:
https://www.reddit.com/r/programming/comments/5wvs91/project_highlight_vibed_an_io_concurrency_and_web/


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Craig Dillabaugh via Digitalmars-d
On Wednesday, 1 March 2017 at 08:12:05 UTC, Nick Sabalausky 
(Abscissa) wrote:

On 02/28/2017 06:29 PM, Jared Jeffries wrote:

What's quora?

(It's really hard to always keep on top of all the latest tread 
sites/appz/whatever. It's all so fly-by-night.)


Quora is a general Q forum and hang-out for narcissistic 
know-it-alls. In fairness, the answers are typically of high 
quality, and there are definitely some smart folks on there.  By 
I get turned off by folks who do things like list their IQ or 
Mensa membership in their personal profiles, or post about their 
sexual exploits.


However the forum does often answer some highly important and 
relevant questions.  My favorite so far was the "If I wanted to 
jump from an airplane flying at 30,000 feet with nothing but 
bubble wrap for protection, how much would I need?"



Since you are no doubt curious, I believe the answer was you 
would need to be wrapped in a ball about 4m in radius.  They 
never explained how you would get that on the plane though.


Re: foreach for string[string]AA

2017-03-01 Thread Minty Fresh via Digitalmars-d-learn
On Tuesday, 28 February 2017 at 18:16:45 UTC, Anton Pastukhov 
wrote:
On Tuesday, 28 February 2017 at 17:16:43 UTC, Daniel Kozák 
wrote:

V Tue, 28 Feb 2017 15:15:00 +
Anton Pastukhov via Digitalmars-d-learn
 napsáno:


I can't see the logic in AA foreach order. Consider this code:
...
Output:
three
two
one
four

I was sure output should be
one
two
three
four


https://forum.dlang.org/post/xbanhtkvrizyqjcib...@forum.dlang.org


Thank you for the link, it was informative reading. It's a pity 
that still there is no ordered AA at least as a library type.


Ordered AA isn't that common a use case, and it's not without 
overhead. You essentially need to store an array of keys that 
define iteration order, which requires extra memory allocations 
(and, depending on implementation, may slow down iteration as 
well).


I come from a Ruby background, so I have found key order useful 
in the past, but in most cases I probably could've gotten by just 
fine with an array or set of element pairs.


Introduction of a more convenient tuple type into D might make 
something like this easier.


Re: Fast hashtable

2017-03-01 Thread deadalnix via Digitalmars-d

On Wednesday, 1 March 2017 at 06:44:34 UTC, Cecil Ward wrote:

const uint power2 = 512; // say, some 1 << n anyway
const uint prime = 509; // some prime just below the power, 
some prime > power2/2


static assert( power2 - 1 - prime < prime );

x = x & ( power2 - 1 );
x = ( x >= prime ) ? x - prime : x;

which is good news on my x86 with GDC -O3 (only 3 operations, 
and sub cmovx ) - all well provided you make sure that you are 
getting CMOVx not branches. I could work out the power from the 
prime using CTFE given a bit of thought. Maybe CTFE could even 
do the reverse?


Have I finally gone mad?


The lower slot will be twice as crowded as the higher ones.


Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread bachmeier via Digitalmars-d

On Wednesday, 1 March 2017 at 05:18:59 UTC, Adam D. Ruppe wrote:
Or better yet, surrender to me! D is gaining features that ddoc 
doesn't even know how to handle but I do...


If by "surrender", you mean adopt your system for the official 
documentation, well I sure hope not. That's a fast way to kill 
progress on anything related to this language.


[Issue 17136] dictionary get(value, defaultValue) should be nothrow

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17136

Lucia Cojocaru  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||lucia.mcojoc...@gmail.com
 Resolution|--- |DUPLICATE

--- Comment #1 from Lucia Cojocaru  ---


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

--


[Issue 12647] Lazy parameter evaluation should be marked as nothrow

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12647

--- Comment #8 from Lucia Cojocaru  ---
*** Issue 17136 has been marked as a duplicate of this issue. ***

--


[Issue 17229] File.byChunk (ubyte) w/ stdout.lockingTextWriter corrupts utf-8 data (and is very slow)

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17229

--- Comment #5 from anonymous4  ---
static assert(is(ubyte:dchar));
This assert succeeds. Is it intended? It's why LockingTextWriter accepts bytes
event though it's a text writer.

--


Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Jared Jeffries via Digitalmars-d

Here is a link to my answer :

https://www.quora.com/Which-is-the-best-programming-language-to-learn-in-2017/answer/Jared-Jeffries-4?prompt_topic_bio=1



Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Jared Jeffries via Digitalmars-d
It's one of those forum websites where you ask a question, 
experts give their advices and people vote for the best answer.


You can find them by searching "best programming language 2017" 
in google for instance.


I suggest that D lovers answer as often as possible to these kind 
of questions on these websites.


For instance :
- best programming language
- best programming language for ...
- best programming language to learn
- etc

It's needed because I didn't know that D existed until somebody 
advised me to try it, and now it's my favorite language.


I'm now studying Java and C++ because I have to, but I'll still 
continue to use D and promote it.


I really learned a lot from D, it's probably the best "first 
programming language to learn" that one can find, much better 
than C, and even Java, C#, C, C++, Javascript, etc.


It should be advertised a lot for that, because it's probably the 
best one can find at the moment.


And it's also probably easier to convince new programmers like me 
to learn D as a first object oriented language, than people who 
are using other similar languages for years or decades.




Re: WebAssembly design is done?

2017-03-01 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 1 March 2017 at 09:00:42 UTC, Nick Sabalausky 
(Abscissa) wrote:
If we could invent a technical way to screw over, underminine, 
and completely replace corporate interests, it would be the 
single greatest achievement in computing (not to mention 
economic theory), EVER.


I bet Intel would have undermined WebAssembly if they were given 
a chance. Now other CPU vendors (e.g. mobile) can strengthen 
their position by making WebAssembly applications a target for 
testing.


So, maybe the conclusion is: don't let corporations create 
technology standards in their main domain, because then they try 
to create monopolies and start misbehaving. Browsers is  a 
side-line tech, so... this might have a chance..?




Re: Fast hashtable

2017-03-01 Thread Daniel Kozak via Digitalmars-d

On Wednesday, 1 March 2017 at 06:44:34 UTC, Cecil Ward wrote:


I liked that article. I didn't really understand the point 
about implementation of modulo primes, maybe I missed 
something. Given that our man is doing modulo a 'known' value 
(he had a switch statement to get to them), why not do 
something rather cheaper than a compiler-expanded constant 
div/mod made up of multiplies and shifts


const uint power2 = 512; // say, some 1 << n anyway
const uint prime = 509; // some prime just below the power, 
some prime > power2/2


static assert( power2 - 1 - prime < prime );

x = x & ( power2 - 1 );
x = ( x >= prime ) ? x - prime : x;

which is good news on my x86 with GDC -O3 (only 3 operations, 
and sub cmovx ) - all well provided you make sure that you are 
getting CMOVx not branches. I could work out the power from the 
prime using CTFE given a bit of thought. Maybe CTFE could even 
do the reverse?


Have I finally gone mad?


Yes :D, this is something compiler should do.

btw: https://github.com/dlang/phobos/pull/1452




Re: Snowflake Strings

2017-03-01 Thread Kagamin via Digitalmars-d-announce
In case strings hash to the same value, the linkers (ld and ms) 
have an option to detect discrepancy in content.


Re: WebAssembly design is done?

2017-03-01 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 1 March 2017 at 08:56:37 UTC, Nick Sabalausky 
(Abscissa) wrote:

On 03/01/2017 03:47 AM, Ola Fosheim Grøstad wrote:

On Wednesday, 1 March 2017 at 08:01:41 UTC, Saurabh Das wrote:
I'm not so up-to-date about the mechanics of WebAssembly, but 
it would

be pretty exciting to run D code in the browser.

Is this now possible or have I completely misunderstood what
WebAssembly allows for?


It should be possible, at least if you give up on the garbage 
collector.




Huh? Isn't webasm GC'ed? Ir is it like a D-vs-wasm CG 
incompatibility?


Nope, no GC. It is a "minimum viable product", so also no 
threading or SIMD. This is a good strategy, make sure that all 
implementations are fully compliant and collect experience before 
adding more features into the mix.


http://webassembly.org/docs/gc/

I believe both Rust  and C++ compilers will target WebAssembly. 
In the beginning I suspect the best approach is to the core 
application in a set of WebAssembly modules and tie it together 
with the UI in JavaScript/TypeScript/JSX/Angular2 etc




Re: How to enforce compile time evaluation (and test if it was done at compile time)

2017-03-01 Thread Christian Köstlin via Digitalmars-d-learn
On 01/03/2017 00:09, Joseph Rushton Wakeling wrote:
> On Tuesday, 28 February 2017 at 00:22:28 UTC, sarn wrote:
>>> If you ever have doubts, you can always use something like this to
>>> check:
>>>
>>> assert (__ctfe);
>>
>> Sorry, "enforce" would more appropriate if you're really checking.
> 
> if (!__ctfe) assert(false);
> 
> ... might be the best option.  That shouldn't be compiled out even in
> -release builds.
thats a nice idea! is this happening because of assert(false) being
always part of release builds (as mentioned here:
https://dlang.org/spec/contracts.html#assert_contracts) or because the
if would have no instructions anymore if this is removed.

cK



[Issue 17229] File.byChunk (ubyte) w/ stdout.lockingTextWriter corrupts utf-8 data (and is very slow)

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17229

Jon Degenhardt  changed:

   What|Removed |Added

Summary|File.byChunk w/ |File.byChunk (ubyte) w/
   |stdout.lockingTextWriter is |stdout.lockingTextWriter
   |very slow   |corrupts utf-8 data (and is
   ||very slow)

--- Comment #4 from Jon Degenhardt  ---
Changing the subject to reflect the more serious problem, corruption of utf-8
encoded data. As described in one of the comments, this corruption occurs in a
file copy example in the documentation.

--


[Issue 17229] File.byChunk w/ stdout.lockingTextWriter is very slow

2017-03-01 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17229

--- Comment #3 from Jon Degenhardt  ---
I've confirmed that File.byChunk with lockingTextWriter corrupts utf-8 encoded
files.

I used the unicode test file:
http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-demo.txt

and the example given with the File.byChunk documentation:

// Efficient file copy, 1MB at a time.
import std.algorithm, std.stdio;
void main()
{
stdin.byChunk(1024 * 1024).copy(stdout.lockingTextWriter());
}

This file copy program corrupts the unicode characters as described in Steven's
comment. This is a quite problematic, both because of character corruption and
because it is an example in the documentation.

The new method, lockingBinaryWriter, copies the file correctly. It is available
starting with 2.073.1. lockingBinaryWriter also copies the file quickly,
eliminating the performance issue.

It is appears from the PR for lockingBinaryWriter
(https://github.com/dlang/phobos/pull/2011) that there was discussion of the
roles of Binary and Text writer.

Regardless of availability of the lockingBinaryWriter, the lockingTextWriter
certainly looks broken when used with the ubyte data type. Personally, I think
it makes sense for lockingTextWriter to assume ubyte arrays are correctly
encoded, or perhaps are utf-8 encoded. This would potentially allow newline
translation, something that the lockingBinaryWriter would presumably not do.

--


Re: WebAssembly design is done?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 03/01/2017 03:46 AM, Ola Fosheim Grøstad wrote:

On Tuesday, 28 February 2017 at 21:50:11 UTC, Jack Stouffer wrote:

What a long, roundabout path we've taken to end up back where we
started: shipping binaries in a sandboxed environment.


Portable object-files is something that that people have tried to
achieve since the 1980s, but vendors have always undermined it. If this
goes through then it will be the first time we have a portable object
files with backing of the major vendors. Even Microsoft.



If we could invent a technical way to screw over, underminine, and 
completely replace corporate interests, it would be the single greatest 
achievement in computing (not to mention economic theory), EVER.


Believe it it not, I'm still holding my breath for that, impossible 
though it may be. Call me a dreamer. Or a nutjob ;) Same thing, I suspect ;)




Re: WebAssembly design is done?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 03/01/2017 03:47 AM, Ola Fosheim Grøstad wrote:

On Wednesday, 1 March 2017 at 08:01:41 UTC, Saurabh Das wrote:

I'm not so up-to-date about the mechanics of WebAssembly, but it would
be pretty exciting to run D code in the browser.

Is this now possible or have I completely misunderstood what
WebAssembly allows for?


It should be possible, at least if you give up on the garbage collector.



Huh? Isn't webasm GC'ed? Ir is it like a D-vs-wasm CG incompatibility?


Re: WebAssembly design is done?

2017-03-01 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 1 March 2017 at 08:01:41 UTC, Saurabh Das wrote:
I'm not so up-to-date about the mechanics of WebAssembly, but 
it would be pretty exciting to run D code in the browser.


Is this now possible or have I completely misunderstood what 
WebAssembly allows for?


It should be possible, at least if you give up on the garbage 
collector.




Re: WebAssembly design is done?

2017-03-01 Thread Ola Fosheim Grøstad via Digitalmars-d

On Tuesday, 28 February 2017 at 21:50:11 UTC, Jack Stouffer wrote:
What a long, roundabout path we've taken to end up back where 
we started: shipping binaries in a sandboxed environment.


Portable object-files is something that that people have tried to 
achieve since the 1980s, but vendors have always undermined it. 
If this goes through then it will be the first time we have a 
portable object files with backing of the major vendors. Even 
Microsoft.


The Java VM essentially ended up as a single vendor solution and 
didn't live up to it's hype in the browser.




Re: Why don't you advertise more your language on Quora etc ?

2017-03-01 Thread Nick Sabalausky (Abscissa) via Digitalmars-d

On 02/28/2017 06:29 PM, Jared Jeffries wrote:

I've read the answer to questions like "Which is the best programming
language to learn in 2017?".

Nobody was telling anything about D, which is really sad, because in my
opinion D could be one of the best answers to this question.

I've answered this question. Better late than never.

I suggest that other "happy users" of this language do the same...


What's quora?

(It's really hard to always keep on top of all the latest tread 
sites/appz/whatever. It's all so fly-by-night.)




Re: WebAssembly design is done?

2017-03-01 Thread Saurabh Das via Digitalmars-d
I'm not so up-to-date about the mechanics of WebAssembly, but it 
would be pretty exciting to run D code in the browser.


Is this now possible or have I completely misunderstood what 
WebAssembly allows for?




Re: dpldocs: xlinking and Documented destructors and postblits

2017-03-01 Thread Sebastiaan Koppe via Digitalmars-d

On Wednesday, 1 March 2017 at 05:18:59 UTC, Adam D. Ruppe wrote:

Contrast to the official docs:
http://dlang.org/phobos/std_typecons.html#.RefCounted
http://dlang.org/library-prerelease/std/typecons/ref_counted.html


my 2 cents:

The officials docs has too much grey and the information is not 
where you expect it to be. Yours is way more readable to me.