Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-announce
On Wednesday, December 13, 2017 06:53:02 rikki cattermole via Digitalmars-d-
announce wrote:
> On 13/12/2017 6:46 AM, bauss wrote:
> > On Wednesday, 13 December 2017 at 01:14:26 UTC, Seb wrote:
> >> On Wednesday, 13 December 2017 at 00:32:11 UTC, rikki cattermole wrote:
> >>> On 12/12/2017 6:37 PM, Seb wrote:
>  === Supported D Compilers ===
> 
>  * Latest DMD nightly
>  * Latest DMD beta
>  * Latest DMD
>  * Latest LDC beta
>  * Latest LDC
> 
>  The Docker images are rebuilt every day automatically.
> >>>
> >>> Can we please select a version we want to test against?
> >>
> >> While it would be rather easier to build more Docker images [1] and
> >> add them to the tour [2], I fear that this will be too much
> >> maintenance overhead and will lead to outdated compiler soon.
> >> Also the storage on the machine is limited and we can't drop an
> >> unlimited amount of Docker images there.
> >>
> >> [1] https://github.com/dlang-tour/core-exec
> >> [2]
> >> https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L22
> >
> > What you could do is support the 3 latest versions of the compilers.
> >
> > Ex. for DMD you would support:
> > 2.077.1
> > 2.076.1
> > 2.075.1
>
> Also the older c++ version (2.06x.x).

What would be the point of that? That's old enough that no one should really
be using it. Targetting it just runs the risk of your code not working with
a recent version of the compiler and standard library.

- Jonathan M Davis



Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Seb via Digitalmars-d-announce
On Wednesday, 13 December 2017 at 06:53:02 UTC, rikki cattermole 
wrote:

On 13/12/2017 6:46 AM, bauss wrote:

On Wednesday, 13 December 2017 at 01:14:26 UTC, Seb wrote:
On Wednesday, 13 December 2017 at 00:32:11 UTC, rikki 
cattermole wrote:

On 12/12/2017 6:37 PM, Seb wrote:

=== Supported D Compilers ===

* Latest DMD nightly
* Latest DMD beta
* Latest DMD
* Latest LDC beta
* Latest LDC

The Docker images are rebuilt every day automatically.


Can we please select a version we want to test against?


While it would be rather easier to build more Docker images 
[1] and add them to the tour [2], I fear that this will be 
too much maintenance overhead and will lead to outdated 
compiler soon.
Also the storage on the machine is limited and we can't drop 
an unlimited amount of Docker images there.


[1] https://github.com/dlang-tour/core-exec
[2] 
https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L22


What you could do is support the 3 latest versions of the 
compilers.


Ex. for DMD you would support:
2.077.1
2.076.1
2.075.1


Also the older c++ version (2.06x.x).


Shouldn't DMD be stable enough that latest is good enough for 
everyone?
As mentioned, I'm afraid that it will look similar like: 
http://asm.dlang.org
And FWIW before I started updating Wikipedia and our DWiki even 
the versions there got outdated.


Anyhow, everything is entirely automated, so if someone 
volunteers to make the update PRs to:


- https://github.com/dlang-tour/core-exec/blob/master/.travis.yml
- 
https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L22
- 
https://github.com/dlang-tour/core/blob/master/views/editor.dt#L27


I wouldn't mind.


Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Mike Franklin via Digitalmars-d-announce

On Tuesday, 12 December 2017 at 18:37:38 UTC, Seb wrote:
After it has been in stealth mode for quite a while, I'm happy 
to announce that there's https://run.dlang.io


I've actually been using it a lot recently to communicate 
bugs/ideas/patterns with others.


Due to the nightlies, I can quickly see if a bug has been 
addressed in master.  I've closed a couple of bugs recently with 
"worksforme" that way.


I also use it to quickly try ideas when I'm out waiting 
somewhere, or just when an idea occurs to me.


It is such a great resource.  Thanks to those who put their time 
into it.


Mike


Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 13, 2017 06:55:46 bauss via Digitalmars-d-learn 
wrote:
> On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote:
> > On 12-12-17 00:35, Seb wrote:
> >> D style would be to use sth. like this (instead of try/catch):
> >>
> >> ```
> >> scope(failure) {
> >>
> >>e.msg.writeln;
> >>1.exit;
> >>
> >> }
> >> ```
> >
> > I might have missed something, but where is `e` defined in this
> > case?
>
> I was thinking the same and can't find anything in the
> documentation that states you can retrieve the exception that
> caused the failure by an "e" variable.
>
> All I could find is that in case you need to use the exception
> you'd have to do a try/catch.
>
> So ultimately that code wouldn't work, according to the language
> specs.
>
> I haven't tested it, so I don't know if it's some hidden feature,
> but if it is, then I'm against it.

If it works, it's a bug related to code lowering (since scope statements are
always lowered to try-catch-finally blocks). You're not supposed to have
access to the exception in a scope statement.

- Jonathan M Davis



Re: Date Formating

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, December 13, 2017 02:34:12 codephantom via Digitalmars-d-learn 
wrote:
> On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote:
> > Hi All,
> >
> >   Request out help on date formatting, I have code which output
> >
> > the date and time as below , i we need it without the last few
> > numbers.,ie "-MMM-DD HH:MM:SI"
> >
> > Output : 2017-Sep-06 16:06:42.7223837
> > Required Output : 2017-Sep-06 16:06:42
> >
> > From,
> > Vino.B
>
> just playing with this...
>
> // --
>
> module test;
>
> void main()
> {
>  import std.stdio;
>
>  writeln( GetFmtDate() ); // e.g: 2017-Dec-13 13:30:23
>
> }
>
>
> string GetFmtDate()
> {
>  import std.datetime;
>  import std.ascii : toUpper;
>  import std.conv : to;
>  import std.string : format;
>
>  auto d = Clock.currTime();
>
>  string fmtMonth = toUpper(to!string(d.month)[0]) ~
>to!string(d.month)[1..$];
>
>  return
>  format("%04s-%s-%02s %02s:%02s:%02s",
>  (d.year),
>  fmtMonth,
>  (d.day),
>  (d.hour),
>  (d.minute),
>  (d.second)
>  );
> }
>
> // --

In general, you probably want to cast the SysTime to a DateTime if you're
going to do something like that. There's a lot of duplicate work being done
if you get each of those properties individually, whereas if you cast to
DateTime, then it does the work once, and the properties for DateTime just
return the correspending member variables. Sometimes, I think that putting
year, month, etc. on SysTime was a mistake, because using thoes properties
almost always the wrong thing to do given how much work is duplicated when
using them, but at the same time, there are cases where the efficiency
doesn't really matter and the simplicity of just grabbing the properties
from SysTime is nice.

- Jonathan M Davis



Re: Is it possible to request a code review?

2017-12-12 Thread Jonathan M Davis via Digitalmars-d
On Wednesday, December 13, 2017 06:14:04 bauss via Digitalmars-d wrote:
> Documentation can be done like this for multiline:
>
> /**
> * ...
> * ...
> * etc.
> */
>
> Instead of:
>
> /// ...
> /// ...
> /// etc.

You can also do

/**
  ...
  ...
  etc.
*/

or

/++
  ...
  ...
  etc.
+/

Personally, I always use the last one if the ddoc comment is multiple lines,
and I've never understood why anyone would want all those extra *'s on the
side.

- Jonathan M Davis



Re: Is it possible to request a code review?

2017-12-12 Thread Ali Çehreli via Digitalmars-d

On 12/12/2017 07:15 PM, IM wrote:

I started learning D recently.


Welcome! There is also the Learn newsgroup[1]. ;)

Ali

[1] Available through a forum interface here:

  http://forum.dlang.org/group/learn


Re: What's the proper way to use std.getopt?

2017-12-12 Thread bauss via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 18:34:26 UTC, Mike Wey wrote:

On 12-12-17 00:35, Seb wrote:

D style would be to use sth. like this (instead of try/catch):

```
scope(failure) {
   e.msg.writeln;
   1.exit;
}
```


I might have missed something, but where is `e` defined in this 
case?


I was thinking the same and can't find anything in the 
documentation that states you can retrieve the exception that 
caused the failure by an "e" variable.


All I could find is that in case you need to use the exception 
you'd have to do a try/catch.


So ultimately that code wouldn't work, according to the language 
specs.


I haven't tested it, so I don't know if it's some hidden feature, 
but if it is, then I'm against it.


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn

On 12/12/2017 10:21 PM, bauss wrote:
> On Tuesday, 12 December 2017 at 22:11:37 UTC, Adam D. Ruppe wrote:
>> On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote:
>>> The same buffer is used for all segments and socket.receive should be
>>> inside while.
>>
>> The buffer is copied by the ~= operator, but indeed you're right that
>> I forgot to receive again inside the loop! That would just spin until
>> it ran out of memory lol.
>>
>> But I did put receive outside the loop for a reason: it just needs to
>> prime the return value before it gets checked the first time. But
>> then, of course, it should receive again at the end of the loop to
>> advance to the next chunk.
>
> do while would work better.

It's a bummer that the loop variable must be defined outside of do-while:

bool done = false;// Can't be inside
do {
// ...
} while(!done);

That's why I think an unconditional loop with an explicit break is 
better in such situations:


while (true) {
// ... everything inside ...
if (!got) {
break;
}
// ...
}

Here is a short program that I played with:

import std.stdio;
import std.range;
import std.algorithm;

int[] makeData(int len) {
return iota(len).array;
}

struct SomeSource {
int[] data;

this(int len) {
this.data = makeData(len);
}

// Alternatively, this can return int[]
size_t read(int[] buffer) {
const len = min(data.length, buffer.length);
buffer[0..len] = data[0..len];
data = data[len..$];// Alternatively, popFrontN
return len;
}
}

void main() {
enum len = 50;
auto foo = SomeSource(len);

int[] result;
while (true) {// <-- UNCONDITIONAL LOOP
int[17] buffer;
const got = foo.read(buffer[]);
if (!got) {
break;
}
result ~= buffer[0..got];
}
assert(result == makeData(len));
writeln(result);
}

Ali



Re: LDC 1.7.0-beta1

2017-12-12 Thread Joakim via Digitalmars-d-announce

On Sunday, 10 December 2017 at 18:11:46 UTC, Suliman wrote:

On Sunday, 10 December 2017 at 17:33:34 UTC, kinke wrote:

Hi everyone,

on behalf of the LDC team, I'm glad to announce the first beta 
for LDC 1.7. The highlights of this version in a nutshell:


* Based on D 2.077.1.
* Catching C++ exceptions supported on Linux and Windows.

Full release log and downloads: 
https://github.com/ldc-developers/ldc/releases/tag/v1.7.0-beta1


Thanks to all contributors!


Is it's possible to produce x64 binaries on Windows x64 without 
installing Visual Studio? DMD do not have linker for x64.


You could try using the llvm linker, lld, as noted in the release 
notes for ldc 1.5:


https://github.com/ldc-developers/ldc/releases/tag/v1.5.0

I don't know what's needed to link against functions from the 
Windows libc though.


On Sunday, 10 December 2017 at 19:00:53 UTC, Timothee Cour wrote:
could these releases be tied to 'homebrew/linuxbrew' upgrades 
as part of release process?


John usually submits a pull to homebrew for the betas, may just 
be behind on this one:


https://github.com/Homebrew/homebrew-core/pull/20580

Looks pretty simple, you or any other brew user could easily 
submit that too.


On Tuesday, 12 December 2017 at 01:37:31 UTC, Meta wrote:
Very impressive. I'm curious, is the work done to catch C++ 
exceptions separate from Walter's previous efforts with dmd, or 
does it build on his work in some way?


As noted in the linked 1.7 release notes, kinke merged ldc's 
non-MSVC exception-handling with Walter's new DWARF efforts and 
integrated some work by Rainer for MSVC.


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread bauss via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 22:11:37 UTC, Adam D. Ruppe wrote:

On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote:
The same buffer is used for all segments and socket.receive 
should be inside while.


The buffer is copied by the ~= operator, but indeed you're 
right that I forgot to receive again inside the loop! That 
would just spin until it ran out of memory lol.


But I did put receive outside the loop for a reason: it just 
needs to prime the return value before it gets checked the 
first time. But then, of course, it should receive again at the 
end of the loop to advance to the next chunk.


do while would work better.


Re: Released vibe.d 0.8.2

2017-12-12 Thread bauss via Digitalmars-d-announce

On Tuesday, 12 December 2017 at 19:44:17 UTC, Sönke Ludwig wrote:
The major changes in this release are HTTP forward proxy 
support, handling incoming HTTP requests on custom transports 
and a MongoDB based session store. On top of that, there are 
many smaller improvements in the HTTP server, web/REST 
generator, JSON/BSON support and the TLS sub system.


Change log:
https://vibed.org/blog/posts/vibe-release-0.8.2

DUB package:
https://code.dlang.org/packages/vibe-d/0.8.2


Great job


Re: Is it possible to request a code review?

2017-12-12 Thread bauss via Digitalmars-d

On Wednesday, 13 December 2017 at 03:15:11 UTC, IM wrote:

Thanks!


First thing.

Generally in D module names are kept lower-case.

To give an example your:
AbstractTaskRunner.d
module tasks.AbstractTaskRunner;

Would usually be:
abstracttaskrunner.d
module tasks.abstracttaskrunner;

Of course it's not necessary, but it's how it usually is in 
idiomatic D.


The same goes for function names etc. they're usually kept 
camelCase and not PascalCase like you have it. Again it's not 
necessary, but that's idiomatic D.


A wild guess from me would be that you come from a C#/.NET 
background OR you have worked heavily with the win api, am I 
right?


Documentation can be done like this for multiline:

/**
* ...
* ...
* etc.
*/

Instead of:

/// ...
/// ...
/// etc.

This might just be a personal thing for me, but I always use /// 
for single-line documentation only.


Also you don't need to define constructors for classes, if they 
don't actually do something.


Ex. your SingleThreadTaskRunner class defines this:

~this() @safe {}

Integers are automatically initialized to int.init which is 0, so 
the following is can be rewritten from: (Find in a unittest)


int value = 0;

to:

int value;

Also empty lambdas like:

() { ... }

can be written like:

{ ... }

Also you have a few Hungarian notations, which is often not used 
in idiomatic D.


The key for an associative array __should__ always be treated 
const internally, so this:


ITaskRunner[const Tid]

shouldn't be necessary and doing:

ITaskRunner[Tid] should work just fine.

If you have experienced otherwise, then I'd argue it's a bug and 
you should report it.


Also statements like this:

immutable int currentNumber

are often preferred written like:

immutable(int) currentNumber

And getting too used to write:

immutable int currentNumber

might have you end up writing something like:

immutable int getAnImmutableNumber() { ... }

Which does not do what you would expect as it doesn't treat the 
return value as immutable, but instead "this" as immutable.


To make the return type immutable you'd write:

immutable(int) getAnImmutableNumber() { ... }

I don't know if you know that already, but just figured I'd give 
a heads up about that.


That was all I could see looking through your code real quick.

Take it with a grain of salt as some of the things might be 
biased.


[Issue 17527] dlangspec.pdf: escape sequences table goes over the page boundaries

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17527

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

   What|Removed |Added

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

--


[Issue 17527] dlangspec.pdf: escape sequences table goes over the page boundaries

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17527

--- Comment #2 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/dlang.org

https://github.com/dlang/dlang.org/commit/ec1d0ef2470561ff412b606200e216164ce63678
Fix Issue 17527 - dlangspec.pdf: escape sequences table goes over the page
boundaries

--


[Issue 18068] No file names and line numbers in stack trace

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18068

--- Comment #3 from Seb  ---
FWIW there's a test case:
https://github.com/dlang/dmd/blob/master/test/runnable/test17559.d

It's just never run with `-fPIC`.

--


[Issue 18070] New: dlangspec.pdf: 20.4: too much whitespace before opCmp

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18070

  Issue ID: 18070
   Summary: dlangspec.pdf: 20.4: too much whitespace before opCmp
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: greensunn...@gmail.com

> Therefore, it is the programmer's responsibility to ensure that opCmp and 
> opEquals are
consistent with each other.

https://imgur.com/UXtw6lM

--


[Issue 17535] dlangspec.pdf: enforce a maximal width for all code examples

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17535

--- Comment #2 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/dlang.org

https://github.com/dlang/dlang.org/commit/c06380e2abf307572b7e139b3711fbf3999fcb78
Fix Issue 17535 - Normalize code line lengths to 80 columns or less

--


[Issue 17535] dlangspec.pdf: enforce a maximal width for all code examples

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17535

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

   What|Removed |Added

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

--


Is it possible to request a code review?

2017-12-12 Thread IM via Digitalmars-d
I started learning D recently. As part of the learning process, I 
started working on some D projects to experiment and learn. My 
first project is a tasking system library that I plan to use in 
another D project I'm working on.


The goal is to be able to post and run any task asynchronously on 
current thread, new thread, or thread pool, and possibly getting 
a callback on the posting thread when the task has run to 
completion. I will probably expand it more as I go. I've just 
published it on DUB here: 
https://code.dlang.org/packages/libdtasks


Being new to D, I probably made many mistakes, or did things in a 
way where there's a more optimum one to do in D. I'm eager to 
know how to improve, and would like to know if there is any 
experienced D developer who is thankfully willing to take a look 
at it and give me feedback?


Thanks!


Re: SDL2 texture blend help

2017-12-12 Thread Ivan Trombley via Digitalmars-d

Here's a page that describes the issue:
http://ssp.impulsetrain.com/gamma-premult.html


Re: Understanding how dub works

2017-12-12 Thread codephantom via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 22:20:41 UTC, datboi wrote:

Hi, I'm learning D (obliviously) 


learning D in an oblivious manner can be difficult ;-)



Re: SDL2 texture blend help

2017-12-12 Thread Ivan Trombley via Digitalmars-d

On Wednesday, 13 December 2017 at 01:44:33 UTC, Dmitry wrote:
On Tuesday, 12 December 2017 at 23:28:23 UTC, Ivan Trombley 
wrote:
Here's the code that produces the correct results (exactly the 
same as GIMP):

Share images you used, please.


Background image:
http://a4.pbase.com/o10/09/605909/1/166706859.XKZZCnSO.background.png

Foreground image:
http://a4.pbase.com/o10/09/605909/1/166706860.c1yD4VWp.image.png

Composited through SDL:
http://a4.pbase.com/o10/09/605909/1/166706869.wLt9RofY.sdl.png

Composited in GIMP 2.9:
http://a4.pbase.com/o10/09/605909/1/166706870.S01BIhVG.gimp.png

When composited using the code I posted looks exactly like the 
GIMP 2.9 image.


[Issue 17531] dlangspec.pdf: overloading unary operators exposes LaTeX

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17531

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

   What|Removed |Added

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

--


[Issue 17531] dlangspec.pdf: overloading unary operators exposes LaTeX

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17531

--- Comment #5 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/dlang.org

https://github.com/dlang/dlang.org/commit/01068170dfde4537a6978462ad7ed8dd0b0a11d6
Fix Issue 17531 - Fix table Overloadable Index Unary Operators

--


Re: Date Formating

2017-12-12 Thread codephantom via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 15:56:59 UTC, Vino wrote:

Hi All,

  Request out help on date formatting, I have code which output 
the date and time as below , i we need it without the last few 
numbers.,ie "-MMM-DD HH:MM:SI"


Output : 2017-Sep-06 16:06:42.7223837
Required Output : 2017-Sep-06 16:06:42

From,
Vino.B


just playing with this...

// --

module test;

void main()
{
import std.stdio;

writeln( GetFmtDate() ); // e.g: 2017-Dec-13 13:30:23

}


string GetFmtDate()
{
import std.datetime;
import std.ascii : toUpper;
import std.conv : to;
import std.string : format;

auto d = Clock.currTime();

string fmtMonth = toUpper(to!string(d.month)[0]) ~
  to!string(d.month)[1..$];

return
format("%04s-%s-%02s %02s:%02s:%02s",
(d.year),
fmtMonth,
(d.day),
(d.hour),
(d.minute),
(d.second)
);
}

// --



[Issue 17531] dlangspec.pdf: overloading unary operators exposes LaTeX

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17531

Seb  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #4 from Seb  ---
PR https://github.com/dlang/dlang.org/pull/1963

--


[Issue 17535] dlangspec.pdf: enforce a maximal width for all code examples

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17535

Seb  changed:

   What|Removed |Added

   Keywords||pull

--- Comment #1 from Seb  ---
PR https://github.com/dlang/dlang.org/pull/1962

--


Re: Date Formating

2017-12-12 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, December 12, 2017 15:56:59 Vino via Digitalmars-d-learn wrote:
> Hi All,
>
>Request out help on date formatting, I have code which output
> the date and time as below , i we need it without the last few
> numbers.,ie "-MMM-DD HH:MM:SI"
>
> Output : 2017-Sep-06 16:06:42.7223837
> Required Output : 2017-Sep-06 16:06:42

If you want to strip off the fractional seconds, then just zero them out.
e.g.

sysTime.fracSecs = Duration.zero;

The to*String functions of SysTime don't display trailing zeroes and don't
display the decimal point if the fractional seconds are zero.

- Jonathan M Davis



Re: mir-algorithm v0.7.0: new interpolation, optmath, bugfixes

2017-12-12 Thread jmh530 via Digitalmars-d-announce

On Tuesday, 12 December 2017 at 23:10:26 UTC, Nathan S. wrote:

About Mir Algorithm

[snip]


+1


Re: Adding Markdown to Ddoc

2017-12-12 Thread Jonathan M Davis via Digitalmars-d
On Tuesday, December 12, 2017 16:12:50 Adam D. Ruppe via Digitalmars-d 
wrote:
> On Tuesday, 12 December 2017 at 11:33:45 UTC, Jonathan M Davis
>
> wrote:
> > Personally, I would _very_ much like to see the magic
> > formatting in ddoc kept to a minimum.
>
> You know what drives me nuts? This* is weird.
>
> * it is rendered as a list item! And I know, you can do \*. But
> ugh.
>
> Ugh. Or why is _this_ italic?
>
>
> But those, while enough to bring my hatred, are not why I did
> something new for adrdox... it is the missed opportunities for
> links. adrdox links are more inspired by the wikipedia link
> syntax and uses knowledge of D to keep them very concise:
>
> /// Does something. See also: [bar].
> void foo();
>
> /// Does something similar. See also: [foo].
> void bar();
>
>
> When it sees a string in brackets, it does a name lookup
> following D's scoping rules for that declaration, and creates a
> link to it. It even understands imports (slightly buggy but i'll
> fix that eventually):
>
> import std.stdio;
> import arsd.color;
>
> /// calls [writeln] on the given [Color|color].
> void bar(Color s, string txt);
>
>
>
> You also see the pipe syntax there which replaces the text for
> the link. It always does [link_to|displayed_text] where
> displayed_text = link_to if it is not present. In markdown, i
> often reverse these.
>
>
> But anyway, I struggled a bit on using single brackets for this,
> since I hate magic syntax too... but I went with it because
> cross-linking like this is VERY common and adds a lot to the
> documentation. I use it very frequently (in the docs I've written
> with the new generator; many of mine are still in the transition
> period from ddoc). In fact, I use it almost as frequently as
> `code` (which doesn't attempt namespace lookups because it is too
> generic and linking in there leads to silly results).
>
>
> Phobos' $(REF) macro tries to do something similar but it is a
> huge pain since it needs more qualification; it doesn't look
> stuff up in the actual D.
>
> Cross linking in documentation I find is a huge win in legibility
> for the coder and readability for the end user. *this* vs $(B
> this)? meh whatever.

Yeah. Unfortunately, given that ddoc is designed to be only a macro language
and tries to not focus on html generation specifically, I don't know how
feasible it is to make it deal with links properly while still working with
other target formats. On some level ddoc's flexibility undermines it as a
good tool for generating documentation. But for most of us, if ddoc could be
improved to actually generate cross-links by default where appropriate (e.g.
parameter types to the documentation for those types) and have built-in
macros for manually generating cross-links within the documentation, then
that would be a huge step up. As it stands, I think that in most cases,
using something like ddox or adrdox works a lot better than using ddoc for
everything, which is kind of sad given that the whole point of ddoc was to
have something built-in for easily generating documentation.

Maybe at some point, I'll look at seeing how reasonable it is to improve
ddoc to deal with the links properly, but I'm not very familiar with the
compiler, and I have too many projects as it is.

- Jonathan M Davis



Re: SDL2 texture blend help

2017-12-12 Thread Dmitry via Digitalmars-d

On Tuesday, 12 December 2017 at 23:28:23 UTC, Ivan Trombley wrote:
Here's the code that produces the correct results (exactly the 
same as GIMP):

Share images you used, please.


[Issue 17527] dlangspec.pdf: escape sequences table goes over the page boundaries

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17527

--- Comment #1 from Seb  ---
PR https://github.com/dlang/dlang.org/pull/1958

--


Re: Understanding how dub works

2017-12-12 Thread timotheecour via Digitalmars-d-learn
On Wednesday, 13 December 2017 at 00:43:31 UTC, rikki cattermole 
wrote:
You don't need to change this and if you think you do, you're 
wrong :)



Except when you need to:
https://github.com/dlang/dub/issues/1305
dub build --compiler=ldmd2 overwrites files in ~/.dub written by 
dub build #1305


Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Seb via Digitalmars-d-announce

On Wednesday, 13 December 2017 at 00:50:40 UTC, Meta wrote:
This is a real life saver considering dpaste is blocked at 
work. It gets very tedious having to create a file, invoke the 
compiler, and run it in 3 separate steps just to test out some 
quick snippet.


Great to hear that it's useful for you!
FYI: another life saver / convenience feature for this online 
editor is WIP:


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


Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Seb via Digitalmars-d-announce
On Wednesday, 13 December 2017 at 00:32:11 UTC, rikki cattermole 
wrote:

On 12/12/2017 6:37 PM, Seb wrote:

=== Supported D Compilers ===

* Latest DMD nightly
* Latest DMD beta
* Latest DMD
* Latest LDC beta
* Latest LDC

The Docker images are rebuilt every day automatically.


Can we please select a version we want to test against?


While it would be rather easier to build more Docker images [1] 
and add them to the tour [2], I fear that this will be too much 
maintenance overhead and will lead to outdated compiler soon.
Also the storage on the machine is limited and we can't drop an 
unlimited amount of Docker images there.


[1] https://github.com/dlang-tour/core-exec
[2] 
https://github.com/dlang-tour/core/blob/master/source/exec/docker.d#L22


Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread H. S. Teoh via Digitalmars-d-announce
On Wed, Dec 13, 2017 at 12:50:40AM +, Meta via Digitalmars-d-announce wrote:
> On Tuesday, 12 December 2017 at 18:37:38 UTC, Seb wrote:
> > After it has been in stealth mode for quite a while, I'm happy to
> > announce that there's https://run.dlang.io
[...]
> This is a real life saver considering dpaste is blocked at work. It
> gets very tedious having to create a file, invoke the compiler, and
> run it in 3 separate steps just to test out some quick snippet.

Can't you just do:

rdmd --eval=''

?


T

-- 
Real Programmers use "cat > a.out".


Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread Meta via Digitalmars-d-announce

On Tuesday, 12 December 2017 at 18:37:38 UTC, Seb wrote:
After it has been in stealth mode for quite a while, I'm happy 
to announce that there's https://run.dlang.io


=== Features ===

* Color-highlighted DMD errors
* Format source code with dfmt
* Generate a short URL for link sharing
* Import/Export to GitHub Gist
* Typical key shortcuts like CTRL+Enter -> Run
* Build cache for fast execution of common examples (e.g. the 
ones on front page of dlang.org)

* Usable on your phone
* Integrated with dlang.org (you can open any example on 
dlang.org in run.dlang.io by clicking the right arrow button)
* Integrated with tour.dlang.org (you can open any example on 
the DTour in run.dlang.io by clicking on the "Export" button)


=== Supported D Compilers ===

* Latest DMD nightly
* Latest DMD beta
* Latest DMD
* Latest LDC beta
* Latest LDC

The Docker images are rebuilt every day automatically.

=== Running DUB packages ===

Via "Add library" DUB packages can be added to the build.
Currently only a whitelist of packages is allowed.
Examples:

mir: https://run.dlang.io/is/FIc6rd
mir-algorithm: https://run.dlang.io/is/3pNRH8

=== DReg ===

When I watched CyberShadow's Bugzilla cruise [1] I spotted this 
amazing tool dreg [2] and it's not that hard to build a docker 
image [3] for it and make it available for everyone, s.t. no 
setup is required.
Dreg allows running old versions of the D compiler in parallel 
and compares their output.

However, it's a lot easier to show than to explain:

https://run.dlang.io/is/ckNT9i
https://run.dlang.io/is/UZhQDh

Currently all versions from 2.060 up to the latest greatest 
2.077.1 are run, so the execution will take a bit longer than a 
single run.


[1] https://youtu.be/qpUTvMokTCs
[2] https://github.com/CyberShadow/misc/blob/master/dreg.d
[3] https://github.com/dlang-tour/core-dreg


=== Source code & report issues ===

Please don't hesitate to open issues or submit pull requests:

-> https://github.com/dlang-tour/core

(it uses Vibe.d)


This is a real life saver considering dpaste is blocked at work. 
It gets very tedious having to create a file, invoke the 
compiler, and run it in 3 separate steps just to test out some 
quick snippet.


Re: Understanding how dub works

2017-12-12 Thread rikki cattermole via Digitalmars-d-learn

On 12/12/2017 10:20 PM, datboi wrote:
Hi, I'm learning D (obliviously) and I can't understand how exactly 
dependencies work. I haven't found answers to my questions in 
documentation (or i did't understand it), so can someone answer to mine 
questions?


1. Does dub compile dependencies as separate binaries? And if yes how to 
specify where should be they placed?


Object/static files, but yes.

Where they go:

Windows: %APPDATA%/roaming/dub
Posix: ~/.dub

You don't need to change this and if you think you do, you're wrong :)

2. It is possible to compile subpackage as a dynamic or static library 
and link it to main binary file? Or just better create separate dub 
package and use it as dependency?


Static yes, dynamic it won't link against (some bug last I heard).
Have to do that manually.

"dependencies": { "mypackage:subpackage": "*" }

Change as required for SDL.




Re: run.dlang.io - a modern way to run D code

2017-12-12 Thread rikki cattermole via Digitalmars-d-announce

On 12/12/2017 6:37 PM, Seb wrote:
After it has been in stealth mode for quite a while, I'm happy to 
announce that there's https://run.dlang.io


=== Features ===

* Color-highlighted DMD errors
* Format source code with dfmt
* Generate a short URL for link sharing


s/shorten/permalink/

Or something else more obvious.


* Import/Export to GitHub Gist
* Typical key shortcuts like CTRL+Enter -> Run
* Build cache for fast execution of common examples (e.g. the ones on 
front page of dlang.org)

* Usable on your phone
* Integrated with dlang.org (you can open any example on dlang.org in 
run.dlang.io by clicking the right arrow button)
* Integrated with tour.dlang.org (you can open any example on the DTour 
in run.dlang.io by clicking on the "Export" button)


=== Supported D Compilers ===

* Latest DMD nightly
* Latest DMD beta
* Latest DMD
* Latest LDC beta
* Latest LDC

The Docker images are rebuilt every day automatically.


Can we please select a version we want to test against?




Re: Released vibe.d 0.8.2

2017-12-12 Thread Seb via Digitalmars-d-announce

On Tuesday, 12 December 2017 at 19:44:17 UTC, Sönke Ludwig wrote:
The major changes in this release are HTTP forward proxy 
support, handling incoming HTTP requests on custom transports 
and a MongoDB based session store. On top of that, there are 
many smaller improvements in the HTTP server, web/REST 
generator, JSON/BSON support and the TLS sub system.


Change log:
https://vibed.org/blog/posts/vibe-release-0.8.2

DUB package:
https://code.dlang.org/packages/vibe-d/0.8.2


I think you should mention more prominently that for people who 
want to use OpenSSL 1.1, they can now use:


dub --override-config="vibe-d:tls/openssl-1.1"


This allows to use OpenSSL 1.1 _without_ needing to set the 
`VibeUseOpenSSL11` version in their dub.sdl


Re: Released vibe.d 0.8.2

2017-12-12 Thread Timothee Cour via Digitalmars-d-announce
that's great... unfortunately
https://github.com/vibe-d/vibe.d/issues/1991 is a regression
preventing from updating to 0.8.X (has a reduced test case). Any help
on this would be very appreciated, thanks!

On Tue, Dec 12, 2017 at 11:44 AM, Sönke Ludwig via
Digitalmars-d-announce  wrote:
> The major changes in this release are HTTP forward proxy support, handling
> incoming HTTP requests on custom transports and a MongoDB based session
> store. On top of that, there are many smaller improvements in the HTTP
> server, web/REST generator, JSON/BSON support and the TLS sub system.
>
> Change log:
> https://vibed.org/blog/posts/vibe-release-0.8.2
>
> DUB package:
> https://code.dlang.org/packages/vibe-d/0.8.2



Re: state of ranges

2017-12-12 Thread Luís Marques via Digitalmars-d
On Tuesday, 12 December 2017 at 23:25:19 UTC, Neia Neutuladh 
wrote:
Have you noticed performance problems or implementation side 
irregularities?


Well, I was referring to things like in front() having to use 
code such as `if(!inited) ...; return value`, which was discussed 
here in the forum in the past.


The performance side hasn't been too bad for me personally (so 
far...), but I started this thread exactly because I wanted to 
know if I could move some code to the empty() method of the 
range, as that would be more convenient and performant. So you 
could say I mostly noticed the "regularity" part.


Re: SDL2 texture blend help

2017-12-12 Thread Ivan Trombley via Digitalmars-d

GIMP 2.9, that is.


Re: SDL2 texture blend help

2017-12-12 Thread Ivan Trombley via Digitalmars-d

On Tuesday, 12 December 2017 at 07:12:07 UTC, Dmitry wrote:
On Tuesday, 12 December 2017 at 06:27:30 UTC, Ivan Trombley 
wrote:

This isn't a scaling problem (which is totally solved by

Scaling is not a prerequisite for this problem.


pre-multiplying the alpha with the colors BTW). This is a gamma
How did you this? Using editor or using shader? If shder, show 
the code.

Can you share both images? I want to check.

correction problem which is solved only by converting the 
color values to linear color space before compositing and then 
converting the final pixel back to sRGB.


Are you sure in that? Because what I see is typical alpha 
blending problem.


Here's the code that produces the correct results (exactly the 
same as GIMP):



auto bk =IMG_Load(toStringz(folder ~ "/background.png"));
auto fg =IMG_Load(toStringz(folder ~ "/image.png"));
enum c = (1.0f / 255.0f);
enum g = 2.2f;
enum ig = (1.0f / 2.2f);
immutable int x = (bk.w - fg.w) / 2;
immutable int y = (bk.h - fg.h) / 2;
auto dst = cast(ubyte*) bk.pixels + y * bk.pitch + x * 3;
immutable size_t add = bk.pitch - fg.w * 3;
auto src = cast(ubyte*) fg.pixels;
const auto max = src + fg.h * fg.pitch;
while (src < max)
{
  const auto line = dst + fg.w * 3;
  while (dst < line)
  {
immutable float a = c * src[3];
dst[0] = cast(ubyte)(((1 - a) * (dst[0] * c) ^^ g + a * 
(src[0] * c) ^^ g) ^^ ig * 255);
dst[1] = cast(ubyte)(((1 - a) * (dst[1] * c) ^^ g + a * 
(src[1] * c) ^^ g) ^^ ig * 255);
dst[2] = cast(ubyte)(((1 - a) * (dst[2] * c) ^^ g + a * 
(src[2] * c) ^^ g) ^^ ig * 255);

src += 4;
dst += 3;
  }
  dst += add;
}



Re: state of ranges

2017-12-12 Thread Neia Neutuladh via Digitalmars-d

On Tuesday, 12 December 2017 at 18:58:11 UTC, Luís Marques wrote:
Ok, so the consensus was to make ranges easy to use. Was there 
any progress on mechanisms to avoid the possible performance 
penalties, and to make the implementation side more regular?


Have you noticed performance problems or implementation side 
irregularities?


It would be handy for us to make benchmarks (if nobody has done 
it yet?), but my feeling is that it doesn't have a measurable 
impact on performance in the context of a single iterator 
compared to opApply. Probably has a greater impact when you're 
stacking things together, since ranges can use design by 
introspection to do less work.


[Issue 12942] ICE in centos

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12942

Iain Buclaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||ibuc...@gdcproject.org
 Resolution|--- |WORKSFORME

--- Comment #1 from Iain Buclaw  ---
Marking as worksforme because there exist rpms for centos on the downloads
page.

--


[Issue 13974] Make it possible simple std.math functions to be CTFE-able

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13974

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #1 from Iain Buclaw  ---
Seems like I never got round to this.

--


[Issue 14732] [2.068 beta] Failing unittest in std.math

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14732

Iain Buclaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
   Hardware|x86_64  |All
 Resolution|--- |FIXED

--- Comment #5 from Iain Buclaw  ---
I have no idea if anything was done about it.  I'll have to check on ARM, or
some other target that has 64bit reals.

--


[Issue 17113] cent/ucent lack basic support

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17113

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org
   Hardware|x86_64  |All
 OS|Windows |All

--


mir-algorithm v0.7.0: new interpolation, optmath, bugfixes

2017-12-12 Thread Nathan S. via Digitalmars-d-announce

About Mir Algorithm

Mir Algorithm[1] is Dlang core library for math, finance and a 
home for Dlang multidimensional array package - ndslice.


New Modules since v0.6.21

- Reworked interpolation API, now found in mir.interpolate, 
mir.interpolate.linear, mir.interpolate.pchip.
- New module mir.interpolate.spline for cubic interpolation. 
Warning: multivariate cubic spline with derivatives is still 
experimental.
- New module mir.interpolate.constant for constant interpolation. 
Warning: multivariate constant interpolant is still experimental.



API Changes since v0.6.21

- Added in mir.math.common function attributes @optmath and 
@fmamath. They only have effect when compiling with LDC but can 
be used with all compilers. (This now also applies to @fastmath.) 
@optmath is similar to @fastmath but does not allow 
unsafe-fp-math. Does not force LDC to replace division with 
multiplication by reciprocal.
- New mir.utility.extMul extended unsigned multiplication that 
makes available the high bits of the result

- New mir.functional.aliasCall
- New mir.ndslice.algorithm.maxLength returns max length across 
all dimensions.
- New mir.ndslice.slice.IteratorOf!(T : Slice) extracts iterator 
type from a Slice
- New mir.ndslice.slice.ndassign assignment utility template that 
works both with scalars and with ndslices.
- In mir.ndslice.slice.Slice: iterator is now inout; opUnary now 
works with - and +; opIndexAssign now returns ref this instead of 
void.

- mir.ndslice.field.MagicField supports length and shape.


Removed Modules

- mir.interpolation, mir.interpolation.linear, mir.interpolation. 
Migrate to replacements (mir.interpolate.*).



Other Changes since v0.6.21

- Uses of @fastmath in the Mir codebase have been replaced by 
@optmath, excepting mir.math.sum Summation.fast.
- In mir.ndslice.topology under-the-hood improvements in slide, 
diff, pairwise
- In mir.ndslice.slice.Slice opBinary and opBinaryRight now 
internally use mir.ndslice.topology.vmap instead of 
mir.ndslice.topology.indexed.



Fixed since v0.6.21

- Fix in mir.ndslice.topology.map for compilation failing in 
cases where chained map calls couldn't be coalesced due to 
capturing multiple contexts (seemingly a compiler bug in some 
cases)
- Made mir.ndslice.topology.flattened backwards compatible with 
LDC 1.2.0 for those who haven't upgraded
- Added workaround in mir.ndslice.algorithm.reduce for DMD 
inlining bug for non-Windows x86-64 (LDC unaffected)

- mir.primitives.shape now takes its argument by reference


[1] https://github.com/libmir/mir-algorithm

Release notes with hyperlinks: 
https://github.com/libmir/mir-algorithm/releases/tag/v0.7.0




[Issue 15008] floor(float x) and floor(double x) have no FPU implementation

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15008

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #2 from Iain Buclaw  ---
Not fixing the issue (have an FPU implementation for D_InlineAsm targets), but
should make things better.


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

--


Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jordi Gutiérrez Hermoso via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 20:57:28 UTC, Jon Degenhardt 
wrote:
On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez 
Hermoso wrote:
What's the proper style, then? Can someone show me a good 
example of how to use getopt and the docstring it 
automatically generates?

[snip]

See:
 
https://github.com/eBay/tsv-utils-dlang/blob/master/tsv-sample/src/tsv-sample.d


Oh, thanks! This is more or less what I wanted.

I suppose showing all of the docstring when the arguments are bad 
is possibly stupid and I shouldn't be doing that to begin with. 
I'll adopt this style to only show which argument was bad.


[Issue 15365] std.math: 80-bit exp() tests are marginally wrong when returning subnormals

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15365

Iain Buclaw  changed:

   What|Removed |Added

Summary|std.math: 80-bit exp()  |std.math: 80-bit exp()
   |tests are utterly wrong |tests are marginally wrong
   |when returning subnormals   |when returning subnormals

--


[Issue 17008] use ldc/gdc intrinsics in std.math

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17008

Iain Buclaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #3 from Iain Buclaw  ---
As per my comments (and kinke representing ldc).

--


[Issue 16474] CTFE pow

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16474

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #12 from Iain Buclaw  ---
This should probably be considered duplicate of issue 5227.

--


datefmt 1.0.0 released: parse datetimes and also format them

2017-12-12 Thread Neia Neutuladh via Digitalmars-d-announce

# Sales pitch

If you've ever had to parse datetime input from multiple sources 
and everyone's standardized on ISO8601, you might have found out 
that that's not quite as standard as you'd wish. This is where 
datefmt helps you.


---
import datefmt;
auto expected = SysTime(Date(2010, 1, 1), UTC());
foreach (date; ["2010-01-01", "2010-01-01T00:00:00", "2010-01-01 
00:00:00.000Z"])

{
  SysTime parsed;
  assert(tryParse(date, ISO8601FORMAT, parsed));
  assert(expected == parsed);
}
---


# How does datefmt's parsing differ from dateparser?

dateparser is great when you have a date that's in some arbitrary 
format and you want to turn it into a sensible date. It's perfect 
for manual input.


datefmt is good when you have a restricted set of formats you 
need to accept and want to reject everything else -- generally 
when a wide range of systems using the same somewhat nebulous 
standard emit the stuff you need to parse.



# What about formatting?

datefmt can do formatting too! Most of its formatting options are 
taken from strftime, so it should be generally familiar.


And of course you can use predefined formats for RFC1123 and 
ISO8601:


auto st = SysTime(DateTime(2010, 4, 12, 15, 30, 00), UTC());
writeln(st.format(ISO8601FORMAT));
// 2010-04-12T15:30:00.00Z
writeln(st.format(RFC1123FORMAT));
// Mon, 12 Apr 2010 15:30:00 Z


# Is anyone using it?

I've been using this in my RSS reader for the past month or two, 
during which time it's been exposed to a number of horrible 
variants of both RFC1123 and ISO8601.



# How do I get it?

Add "datefmt": "~>1.0.0" to your dub.json and Bob's your uncle!

Or download the single file from 
https://raw.githubusercontent.com/dhasenan/datefmt/master/source/datefmt.d and put it in your project.


Licensed under MS-PL (BSD-style permissive license with patent 
grant); open an issue at 
https://github.com/dhasenan/datefmt/issues if you need a 
different license.


[Issue 5227] X ^^ FP at compile-time

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5227

Iain Buclaw  changed:

   What|Removed |Added

 CC||n8sh.second...@hotmail.com

--- Comment #14 from Iain Buclaw  ---
*** Issue 18069 has been marked as a duplicate of this issue. ***

--


[Issue 18069] Exponentiation operator ^^ not evaluable at compile time

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18069

Iain Buclaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||ibuc...@gdcproject.org
 Resolution|--- |DUPLICATE

--- Comment #1 from Iain Buclaw  ---


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

--


[Issue 6715] Using a custom pow function for ^^

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6715

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #4 from Iain Buclaw  ---
The function rewrite should really be targeting `core.math` instead of
`std.math`.

Or, granted that this is an operation with a special syntax, the initial
template could be part of object.d, which then forwards to the correct function
as appropriate.

--


[Issue 8262] ICE(mtype.c) alias this to alias of an expression tuple

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8262

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

https://github.com/dlang/dmd/commit/2f27c59732481880545ca65a4641806087cc23e7
fix issue 8262 -  ICE(mtype.c) alias this to alias of an expression tuple

check return of aliasthisOf

https://github.com/dlang/dmd/commit/4616d4485102fc4650d14d185e224a621c25d965
Merge pull request #4195 from rainers/aliasthisof

Issue 8262 -  ICE(mtype.c) alias this to alias of an expression tuple
merged-on-behalf-of: Andrei Alexandrescu 

--


[Issue 13469] x^^y wrong result

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13469

Iain Buclaw  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||ibuc...@gdcproject.org
 Resolution|--- |INVALID

--- Comment #3 from Iain Buclaw  ---
CTFE folds floating point expressions at the highest precision supported by
target.  This is not going to change.

--


[Issue 8262] ICE(mtype.c) alias this to alias of an expression tuple

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=8262

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

   What|Removed |Added

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

--


[Issue 10738] double2 ^^ 2 and double2 ^^ 3 are missing

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10738

Iain Buclaw  changed:

   What|Removed |Added

 CC||ibuc...@gdcproject.org

--- Comment #1 from Iain Buclaw  ---
SIMD ^^ is neither generic, nor a trivial thing to implement.

We should really just flat out error here.

--


Understanding how dub works

2017-12-12 Thread datboi via Digitalmars-d-learn
Hi, I'm learning D (obliviously) and I can't understand how 
exactly dependencies work. I haven't found answers to my 
questions in documentation (or i did't understand it), so can 
someone answer to mine questions?


1. Does dub compile dependencies as separate binaries? And if yes 
how to specify where should be they placed?
2. It is possible to compile subpackage as a dynamic or static 
library and link it to main binary file? Or just better create 
separate dub package and use it as dependency?


For all answers thank You in advance.
Also sorry for mine English. I'm still learning it. So if I made 
some grammatic mistakes point them :)


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 21:52:57 UTC, Ali Çehreli wrote:
The same buffer is used for all segments and socket.receive 
should be inside while.


The buffer is copied by the ~= operator, but indeed you're right 
that I forgot to receive again inside the loop! That would just 
spin until it ran out of memory lol.


But I did put receive outside the loop for a reason: it just 
needs to prime the return value before it gets checked the first 
time. But then, of course, it should receive again at the end of 
the loop to advance to the next chunk.


[Issue 18057] [ICE] Segmentation fault (stack overflow) in Expression::ctfeInterpret()

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18057

--- Comment #2 from Iain Buclaw  ---
In this instance, it should detect and guard against stack overflow, because
the value of the initializer is indeed recursive.

Consider the following, that would cause a stack overflow at runtime:
---
struct RBNode
{
RBNode *copy;
this(int num)
{
this.copy = new RBNode(num++);
}
}
---

--


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn

On 12/12/2017 01:52 PM, Ali Çehreli wrote:

>  > ubyte[] result;
>  > ubyte[1024] buffer;

>  > result ~= buffer[0 .. got];

> The same buffer is used for all segments

Not! Ok, I better go take a nap. :)

Ali



Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn

On 12/12/2017 01:14 PM, Adam D. Ruppe wrote:
> On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed Spectaculum wrote:
>> I've decided to go for the run-time approach to this, it works fine
>> with all of my tests so you have my greatest gratitude.
>
> the way I'd do it btw is simply:

I know you normally do it much better. :)

> ubyte[] result;
> ubyte[1024] buffer;
> auto got = socket.receive(buffer[]);
> while(got > 0) {
> result ~= buffer[0 .. got];
> }

There are a couple of bugs in that code. The same buffer is used for all 
segments and socket.receive should be inside while.


Ali



Re: I just slept with my sister.

2017-12-12 Thread Thoughtful Advice via Digitalmars-d

Looks like your only options are to stone her or marry her.



Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 21:14:30 UTC, Adam D. Ruppe wrote:
On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed 
Spectaculum wrote:
I've decided to go for the run-time approach to this, it works 
fine with all of my tests so you have my greatest gratitude.


the way I'd do it btw is simply:

ubyte[] result;
ubyte[1024] buffer;
auto got = socket.receive(buffer[]);
while(got > 0) {
   result ~= buffer[0 .. got];
}

if(got < 0)
  throw new Exception(lastSocketError());

return result;


so it uses the one static buffer to receive the stuff one block 
at a time but just copies it over to the dynamic array with the 
~= operator


Oh, thanks; it's definitely shorter however I do enjoy the 
ability to generalize/ambiguate functions by providing optional 
parameters, however thanks for showing another way; I enjoy 
knowing multiple ways of performing one task so anything helps :)


[Issue 16265] unittest imports should not be counted as dependencies for static ctors

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16265

--- Comment #6 from Steven Schveighoffer  ---
(In reply to Mike Franklin from comment #5)
> I think it would help to have an example that someone could quickly cut and
> paste into their development environment to reproduce and illustrate the
> problem.


Of course. It's going to be a toy example, but things like documented unit
tests cause these kinds of problems, especially when you have so many modules
that you need stuff from in order to run a complete program.

mod1.d:
module mod1;

immutable int val;

shared static this()
{
   val = 2;
}

size_t bar(size_t x) { return x + 1; }

unittest
{
   import mod2;
   assert("abc".foo.bar == 7);
}

mod2.d:
module mod2;

import mod1;

immutable int multiplier;

shared static this()
{
   multiplier = val;   
}

size_t foo(string s) { return s.length * multiplier; }

--


Re: AssocArray to string is ok,but how to get the AssocArray from string? Thanks

2017-12-12 Thread Azi Hassan via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 17:32:15 UTC, Frank Like wrote:

Hi,everyone,
who can help me,about the "AssocArray to string is ok,but how 
to get the AssocArray from string? ".


For example:

SysTime[][string] AATimes;
AATimes["a1"] =[SysTime(DateTime(2017, 1, 1, 12, 33, 
33)),SysTime(DateTime(2017, 1, 2, 12, 33, 33))];
AATimes["a2"] =[SysTime(DateTime(2017, 1, 2, 12, 33, 
33)),SysTime(DateTime(2017, 1, 3, 12, 33, 33))];


  ubyte[] ua = cast(ubyte[])AATimes.to!string;
  writeln("ua is ",ua);

  string strTimes = cast(string)ua;
   writeln("strTimes is ",strTimes);

But now,how to get the AATimes from string?

Thanks.

Frank.


Serialization seems to be the answer. Unfortunately I could 
neither get it to work with Cereal nor with Orange. If all else 
fails, you could still attempt to manually parse it ot of its 
string representation (AATimes.to!string).


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Adam D. Ruppe via Digitalmars-d-learn
On Tuesday, 12 December 2017 at 21:03:54 UTC, Unazed Spectaculum 
wrote:
I've decided to go for the run-time approach to this, it works 
fine with all of my tests so you have my greatest gratitude.


the way I'd do it btw is simply:

ubyte[] result;
ubyte[1024] buffer;
auto got = socket.receive(buffer[]);
while(got > 0) {
   result ~= buffer[0 .. got];
}

if(got < 0)
  throw new Exception(lastSocketError());

return result;


so it uses the one static buffer to receive the stuff one block 
at a time but just copies it over to the dynamic array with the 
~= operator


Re: toChars Bug?

2017-12-12 Thread Steven Schveighoffer via Digitalmars-d

On 12/12/17 7:49 AM, ketmar wrote:
see documentation: 
http://dpldocs.info/experimental-docs/std.conv.toChars.html


"...Can be uint or ulong. If radix is 10, can also be int or long."

45 is int, not uint. so no radices except `10` will work.


So, the answer is:

toChars!2(45u);

BTW, I find this limitation is a bad code smell. IFTI needs some design 
thought on how to deal with literals.


-Steve


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 20:27:04 UTC, Ali Çehreli wrote:

On 12/12/2017 12:10 PM, Unazed Spectaculum wrote:
> string receiveAll(T)(T socket, int segment_size = 1024)
> {
>  char[segment_size][] data;

Unrelated, you most likely want to use ubyte. (char is for 
UTF-8.)


The problem is, char[segment_size] is a static array, where the 
length must be known at compile time because length is a part 
of its type.


So, depending on what you need you have two options:

a) Use dynamic array if the length is known at run time

b) Although (a) will work just fine, use template parameter for 
length if the length is known at compile time and you want to 
avoid dynamic allocation.


However, too large arrays won't fit on the stack. (Further 
however, your 'data' is a slice anyway, just the elements are 
static.)


The following program shows the two options with 
one-dimensional arrays:


// Size is known at run time
void foo(T)(T t, size_t size = 1024) {
auto data = new ubyte[](size);
}

// Size is known at compile time
void bar(size_t size = 1024, T)(T t) {
ubyte[size] data;
}

void main() {
int i;
foo(i, 10);
bar!20(i);
}

Here is one with two-dimensional arrays:

import std.stdio;

size_t counter = 0;
bool done() {
return (++counter % 4) == 0;
}

// Size is known at run time
void foo(T)(T t, size_t size = 1024) {
ubyte[][] data;

while (!done) {
data ~= new ubyte[size];
// Use data[$-1]
writeln("a) Will read here: ", data[$-1]);
}
}

// Size is known at compile time
void bar(size_t size = 1024, T)(T t) {
ubyte[size][] data;

while (!done) {
++data.length;
writeln("b) Will read here: ", data[$-1]);
}
}

void main() {
int i;
foo(i, 10);
bar!20(i);
}

Ali


string receiveAll(T)(T socket, size_t segment_size = 1024)
{
ubyte[][] data;
size_t count = 0;

while (true)
{
data ~= new ubyte[segment_size];

auto received = socket.receive(data[count]);
data[count] = data[count][0 .. received];

if (!received)
break;
else if (received < segment_size)
break;  /* early exit */

++count;
}

char[] stringData;

foreach (elem; data)
stringData ~= elem;

return to!string(stringData);
}


I've decided to go for the run-time approach to this, it works 
fine with all of my tests so you have my greatest gratitude.


I might have created some weird inefficiencies but don't worry 
take time telling me about them unless they're going to blow up 
my program since I think you've explained enough already :D.


Since I'm only a few days into D I wouldn't expect much of my 
code, I'm moreover from the generic Python and thereabouts C-ish 
background.


again, thanks.


Re: What's the proper way to use std.getopt?

2017-12-12 Thread Jon Degenhardt via Digitalmars-d-learn
On Monday, 11 December 2017 at 20:58:25 UTC, Jordi Gutiérrez 
Hermoso wrote:
What's the proper style, then? Can someone show me a good 
example of how to use getopt and the docstring it automatically 
generates?


The command line tools I published use the approach described in 
a number of the replies, but with a tad more structure. It's 
hardly perfect, but may be useful if you want more examples. See: 
 
https://github.com/eBay/tsv-utils-dlang/blob/master/tsv-sample/src/tsv-sample.d. See the main() routine and the TsvSampleOptions struct. Most of the tools have a similar pattern.


--Jon


Re: Why is there no std.stream anymore?

2017-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 12/11/17 6:33 PM, Seb wrote:

Though if you need superb performance, iopipe or similar will be faster.

Since iopipe was mentioned several times, I will say a couple things:

1. iopipe is not made for processing one element at a time, it focuses 
on buffers. The reason for this is because certain tasks (i.e. parsing) 
are much more efficient with buffered data than when using the range 
API. Even with FILE *, using fgetc for every character is going to suck 
when compared to fread, and processing the resulting array in-memory.


2. If you do want to process by element, I recommend the following chain:

// an example that uses iopipe's file stream and assumes it's UTF8 text.
// other mechanisms are available.
auto mypipe = openDev("somefile") // open a file
.bufd // buffer it
.assumeText   // assume it's utf-8 text
.ensureDecodeable;// ensure there are no partial 
code-points in the window


// convert to range of "chunks", and then join into one large range
foreach(c; mypipe.asInputRange.joiner) {
process(c);
}

Note, due to Phobos's auto-decoding, joiner is going to auto-decode all 
of the data. This means typeof(c) is going to be dchar, and not char, 
and everything needs to be proper utf-8. If you want to process the 
bytes raw, you can omit the .assumeText.ensureDecodeable part, and the 
data will be ubytes.


-Steve


Re: I just slept with my sister.

2017-12-12 Thread Youneedhelp via Digitalmars-d

On Tuesday, 12 December 2017 at 20:31:36 UTC, unazed wrote:

[...]


Best to tell all ur friends.


Re: Date Formating

2017-12-12 Thread Steven Schveighoffer via Digitalmars-d-learn

On 12/12/17 10:56 AM, Vino wrote:

Hi All,

   Request out help on date formatting, I have code which output the 
date and time as below , i we need it without the last few numbers.,ie 
"-MMM-DD HH:MM:SI"


Output : 2017-Sep-06 16:06:42.7223837
Required Output : 2017-Sep-06 16:06:42



You need to extract the date components and print them separately. There 
is no mechanism to format a SysTime (and it's a hairy subject to be 
sure, every locale is different).


-Steve


I just slept with my sister.

2017-12-12 Thread unazed via Digitalmars-d
I don't know if Dlang.org is the right place for this thread, but 
I honestly have no where else to turn because this situation 
directly involves my family, and friends.
Let me start from the beginning, I am 18 and my sister is 21. I 
just finished high school and my sister is home from college. I 
guess this year her grades started slipping or something, because 
I walked past her room and she was crying. I walked inside her 
room to ask her what's up and she hands me a letter - apparently 
she's up for review by her college for dismissal. I feel kinda 
sorry for her so I gave her a hug and one thing led to another 
and we started making out. This is really weird because I've made 
out with girls before, but my sister blows them all out of the 
water. In the back of my mind lies the fact that she's my sister 
and what we are doing is sick and wrong, but I guess my sister 
has more experience and it felt so fucking good.
Here's the dilemma - after making out, Karen started taking her 
clothes off and she started pulling my pants down. I'm like, hey, 
what are you doing? She's like, oh come on Jordan, aren't you 
even a LITTLE curious? I felt bad because its true, my sister is 
a hottie and I always wished that she wasn't my sister. I've even 
gone as far as to fap to thoughts of doing her. She then said 
"For tonight, let's not be brother and sister. I really need this 
because I feel like shit right now and our parents won't be back 
till late and we aren't going to tell anyone.


I pretty much just fucked my sister. No, to be more honest, I 
just lost my virginity to my sister. My question is: WHAT THE 
FUCK DO I DO NOW?? What do people usually do after they fuck 
their sisters?


Re: how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Ali Çehreli via Digitalmars-d-learn

On 12/12/2017 12:10 PM, Unazed Spectaculum wrote:
> string receiveAll(T)(T socket, int segment_size = 1024)
> {
>  char[segment_size][] data;

Unrelated, you most likely want to use ubyte. (char is for UTF-8.)

The problem is, char[segment_size] is a static array, where the length 
must be known at compile time because length is a part of its type.


So, depending on what you need you have two options:

a) Use dynamic array if the length is known at run time

b) Although (a) will work just fine, use template parameter for length 
if the length is known at compile time and you want to avoid dynamic 
allocation.


However, too large arrays won't fit on the stack. (Further however, your 
'data' is a slice anyway, just the elements are static.)


The following program shows the two options with one-dimensional arrays:

// Size is known at run time
void foo(T)(T t, size_t size = 1024) {
auto data = new ubyte[](size);
}

// Size is known at compile time
void bar(size_t size = 1024, T)(T t) {
ubyte[size] data;
}

void main() {
int i;
foo(i, 10);
bar!20(i);
}

Here is one with two-dimensional arrays:

import std.stdio;

size_t counter = 0;
bool done() {
return (++counter % 4) == 0;
}

// Size is known at run time
void foo(T)(T t, size_t size = 1024) {
ubyte[][] data;

while (!done) {
data ~= new ubyte[size];
// Use data[$-1]
writeln("a) Will read here: ", data[$-1]);
}
}

// Size is known at compile time
void bar(size_t size = 1024, T)(T t) {
ubyte[size][] data;

while (!done) {
++data.length;
writeln("b) Will read here: ", data[$-1]);
}
}

void main() {
int i;
foo(i, 10);
bar!20(i);
}

Ali



Re: d-apt update

2017-12-12 Thread Jordi Sayol via Digitalmars-d-announce
New d-apt dmd deb packages released (ver. 2.077.1-0.1)

This release fix these problems:

- Move rdmd from "dmd-tools" to "dmd-compiler"
- Add "dmd-bin (<< 2.077.1-0)" at "Conflicts:" and "Replaces:" fields on 
"dmd-compiler" and "dmd-tools" deb packages, to avoid upgrade conflicts.

Jordi


how would I go about creating a Socket receiveAll method?

2017-12-12 Thread Unazed Spectaculum via Digitalmars-d-learn

string receiveAll(T)(T socket, int segment_size = 1024)
{
char[segment_size][] data;
int cnt = 0;

while(true)
{
auto received = socket.receive(data[cnt]);
if (received < segment_size)
break;  /* early exit */
else if (!received)
break;
++cnt;
}

return data;
}


This is my theoretical function, it errors at 
`char[segment_size][] data;` with the painful `app.d(20): Error: 
variable segment_size cannot be read at compile time` and I 
recall having an issue similar to this earlier (yesterday) but I 
don't think any of my solutions seemed valid for this situation.


I understand it's to do with CTFE or some form of compile-time 
checking but that's really the only thing that annoys me about D, 
perhaps somebody could link to some resource that explains (not 
shortly) how to make the D compiler evaluate some things at 
run-time opposed to compile time.


Perhaps somebody can link some resources e.g. socket servers in D 
so I can learn how it's implemented by somebody with a bit more 
experience, or some resources on how to use sockets properly 
¯\_(ツ)_/¯


[Issue 17868] add pragma(crt_con/destructor)

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17868

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

   What|Removed |Added

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

--


[Issue 17868] add pragma(crt_con/destructor)

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17868

--- Comment #10 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/dmd

https://github.com/dlang/dmd/commit/276df5b9e95012475077f20a6662a0e386f9d68e
fix Issue 17868 - add pragma(crt_con-/destructor)

- allows to run con-/destructors before/after CRT startup/shutdown
- primary use-case is implementing modular startup in druntime itself

--


Released vibe.d 0.8.2

2017-12-12 Thread Sönke Ludwig via Digitalmars-d-announce
The major changes in this release are HTTP forward proxy support, 
handling incoming HTTP requests on custom transports and a MongoDB based 
session store. On top of that, there are many smaller improvements in 
the HTTP server, web/REST generator, JSON/BSON support and the TLS sub 
system.


Change log:
https://vibed.org/blog/posts/vibe-release-0.8.2

DUB package:
https://code.dlang.org/packages/vibe-d/0.8.2


Re: d-apt update

2017-12-12 Thread Jordi Sayol via Digitalmars-d-announce
El 11/12/17 a les 23:02, Manu ha escrit:
> I would strongly suggest the rdmd be included in dmd-bin rather than 
> dmd-tools.

Yes, You're right and will be as you say on next dmd release. But will be in 
dmd-compiler rather than in the deprecated dmd-bin.



Re: operator overload

2017-12-12 Thread dark777 via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 17:13:55 UTC, Biotronic wrote:

On Tuesday, 12 December 2017 at 16:54:17 UTC, Biotronic wrote:
There is no way in C++ to set the format the way you want it. 
If you want binary output, you need to call a function like 
your binario function.


Of course this is not entirely true - there is a way, but it's 
ugly and probably not what you want:


struct BinStream
{
std::ostream& os;
BinStream(std::ostream& os) : os(os) {}

template
BinStream& operator<<(T&& value)
{
os << value;
return *this;
}

BinStream& operator<<(int value)
{
os << binario(value);
return *this;
}

std::ostream& operator<<(std::ios_base& (__cdecl 
*_Pfn)(std::ios_base&))

{
return os << _Pfn;
}
};

struct Bin
{
friend BinStream operator<<(std::ostream& os, const 
Bin& f);

} bin;

BinStream operator<<(std::ostream& os, const Bin& f)
{
return BinStream(os);
}

int main()
{
std::cout << "\n\t127 em binario: " << binario(127)
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em octal:   " << std::oct << 127
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em hexadecimal: " << std::hex << 127
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em decimal: " << std::dec << 127
<< "\n\t127 em binario: " << bin << 127 << "\n\n";
}

What is this black magic? Instead of overriding how 
std::ostream does formatting, Bin::Operator<< now returns a 
wrapper around a std::ostream, which special cases ints. If it 
gets any other format specifiers, it returns the ostream again, 
and the binary formatting is gone.


All in all, I think the conclusion is: Stay with D.

--
  Biotronic


I tried to execute with this part of the code

  std::ostream& operator<<(std::ios_base& (__cdecl 
*_Pfn)(std::ios_base&))

  {
   return os <<_Pfn;
  }

and it returns me this error below what is the include?

bin2.cxx:44:43: error: expected ‘,’ or ‘...’ before ‘(’ token
   std::ostream& operator<<(std::ios_base& (__cdecl 
*_Pfn)(std::ios_base&))

   ^
bin2.cxx: In member function ‘std::ostream& 
BinStream::operator<<(std::ios_base&)’:

bin2.cxx:46:16: error: ‘_Pfn’ was not declared in this scope
return os <<_Pfn;


Re: Static array as immutable

2017-12-12 Thread H. S. Teoh via Digitalmars-d-learn
On Tue, Dec 12, 2017 at 06:06:48PM +, Ivan Trombley via Digitalmars-d-learn 
wrote:
> On Tuesday, 12 December 2017 at 15:30:01 UTC, Nathan S. wrote:
> > While what you're saying is true, exponentiation not being runnable
> > at compile-time is a defect and I would assume a regression.
[...]
> FWIW, if the exponent is an integer, I don't get an error.

I don't think exponentiation with non-integer exponents have ever been
supported at compile-time. It requires evaluating exp(x) for non-integer
x, which, AFAIK, has never been supported at compile-time because the
implementation of exp(x) requires constructs that the current CTFE
engine doesn't support, namely, inline asm in older versions of
std.math, or more recently, the need to access the binary representation
of floats/doubles.

Perhaps when Stefan Koch's new CTFE engine is ready for public
consumption, we will be able to finally have std.math runnable in CTFE.


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: Tuple Array Sorting

2017-12-12 Thread Biotronic via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 15:19:35 UTC, Vino wrote:

import std.algorithm: filter, map, sort;
import std.container.array;
import std.file: SpanMode, dirEntries, isDir ;
import std.stdio: writefln;
import std.typecons: Tuple, tuple;
import std.datetime.systime: SysTime;

void main () {
auto FFs =  ["C:\\Temp\\sapnas2\\BACKUP", 
"C:\\Temp\\sapnas2\\EXPORT", "C:\\Temp\\sapnas2\\PROD_TEAM"];

Array!(Tuple!(string, SysTime)) Result;
foreach(d; FFs[]) {
	auto dFiles = Array!(Tuple!(string, SysTime))(dirEntries(d, 
SpanMode.shallow).filter!(a => a.isDir).map!(a => tuple(a.name, 
a.timeCreated)));

foreach(e; dFiles) { Result ~= e; } }
writefln("%(%-(%-63s %.20s %)\n%)", Result[].sort!((a, b) 
=> a[1] < b[1]));

}


Since there's little need to extract timeCreated and name before 
sorting, here's a version that doesn't:


import std.algorithm : map, filter, sort;
import std.array : array;
import std.range : join;
import std.file : SpanMode, dirEntries, isDir;
import std.stdio : writefln;
import std.typecons : tuple;

void main() {
auto folders = [`C:\Windows`, `C:\Program Files`, `C:\Users`];

auto sorted = folders
.map!(f => f.dirEntries(SpanMode.shallow))
.join
.filter!(e => e.isDir)
.array
.sort!((a,b) => a.timeCreated < b.timeCreated)
.map!(e => tuple(e.name, e.timeCreated.toSimpleString[0 
.. 20]));


writefln("%(%-(%-63s %s %)\n%)", sorted);
}

And a version with normal loops, since the heavily range-based 
version above can be a bit dense. These programs do essentially 
the same thing:


import std.algorithm : sort;
import std.array : array;
import std.file : SpanMode, dirEntries, DirEntry, isDir;
import std.stdio : writefln;
import std.typecons : tuple, Tuple;

void main() {
auto folders = [`C:\Windows`, `C:\Program Files`, `C:\Users`];

DirEntry[] subFolders;

foreach (folder; folders) {
auto children = dirEntries(folder, SpanMode.shallow);
foreach (child; children) {
if (child.isDir) subFolders ~= child;
}
}

subFolders.sort!((a,b) => a.timeCreated < b.timeCreated);
Tuple!(string, string)[] interestingParts;

foreach (subFolder; subFolders) {
interestingParts ~= tuple(subFolder.name, 
subFolder.timeCreated.toSimpleString[0..20]);

}

writefln("%(%-(%-63s %s %)\n%)", interestingParts);
}

As you can see, I'm just chopping off the parts I don't like from 
toSimpleString. It seems a good format function for dates does 
not exist in Phobos.


--
  Biotronic


Re: state of ranges

2017-12-12 Thread Luís Marques via Digitalmars-d

On Tuesday, 12 December 2017 at 18:40:51 UTC, Seb wrote:
Spec: "r.front can be legally evaluated if and only if 
evaluating r.empty has, or would have, equaled false."


Spec: "r.front evaluated multiple times, without calling 
r.popFront, or otherwise mutating the range object or the 
underlying data, yields the same result for every evaluation."


Ok, so the consensus was to make ranges easy to use. Was there 
any progress on mechanisms to avoid the possible performance 
penalties, and to make the implementation side more regular?


[Issue 18065] pdf not build with "make"

2017-12-12 Thread d-bugmail--- via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=18065

Andrei Alexandrescu  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |WONTFIX

--- Comment #2 from Andrei Alexandrescu  ---
I'm bummed that "make" doesn't really make the whole thing, but I'll leave this
be.

--


Re: state of ranges

2017-12-12 Thread Seb via Digitalmars-d

On Tuesday, 12 December 2017 at 18:32:11 UTC, Luís Marques wrote:

What's the current state of the range specification?


-> https://dlang.org/phobos/std_range_primitives.html#isInputRange


For instance, do we have to call empty before calling front?


Spec: "r.front can be legally evaluated if and only if evaluating 
r.empty has, or would have, equaled false."



Can front provide different answers each time (e.g. map)?


Spec: "r.front evaluated multiple times, without calling 
r.popFront, or otherwise mutating the range object or the 
underlying data, yields the same result for every evaluation."



Were these kinds of issues resolved or not?
Is Phobos respecting some consensual protocol or are there 
still gotchas?


Yes, otherwise please open a bug.



run.dlang.io - a modern way to run D code

2017-12-12 Thread Seb via Digitalmars-d-announce
After it has been in stealth mode for quite a while, I'm happy to 
announce that there's https://run.dlang.io


=== Features ===

* Color-highlighted DMD errors
* Format source code with dfmt
* Generate a short URL for link sharing
* Import/Export to GitHub Gist
* Typical key shortcuts like CTRL+Enter -> Run
* Build cache for fast execution of common examples (e.g. the 
ones on front page of dlang.org)

* Usable on your phone
* Integrated with dlang.org (you can open any example on 
dlang.org in run.dlang.io by clicking the right arrow button)
* Integrated with tour.dlang.org (you can open any example on the 
DTour in run.dlang.io by clicking on the "Export" button)


=== Supported D Compilers ===

* Latest DMD nightly
* Latest DMD beta
* Latest DMD
* Latest LDC beta
* Latest LDC

The Docker images are rebuilt every day automatically.

=== Running DUB packages ===

Via "Add library" DUB packages can be added to the build.
Currently only a whitelist of packages is allowed.
Examples:

mir: https://run.dlang.io/is/FIc6rd
mir-algorithm: https://run.dlang.io/is/3pNRH8

=== DReg ===

When I watched CyberShadow's Bugzilla cruise [1] I spotted this 
amazing tool dreg [2] and it's not that hard to build a docker 
image [3] for it and make it available for everyone, s.t. no 
setup is required.
Dreg allows running old versions of the D compiler in parallel 
and compares their output.

However, it's a lot easier to show than to explain:

https://run.dlang.io/is/ckNT9i
https://run.dlang.io/is/UZhQDh

Currently all versions from 2.060 up to the latest greatest 
2.077.1 are run, so the execution will take a bit longer than a 
single run.


[1] https://youtu.be/qpUTvMokTCs
[2] https://github.com/CyberShadow/misc/blob/master/dreg.d
[3] https://github.com/dlang-tour/core-dreg


=== Source code & report issues ===

Please don't hesitate to open issues or submit pull requests:

-> https://github.com/dlang-tour/core

(it uses Vibe.d)


Re: operator overload

2017-12-12 Thread dark777 via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 17:13:55 UTC, Biotronic wrote:

On Tuesday, 12 December 2017 at 16:54:17 UTC, Biotronic wrote:
There is no way in C++ to set the format the way you want it. 
If you want binary output, you need to call a function like 
your binario function.


Of course this is not entirely true - there is a way, but it's 
ugly and probably not what you want:


struct BinStream
{
std::ostream& os;
BinStream(std::ostream& os) : os(os) {}

template
BinStream& operator<<(T&& value)
{
os << value;
return *this;
}

BinStream& operator<<(int value)
{
os << binario(value);
return *this;
}

std::ostream& operator<<(std::ios_base& (__cdecl 
*_Pfn)(std::ios_base&))

{
return os << _Pfn;
}
};

struct Bin
{
friend BinStream operator<<(std::ostream& os, const 
Bin& f);

} bin;

BinStream operator<<(std::ostream& os, const Bin& f)
{
return BinStream(os);
}

int main()
{
std::cout << "\n\t127 em binario: " << binario(127)
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em octal:   " << std::oct << 127
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em hexadecimal: " << std::hex << 127
<< "\n\t127 em binario: " << bin << 127
<< "\n\t127 em decimal: " << std::dec << 127
<< "\n\t127 em binario: " << bin << 127 << "\n\n";
}

What is this black magic? Instead of overriding how 
std::ostream does formatting, Bin::Operator<< now returns a 
wrapper around a std::ostream, which special cases ints. If it 
gets any other format specifiers, it returns the ostream again, 
and the binary formatting is gone.


All in all, I think the conclusion is: Stay with D.

--
  Biotronic


I understand is basically this now I will see the necessity of 
this basically the example I wanted to do is to understand how it 
would be done in the most correct way, now I will study to do 
other cases if nescessarios but primarily is to convert only 
integers but you did exactly the that I wanted


I did some studies in the D language and it already has a way to 
convert to binary without any work just using% b as in printf you 
use% X or% x to convert to exa ... and that was the reason that 
made me interested in understand this was looking at some older 
glibc and the way printf understands these very interesting 
conversion operators


state of ranges

2017-12-12 Thread Luís Marques via Digitalmars-d
What's the current state of the range specification? For 
instance, do we have to call empty before calling front? Can 
front provide different answers each time (e.g. map)? Were these 
kinds of issues resolved or not? Is Phobos respecting some 
consensual protocol or are there still gotchas?


Re: What's the proper way to use std.getopt?

2017-12-12 Thread Mike Wey via Digitalmars-d-learn

On 12-12-17 00:35, Seb wrote:

D style would be to use sth. like this (instead of try/catch):

```
scope(failure) {
   e.msg.writeln;
   1.exit;
}
```


I might have missed something, but where is `e` defined in this case?

--
Mike Wey


Re: Adding Markdown to Ddoc

2017-12-12 Thread Jakob Bornecrantz via Digitalmars-d

On Tuesday, 12 December 2017 at 02:30:39 UTC, Walter Bright wrote:

On 12/11/2017 2:30 PM, Jakob Bornecrantz wrote:
It is not written in D, but the language is close enough in 
concepts that it can be mechanically ported into D, and is 
licensed under BOOST. Feel free to do what ever to it[1].


Thank you for Boost licensing it!



Happy if it can help you in anyway. We have imported some code 
from Druntime/Phobos as well, so licensing it all under BOOST 
made sense.




We first used the markdown parser from vibe.d, when we threw 
the CommonMark testsuit, 10 tests segfaulted and 1 
infinite-spun in a loop somewhere in the code. We then rewrote 
from scratch using the recommended practices from the 
CommonMark spec and the XML output from cmark as a guide.


The code is used in our documentation system. Both 
doc-comments and outside documentation files are written in 
CommonMark. The doc-comments uses Doxygen tags which is then 
run through CommonMark, most of the time it does nothing to 
the comments, but if you want to write long comments it makes 
it much more natural and enjoyable.


[1] 
https://github.com/VoltLang/Watt/tree/master/markdown/src/watt/markdown


It's apparently written in Volt:

https://github.com/VoltLang/Watt


It's a language a small group of people (me included) have been 
working on for a while, I avoid naming it here because it's a 
system level language like D. I don't want to advertise it in any 
form here to keep the discussion on D.


But in this case the intent was code sharing. :D

Cheers, Jakob.


Re: Static array as immutable

2017-12-12 Thread Ivan Trombley via Digitalmars-d-learn

On Tuesday, 12 December 2017 at 15:30:01 UTC, Nathan S. wrote:
While what you're saying is true, exponentiation not being 
runnable at compile-time is a defect and I would assume a 
regression. I'll file a bug report. FWIW when trying to run the 
following with DMD v2.077.1 I get:


```
void main(string[] args)
{
import std.stdio;
enum e = (1.0 / 255.0f) ^^ (1 / 2.2f);
writeln("e = ", e);
}
```

=>

[...]/dmd/std/math.d(440): Error: y.vu[4] is used before 
initialized

[...]/dmd/std/math.d(413):originally uninitialized here
[...]/dmd/std/math.d(4107):called from here: 
floorImpl(x)
[...]/dmd/std/math.d(2373):called from here: floor(x + 
0.5L)

[...]/dmd/std/math.d(2110):called from here: exp2Impl(x)
[...]/dmd/std/math.d(6743):called from here: 
exp2(yl2x(x, y))
[...]/dmd/std/math.d(6756):called from here: 
impl(cast(real)x, cast(real)y)


FWIW, if the exponent is an integer, I don't get an error.


  1   2   >