Re: Should the "front" range primitive be "const" ?

2018-01-31 Thread Simen Kjærås via Digitalmars-d-learn

On Wednesday, 31 January 2018 at 01:45:57 UTC, H. S. Teoh wrote:
I haven't thought through it carefully, but if .headConst is a 
viable solution to the head-const problem, then conceivably we 
could also extend it to deal with immutable payloads too.  Then 
we could go from, say, RefCounted!(immutable(T)) to 
RefCounted!(const(T)) generically, without any casting or 
breaking the type system.  We could potentially expand the 
scope of usefulness of immutable this way, if this approach 
turns out to be workable.


Going from RefCounted!(immutable(T)) to RefCounted!(const(T)) is 
nice, but I'd like to see a conversion from, const(RefCounted!T) 
to RefCounted!(const(T)). While this cannot be done without 
casts, the logic can be put inside .headMutable(), and include 
relevant checks. This will make it much safer than having the 
programmer cast manually.


--
  Simen


[Issue 18347] New: stdx.allocator dispose should be @safe

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18347

  Issue ID: 18347
   Summary: stdx.allocator dispose should be @safe
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

---
import std.stdio;

void main() @safe
{
import std.experimental.allocator.mallocator : Mallocator;
import std.experimental.allocator : makeArray, dispose;
alias alloc = Mallocator.instance;
auto p = alloc.makeArray!ubyte(20);
alloc.dispose(p);
}
---

https://run.dlang.io/is/t2IMq2

No ready why this shouldn't work.

--


[Issue 11900] Implicit cast of string literal -> char* causing ambiguous call

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11900

Simen Kjaeraas  changed:

   What|Removed |Added

 CC||c...@benjamin-thaut.de

--- Comment #6 from Simen Kjaeraas  ---
*** Issue 15529 has been marked as a duplicate of this issue. ***

--


[Issue 15529] opEquals(string) conflicts with opEquals(const(char)*)

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15529

Simen Kjaeraas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||simen.kja...@gmail.com
 Resolution|--- |DUPLICATE

--- Comment #1 from Simen Kjaeraas  ---


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

--


[Issue 3968] Some way to do certain implicit casts with operator overloading

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3968

Simen Kjaeraas  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||simen.kja...@gmail.com
 Resolution|--- |FIXED

--- Comment #1 from Simen Kjaeraas  ---
This works today:

struct Foo {
int x;
int opCast(T:int)() {
return this.x;
}
alias fn = opCast!size_t;
alias fn this;
}
unittest {
Foo f = Foo(5);
auto a1 = new int[cast(int)f]; // OK
auto a2 = new int[f];  // Also OK
}

The syntax 'alias opCast!size_t this;' fails to compile, citing 'no identifier
for declarator opCast!size_t'.

--


Re: Don't expect class destructors to be called at all by the GC

2018-01-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 31, 2018 10:51:10 DanielG via Digitalmars-d-learn 
wrote:
> On Wednesday, 31 January 2018 at 10:34:53 UTC, Mike Parker wrote:
> > delete is deprecated:
> >
> > https://dlang.org/deprecate.html#delete
>
> Ah, thanks! Actually double-thanks, because my progress through
> your book is what prompted me to search for threads about class
> destructors. The existence of .destroy answers my question
> (namely, "should I just use 'delete', or my own .dispose method,
> for deterministic resource freeing?")

The main problem with delete is that it's inherently unsafe. GC-managed
memory is supposed to be @safe (it's one of the main reasons that D has a GC
in the first place), but having the programmer go and delete a GC-managed
object rather than waiting for the GC to do it makes it trivial to do wrong
stuff like free an object's memory while it's still referenced by something
else (the sort of thing that the GC is supposed to avoid). It's far better
to either explicitly destroy the object without freeing its memory or to use
memory that is not managed by the GC if you want deterministic destruction
of an object on the heap.

- Jonathan M Davis



Re: adrdox vs markdown vs ddoc

2018-01-31 Thread Seb via Digitalmars-d

On Thursday, 1 February 2018 at 01:23:38 UTC, Adam D. Ruppe wrote:
Now, if a 5-character insertion requires 29 edit operations, 
what do you think the programmer is going to do? Keep up with 
it, or let the documentation stay slightly suboptimal and 
out-of-date because it is a hassle?


To be fair, I feel with you and all the tables I have created are 
formatted as good as DDoc allows, e.g.


https://github.com/dlang/phobos/blob/master/std/exception.d

Actually I prefer doing tables in Ddoc because it's a little 
easier (if you know all the macros)


BTW, I also hate any syntax that requires editing every line. 
Again, it goes back to that linear vs constant time edit. I 
just copy/pasted that from the website. Using bbcode or html or 
ddoc or adrdox, you just surround it with some tag like I did 
there. Even indenting it is not really necessary to make it 
legible and functional (though like every editor makes that 
simple anyway).


I prefer markdown's ``` blocks to the leading for spaces 
primarily for this reason, though adding language tags is a 
secondary benefit to that.


This is also why I friggen hate comments with leading stars:

/*
 * why write all
 * this leading crap?
 */

/*
This is so much better
*/


Same here.
We recently added this to the DStyle:

https://dlang.org/dstyle.html#phobos_documentation
https://github.com/dlang/dlang.org/pull/2129

So, new Phobos code will be written without stars.

Edit those without using editor macros. Barf. And if you are 
willing to use editor macros, the other justification for it - 
making the comment look different than code - disappears since 
if your editor is fancy enough to understand that leading * 
crap and automatically reformat it, it could just as well 
syntax highlight it in some way (including displaying leading 
stars without saving them to the file!)


I wouldn't expect `...` to produce a link; it should just be 
formatted differently (typically in monospace font) to 
indicate that it's a code snippet.


It tells quite a bit about the complexity of Ddoc that I had to 
add support for -D to run.dlang.io ...


Using [...] syntax for links makes more sense to me, even 
though personally, I really prefer to just write plain ole 
text and paste the URL in its own indented block:


http://example.nowhere.edu/blah/blah/blah


adrdox recognizes urls and I like writing them like that when I 
actually write a url but the benefit of [reference] is that 
it doesn't require an actual url. It is just a symbol, in scope 
even.


I'm not a fan of Ddoc by any means, but that has been fixed in 
Ddoc does this too now: https://run.dlang.io/is/75Z55o



https://github.com/dlang/dmd/pull/7043


[Issue 18346] New: implicit conversion from int to char in `"foo" ~ 255` should be illegal

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18346

  Issue ID: 18346
   Summary: implicit conversion from int to char in `"foo" ~ 255`
should be illegal
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: minor
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

string a="foo" ~ 255; // compiles but should not (too easy to confuse with
"foo"~"255" as in other languages, when instead it means append char(255))

string a="foo" ~ 256;
Error: incompatible types for (("foo") ~ (256)): 'string' and 'int'

instead: we should write:
```
string a="foo" ~ char(255);
```

--


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d

On Wednesday, 31 January 2018 at 21:19:50 UTC, H. S. Teoh wrote:
On Wed, Jan 31, 2018 at 08:05:37PM +, Adam D. Ruppe via 
Digitalmars-d wrote:

On Wednesday, 31 January 2018 at 19:59:23 UTC, Seb wrote:
> ... and Mike did put _a lot_ of effort in pushing colorful 
> error messages:


Yes, that was a direct result of that forum post I alluded to. 
It isn't something he (or most anyone else, in my experience) 
really cares about, but he felt if he did it then many Walter 
wouldn't waste any more time on it.


In fact, I find the colors distracting.  Pretty? Certainly.  
But helpful?  Not really, at least not for me.  I'd rather 
stick with just B But all things considered, it's a pretty 
minor issue, and one that's not worth the time to complain 
about.  (Haha, and look what I just did. :-P)



T


BTW run.dlang.io supports DMD's colorized error messages since a 
while too, e.g.


https://run.dlang.io/is/neLaOB

If anyone minds, send a PR to 
https://github.com/dlang-tour/core/blob/master/public/static/css/ansi.css


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 19:01:46 Walter Bright via Digitalmars-d 
wrote:
> On 1/31/2018 6:14 PM, Jonathan M Davis wrote:
> > I have to wonder if my settings are right. I've never noticed any color
> > in error messages. Messing around with some errors right now, the only
> > color I see is that "Error:" is in red, and some of the text is bolded,
> > so it's white instead of the grey that text is normally on my console.
> > Maybe my console's settings aren't interacting with the color stuff
> > very well.
> Nah, it's just the code in dmd:
>
> if (username == "Jonathan")
> color = off;// muwa-ha-ha-hah!

Clearly, there are downsides to actually knowing the people who work on the
compiler. ;)

- Jonathan M Davis



Re: Inline code in the docs - the correct way

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 18:58:29 Walter Bright via Digitalmars-d 
wrote:
> On 1/31/2018 5:37 PM, Steven Schveighoffer wrote:
> > Where it breaks down is when you have many nested tags, and you end with
> > )
> Long ago, I adjusted my text editor so that when the cursor is placed on
> ), the matching ( is found. Ditto for { }, [ ], < >, and
> #if/#elif/#else/#endif (!). It's been incredibly convenient.
>
> With Ddoc, I do this at the opening (, and see if the matching one is the
> closing ). If not, surprisingly, the match shown is the one that is
> erroneous.
>
> https://github.com/DigitalMars/med/blob/master/src/med/search.d#L453

vim does that and it's invaluable. It also makes it easy to hop between
matching parens or braces, which is part of what drives me nuts about
python. Because it doesn't have braces, it's harder to hop to the opposite
end of a block.

Now, I think that it's still problematic when you end up with a bunch of
parens in a row, since you tend to have to put your study it and put your
cursor on each paren to understand what you're looking at, but having that
highlighting definitely helps.

- Jonathan M Davis



[Issue 13632] Second argument for std.string.strip

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13632

--- Comment #3 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/2346990c091e68d0b07ed2fbd41dd865a3251713
Fix issue 13632: Enhancement to std.string.strip

Added second argument similar to Python `str.strip`

Second argument accepts a string of characters to strip and
strips only those characters.

Examples:

"xyzhello".stripLeft("xyz") == "hello"
"helloxy ".stripRight("xy ") == "hello"
"xhellox".strip("x") == "hello"

Signed-off-by: Aravinda VK 

https://github.com/dlang/phobos/commit/8d93656917bb0f301ed07fe9de773f7484987361
Merge pull request #6023 from aravindavk/string_strip_enhancement

Fix issue 13632: Enhancement to std.string.strip
merged-on-behalf-of: unknown

--


[Issue 13632] Second argument for std.string.strip

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13632

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

   What|Removed |Added

 Status|ASSIGNED|RESOLVED
 Resolution|--- |FIXED

--


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 3:38 PM, H. S. Teoh wrote:

A "small fry" like myself wouldn't dare
to push the merge button on changes of this kind of magnitude, since it
could have drastic consequences that I can't foresee due to not having a
full grasp of the full scale of what is being changed.

https://youtu.be/amclN9RG49c?t=146


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 6:14 PM, Jonathan M Davis wrote:

I have to wonder if my settings are right. I've never noticed any color in
error messages. Messing around with some errors right now, the only color I
see is that "Error:" is in red, and some of the text is bolded, so it's
white instead of the grey that text is normally on my console. Maybe my
console's settings aren't interacting with the color stuff very well.


Nah, it's just the code in dmd:

   if (username == "Jonathan")
   color = off;// muwa-ha-ha-hah!



Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 5:58 PM, H. S. Teoh wrote:

cosmetic features.


I tough lesson I've learned is that cosmetics matter, a lot. Sometimes much more 
than substance. There's no getting away from it.


Re: Inline code in the docs - the correct way

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 5:37 PM, Steven Schveighoffer wrote:

Where it breaks down is when you have many nested tags, and you end with )


Long ago, I adjusted my text editor so that when the cursor is placed on ), the 
matching ( is found. Ditto for { }, [ ], < >, and #if/#elif/#else/#endif (!). 
It's been incredibly convenient.


With Ddoc, I do this at the opening (, and see if the matching one is the 
closing ). If not, surprisingly, the match shown is the one that is erroneous.


https://github.com/DigitalMars/med/blob/master/src/med/search.d#L453


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Thursday, February 01, 2018 02:42:52 Adam D. Ruppe via Digitalmars-d 
wrote:
> On Thursday, 1 February 2018 at 02:24:44 UTC, H. S. Teoh wrote:
> > I thought that *is* the color support that was added?  If
> > you're expecting IDE-style syntax highlighting, I think you're
> > setting your expectations a little high for something that
> > ostensibly was banged out in a couple of hours.
>
> Nope, the dmd compiler will highlight code between `` in its
> outputted error messages. dmd already knows how to lex D code
> (obviously) and even has a highlighter for ddoc, so it just pipes
> it through that existing function.
>
> Not all error messages had the `` around its code though. That's
> what Mike did in most his PRs.

I haven't see any syntax highlighting in any error messages. The closest
I've seen is a type name or symbol name being in white instead of grey when
it's mentioned explicitly by name outside of code snippets, but no code
snippets have been anything but grey (which is the default text color for
the console). So, either none of the errors I've gotten are marked up with
`` correctly, or there's something with my setup which makes it so that the
coloring doesn't work.

- Jonathan M Davis



Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Thursday, 1 February 2018 at 02:24:44 UTC, H. S. Teoh wrote:
I thought that *is* the color support that was added?  If 
you're expecting IDE-style syntax highlighting, I think you're 
setting your expectations a little high for something that 
ostensibly was banged out in a couple of hours.


Nope, the dmd compiler will highlight code between `` in its 
outputted error messages. dmd already knows how to lex D code 
(obviously) and even has a highlighter for ddoc, so it just pipes 
it through that existing function.


Not all error messages had the `` around its code though. That's 
what Mike did in most his PRs.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 07:14:57PM -0700, Jonathan M Davis via Digitalmars-d 
wrote:
> On Wednesday, January 31, 2018 17:16:21 Walter Bright via Digitalmars-d 
> wrote:
> > On 1/31/2018 1:19 PM, H. S. Teoh wrote:
> > > I'd rather stick with just B
> >
> >dmd -color=off file.d
> 
> I have to wonder if my settings are right. I've never noticed any
> color in error messages. Messing around with some errors right now,
> the only color I see is that "Error:" is in red, and some of the text
> is bolded, so it's white instead of the grey that text is normally on
> my console. Maybe my console's settings aren't interacting with the
> color stuff very well.
[...]

I thought that *is* the color support that was added?  If you're
expecting IDE-style syntax highlighting, I think you're setting your
expectations a little high for something that ostensibly was banged out
in a couple of hours. :-D


T

-- 
Be in denial for long enough, and one day you'll deny yourself of things you 
wish you hadn't.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 17:16:21 Walter Bright via Digitalmars-d 
wrote:
> On 1/31/2018 1:19 PM, H. S. Teoh wrote:
> > I'd rather stick with just B
>
>dmd -color=off file.d

I have to wonder if my settings are right. I've never noticed any color in
error messages. Messing around with some errors right now, the only color I
see is that "Error:" is in red, and some of the text is bolded, so it's
white instead of the grey that text is normally on my console. Maybe my
console's settings aren't interacting with the color stuff very well.

- Jonathan M Davis



Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 05:16:21PM -0800, Walter Bright via Digitalmars-d wrote:
> On 1/31/2018 1:19 PM, H. S. Teoh wrote:
> > I'd rather stick with just B
> 
>   dmd -color=off file.d

Thanks!

Though, as I said, it doesn't bother me quite enough to want to go
through the effort of explicitly specifying that.  It's just that, if it
were up to me, I wouldn't bother putting in the time and energy to
implement such kinds of cosmetic features.


T

-- 
He who sacrifices functionality for ease of use, loses both and deserves 
neither. -- Slashdotter


Re: Inline code in the docs - the correct way

2018-01-31 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, January 31, 2018 16:19:53 H. S. Teoh via Digitalmars-d wrote:
> In general, almost all text macro / formatting systems, from LaTeX to
> HTML to ddoc, are universally ugly and verbose when it comes to tables,
> and makes my eyes bleed. The only exception I've found so far is
>
> markdown, where you can actually write this:
>   |Blah|Blah|
>   |||
>   |abc |def |
>   |ghi |jkl |
>
> It's not perfect, but it's worlds better than the line noise syntax of
> the alternatives.

Yeah. Tables are generally ugly, though they're also not super-common in
documentation - perhaps enough to be annoying, but most functions don't have
them.

> Actually, for me it's not so much a matter of "it's faster to type";
> it's more of an issue of "when I'm reading (and presumably thinking
> (hard) about) source code, do I really want to expend the mental
> resources to parse the syntax of yet another embedded DSL inside a
> *comment*?".  If I had my way, I would just write a normal comment as
> opposed to a doc comment.  What makes the doc proposition attractive is
> that, in an ideal world, a "normal" comment can be automatically
> translated into nice docs without needing to pepper-spray it with
> foreign syntax particles, so that I can read the comment while working
> on the code, in addition to having nice docs to show to others in a
> format they prefer, like HTML or whatever.
>
> That's why I would actually welcome markdown-like syntax in ddoc. Yeah,
> it has limitations and sux in many ways, but IMNSHO you shouldn't be
> reimplementing complex HTML syntax inside a doc comment anyway -- leave
> that to an external templating engine or whatever you wish to use, and
> just let the doc comment be as readable as possible *as source code*.

Personally, I hate markdown, because it makes certain syntax magical - e.g.
it's not uncommon that a commit message ends up looking bad when github uses
it as the message for a PR, because some piece of code contained * or some
other piece of syntax that markdown decides to do something magical with.

I _much_ prefer the explicit syntax used by ddoc, so I can't say that I'm at
all happy at the idea of markdown syntax being added to ddoc. Ddoc is by no
means perfect, but I don't see adding magical syntax as being a particular
nice fix. Clearly, there's some disagreement on that front however.

Personally, I actually like the fact that the website is done in ddoc, and
while sometimes it looks ugly in the documentation, it mostly looks just
fine. IMHO, the main problem with ddoc for documentation is that it doesn't
automatically handle stuff like cross-links, and it fundamentally can't,
because to do that properly, you have to generate all of the docs at once
with a standard layout for where everything goes so that the links can link
to stuff. To get it right, the compiler would have to actually act like a
documentation generator and not just like it's compiling a file to ddoc.

- Jonathan M Davis



Re: Inline code in the docs - the correct way

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d

On 1/31/18 5:55 PM, Adam D. Ruppe wrote:

Now though, inline code like $(D) and $(REF) are ambiguous. They are 
short enough that they'd normally fall into my "ok with it" zone like 
$(B)... but they are also so common and I want to encourage their use. 
And having three shifted characters that must appear in order is kinda 
painful to type - it just breaks up the thought process, and can get 
somewhat weird to look at.


Where it breaks down is when you have many nested tags, and you end with 
)


I hate that. I've seen many bugs in the D documentation because of that.

I'd rather we use different delimeters for different tags, like markdown.

-Steve


Re: Should the "front" range primitive be "const" ?

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/31/18 7:49 PM, Jonathan M Davis wrote:

On Wednesday, January 31, 2018 11:58:38 Steven Schveighoffer via
Digitalmars-d-learn wrote:

On 1/30/18 8:05 PM, Jonathan M Davis wrote:

Except that unless front returns by ref, it really doesn't matter
whether
front is const unless it's violating the range API, since front is
supposed to return the same value until popFront is called (or if it's
assigned a new value via a front that returns by ref). So, in practice,
putting const on front really doesn't help you any, and it actually
hurts you for range composability.


Right, but that is the difference between a convention ("front is
supposed to...") vs. a compiler-enforced guarantee (modifying data by
calling a const-tagged front is a compiler error).

If you are OK with conventions, you don't need const at all.


Except that if you're the one writing the function and decided whether it's
const or not, you're also the one deciding whether it returns by ref or not.
Unless you're dealing with a reference type, and it doesn't return by ref,
then const doesn't protect front at all. It just affects whether it can be
called on a const range.


You are misunderstanding here. You don't put const on front for the 
purpose of allowing const ranges (which are useless), what it does is 
say that the compiler guarantees, *even if the range is mutable* that 
front won't modify it.


That is, code like the following is rejected by the compiler:

int front() const { return ++val; }

In other words, it's a contract that you can read without having to 
examine the code saying "this won't mutate the range".


Sure, you can document "front shouldn't modify the range", and use that 
convention, but without const, the compiler doesn't care.



If you're dealing with generic code, then you have less control, and const
starts mattering more, since you don't necessarily know what type is being
returned, and if you're returning front from an underlying range, you the
choice of eixther returning it by value or returning it by auto ref in case
the underlying range returned by ref and passing that refness on is
desirable. But const also interacts far more badly with generic code,
because the odds are pretty high that it won't work in many cases. So, while
in principle, using const to actually have the guarantees is valuable, in
practice, it isn't very viable, because D's const is so restrictive.


Technically, wrapping requires introspection. If you don't care about 
forwarding the "guarantee" of constness, then you can just tag all your 
functions mutable, but if you do care, then you have to introspect.



Personally, I avoid const in generic code like the plague, because unless
you've restricted the types enough to know what you're dealing with and know
that it will work with const, the odds are quite high that you're writing
code that's going to fall flat on its face with many types.


Indeed, it's not straightforward, if you have to deal with types that 
aren't tagged the way they should be. In addition, const is not inferred 
for templates like other attributes, so you can't rely on that either.


-Steve


Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 31 January 2018 at 15:40:04 UTC, Jakub Łabaj wrote:
What is the current state of the art of writing inline code in 
the documentation?


To give you a quick answer, the tide is going toward ``. You 
should probably just use it in most cases as long as the code 
fits on a single line. If it is a multi-line sample, use ddoc's 
`---` brackets or a documented unittest instead.


If you do want cross referencing, don't rely on $(D) nor `` to do 
it. Instead, there's a $(REF) macro in std.ddoc to use. Do NOT 
combine them:


See also: $(REF std,string,lowerCase) // correct (i think)*
See also: `$(REF ...)` // wrong, do not use `` here


* I don't remember the actual syntax for that ref macro.


adrdox vs markdown vs ddoc

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d
FYI I am changing the subject line with this post since it is 
branching off the original question of simple best practices of 
code in ddoc.



On Thursday, 1 February 2018 at 00:19:53 UTC, H. S. Teoh wrote:
In general, almost all text macro / formatting systems, from 
LaTeX to HTML to ddoc, are universally ugly and verbose when it 
comes to tables, and makes my eyes bleed. The only exception 
I've found so far is markdown, where you can actually write 
this:


|Blah|Blah|
|||
|abc |def |
|ghi |jkl |

It's not perfect, but it's worlds better than the line noise 
syntax of the alternatives.



So adrdox actually supports that (though you must label it), but 
I actually kinda hate it because it is enormously difficult to 
edit.


Earlier today, in a work call, the non-programmers on the team 
asked me to define "beautiful code". I have two main criteria:


1) does it work?

2) is it easy to edit while keeping it working?


When people say "code is read far more than it is written", I 
usually disagree: the main reason I read code is when I have to 
edit it! If it is working fine, it disappears into the 
background. But when there's a bug, I read it... as a means to 
the end of fixing the bug, which means editing it.


So, technically, sure I'll agree it is read more than it is 
written, but code is rarely actually written just once. It needs 
to get edited for bug fixes, new features, and changing external 
requirements.



How does that relate here? Take your ASCII table above and fix a 
misspelled word in the upper left cell. If you wrote "mispelled" 
instead of "misspelled", you just need to add the missing 's' 
and then go back and add spaces and/or dashes on each and every 
row to line the '|' column back up.


In CS terms, it turned a constant-time edit into a O(n) 
operation, scaling linearly with the number of rows. But it isn't 
even the number of rows in the table, it is the number of rows in 
the source text, which can really explode when you need to 
elaborate in the table somehow:


+---+
| This header  | This   |
| needed three | does   |
| rows to fit. | not.   |
+==++
| Here's some  | More!  |
| text.||
+--++

Let's add another word.

+---+
| This header  | This   |
| needed three | does   |
| more rows to | not.   |
| fit. ||
+==++
| Here's some  | More!  |
| text.||
+--++


Adding a 5-character word there took me *29* edit operations, not 
counting navigation of the caret. Now, maybe you use some editor 
macros to clean it up instead of doing it manually, but I don't 
have those... and if you need a fancy editor macro to just add a 
word to a comment, I think the comment syntax has failed.


And how do you add a code sample inside the table? Oh I don't 
even want to try that.



And let me emphasize this: this is comment in source code. If you 
want to read it as an end user, you can render it to HTML or 
whatever. In the source code, if you are reading it there... 
again, it is probably because you are editing it!



Now, if a 5-character insertion requires 29 edit operations, what 
do you think the programmer is going to do? Keep up with it, or 
let the documentation stay slightly suboptimal and out-of-date 
because it is a hassle?




So, that syntax is nice for little tables that get trivial edits, 
but for larger info tables, I prefer writing it out as paragraphs 
some how. That's why adrdox also supports "table_rows" and 
"table_columns", which I borrowed from Python's restructured text.


It is basically a vertical list - similar to Markdown's nested 
list syntaxes - of rows and columns, or columns and rows.



See more of my stuff here:
http://dpldocs.info/experimental-docs/adrdox.syntax.html#tables

I don't love it all, but for the most part, I implement it 
because it is useful to me and I at least don't hate it (or 
because I was forced to for Phobos compatibility lol).


So my above thing becomes:

* + This header needed three more rows to fit.
  + This does not

* - Here's some text.
  - More!


So each * introduces a new row (or column, these must be 
bracketed to tell which style it is), then + introduces a table 
header, and - introduces a table cell.


Alignment is trivial now, since it is just leading indentation 
(and that's optional, but to be fair, actually aligning the pipes 
is optional in Markdown's tables too, but if you don't it gets 
ugly anyway in both cases).


Adding a new word there? Constant time operation again. Adding a 
code sample is simple too, you can write it vertically like any 
other.


And it isn't quite as beautiful as the ASCII table for some 
cases... but it is still very legible in plain text source view, 
while being infinitely easier to edit.



BTW this is my big justification for bracketed syntax: putting 
$(SMALL_TABLE) or 

Re: enforce (i > 0) for i = int.min does not throw

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/31/18 6:19 PM, Azi Hassan wrote:

On Saturday, 27 January 2018 at 14:13:49 UTC, kdevel wrote:

I would expect this code

enforce3.d
---
import std.exception;

void main ()
{
   int i = int.min;
   enforce (i > 0);
}
---

to throw an "Enforcement failed" exception, but it doesn't:

$ dmd enforce3.d
$ ./enforce3
[nothing]


I wonder if it's caused by a comparison between signed and unsigned 
integers.


No, the answer is, there's a shortcut optimization used by the compiler. 
See the discussion elsewhere in this thread.




import std.stdio;

void main ()
{
     int zero = 0;
     writeln(int.min > 0u);
     writeln(int.min > zero);
}


Note that comparing the literal int.min will get folded into a constant, 
and do the right thing. You have to assign it a variable to see the 
incorrect behavior:


int i = int.min;
writeln(i > 0);

-Steve


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 1:19 PM, H. S. Teoh wrote:

I'd rather stick with just B


  dmd -color=off file.d


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 11:59 AM, Seb wrote:

... and Mike did put _a lot_ of effort in pushing colorful error messages:


Yes, and he did a nice job of it.

The results are attractive, worthwhile, and resolves a specific complaint people 
had about dmd's error messages.


Re: The daily D riddle

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 4:19 PM, Amorphorious wrote:

[...]


Don't berate other forum members.


On reddit: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

https://www.reddit.com/r/programming/comments/7udfs4/is_anyone_replacing_c_with_d/


Re: Should the "front" range primitive be "const" ?

2018-01-31 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, January 31, 2018 11:58:38 Steven Schveighoffer via 
Digitalmars-d-learn wrote:
> On 1/30/18 8:05 PM, Jonathan M Davis wrote:
> > Except that unless front returns by ref, it really doesn't matter
> > whether
> > front is const unless it's violating the range API, since front is
> > supposed to return the same value until popFront is called (or if it's
> > assigned a new value via a front that returns by ref). So, in practice,
> > putting const on front really doesn't help you any, and it actually
> > hurts you for range composability.
>
> Right, but that is the difference between a convention ("front is
> supposed to...") vs. a compiler-enforced guarantee (modifying data by
> calling a const-tagged front is a compiler error).
>
> If you are OK with conventions, you don't need const at all.

Except that if you're the one writing the function and decided whether it's
const or not, you're also the one deciding whether it returns by ref or not.
Unless you're dealing with a reference type, and it doesn't return by ref,
then const doesn't protect front at all. It just affects whether it can be
called on a const range.

If you're dealing with generic code, then you have less control, and const
starts mattering more, since you don't necessarily know what type is being
returned, and if you're returning front from an underlying range, you the
choice of eixther returning it by value or returning it by auto ref in case
the underlying range returned by ref and passing that refness on is
desirable. But const also interacts far more badly with generic code,
because the odds are pretty high that it won't work in many cases. So, while
in principle, using const to actually have the guarantees is valuable, in
practice, it isn't very viable, because D's const is so restrictive.

Personally, I avoid const in generic code like the plague, because unless
you've restricted the types enough to know what you're dealing with and know
that it will work with const, the odds are quite high that you're writing
code that's going to fall flat on its face with many types.

- Jonathan M Davis



Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 10:55:38PM +, Adam D. Ruppe via Digitalmars-d wrote:
> On Wednesday, 31 January 2018 at 21:34:47 UTC, H. S. Teoh wrote:
> > Coming from you, I'm a little surprised.  Weren't you one of the
> > people complaining that ddoc macro syntax is ugly?
> 
> $(H1 Rebuttal)
> 
> It depends how you use it. For large blocks or for small, special
> bits, it doesn't bother me.
> 
> So if I wanted to $(I point out) something in the middle, it doesn't
> bug me.

Then I guess we differ on this point.  While I think the ddoc macro
system, *as a macro system*, is pretty elegant in and of itself, I
personally can't stand mixing it in with ddoc comments, which I've grown
accustomed to be plain ole text, like other code comments.  Interpreted
differently by the compiler, sure.  But having a different syntax? I
find it too jarring and distracting.


[...]
> $(P Where it starts to bug me is when you are using it $(I all over the
> place), especially with $(B random nesting).)
> 
> $(P It is obnoxious to write on every paragraph, for example.)
> 
> $(TABLE $(TR $(TD $(P or trying to make a table out of it) $(P especially if
> it is
> randomly formatted in the source. $(BR) $(B yikes!)

Urgh, as if $(I this syntax) isn't already jarring enough, inserting
what is basically a poor man's transliteration of HTML into ddoc syntax
into source code is just ... it makes me wanna reach for the
'mark-block-delete' key combo in Vim.

In general, almost all text macro / formatting systems, from LaTeX to
HTML to ddoc, are universally ugly and verbose when it comes to tables,
and makes my eyes bleed. The only exception I've found so far is
markdown, where you can actually write this:

|Blah|Blah|
|||
|abc |def |
|ghi |jkl |

It's not perfect, but it's worlds better than the line noise syntax of
the alternatives.


[...]
> My adrdox tries to eliminate most of the latter stuff Phobos uses, but
> it retains the ddoc syntax for the stuff I don't mind. In fact, I
> kinda $(B prefer) it to the *markdown way* in some places, since at
> least the ddoc is deliberate. Only thing that bugs me is when I try to
> write :) or 1) or similar in there but I plan to fix that.

Yeah, I'm not really a fan of *...* or _..._ in markdown syntax. It's
just too easy to mix them up / misidentify them for identifiers in code
or expressions, esp. if C-like pointer dereference syntax is used.
Though I suppose that's what `...` is for.

But then again, I rarely find the need to have emphasis in technical
docs, so it's not a biggie.  And I do still prefer *...* over $(B ...).
I just don't like alphabetical macro names interspersed with text; it
makes it hard to parse the text with the eye.


> Now though, inline code like $(D) and $(REF) are ambiguous. They are
> short enough that they'd normally fall into my "ok with it" zone like
> $(B)... but they are also so common and I want to encourage their use.
> And having three shifted characters that must appear in order is kinda
> painful to type - it just breaks up the thought process, and can get
> somewhat weird to look at.
> 
> So like I probably wouldn't write "The $(REF SimpleWindow) class is
> used along with the $(REF EventLoop) to create a window." without
> actually thinking about it, but "The [SimpleWindow] class is used with
> [EventLoop]" is almost thoughtless to type.

This is why I prefer markdown-style syntax.


> The latter may be slightly easier to read but I think the bigger
> difference is just the friction in typing it the first time in this
> case.  Emphasis ought to be rare anyway, but interlinking ought to be
> very common.  I'm very very skeptical of claims of "it is faster to
> type" being significant... but easier to type I do think makes it more
> likely to be used. Most macros I think ought not be used frequently
> but this is different.

Actually, for me it's not so much a matter of "it's faster to type";
it's more of an issue of "when I'm reading (and presumably thinking
(hard) about) source code, do I really want to expend the mental
resources to parse the syntax of yet another embedded DSL inside a
*comment*?".  If I had my way, I would just write a normal comment as
opposed to a doc comment.  What makes the doc proposition attractive is
that, in an ideal world, a "normal" comment can be automatically
translated into nice docs without needing to pepper-spray it with
foreign syntax particles, so that I can read the comment while working
on the code, in addition to having nice docs to show to others in a
format they prefer, like HTML or whatever.

That's why I would actually welcome markdown-like syntax in ddoc. Yeah,
it has limitations and sux in many ways, but IMNSHO you shouldn't be
reimplementing complex HTML syntax inside a doc comment anyway -- leave
that to an external templating engine or whatever you wish to use, and
just let the doc comment be as readable as possible *as source code*.


> BTW adrdox does 

Re: The daily D riddle

2018-01-31 Thread Amorphorious via Digitalmars-d
On Sunday, 28 January 2018 at 06:44:40 UTC, Jonathan M Davis 
wrote:
On Sunday, January 28, 2018 08:25:51 Shachar Shemesh via 
Digitalmars-d wrote:

What will the following code print? Do not use the compiler:

import std.stdio;

struct A {
  int a = 1;

  void initialize() {
  a = a.init;
  }
}

void main() {
  A a;
  a.initialize();

  writeln(a.a);
}

I find this behavior unexpected.


It does exactly what I'd expect it to do, though honestly, it's 
the sort of thing I wish weren't legal, just like I wish that 
it weren't legal to call a static member function via a member. 
Maybe there are cases where it's useful, but it just seems 
wrong.


In any case, init goes with a type, not a variable, which is 
why it acts the way it does.


- Jonathan M Davis


One day you will hopefully learn that you are not the god of 
logic and just because you think something is right or wrong 
doesn't mean it is so.  What happens with people like you is that 
they end up causing more problems down the road because they were 
wrong and too ignorant to understand it. It's not your fault... 
blame it on evolution if you want, but what determines right and 
wrong  should be decided by mathematical proof, not gut feelings.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 09:07:39PM +, John Gabriele via Digitalmars-d wrote:
> On Wednesday, 31 January 2018 at 20:03:11 UTC, Adam D. Ruppe wrote:
> > 
> > {snip} (well, I tried to get it upstream but I think upstream is a
> > brick wall and not worth trying anymore)
> 
> That is very concerning to hear.

FWIW, here's my POV regarding "upstream", speaking as one who has no
prior (or current!) personal connection with anyone involved with D
development at the time, and who got granted commit access to Phobos
only because one day I and another person whom I do not wish to name
(who was at the time also not connected to "upstream") were complaining
on the forum about lack of response to Phobos PRs, and *somebody*,
presumably Andrei (but this is speculation on my part, as I was never
actually told what happened exactly), decided to hand us the keys to the
kingdom, so to speak, to see what we'd do with it.  I didn't merge
anything for about a month or more afterwards, not out of intimidation
or anything like that, but just feeling unqualified to make decisions of
that sort just yet. I continued submitting PRs like an "outsider" for a
while, and only later began to build up enough confidence to start
merging PRs.

Even today, I contribute to D development purely out of my own interest,
both in terms of technical interest, interest in seeing D improve
because I use it for numerous personal projects, and also some amount of
personal fulfilment in being able to contribute to something bigger than
just my own projects.

The way I see it, is that the majority of PRs that get merged are in the
category of small, incremental changes, things like bugfixes, small
improvements to existing features, the odd useful tool here and there,
that sort of thing.  Larger-scale changes do tend to take a lot more
work (and persistence!) to push through, not because of any active
policy or motive that hinder such changes, but primarily because as a
volunteer-driven project, it's not very often that someone from among
the volunteers would:

(1) Have the time to spend reviewing a large and complicated change;

(2) Have enough expertise in the affected area(s) of the project to feel
confident enough to make decisions about it;

(3) Have all of the above plus the interest to actually *want* to wade
into the depths of a large changeset, which implies the commitment
to continue interacting with the submitter until it's merged or
rejected, rather than do something else that's (a) more
self-contained and easier to review, (b) can be done in a short
amount of time that fits into their current stretch of free time,
and (c) still contributes something positive to the project.

Large-scale changes do happen every now and then, such as Daniel
Murphy's monumental effort in translating dmd's original C++ source into
D, leading to the bootstrapping compiler we have today.  But these
require a lot more effort and coordination with key decision makers,
usually Walter & Andrei, and it really helps if you can convince one or
both of them to take your side.  A "small fry" like myself wouldn't dare
to push the merge button on changes of this kind of magnitude, since it
could have drastic consequences that I can't foresee due to not having a
full grasp of the full scale of what is being changed. Plus, sometimes
somebody else *did* raise valid points of concern against the PR, so I
would hold off merging until the concern is addressed and that person
approves of the updated change. And in a large changeset, there can be a
large number of such concerns, which requires a lot of back-and-forth
before a decision can be reached.

Anyway, as far as Adam's dpldocs are concerned, the way I see it is this
(and I'm saying this not as someone making the decision, but as a
mostly-disinterested observer): Around the time it was first proposed,
there are already two other competing documentation systems:

- The ddoc system, the original, and still in heavy use at the time, up
  till today;

- Sonke's newer one-page-per-function ddox system (which today has been
  partly integrated, but still not fully the default yet because of
  various issues that I didn't look too much into).

Having 3 different competing documentation systems is really crowded for
this space, so for any of them to stand a chance, it has to be either
already entrenched (ddoc), or else must offer significant advantages
over its competitors.  More importantly, its proponent(s) would have to
convince Andrei or Walter of said significant advantages, since that's
what will tip the scale (obviously, its proponents must believe it has
significant advantages otherwise they wouldn't have proposed it in the
first place -- but the deciding factor is whether Andrei and/or Walter
think likewise).

And IIRC, Andrei had already bought into the ddox system by then (the
process of merging it might have already begun, I'm not 100% certain),
so dpldocs was already starting from a 

Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Walter Bright via Digitalmars-d

On 1/31/2018 5:54 AM, Jack Stouffer wrote:

On Wednesday, 31 January 2018 at 07:56:37 UTC, Andrew Benton wrote:

E.g. three compilers


Every other compiled language (and a lot of scripting ones) uses the fact of 
multiple compilers for the language as a sign of adoption and ecosystem growth.


I've only ever seen people complain about D in this area. Never once have I seen 
someone argue that the existence of PyPy hurts Python or gogcc hurts Go.


Back when D had only one compiler, dmd, people complained it had only one 
compiler. Now that it has three, they complain that it has three.


Sometimes, ya just gotta ignore people.


Re: enforce (i > 0) for i = int.min does not throw

2018-01-31 Thread Azi Hassan via Digitalmars-d-learn

On Saturday, 27 January 2018 at 14:13:49 UTC, kdevel wrote:

I would expect this code

enforce3.d
---
import std.exception;

void main ()
{
   int i = int.min;
   enforce (i > 0);
}
---

to throw an "Enforcement failed" exception, but it doesn't:

$ dmd enforce3.d
$ ./enforce3
[nothing]


I wonder if it's caused by a comparison between signed and 
unsigned integers.


import std.stdio;

void main ()
{
int zero = 0;
writeln(int.min > 0u);
writeln(int.min > zero);
}

$ rdmd test.d
true
false

The same behavior can be observed in C :

#include 
#include 

int main(void)
{
int zero = 0;
printf("%d\n", INT_MIN > 0u);
printf("%d\n", INT_MIN > zero);
return 0;
}

$ gcc test.c && ./a.out
1
0


Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 31 January 2018 at 21:34:47 UTC, H. S. Teoh wrote:
Coming from you, I'm a little surprised.  Weren't you one of 
the people complaining that ddoc macro syntax is ugly?


$(H1 Rebuttal)

It depends how you use it. For large blocks or for small, special 
bits, it doesn't bother me.


So if I wanted to $(I point out) something in the middle, it 
doesn't bug me.


$(QUOTE
Similarly, if I want to call out a whole block of text,
ddoc has some nice bits, like how easily it nests and can
be added around existing text without thinking about it.
)

$(H1 But...)

$(P Where it starts to bug me is when you are using it $(I all 
over the place), especially with $(B random nesting).)


$(P It is obnoxious to write on every paragraph, for example.)

$(TABLE $(TR $(TD $(P or trying to make a table out of it) $(P 
especially if it is

randomly formatted in the source. $(BR) $(B yikes!)



Phobos does a lot of that latter filth, and almost never even 
tries to format it, making it even worse.


My adrdox tries to eliminate most of the latter stuff Phobos 
uses, but it retains the ddoc syntax for the stuff I don't mind. 
In fact, I kinda $(B prefer) it to the *markdown way* in some 
places, since at least the ddoc is deliberate. Only thing that 
bugs me is when I try to write :) or 1) or similar in there but I 
plan to fix that.



Now though, inline code like $(D) and $(REF) are ambiguous. They 
are short enough that they'd normally fall into my "ok with it" 
zone like $(B)... but they are also so common and I want to 
encourage their use. And having three shifted characters that 
must appear in order is kinda painful to type - it just breaks up 
the thought process, and can get somewhat weird to look at.


So like I probably wouldn't write "The $(REF SimpleWindow) class 
is used along with the $(REF EventLoop) to create a window." 
without actually thinking about it, but "The [SimpleWindow] class 
is used with [EventLoop]" is almost thoughtless to type.



The latter may be slightly easier to read but I think the 
bigger difference is just the friction in typing it the first 
time in this case. Emphasis ought to be rare anyway, but 
interlinking ought to be very common. I'm very very skeptical of 
claims of "it is faster to type" being significant... but easier 
to type I do think makes it more likely to be used. Most macros I 
think ought not be used frequently but this is different.


BTW adrdox does [reference] instead of `reference` linking 
because of what I said before: `code` is too generic. It isn't 
necessarily a link. Moreover, my [reference|also allows 
alternative text to display], which wouldn't work well in ``.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 31 January 2018 at 19:00:57 UTC, Jack Stouffer 
wrote:
That's just something that Walter was able to bang out in an 
hour, should have been done years ago, and was excited about.


So it isn't a big deal, but IMO that should be left to an IDE or 
shell.


Back to the argument about cPython vs PyPy/dmd vs ldc. You want 
the reference compiler to be relatively simple and leave the 
unnecessary complications to the production compiler. So if DMD's 
backend was simple and only was a bare minimum implementation of 
the semantics then having multiple compilers would be comparable 
to the Python situation. PyPy is probably way too complicated to 
act as a reference and it would be difficult for Python to move 
if it had been the reference.


Some might say that DMD is too complicated to act as a reference 
as well, and that D has a problem moving because of it. If that 
is true, and I think it is, then the logical conclusion would be 
to make the DMD codebase simpler and leave performance to LDC. 
Like Python does with PyPy.




Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Benny via Digitalmars-d

On Wednesday, 31 January 2018 at 11:42:14 UTC, Seb wrote:

Here's a spoiler:

1) Andrei does an excellent job at managing his students [1] 
and there work over the last couple of months has been 
tremendous. As the experiment with UPB was very successful, 
there will be more projects like this one and global scholarship


2) The vision document will finally get updated (there have 
been a few delays due to holiday, illnesses etc.)


https://wiki.dlang.org/Vision/2017H2

3) More community input (I'm preparing a State of D survey atm)

4) More active voting by the community on important issues

5) Better documentation and overview on what the foundation is 
doing


Currently under discussion/work:

6) Using OpenCollective for tracking expenses openly
7) Offering membership packages for companies
8) Doing bi-annual Kickstarter compaigns for important issues 
to the community (e.g. "fix shared")


Thank you Seb and the other.

Sorry for going off the rails but i do like D a lot. Its the only 
reason i keep coming back for the same punishment time and time 
again. It simply gets so frustrating at times what feels like 
running into a stone wall.


Maybe the real issue is not the issues that need to be solved but 
the lack of "news". The blogs are very interesting and i applaud 
them. But is it maybe not time to have a real news section on the 
site where project status updates are provided. We are not 
talking blogs but smaller news snipes that do not take a lot of 
time, so people who do not spend there life on the forum or other 
locations feel like there is indeed movement. It can also help in 
the actual marketing.


Re: Terminating multiple processes

2018-01-31 Thread Arek via Digitalmars-d-learn
On Wednesday, 31 January 2018 at 17:44:37 UTC, Russel Winder 
wrote:
So, I have an application which has a sort of nano-services 
architecture, basically it is a set of communicating processes. 
Terminating those processes blocked on an input channel is 
quite easy, send a terminate message on the input channel. But 
what about a process that has no input channel, one that is 
blocked on OS events?


Is there a way of forcibly, but nicely, terminating a spawned 
process that never executes `receive()`?


Assuming your're talking about threads: there's no secure method 
of forcing the thread to stop. Threads share the state (eg. can 
hold the locks) and killing them is always risky.


If your threads are blocked reading the socket, you probably can 
close these sockets and exit after the read error.


Another way is to use atomic flag indicating that thread needs to 
be interrupted.
After any blocking operation, the thread have to check this flag 
and finish the job.
It's good to use timeouts (eg socket timeout) in such scenario 
(if possible).


Arek


Re: DConf 2018: Register Now!

2018-01-31 Thread David Gileadi via Digitalmars-d-announce

On 1/31/18 3:08 PM, David Gileadi wrote:

On 1/31/18 3:02 PM, Seb wrote:
It was the middle of November when DConf 2018 was announced here on 
the DBlog in a Q & A session with Andrei Alexandrescu. Since then, the 
DConf train has slowly been building up steam as things have been 
happening behind the scenes. Now it’s full steam ahead!


https://dlang.org/blog/2018/01/31/dconf-2018-register-now

Reddit: 
https://www.reddit.com/r/programming/comments/7udoi2/registration_for_dconf_2018_is_now_open/ 



Broken link: the link to the "DConf 2018 venue page" needs an extra 'l' 
at the end, i.e. venue.htm -> venue.html


Whoops, another broken link: "HLMC" links to 
https://dlang.org/blog/2018/01/31/dconf-2018-register-now/www.hlmc.de, 
but it should link to http://www.hlmc.de


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 31 January 2018 at 21:42:47 UTC, Ali wrote:

The kinda small discussion on ycombinator
https://news.ycombinator.com/item?id=16270841


Interesting... most of them don't grok C++, D, Java or Go... Hope 
people don't look to ycombinator for answers.


Re: DConf 2018: Register Now!

2018-01-31 Thread David Gileadi via Digitalmars-d-announce

On 1/31/18 3:02 PM, Seb wrote:
It was the middle of November when DConf 2018 was announced here on the 
DBlog in a Q & A session with Andrei Alexandrescu. Since then, the DConf 
train has slowly been building up steam as things have been happening 
behind the scenes. Now it’s full steam ahead!


https://dlang.org/blog/2018/01/31/dconf-2018-register-now

Reddit: 
https://www.reddit.com/r/programming/comments/7udoi2/registration_for_dconf_2018_is_now_open/ 


Broken link: the link to the "DConf 2018 venue page" needs an extra 'l' 
at the end, i.e. venue.htm -> venue.html


DConf 2018: Register Now!

2018-01-31 Thread Seb via Digitalmars-d-announce
It was the middle of November when DConf 2018 was announced here 
on the DBlog in a Q & A session with Andrei Alexandrescu. Since 
then, the DConf train has slowly been building up steam as things 
have been happening behind the scenes. Now it’s full steam ahead!


https://dlang.org/blog/2018/01/31/dconf-2018-register-now

Reddit: 
https://www.reddit.com/r/programming/comments/7udoi2/registration_for_dconf_2018_is_now_open/


Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 06:31:34PM +, Adam D. Ruppe via Digitalmars-d wrote:
> On Wednesday, 31 January 2018 at 17:14:56 UTC, H. S. Teoh wrote:
> > But otherwise, the two are equivalent. (In fact, backticks translate
> > directly into $(D ...) in the ddoc code. They are just syntactic
> > sugar.)
> 
> No, they aren't. The `` is different in several ways including doing
> character escaping that macros are incapable of, and it expands to
> BACKTICK, not D. Read the comment of mine linked by the OP.

Ah, then I stand corrected.


> They are intended to be separate, but you are right that the lighter
> syntax is getting more attention, much to my chagrin.

Coming from you, I'm a little surprised.  Weren't you one of the people
complaining that ddoc macro syntax is ugly?  I actually share that
sentiment, and have been avoiding using any explicit macro markup in my
ddoc comments until `` came along that didn't make the source code (IMO)
unreadable.  Even now, I still refuse to use anything more than that in
my own code, at least not directly (I did do one or two ddoc template
customizations, but would not insert that into my source code itself).
Though of course, when contributing to Phobos I just have to follow
whatever other Phobos code does.  (Still, I try to avoid touching ddoc
macro syntax where possible. It makes me feel like I have to wash my
hands afterwards.)


T

-- 
One reason that few people are aware there are programs running the internet is 
that they never crash in any significant way: the free software underlying the 
internet is reliable to the point of invisibility. -- Glyn Moody, from the 
article "Giving it all away"


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ali via Digitalmars-d
On Tuesday, 30 January 2018 at 20:45:44 UTC, Andrei Alexandrescu 
wrote:

https://www.quora.com/Why-hasnt-D-started-to-replace-C++

Andrei


The kinda small discussion on ycombinator
https://news.ycombinator.com/item?id=16270841


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 08:05:37PM +, Adam D. Ruppe via Digitalmars-d wrote:
> On Wednesday, 31 January 2018 at 19:59:23 UTC, Seb wrote:
> > ... and Mike did put _a lot_ of effort in pushing colorful error
> > messages:
> 
> Yes, that was a direct result of that forum post I alluded to. It
> isn't something he (or most anyone else, in my experience) really
> cares about, but he felt if he did it then many Walter wouldn't waste
> any more time on it.

In fact, I find the colors distracting.  Pretty? Certainly.  But
helpful?  Not really, at least not for me.  I'd rather stick with just
B But all things considered, it's a pretty minor issue, and one
that's not worth the time to complain about.  (Haha, and look what I
just did. :-P)


T

-- 
Latin's a dead language, as dead as can be; it killed off all the Romans, and 
now it's killing me! -- Schoolboy


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread John Gabriele via Digitalmars-d
On Wednesday, 31 January 2018 at 20:03:11 UTC, Adam D. Ruppe 
wrote:


{snip} (well, I tried to get it upstream but I think upstream 
is a brick wall and not worth trying anymore)


That is very concerning to hear.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 31 January 2018 at 18:05:30 UTC, jmh530 wrote:
contribute their skills. For instance, Mike Parker's work on 
the D blog has been a great improvement in communication the 
past year or two.


Yep, to have a living blog is very important IMHO.




Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d

On Wednesday, 31 January 2018 at 18:05:30 UTC, jmh530 wrote:
contribute their skills. For instance, Mike Parker's work on 
the D blog has been a great improvement in communication the 
past year or two.


Yep, having a living blog is very important I think.  It is 
always something I look at when visiting project website, just to 
assess where the project is moving.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 31 January 2018 at 19:59:23 UTC, Seb wrote:
... and Mike did put _a lot_ of effort in pushing colorful 
error messages:


Yes, that was a direct result of that forum post I alluded to. It 
isn't something he (or most anyone else, in my experience) really 
cares about, but he felt if he did it then many Walter wouldn't 
waste any more time on it.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:
Auto generated libraries where all functions are dumped into 
massive one pagers.


This is why I just forked the documentation (well, I tried to get 
it upstream but I think upstream is a brick wall and not worth 
trying anymore)


http://dpldocs.info/std.datetime.date

That's still not amazing, but it is a lot easier to navigate and 
link.


It also has search: http://dpldocs.info/locate?q=daysInMonth



No clear function calls:


http://dpldocs.info/experimental-docs/std.datetime.date.Date.daysInMonth.html

So I also show that info because it is somewhat important to 
understand the contract, but I tried to present it so the name 
and position among its parents and siblings is clear.




Of course, I argue part of the problem is I'm sure I'm not the 
only one who has decided to just fork rather than try to keep 
wrestling with upstream...


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d
On Wednesday, 31 January 2018 at 19:54:05 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 31 January 2018 at 19:00:57 UTC, Jack Stouffer 
wrote:

For some reason this ranks below colourful error-messages.


That's just something that Walter was able to bang out in an 
hour


Yet he recently, months after starting, complained that 
"technical debt", specifically citing coloring error messages, 
was eating enough of his time to cause a forum lamentation.


... and Mike did put _a lot_ of effort in pushing colorful error 
messages:


https://github.com/dlang/dmd/projects/2


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d
On Wednesday, 31 January 2018 at 19:00:57 UTC, Jack Stouffer 
wrote:

For some reason this ranks below colourful error-messages.


That's just something that Walter was able to bang out in an 
hour


Yet he recently, months after starting, complained that 
"technical debt", specifically citing coloring error messages, 
was eating enough of his time to cause a forum lamentation.




Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Andrei Alexandrescu via Digitalmars-d

On 01/31/2018 05:55 AM, Benny wrote:

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:

Let me say this again


*uch* Never mind this rant. I am just fed up with the issues. I will not 
post anymore as its just a wast of time for everybody involved.


A few of the points were actionable. I've asked folks to look into the 
documentation matters. Thanks, and keep them coming. -- Andrei


Re: Release D 2.078.1

2018-01-31 Thread Rainer Schuetze via Digitalmars-d-announce



On 31/01/2018 16:58, Atila Neves wrote:

On Thursday, 25 January 2018 at 20:11:54 UTC, Rainer Schuetze wrote:



On 25.01.2018 14:54, Atila Neves wrote:

On Tuesday, 23 January 2018 at 15:16:02 UTC, Andre Pany wrote:

On Tuesday, 23 January 2018 at 13:08:35 UTC, thedeemon wrote:

On Monday, 22 January 2018 at 20:43:56 UTC, Martin Nowak wrote:

Glad to announce D 2.078.1.



The Windows 7z archive version now has much simpler sc.ini, in fact 
too simple.

With Visual C++ 2015 x64 Native Build Tools now trying to run
dmd -m64 hi.d
I get
LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
Error: linker exited with status 1104

So I needed to edit sc.ini and add back
LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\ucrt\x64"
to the [Environment64] section.

Then it went just as 2.078.0 - still missing 
legacy_stdio_definitions.lib that I need to add manually in the 
command line.


Did you call vcvarsall in the current dos box/PowerShell? It is a 
tool included with all visual studio variants.


Kind regards
Andre


I just ran into this today. With the dmd 2.077.1 Windows installer 
things just work, and it's never necessary to call vcvarsall.bat to 
build D code for 64-bit.


Since dmd 2.078.0, with Visual Studio 2015, nothing works anymore, 
and sc.ini doesn't seem to reference Visual Studio at all like it 
used to.


Atila


Visual Studio is supposed to be detected by dmd now, either from the 
environment or from the registry.


What errors do you get? Try running with -v to show the linker command 
line.


$ dub init
$ dub build --arch=x86_64
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for x86_64.
example ~master: building configuration "application"...
Linking...
LINK : fatal error LNK1104: cannot open file 'shell32.lib'

-v shows that it's linking like so:

C:\D\dmd2\windows\bin\dmd.exe 
-of.dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.exe 
.dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.obj 
-m64 -g


Unfortunately, that is not dmds output of the linker command line, but 
dubs invocation of dmd. Just try "dmd -v -m64 test.d".


Does Arjan's suggestion help, i.e. are you working as a restricted user? 
Did you install VS for the current user only (not sure if that's 
actually possible)?




Should I file a bug for dmd or the installer? 


It's a dmd issue.

Are 64-bit dub builds not 
done by CI on Windows? This is pretty embarassing.


Every PR is tested against both VS2013 (auto-tester) and VS2015 (Appveyor).


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jack Stouffer via Digitalmars-d
On Wednesday, 31 January 2018 at 17:02:06 UTC, Ola Fosheim 
Grøstad wrote:

Ok, and now you are entering a messy space, define "legitimate"?


Actionable, clear, and made with the intent to better the 
language/ecosystem and not just to complain.



Development processes need continuous improvement.


And we have been. I would rate our QA tooling to be 3x better now 
than when I started.



For some reason this ranks below colourful error-messages.


That's just something that Walter was able to bang out in an 
hour, should have been done years ago, and was excited about. 
There's tons of work being done on GH that's never talked about 
here in the forums.


Whatever spot D is in right now in comparison to other 
projects, good or bad, most certainly isn't because of a lack 
of marketing.


We clearly have a lot of work to do on messaging when many of the 
Quora answers are using eight year old information as 
condemnation.



People expect less friction today than they did 10 years ago.
To some extent Microsoft, Google, Jetbrains and others have 
handed out slick freebies and conditioned programmers to be 
more demanding.


True. D would be a in great place if everything worked out of the 
box if people wanted an IDE. But the post I was replying to first 
noted issues with the ecosystem six days ago, and has already 
rage quit over it.


[Issue 18344] Downloads page should link to https://dlang.org/install.html

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18344

bachm...@yahoo.com changed:

   What|Removed |Added

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

--- Comment #1 from bachm...@yahoo.com ---
This issue is now being dealt with in this PR:
https://github.com/dlang/dlang.org/pull/2154

--


[Issue 18345] New: std.datetime documentation isn't properly split

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18345

  Issue ID: 18345
   Summary: std.datetime documentation isn't properly split
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Keywords: ddoc
  Severity: minor
  Priority: P1
 Component: phobos
  Assignee: issues.dl...@jmdavisprog.com
  Reporter: schvei...@yahoo.com

https://dlang.org/phobos/std_datetime.html starts with:

"Module containing Date/Time functionality."

And proceeds as if std.datetime was still one module.

Conversely, looking at https://dlang.org/phobos/std_datetime_date.html has no
summary documentation, and just has ddocs on types and functions.

Just putting this issue here so it's not forgotten.

--


Re: How to get a range from std.container.array for use with std.format.sformat?

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/30/18 2:19 PM, cc wrote:

Still doesn't work without the cast it seems..

 auto rng = str[];
 rng.sformat!"%s:%s"("some", "string");
 // Error: template std.format.sformat cannot deduce function from 
argument types !("%s:%s")(RangeT!(Array!char), string, string)


I misunderstood what you were trying to do. I thought you were just 
trying to get a valid range, missed the requirement that the range works 
with sformat (obviously from the subject! sorry).


Indeed, there isn't a way to extract an actual char[] from Array (and 
this is intentional).


But as Seb says, you can use formattedWrite:

auto rng = str[];
rng.formattedWrite("%s:%s", "some", "string");

-Steve


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d

On 1/31/18 5:35 AM, Benny wrote:

Auto generated libraries where all functions are dumped into massive one 
pagers.


https://dlang.org/phobos/std_datetime_date.html

Is this readable when the first two pages are this:

jan
feb
mar
apr
may
jun
jul
aug
sep
oct
nov
dec
sun
mon
tue
wed
thu
fri
sat

Const "jump to" lists intermixed between the documentation.

No clear function calls:

const pure nothrow @nogc @property @safe ubyte daysInMonth();

Const
Pure
nothrow
@nogc
@property
@safe
ubyte ...

and FINALLY the actual function call your looking for: daysInMonth();


This is an issue that was recently introduced. Until dconf2017 (May of 
last year), all of std.datetime was in one file.


But while the code was split into logical units, the documentation was 
not. Unfortunately, it needs a lot of attention to make sure the docs 
are written to cater to the new split design.


And please ... do like always, cut my post into small parts and start 
criticizing and attacking the author that he needs to "put more effort 
into it or pay". Or some other bullshit. And then complain how people 
troll the forum because they complain and not do anything to solve it. 
Tired of reading the same rhetoric as are the people who think posts 
like this are troll posts.


We are always here to help with issues in D, and constructive criticism 
is welcome and appreciated! But I don't know how to help you with the "D 
sucks, everyone should use some other language" issue. It's not part of 
my knowledgebase.


-Steve


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Nicholas Wilson via Digitalmars-d

On Wednesday, 31 January 2018 at 18:16:40 UTC, 12345swordy wrote:

On Tuesday, 30 January 2018 at 23:36:59 UTC, H. S. Teoh wrote:
On Tue, Jan 30, 2018 at 10:12:07PM +, Ola Fosheim Grøstad 
via Digitalmars-d wrote:

On Tuesday, 30 January 2018 at 21:49:39 UTC, H. S. Teoh wrote:
> [...]

Well, it isn't relevant for those people who would adopt D 
anyway.

[...]

Ha! Exactly!  It's just as Walter has said before: our time is 
better spent making D better for those who are already using 
D, or who are *genuinely* interested in adopting D, rather 
than bending over backwards trying to please the crowd that, 
after you fix their current complaint, will only move on to 
the next excuse not to use D.



T


Created a new thread?


It's a forum quirk.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d
On Wednesday, 31 January 2018 at 12:34:01 UTC, Martin 
Tschierschke wrote:

On Wednesday, 31 January 2018 at 12:03:22 UTC, rjframe wrote:

On Wed, 31 Jan 2018 10:55:56 +, Benny wrote:


[...]

Anyway, mostly because of your recent posts I'm going to take 
a look at DlangIDE. If we can package a cross-platform 
IDE+compiler+dub as a single download and you're ready to go, 
that might make it easier to give D a try, even if most people 
would later set up something else; at least you'd only deal 
with the problems after you've decided it's worth it.


Yes, would be very good!

And than ad a series of short example programs, to this 
one-stop-download,

maybe party from Adam's arsd.

Like: 
https://github.com/adamdruppe/arsd/blob/master/simpledisplay.d

And the examples from D-Lang Tour.

So you only push a button [try D], and get a running 
environment to play around.


Like this?

https://tour.dlang.org/tour/en/dub/mir

It's a small series since today. Any help with filling the blank 
content or new pages is welcome.


See 
https://forum.dlang.org/post/acovehcwaxjykmhek...@forum.dlang.org 
for adding new libraries to run.dlang.io


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread 12345swordy via Digitalmars-d
On Tuesday, 30 January 2018 at 20:45:44 UTC, Andrei Alexandrescu 
wrote:

https://www.quora.com/Why-hasnt-D-started-to-replace-C++

Andrei


For me personally, there are some really nasty bugs regarding 
default attributes (@nogc/@safe) that prevent me from using D in 
personal code projects.

Examples being:
Destroy can't be called in @safe and @nogc  context even it is 
the base class destructor is marked with @safe and @nogc. Among 
other base object functions.

https://dlang.org/phobos/object.html
This bug requires a DIP to fix(I was thinking about writing up 
one, but I am not sure if I should do that).
I don't want new features, I just want to fix the current 
existing bugs.



Alex


Re: Inline code in the docs - the correct way

2018-01-31 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 31 January 2018 at 17:14:56 UTC, H. S. Teoh wrote:

But otherwise, the two are
equivalent. (In fact, backticks translate directly into $(D 
...) in the ddoc code. They are just syntactic sugar.)


No, they aren't. The `` is different in several ways including 
doing character escaping that macros are incapable of, and it 
expands to BACKTICK, not D. Read the comment of mine linked by 
the OP. They are intended to be separate, but you are right that 
the lighter syntax is getting more attention, much to my chagrin.


Re: Terminating multiple processes

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/31/18 12:44 PM, Russel Winder wrote:

So, I have an application which has a sort of nano-services
architecture, basically it is a set of communicating processes.
Terminating those processes blocked on an input channel is quite easy,
send a terminate message on the input channel. But what about a process
that has no input channel, one that is blocked on OS events?

Is there a way of forcibly, but nicely, terminating a spawned process
that never executes `receive()`?



You talking about processes or threads? `receive` I believe is an 
inter-thread channel, no?


Terminating processes is generally done via signals or in the case of 
windows, calling the right system call.


Threads are another story. Typically, you need to have the thread check 
periodically for a termination event. There's no "nice" way to do it out 
of band.


In my experience, the best way to do it is to never block, but use some 
sort of "wait on input" for any would-be-blocking operation. You can use 
a large timeout, like 1 second, if immediate termination isn't important.


If you are using Fibers, and all your i/o is done using some event-based 
system (e.g. vibe.d), then things can be easier.


-Steve


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread John Gabriele via Digitalmars-d

On Wednesday, 31 January 2018 at 17:30:54 UTC, H. S. Teoh wrote:

On Wed, Jan 31, 2018 at 05:20:59PM +, Seb via Digitalmars-d


Please let us know what would help you to find this page 
quicker.


Wow.  I set out *deliberately* looking for that link, and 
couldn't find it until I looked at your screenshot. I 
definitely wouldn't have found it if I didn't even know it was 
there.


I just discovered that the individual os-specific dmd downloads 
*also* have links associated with them.


Seb, I've added a comment to your PR 2154. Thanks.



Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread 12345swordy via Digitalmars-d

On Tuesday, 30 January 2018 at 23:36:59 UTC, H. S. Teoh wrote:
On Tue, Jan 30, 2018 at 10:12:07PM +, Ola Fosheim Grøstad 
via Digitalmars-d wrote:

On Tuesday, 30 January 2018 at 21:49:39 UTC, H. S. Teoh wrote:
> [...]

Well, it isn't relevant for those people who would adopt D 
anyway.

[...]

Ha! Exactly!  It's just as Walter has said before: our time is 
better spent making D better for those who are already using D, 
or who are *genuinely* interested in adopting D, rather than 
bending over backwards trying to please the crowd that, after 
you fix their current complaint, will only move on to the next 
excuse not to use D.



T


Created a new thread?


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread jmh530 via Digitalmars-d
On Wednesday, 31 January 2018 at 17:02:06 UTC, Ola Fosheim 
Grøstad wrote:


Is it?  Why do so many people have problems with it then? 
Stupidity?


Perhaps the D front page can say "Now with 1 Standard Library!" ;)



Ok, and now you are entering a messy space, define 
"legitimate"?  I think the most important issue he raised was 
how project management is either under-communicated or 
conducted.


The best programmers won't necessarily be the best at project 
management or communication. That's ok...provided people better 
suited at project management or communication can and do 
contribute their skills. For instance, Mike Parker's work on the 
D blog has been a great improvement in communication the past 
year or two.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d

On Wednesday, 31 January 2018 at 17:30:54 UTC, H. S. Teoh wrote:
Wow.  I set out *deliberately* looking for that link, and 
couldn't find it until I looked at your screenshot. I 
definitely wouldn't have found it if I didn't even know it was 
there.


I'm no UI consultant, but that link definitely needs to be made 
more visible.  Is the hover thing really *necessary*?  For 
something this important, I'd say it's a bad idea to hide it 
behind a hover (I use keyboard navigation, and so wouldn't even 
have noticed it, though I concede that I'm a rare case :-P). 
But then I don't know the original reasoning behind making it 
hover.


Let's try to change this!

https://github.com/dlang/dlang.org/pull/2154


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d
On Wednesday, 31 January 2018 at 16:13:51 UTC, John Gabriele 
wrote:
I've never seen that page. Would've helped me to see it 
earlier. The D download page should include a blurb with a link 
to that install page.


BTW that's why opening issues is so important:
- everyone has a different experience, knowledge and mindset
- feedback is very important

PR to always display the icons: 
https://github.com/dlang/dlang.org/pull/2154


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread jmh530 via Digitalmars-d
On Wednesday, 31 January 2018 at 16:13:51 UTC, John Gabriele 
wrote:

On Wednesday, 31 January 2018 at 11:42:14 UTC, Seb wrote:


That's only an issue on Windows.
For Posix there's the official install.sh script [1].

[1] https://dlang.org/install.html


I've never seen that page. Would've helped me to see it 
earlier. The D download page should include a blurb with a link 
to that install page.




It's actually pretty new. I had created an issue in December to 
add it and wilzbach created it.


Terminating multiple processes

2018-01-31 Thread Russel Winder via Digitalmars-d-learn
So, I have an application which has a sort of nano-services
architecture, basically it is a set of communicating processes.
Terminating those processes blocked on an input channel is quite easy,
send a terminate message on the input channel. But what about a process
that has no input channel, one that is blocked on OS events?

Is there a way of forcibly, but nicely, terminating a spawned process
that never executes `receive()`?

-- 
Russel.
===
Dr Russel Winder  t: +44 20 7585 2200
41 Buckmaster Roadm: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk


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


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 05:20:59PM +, Seb via Digitalmars-d wrote:
> On Wednesday, 31 January 2018 at 16:13:51 UTC, John Gabriele wrote:
> > I've never seen that page. Would've helped me to see it earlier. The
> > D download page should include a blurb with a link to that install
> > page.
> 
> They are there - hover over them:
> 
> https://imgur.com/a/JvZwI
> 
> I submitted it without hovering initially:
> 
> https://github.com/dlang/dlang.org/pull/1697
> 
> And the install.sh page was added in this PR:
> 
> https://github.com/dlang/dlang.org/pull/1936
> 
> Please let us know what would help you to find this page quicker.

Wow.  I set out *deliberately* looking for that link, and couldn't find
it until I looked at your screenshot. I definitely wouldn't have found
it if I didn't even know it was there.

I'm no UI consultant, but that link definitely needs to be made more
visible.  Is the hover thing really *necessary*?  For something this
important, I'd say it's a bad idea to hide it behind a hover (I use
keyboard navigation, and so wouldn't even have noticed it, though I
concede that I'm a rare case :-P). But then I don't know the original
reasoning behind making it hover.


T

-- 
Genius may have its limitations, but stupidity is not thus handicapped. -- 
Elbert Hubbard


Re: Inline code in the docs - the correct way

2018-01-31 Thread H. S. Teoh via Digitalmars-d
On Wed, Jan 31, 2018 at 03:40:04PM +, Jakub Łabaj via Digitalmars-d wrote:
> What is the current state of the art of writing inline code in the
> documentation?
> 
> Wiki says "use `...` instead of $(D ...)":
> https://wiki.dlang.org/Contributing_to_Phobos#Documentation_style.
> 
> Some arguments made here:
> https://github.com/dlang/phobos/pull/5183#issuecomment-281895450
> suggest that backticks, among others, may not work well with
> cross-references as they may contain a code of a different language
> than D.
> 
> Still, pretty recent PRs suggest that backticks should be used, but
> only for single words:
> - https://github.com/dlang/phobos/pull/5801
> - https://github.com/dlang/phobos/pull/5970
> 
> I thought of updating the wiki to match the apparent consensus in this
> regard but wanted to make sure if it's really the way to go.

AFAIK, backticks is preferred because $(D ...) syntax is noisier, and
harder to read in the source code. But otherwise, the two are
equivalent. (In fact, backticks translate directly into $(D ...) in the
ddoc code. They are just syntactic sugar.)

But if your code snippet is longer than a line, you should use inline
code block syntax:

/**
blah blah discussion here

/* code here */
void main()
{
...
}

blah blah discussion here
*/


T

-- 
In a world without fences, who needs Windows and Gates? -- Christian Surchi


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Seb via Digitalmars-d
On Wednesday, 31 January 2018 at 16:13:51 UTC, John Gabriele 
wrote:
I've never seen that page. Would've helped me to see it 
earlier. The D download page should include a blurb with a link 
to that install page.


They are there - hover over them:

https://imgur.com/a/JvZwI

I submitted it without hovering initially:

https://github.com/dlang/dlang.org/pull/1697

And the install.sh page was added in this PR:

https://github.com/dlang/dlang.org/pull/1936

Please let us know what would help you to find this page quicker.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread bachmeier via Digitalmars-d
On Wednesday, 31 January 2018 at 16:13:51 UTC, John Gabriele 
wrote:


I've never seen that page. Would've helped me to see it 
earlier. The D download page should include a blurb with a link 
to that install page.


I tried going to github.com/dlang/dlang.org, finding the 
download page, and adding a blurb+link to install.html above 
those `curl ... install.sh` commands, but that download.dd page 
is written in a format I'm not familiar with. It's difficult to 
read, and appears quite clumsy to write as well.


It surprises me that D docs are written in that ddoc macro 
format --- especially for standalone docs like the download 
page. I think people unfamiliar with D have a perception of D 
as being this older language from times past, before C++11, and 
using ddoc for docs instead of markdown contributes to this 
perception. Let me know if you'd like help in translating D 
website and doc pages from ddoc to markdown.


You can click "Improve this page" in the upper right corner to 
make things easier. The INSTALL_SCRIPT macro at the bottom is 
something I don't have time to dig into, so I filed a bug 
instead. Shouldn't take long for someone with an understanding of 
ddoc to make the change.


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

Please add any comments there if my statement/solution are 
incorrect.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread kinke via Digitalmars-d

On Wednesday, 31 January 2018 at 11:42:14 UTC, Seb wrote:

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:

* three compilers


Not sure why that's a bad thing. They all have their ups and 
downs:


- dmd SUPER fast compilation
- ldc multiarch + good optimization + cross-compilation
- gdc multiarch + good optimization (in many cases better than 
LLVM) + cross-compilation + GNU


Off topic, but I'm not aware of _many_ cases, so please let us 
know whenever you encounter something that GDC optimizes 
significantly better than LDC.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread David Gileadi via Digitalmars-d

On 1/31/18 9:13 AM, John Gabriele wrote:

On Wednesday, 31 January 2018 at 11:42:14 UTC, Seb wrote:

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:


And 3 different installation method's depending on the platform.

Windows: DMD installer, LDC manually extract zip and setup path, GDC ...


That's only an issue on Windows.
For Posix there's the official install.sh script [1].

[1] https://dlang.org/install.html


I've never seen that page. Would've helped me to see it earlier. The D 
download page should include a blurb with a link to that install page.


I tried going to github.com/dlang/dlang.org, finding the download page, 
and adding a blurb+link to install.html above those `curl ... 
install.sh` commands, but that download.dd page is written in a format 
I'm not familiar with. It's difficult to read, and appears quite clumsy 
to write as well.


It surprises me that D docs are written in that ddoc macro format --- 
especially for standalone docs like the download page. I think people 
unfamiliar with D have a perception of D as being this older language 
from times past, before C++11, and using ddoc for docs instead of 
markdown contributes to this perception. Let me know if you'd like help 
in translating D website and doc pages from ddoc to markdown.


I'm working on adding Markdown support to DDoc. If my changes are 
accepted it could make these kinds of edits easier, without having to 
change the whole website at once.


Ages ago I helped redesign the website, which involved messing with DDoc 
macros. I have to agree that DDoc macros aren't always the friendliest.


[Issue 18344] New: Downloads page should link to https://dlang.org/install.html

2018-01-31 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18344

  Issue ID: 18344
   Summary: Downloads page should link to
https://dlang.org/install.html
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: trivial
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: bachm...@yahoo.com

The Downloads page includes a curl command under "Install Script". It should
link to https://dlang.org/install.html.

I recommend adding before the curl command:

"The install.sh script is the official D version manager for DMD, GDC and LDC
on FreeBSD, Linux and macOS. It provides a convenient way to fetch and install
a D compiler without requiring administrative privileges or external
dependencies. For more information, see [link to
https://dlang.org/install.html].;

--


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 31 January 2018 at 14:22:03 UTC, Jack Stouffer 
wrote:
It's quite easy to tell when criticism is made in good or bad 
faith


Is it?  Why do so many people have problems with it then? 
Stupidity?


and at this point I'm going to reply to every rant in bad faith 
on here about how terrible D is with "Post issue numbers" and 
nothing else. If you have a legitimate problem, make an issue 
at issues.dlang.org


Ok, and now you are entering a messy space, define "legitimate"?  
I think the most important issue he raised was how project 
management is either under-communicated or conducted.  Either way 
he sends a strong signal that he is one person (of many) that D 
failed to convert even though he was motivated and able. I don't 
think that is his problem... as he has many other options, but it 
most certainly could be an indicator of a project challenge.


By neglecting that you also neglect what could be a source for 
process improvement.  Development processes need continuous 
improvement. They don't happen by themselves, they need attention 
throughout the lifespan of the project. It is a matter of 
priorities, of course, but that is not a question of 
"legitimate", that is a question of "ranking".


For some reason this ranks below colourful error-messages. I 
don't know the reasoning behind that ranking, so I am not going 
to argue whether that is the right priorities, but it _looks_ 
odd, so something is either under-communicated or maybe he was 
right about management related issues. I don't know.


Whatever spot D is in right now in comparison to other projects, 
good or bad, most certainly isn't because of a lack of marketing. 
Marketing would only bring in more demanding users and more such 
not "legitimate" issues would be raised.


People expect less friction today than they did 10 years ago. To 
some extent Microsoft, Google, Jetbrains and others have handed 
out slick freebies and conditioned programmers to be more 
demanding. That is the dynamics of the current "market".




Re: rdmd main.d leads to Segmentation fault

2018-01-31 Thread Timoses via Digitalmars-d-learn

On Wednesday, 31 January 2018 at 08:40:26 UTC, Kagamin wrote:

On Tuesday, 30 January 2018 at 16:56:28 UTC, Timoses wrote:

Output:
https://pastebin.com/raw/SSx0P1Av

Helps?


Looks like TLS is not initialized.


And I would need to do what about it?

Sorry, I'm not familiar with assembly code stuff in detail.


Re: Should the "front" range primitive be "const" ?

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/30/18 8:05 PM, Jonathan M Davis wrote:


Except that unless front returns by ref, it really doesn't matter whether
front is const unless it's violating the range API, since front is supposed
to return the same value until popFront is called (or if it's assigned a new
value via a front that returns by ref). So, in practice, putting const on
front really doesn't help you any, and it actually hurts you for range
composability.


Right, but that is the difference between a convention ("front is 
supposed to...") vs. a compiler-enforced guarantee (modifying data by 
calling a const-tagged front is a compiler error).


If you are OK with conventions, you don't need const at all.

-Steve


Re: enforce (i > 0) for i = int.min does not throw

2018-01-31 Thread Steven Schveighoffer via Digitalmars-d-learn

On 1/30/18 3:37 PM, kdevel wrote:

On Sunday, 28 January 2018 at 19:17:49 UTC, Steven Schveighoffer wrote:
This is insane. i > 0 is used in so many places. The only saving grace 
appears to be that int.min is just so uncommonly seen in the wild.


And another one that it does not happen when compiled with optimization 
(-O) and also that it does not affect all the ints:


---
import std.stdio;

void foo (T) ()
{
    auto i = T.min;
    writefln ("%12s: %24X %12s", T.stringof, i, i > cast(T) 0);
}

void main ()
{
    foo!byte;
    foo!short;
    foo!int;
    foo!long;
}
---

     byte:   80    false
    short: 8000    false
  int: 8000 true
     long: 8000 true



This is due to integer promotion 
(https://dlang.org/spec/type.html#usual-arithmetic-conversions). Any 
operation between two non-integers, first the two operands are promoted 
to integers.


You can see the result here:

https://run.dlang.io/is/RAk9tE


In 32 bit mode:

     byte:   80    false
    short: 8000    false
  int: 8000 true
     long: 8000    false



Most likely, this is due to the fact that working with longs cannot be 
done natively by the CPU, so it can't use the same shifting shortcut 
that causes the issue in the first place.


-Steve


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Ola Fosheim Grøstad via Digitalmars-d
On Wednesday, 31 January 2018 at 13:54:25 UTC, Jack Stouffer 
wrote:
I've only ever seen people complain about D in this area. Never 
once have I seen someone argue that the existence of PyPy hurts 
Python or gogcc hurts Go.


Well, I've seen that people think that MS C++ is keeping C++ back 
because it failed to keep up, so people couldn't write portable 
code using the latest features...


PyPy and gogcc doesn't hurt Python and Go because the reference 
interpreters/compilers are mature, stable and cannot take more 
manpower...


Apples and oranges, does not compare well.



Re: Release D 2.078.1

2018-01-31 Thread Arjan via Digitalmars-d-announce

On Wednesday, 31 January 2018 at 15:58:02 UTC, Atila Neves wrote:
On Thursday, 25 January 2018 at 20:11:54 UTC, Rainer Schuetze 
wrote:



On 25.01.2018 14:54, Atila Neves wrote:

[...]


Visual Studio is supposed to be detected by dmd now, either 
from the environment or from the registry.


What errors do you get? Try running with -v to show the linker 
command line.


$ dub init
$ dub build --arch=x86_64
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe 
for x86_64.

example ~master: building configuration "application"...
Linking...
LINK : fatal error LNK1104: cannot open file 'shell32.lib'

-v shows that it's linking like so:

C:\D\dmd2\windows\bin\dmd.exe 
-of.dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.exe .dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.obj -m64 -g


Should I file a bug for dmd or the installer? Are 64-bit dub 
builds not done by CI on Windows? This is pretty embarassing.


Atila


By any chance, is this on a corperate machine? I've hit the same 
issue seems to do with enforced windows group-policy which 
disables registry access for certain type of applications at my 
place.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread John Gabriele via Digitalmars-d

On Wednesday, 31 January 2018 at 11:42:14 UTC, Seb wrote:

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:

And 3 different installation method's depending on the 
platform.


Windows: DMD installer, LDC manually extract zip and setup 
path, GDC ...


That's only an issue on Windows.
For Posix there's the official install.sh script [1].

[1] https://dlang.org/install.html


I've never seen that page. Would've helped me to see it earlier. 
The D download page should include a blurb with a link to that 
install page.


I tried going to github.com/dlang/dlang.org, finding the download 
page, and adding a blurb+link to install.html above those `curl 
... install.sh` commands, but that download.dd page is written in 
a format I'm not familiar with. It's difficult to read, and 
appears quite clumsy to write as well.


It surprises me that D docs are written in that ddoc macro format 
--- especially for standalone docs like the download page. I 
think people unfamiliar with D have a perception of D as being 
this older language from times past, before C++11, and using ddoc 
for docs instead of markdown contributes to this perception. Let 
me know if you'd like help in translating D website and doc pages 
from ddoc to markdown.




Re: Release D 2.078.1

2018-01-31 Thread Atila Neves via Digitalmars-d-announce
On Thursday, 25 January 2018 at 20:11:54 UTC, Rainer Schuetze 
wrote:



On 25.01.2018 14:54, Atila Neves wrote:

On Tuesday, 23 January 2018 at 15:16:02 UTC, Andre Pany wrote:

On Tuesday, 23 January 2018 at 13:08:35 UTC, thedeemon wrote:
On Monday, 22 January 2018 at 20:43:56 UTC, Martin Nowak 
wrote:

Glad to announce D 2.078.1.



The Windows 7z archive version now has much simpler sc.ini, 
in fact too simple.

With Visual C++ 2015 x64 Native Build Tools now trying to run
dmd -m64 hi.d
I get
LINK : fatal error LNK1104: cannot open file 'libucrt.lib'
Error: linker exited with status 1104

So I needed to edit sc.ini and add back
LIB=%LIB%;"%UniversalCRTSdkDir%\Lib\%UCRTVersion%\ucrt\x64"
to the [Environment64] section.

Then it went just as 2.078.0 - still missing 
legacy_stdio_definitions.lib that I need to add manually in 
the command line.


Did you call vcvarsall in the current dos box/PowerShell? It 
is a tool included with all visual studio variants.


Kind regards
Andre


I just ran into this today. With the dmd 2.077.1 Windows 
installer things just work, and it's never necessary to call 
vcvarsall.bat to build D code for 64-bit.


Since dmd 2.078.0, with Visual Studio 2015, nothing works 
anymore, and sc.ini doesn't seem to reference Visual Studio at 
all like it used to.


Atila


Visual Studio is supposed to be detected by dmd now, either 
from the environment or from the registry.


What errors do you get? Try running with -v to show the linker 
command line.


$ dub init
$ dub build --arch=x86_64
Performing "debug" build using C:\D\dmd2\windows\bin\dmd.exe for 
x86_64.

example ~master: building configuration "application"...
Linking...
LINK : fatal error LNK1104: cannot open file 'shell32.lib'

-v shows that it's linking like so:

C:\D\dmd2\windows\bin\dmd.exe 
-of.dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.exe .dub\build\application-debug-windows-x86_64-dmd_2078-70A25404824ECE07D24A9F4D03E746CD\example.obj -m64 -g


Should I file a bug for dmd or the installer? Are 64-bit dub 
builds not done by CI on Windows? This is pretty embarassing.


Atila


Re: How to proceed with learning to code Windows desktop applications?

2018-01-31 Thread DanielG via Digitalmars-d-learn

On Wednesday, 31 January 2018 at 12:25:36 UTC, John Chapman wrote:
Just to say that it is actually possible to write modern 
Windows apps in D - I've done it. WinRT is just COM. Granted 
it's not as easy as using Microsoft's language projections, but 
it's doable if you really want to.


The .winmd files describing the WinRT API surface are 
machine-readable, so in theory some enterprising D developer 
should be able to generate an elegant D projection. But as with 
many things, there might not be much overlap between "those who 
can" and "those who want to" :P


It's certainly beyond my skill level at the moment ...


Inline code in the docs - the correct way

2018-01-31 Thread Jakub Łabaj via Digitalmars-d
What is the current state of the art of writing inline code in 
the documentation?


Wiki says "use `...` instead of $(D ...)": 
https://wiki.dlang.org/Contributing_to_Phobos#Documentation_style.


Some arguments made here: 
https://github.com/dlang/phobos/pull/5183#issuecomment-281895450 
suggest that backticks, among others, may not work well with 
cross-references as they may contain a code of a different 
language than D.


Still, pretty recent PRs suggest that backticks should be used, 
but only for single words:

- https://github.com/dlang/phobos/pull/5801
- https://github.com/dlang/phobos/pull/5970

I thought of updating the wiki to match the apparent consensus in 
this regard but wanted to make sure if it's really the way to go.


what is local package map(local-packages.json) for dub while doing building?

2018-01-31 Thread Johann via Digitalmars-d-learn

$ dub build -b release -v


Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at 
/var/lib/dub/packages/local-packages.json
Looking for local package map at 
/home/john/.dub/packages/local-packages.json

Refreshing local packages (refresh existing: false)...
Looking for local package map at 
/var/lib/dub/packages/local-packages.json
Looking for local package map at 
/home/john/.dub/packages/local-packages.json

  Found dependency gtk-d 3.7.3
Found dependency gtk-d:sv 3.7.3
  Found dependency gtk-d:gtkd 3.7.3
Found dependency gtk-d:gstreamer 3.7.3
Found dependency gtk-d:peas 3.7.3
Found dependency gtk-d:vte 3.7.3
Refreshing local packages (refresh existing: false)...
Looking for local package map at 
/var/lib/dub/packages/local-packages.json
Looking for local package map at 
/home/john/.dub/packages/local-packages.json

  Found dependency gtk-d 3.7.3
Found dependency gtk-d:sv 3.7.3
  Found dependency gtk-d:gtkd 3.7.3
Found dependency gtk-d:gstreamer 3.7.3
Found dependency gtk-d:peas 3.7.3
Found dependency gtk-d:vte 3.7.3
Checking for upgrades.
Using cached upgrade results...
Generating using build


The verbose message is confusing. Why are there so many attempts 
to look for local package map? And I don't even have it. How can 
I generate one if it's useful?


What does "Checking for upgrades" do?


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jack Stouffer via Digitalmars-d

On Wednesday, 31 January 2018 at 10:55:56 UTC, Benny wrote:

On Wednesday, 31 January 2018 at 10:35:06 UTC, Benny wrote:

Let me say this again


*uch* Never mind this rant. I am just fed up with the issues. I 
will not post anymore as its just a wast of time for everybody 
involved.


It's quite easy to tell when criticism is made in good or bad 
faith, and at this point I'm going to reply to every rant in bad 
faith on here about how terrible D is with "Post issue numbers" 
and nothing else. If you have a legitimate problem, make an issue 
at issues.dlang.org


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Jack Stouffer via Digitalmars-d
On Wednesday, 31 January 2018 at 07:56:37 UTC, Andrew Benton 
wrote:

E.g. three compilers


Every other compiled language (and a lot of scripting ones) uses 
the fact of multiple compilers for the language as a sign of 
adoption and ecosystem growth.


I've only ever seen people complain about D in this area. Never 
once have I seen someone argue that the existence of PyPy hurts 
Python or gogcc hurts Go.


Re: The daily D riddle

2018-01-31 Thread Jorge Lima via Digitalmars-d

On Sunday, 28 January 2018 at 06:44:06 UTC, Shachar Shemesh wrote:

On 28/01/18 08:33, Mike Franklin wrote:
On Sunday, 28 January 2018 at 06:25:51 UTC, Shachar Shemesh 
wrote:

What will the following code print? Do not use the compiler:

import std.stdio;

struct A {
int a = 1;

void initialize() {
    a = a.init;
}
}

void main() {
A a;
a.initialize();

writeln(a.a);
}

I find this behavior unexpected.


Works exactly as I predicted.


Good for you.

I think the compiler should warn about such a case.


I also run the test and it worked as I expected. It seems pretty 
straingtforward logic. I wonder if I didn't get your question 
right. What result were you expecting and why?


Re: Don't expect class destructors to be called at all by the GC

2018-01-31 Thread Bienlein via Digitalmars-d-learn
On Thursday, 21 December 2017 at 18:45:27 UTC, Adam D. Ruppe 
wrote:

On Thursday, 21 December 2017 at 18:20:19 UTC, H. S. Teoh wrote:
When the scoped destruction of structs isn't an option, 
RefCounted!T seems to be a less evil alternative than an 
unreliable class dtor. :-/


Alas, RefCounted doesn't work well with inheritance...

Though, what you could do is make the refcounted owners and 
borrow the actual reference later.


Is there some summary of the things you have to be aware of when 
using the GC in D and not using the GC? I feel this would be very 
useful especially for people that are new to D or are not used to 
that kind of issues (because coming from a GCed language).


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread Michael via Digitalmars-d
On Wednesday, 31 January 2018 at 07:56:37 UTC, Andrew Benton 
wrote:
On Tuesday, 30 January 2018 at 20:45:44 UTC, Andrei 
Alexandrescu wrote:

https://www.quora.com/Why-hasnt-D-started-to-replace-C++

Andrei


I think that the largest issue there is probably the marketing 
and advocacy.  When Rust was about the same share as D, it had 
much better marketing.  Someone was running their twitter 
channel and working to make the language much more visible.  D 
flat out doesn't have that.


If I had to pick a second issue, it's that the ecosystem story 
is hard compared to other languages.  New programmers aren't 
certain what to choose or how to get their environment up and 
running.  Compared against Rust, Go, and Java we have horrible 
ecosystem fragmentation.  E.g. three compilers, two separate 
languages for dub


I agree that marketing is a pretty serious problem for D. Many 
people just aren't aware of it. Even for people who do not 
program in the newer languages, Rust and Go are already well 
known to anybody who uses C# or C/C++ or Java, and even many 
Python or JavaScript programmers. D is often looked over and not 
visible enough on people's radars for them to even notice it, 
which is hugely disappointing as I've no doubt many would come to 
realise that it offers much of what they're looking for. 
Marketing is definitely failing the language here, but 
considering we don't have some huge company backing D, it's doing 
fairly well on its own. I just worry it's not enough to rely on 
word-of-mouth because it doesn't seem to be enough.


Personally I don't find the ecosystem to be a huge problem any 
more than C++'s is a problem. I can install DMD and LDC and, 
if/when I want/need to, I can tell rdmd to build using LDC. I am 
glad to have options, as I don't feel that they hinder my use of 
D.


Re: Quora: Why hasn't D started to replace C++?

2018-01-31 Thread drug via Digitalmars-d
It would be really nice if we could know about current WIP a little bit 
more... And regularly.


Re: How to proceed with learning to code Windows desktop applications?

2018-01-31 Thread Arredondo via Digitalmars-d-learn

On Tuesday, 30 January 2018 at 18:52:18 UTC, I Lindström wrote:

On Tuesday, 30 January 2018 at 12:30:36 UTC, rjframe wrote:


VS release builds compile to native now by default; for easy 
Windows programming, you really can't beat C# and drawing the 
GUI (Windows Forms, not necessarily the new stuff). If the OP 
wants to learn what's needed for more complex GUI tasks (like 
for most non-simple applications), learning to build a GUI 
from source is kind of necessary though.




I've been looking into C# and VS2017 today along with VisualD. 
Reading through all this it looks like the simplest path is to 
learn C# and VS and go from there. I've found a pile of courses 
on LinkedIn that seem to build up to what I need. What makes me 
sad is that I have to drop D for at least the time being.


As other have said, WPF and C# is the way to go for Windows GUI 
programming, but you don't necessarily need to drop D. You could 
write your interface code in VS and have it call your D library 
via pinvoke (Platform Invoke). To make this work you must mark 
your public D functions with extern(C). Read the documentation on 
extern(C) and PInvoke.


Honestly, I don't know why more people don't do this. It really 
seems to be like the best of both worlds, as C# + WPF is king for 
Windows GUI and D is king for library development. The only 
drawback I can think of is you have to expose your awesome D 
library via a dumped down C interface.





  1   2   >