Re: Uniform Function Call Syntax?

2016-03-05 Thread Ola Fosheim Grøstad via Digitalmars-d

On Friday, 4 March 2016 at 01:56:34 UTC, user001 wrote:
"dot". For mathematical purposes it is a lot easier to 
understand "dot(a, b)" than "a.dot(b)", at least in my opinion.


Why don't you just define it as "dot(a,b)" to begin with?

I think it would be better idea to just add the ability to add 
unicode operators, and to avoid precedence issues one could just 
require them to use parentheses. That way you could define 
opCustom"•" and use it as:


( point1 • point2 )

An often stated golden rule in language design is that there 
should be one way to do something. When you break that rule it 
often is due to a language design deficiency. UFCS in both D and 
C++ are hacks. IMO that makes things more confusing, not more 
clear.




Pitching D to academia

2016-03-05 Thread Ali Çehreli via Digitalmars-d
Motivated by Dmitry's "Pitching D to a gang of Gophers" thread, how 
about pitching it to a gang of professors and graduate students?


I will be presenting D to such an audience at METU in Ankara. What are 
the points that you would stress? I am thinking that they would be 
interested more in whether D is better as a teaching tool. Do you agree?


Ali


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Shammah Chancellor via Digitalmars-d

On Saturday, 5 March 2016 at 11:05:09 UTC, Dmitry Olshansky wrote:
I'm having an opportunity to do a small tech-talk on things D 
in a eCommerce shop that is currently sold on Go (migrating to 
SOA from PHP monolith). I do not intend that to become Go vs D 
battle but it gives the context.


What guys seem to like of Go from my observation:
- goroutines instead of direct asynchronous programming*
- fast runtime with state of the art GC
- host of ready-made libraries esp. http & networking**
- lightweight OOP that doesn't get in your way
- tooling, tooling, tooling (IDE plugins and build tools work 
great)


*Note: all of standard I/O is transparently handled with 
goroutines much like vibe.d but goroutines are migrating across 
thread pool
** That being said there are tons of 1-man projects of dubious 
quality,


So far I'd thought of a few big themes:
- little nice things (slices/maps, things like 1_000_000 and 
e.g. a < b && d < e is parse error, UFCS)
- code reuse (templates & ranges, with examples like generic 
min and some algo)

- compile-time works (CTFE, need simpler example then regex)

I'm still pondering whether I should dive into UDA, I'd try to 
stay simple as simplicity is one of things Go guys known to 
love.


What features you'd highlight to enterprise-ish user?


I work in a 99% Go shop (a splash of C, and some smattering of 
scripts for in-house tools.)  I've tried to use D for a few 
things, and tried to get other people interested in it.  So, 
here's my perception:


Everything you've said is true, and D should focus on making some 
of these things much better.  Additionally, the compiled (mostly 
single binary nature) of Go makes it very nice for deployments.   
Focusing on dfmt, and dfix would be a huge win.


Here's some stuff D shares with Go:

"Single" binary deployments.
Garbage Collector
In-language slices and maps
Foreach (Although D is much more powerful here)

Some things D is weak on:
* The name -- all I ever hear are penis jokes.
* Garbage Collector (!)
* dfix and dfmt aren't as good as gofmt and gofix. (And believe 
me I understand they will be much more difficult to get to parity 
due to the feature set of D)
* Docs  -- although these have gotten much much better recently 
-- the current implementation of concepts makes it hard for 
people to know where and when they can use a type.  E.g sort docs 
(http://dlang.org/phobos/std_algorithm_sorting.html#sort) How do 
I know what types of things I can sort as a newcomer? Even if I 
figure out that I need to look at isForwardRange, the docs there 
aren't terribly helpful either 
(https://dlang.org/phobos/std_range_primitives.html#isForwardRange)  I would put up a PR, but I don't know how to fix it without introducing a language structure for Concepts -- but this has been veto'd for a variety of reasons (primarily type explosion as I understand the arguments)

* Libraries

Some things D is much better on (and would cause me to choose it 
every time and just contribute fixes where I could to the 
external tools):


* Package management/build tools
* Integration with existing build systems/libraries
* Reusable algorithms that are FAST
* Empowering programmer expressiveness without enabling magic

-S.


[Issue 15770] New: SocketSet.add OutOfMemoryError on Posix

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15770

  Issue ID: 15770
   Summary: SocketSet.add OutOfMemoryError on Posix
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: minor
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: an...@s-e-a-p.de

While adding a not alive socket to a SocketSet using method add() there is
following error:

ERR core.exception.OutOfMemoryError@src/core/exception.d(679): Memory
allocation failed

In some scenarios it is quite hard to find the root cause (not alive socket).
An exception like InvalidSocket instead would be quite nice.

Tested on linux.

--


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Shammah Chancellor via Digitalmars-d

On Saturday, 5 March 2016 at 11:31:27 UTC, John Colvin wrote:
On Saturday, 5 March 2016 at 11:05:09 UTC, Dmitry Olshansky 
wrote:
I'm having an opportunity to do a small tech-talk on things D 
in a eCommerce shop that is currently sold on Go (migrating to 
SOA from PHP monolith). I do not intend that to become Go vs D 
battle but it gives the context.


[...]


Have you seen this? 
http://www.jtolds.com/writing/2016/03/go-channels-are-bad-and-you-should-feel-bad/ I'm not sure if it's all correct and how to compare the situation to D, but it was interesting to read.


That article is correct -- I've used go extensively at this 
point.  This is also a good article: 
https://gist.github.com/kachayev/21e7fe149bc5ae0bd878


Re: Create Windows "shortcut" (.lnk) with D?

2016-03-05 Thread 岩倉 澪 via Digitalmars-d-learn

On Sunday, 6 March 2016 at 05:00:55 UTC, BBasile wrote:
If you don't want to mess with the Windows API then you can 
dynamically create a script (I do this in CE installer):


This might be an option but I'd prefer to use the Windows API 
directly. I don't know vb script and maintaining such a script 
inline would just add cognitive overhead I think.


If I can't get it working with the Windows API; I'll probably 
have to do it this way though. Thanks for the suggestion!





Re: Create Windows "shortcut" (.lnk) with D?

2016-03-05 Thread BBasile via Digitalmars-d-learn

On Sunday, 6 March 2016 at 03:13:23 UTC, 岩倉 澪 wrote:
I'm creating a small installation script in D, but I've been 
having trouble getting shortcut creation to work! I'm a linux 
guy, so I don't know much about Windows programming...


[...]

Any help would be highly appreciated as I'm new to Windows 
programming in D and have no idea what I'm doing wrong!


If you don't want to mess with the Windows API then you can 
dynamically create a script (I do this in CE installer):


void createLnk(string exeName, string displayName)
{
import std.process: environment, executeShell;
import std.file: remove, exists;
import std.random: uniform;
import std.conv: to;

string vbsName;
do vbsName = environment.get("TEMP") ~ r"\shcsh" ~ 
uniform(0,int.max).to!string ~ ".vbs";

while (vbsName.exists);

string vbsCode = "
set WshShell = CreateObject(\"WScript.shell\")
strDesktop = WshShell.SpecialFolders(\"Desktop\")
set lnk = WshShell.CreateShortcut(strDesktop + 
\"\\%s.lnk\")

lnk.TargetPath = \"%s\"
lnk.Save
";
File vbs = File(vbsName, "w");
vbs.writefln(vbsCode, displayName, exeName);
vbs.close;
executeShell(vbsName);

vbsName.remove;
}



Re: Good project: stride() with constant stride value

2016-03-05 Thread Seb via Digitalmars-d
On Saturday, 5 March 2016 at 13:15:46 UTC, Andrei Alexandrescu 
wrote:

On 03/04/2016 11:34 PM, Jonathan M Davis wrote:
This makes me wonder if something like iota would benefit from 
a similar

optimization.


Certainly. -- Andrei


I haven't done much with CTFE yet, but how would one get the type 
there right?
iota accepts any Integral type, so the following seems a bit 
bulky..


```
template Iota(T)
{
auto i(T end, T step = 1)()
{
return iota(end, step);
}
auto i(T begin, T end, T step = 1)()
{
return iota(begin, end, step);
}
}

unittest
{
import std.algorithm: equal;
static assert(Iota!int.i!(0, 10, 1).equal([0, 1, 2, 3, 4, 5, 
6, 7, 8, 9]));

}
```


Re: Dub and unit-threaded import problem

2016-03-05 Thread Casey via Digitalmars-d-learn

On Saturday, 5 March 2016 at 18:01:48 UTC, Atila Neves wrote:

On Saturday, 5 March 2016 at 15:05:50 UTC, Casey wrote:

Hello,

I'm just starting a small project with dub and unit-threaded, 
but I'm getting an issue where the file "unit_threaded.d" 
cannot be found.


[...]


You mispelled "dependencies".

Atila


Oh, and forgot to mention I like what you did with this new 
update of unit-threaded.  Can't wait to get some code written.


Re: Dub and unit-threaded import problem

2016-03-05 Thread Casey via Digitalmars-d-learn

On Saturday, 5 March 2016 at 18:01:48 UTC, Atila Neves wrote:

On Saturday, 5 March 2016 at 15:05:50 UTC, Casey wrote:

Hello,

I'm just starting a small project with dub and unit-threaded, 
but I'm getting an issue where the file "unit_threaded.d" 
cannot be found.


[...]


You mispelled "dependencies".

Atila


Thanks.  I knew it had to be something dumb.


Create Windows "shortcut" (.lnk) with D?

2016-03-05 Thread 岩倉 澪 via Digitalmars-d-learn
I'm creating a small installation script in D, but I've been 
having trouble getting shortcut creation to work! I'm a linux 
guy, so I don't know much about Windows programming...


Here are the relevant bits of code I have:

import core.sys.windows.basetyps, core.sys.windows.com, 
core.sys.windows.objbase, core.sys.windows.objidl, 
core.sys.windows.shlobj, core.sys.windows.windef;
import std.conv, std.exception, std.file, std.format, std.path, 
std.stdio, std.string, std.utf, std.zip;


//Couldn't find these in core.sys.windows
extern(C) const GUID CLSID_ShellLink = {0x00021401, 0x, 
0x,

  [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};

extern(C) const IID IID_IShellLinkA  = {0x000214EE, 0x, 
0x,

  [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};

extern(C) const IID IID_IPersistFile = {0x010B, 0x, 
0x,

  [0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46]};

void main()
{
string programFolder, dataFolder, desktopFolder;
{
char[MAX_PATH] _programFolder, _dataFolder, 
_desktopFolder;
SHGetFolderPathA(null, CSIDL_PROGRAM_FILESX86, null, 0, 
_programFolder.ptr);
SHGetFolderPathA(null, CSIDL_LOCAL_APPDATA, null, 0, 
_dataFolder.ptr);
SHGetFolderPathA(null, CSIDL_DESKTOPDIRECTORY, null, 0, 
_desktopFolder.ptr);
programFolder = 
_programFolder.assumeUnique().ptr.fromStringz();

dataFolder = _dataFolder.assumeUnique().ptr.fromStringz();
desktopFolder = 
_desktopFolder.assumeUnique().ptr.fromStringz();

}
auto inputFolder = buildNormalizedPath(dataFolder, 
"Aker/agtoolbox/input");
auto outputFolder = buildNormalizedPath(dataFolder, 
"Aker/agtoolbox/output");

CoInitialize(null);
scope(exit)
CoUninitialize();
IShellLinkA* shellLink;
IPersistFile* linkFile;
CoCreateInstance(_ShellLink, null, 
CLSCTX_INPROC_SERVER, _IShellLinkA, cast(void**));
auto exePath = buildNormalizedPath(programFolder, 
"Aker/agtoolbox/agtoolbox.exe").toStringz();

shellLink.SetPath(exePath);
auto arguments = format("-i %s -o %s", inputFolder, 
outputFolder).toStringz();

shellLink.SetArguments(arguments);
auto workingDirectory = programFolder.toStringz();
shellLink.SetWorkingDirectory(workingDirectory);
shellLink.QueryInterface(_IPersistFile, 
cast(void**));
auto linkPath = buildNormalizedPath(desktopFolder, 
"agtoolbox.lnk").toUTF16z();

linkFile.Save(linkPath, TRUE);
}

I tried sprinkling it with print statements and it crashes on 
shellLink.setPath(exePath);


This is the full script: 
https://gist.github.com/miotatsu/1cc55fe29d8a8dcccab5
I found the values for the missing windows api bits from this: 
http://www.dsource.org/projects/tutorials/wiki/CreateLinkUsingCom


I compile with: dmd agtoolbox-installer.d ole32.lib
I got the ole32.lib from the dmd install

Any help would be highly appreciated as I'm new to Windows 
programming in D and have no idea what I'm doing wrong!


[Issue 15769] Unittests example should have titles

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15769

greenify  changed:

   What|Removed |Added

  Component|phobos  |dlang.org

--


[Issue 15769] New: Unittests example should have titles

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15769

  Issue ID: 15769
   Summary: Unittests example should have titles
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: greeen...@gmail.com

We see multiple Examples statement and the title of the snippet is display as a
comment. 

e.g. http://dlang.org/phobos/std_algorithm_sorting.html#sort

Examples:
// Showcase stable sorting
...

Examples:
// Sorting floating-point numbers in presence of NaN
...



Ideally I think we should 
1) only show "Examples" once (easy)
2) get the title from the comment string above the unittest  (maybe trickier)

--


[Issue 15700] Source code links are partially broken

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15700

greenify  changed:

   What|Removed |Added

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

--- Comment #1 from greenify  ---
seems to be fixed with newer versions.

--


provide compiler hooks to customize compilation [cf EMAIL:In language tooling]

2016-03-05 Thread Timothee Cour via Digitalmars-d
one takeaway from the video in [EMAIL:In language tooling] that would be
doable in D with a compiler as a library:

we could provide hooks (via user defined function delegates) in the
compiler when some action happen, eg: opening a file to be compiled,
parsing an import, processing an expression etc.

This would allow for example writing user defined callbacks
to interactively visualize on a webserver the number of
[files,functions,symbols,LOC, mixin expansions, CTFE execution] being
compiled in realtime, warn when a file about to be compiled doesn't match
some regular expression, and many other use cases (see video)


Re: If stdout is __gshared, why does this throw / crash?

2016-03-05 Thread Marco Leise via Digitalmars-d-learn
Got it now: https://issues.dlang.org/show_bug.cgi?id=15768

writeln() creates a copy of the stdout struct in a non
thread-safe way. If stdout has been assigned a File struct
created from a file name this copy includes a "racy"
increment/decrement of a reference count to the underlying
C-library FILE*. In the case that the reference count is
erroneously reaching 0, the file is closed prematurely and
when Glibc tries to access internal data it results in the
observable SIGSEGV.

-- 
Marco



[Issue 15768] New: std.stdio.trustedStdout accesses __gshared data without synchronization.

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15768

  Issue ID: 15768
   Summary: std.stdio.trustedStdout accesses __gshared data
without synchronization.
   Product: D
   Version: D2
  Hardware: All
   URL: http://forum.dlang.org/post/vrchiulmsqxtdeadrrjo@forum
.dlang.org
OS: All
Status: NEW
  Severity: major
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: marco.le...@gmx.de

std.stdio.trustedStdout returns a copy of stdout which invokes the postblit of
File. This is done without internal synchronization and so the reference count
increment/decrement is prone to race conditions if stdout has been assigned an
ordinary file. The following snippet is thus likely to close stdout too early,
resulting - for example - in segmentation faults inside Glibc:

stdout = File("/dev/null", "w");
foreach(t; 1000.iota.parallel)
writeln("Oops");

When Phobos is compiled with assertions, the bug is generally caught within the
File struct itself.

The compiler did warn that accessing the global data `stdout` would be unsafe
(because of potential race conditions). A wrapper `trustedStdout` was written
to make stdout usable in @safe code, but it bears no warning as to threading
issues.

Compare to: https://issues.dlang.org/show_bug.cgi?id=15645 where @trusted was
added to silence legitimate compiler warnings about safety, resulting in a
Phobos bug.

Ultimately I believe that stdout must be a shared resource with a shared
postblit and dtor that decrements the ref count in an atomic way or stdout must
not be reassignable at all. See also: The situation with thread-safety of
std.logger's global stdlog.

--


Re: If stdout is __gshared, why does this throw / crash?

2016-03-05 Thread Anon via Digitalmars-d-learn

On Saturday, 5 March 2016 at 14:18:31 UTC, Atila Neves wrote:
With a small number of threads, things work as intended in the 
code below. But with 1000, on my machine it either crashes or 
throws an exception:



import std.stdio;
import std.parallelism;
import std.range;


void main() {
stdout = File("/dev/null", "w");
foreach(t; 1000.iota.parallel) {
writeln("Oops");
}
}


Note that `1000.iota.parallel` does *not* run 1000 threads. 
`parallel` just splits the work of the range up between the 
worker threads (likely 2, 4, or 8, depending on your CPU). I see 
the effect you describe with any parallel workload. Smaller 
numbers in place of 1000 aren't necessarily splitting things off 
to additional threads, which is why smaller numbers avoid the 
multi-threaded problems you are encountering.


I get, depending on the run, "Bad file descriptor", "Attempting 
to write to a closed file", or segfaults. What am I doing wrong?


Atila


`File` uses ref-counting internally to allow it to auto-close. 
`stdout` and friends are initialized in a special way such that 
they have a high initial ref-count. When you assign a new file to 
stdout, the ref count becomes one. As soon as one of your threads 
exits, this will cause stdout to close, producing the odd errors 
you are encountering on all the other threads.


I would avoid reassigning `stdout` and friends in favor of using 
a logger or manually specifying the file to write to if I were 
you.


[Issue 15767] New: Why isn't there a deprecation plan for TypeTuple?

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15767

  Issue ID: 15767
   Summary: Why isn't there a deprecation plan for TypeTuple?
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: greeen...@gmail.com

I read that TypeTuple is an alternate name for AliasSeq for legacy
compatibility.

https://github.com/D-Programming-Language/phobos/blob/master/std/typetuple.d

If it's legacy, why is there no @deprecated and no deprecation plan for
std.typetuple?

--


Re: If stdout is __gshared, why does this throw / crash?

2016-03-05 Thread Marco Leise via Digitalmars-d-learn
Am Sat, 05 Mar 2016 14:18:31 +
schrieb Atila Neves :

> void main() {
>  stdout = File("/dev/null", "w");
>  foreach(t; 1000.iota.parallel) {
>  writeln("Oops");
>  }
> }

First thing I tried:

void main() {
 stdout = File("/dev/null", "w");
 foreach(t; 1000.iota.parallel) {
 stdout.writeln("Oops");
 }
}

That does NOT segfault ... hmm.

-- 
Marco



Re: If stdout is __gshared, why does this throw / crash?

2016-03-05 Thread Yuxuan Shui via Digitalmars-d-learn

On Saturday, 5 March 2016 at 14:18:31 UTC, Atila Neves wrote:
With a small number of threads, things work as intended in the 
code below. But with 1000, on my machine it either crashes or 
throws an exception:



import std.stdio;
import std.parallelism;
import std.range;


void main() {
stdout = File("/dev/null", "w");
foreach(t; 1000.iota.parallel) {
writeln("Oops");
}
}



I get, depending on the run, "Bad file descriptor", "Attempting 
to write to a closed file", or segfaults. What am I doing wrong?


Atila


Could this be a bug in phobos/compiler?


Re: Backslash escaping weirdness

2016-03-05 Thread Marco Leise via Digitalmars-d-learn
Am Tue, 01 Mar 2016 05:14:13 +
schrieb Nicholas Wilson :

> On Tuesday, 1 March 2016 at 04:48:01 UTC, Adam D. Ruppe wrote:
> > On Tuesday, 1 March 2016 at 04:18:11 UTC, Nicholas Wilson wrote:
> >> What is causing these errors? I'm using \t and \n in string 
> >> all over the place and they work.
> >
> > I don't think there's enough context to know for sure... but my 
> > guess is you forgot to close one of the quotes a couple lines 
> > above.
> >
> > So look up for an unpaired "
> 
> It was. Thanks.

And then God created syntax highlighting and He saw that it
was good. ;)

-- 
Marco



Re: Pitching D to a gang of Gophers

2016-03-05 Thread Jack Stouffer via Digitalmars-d

On Saturday, 5 March 2016 at 22:13:40 UTC, Walter Bright wrote:

On 3/5/2016 3:05 AM, Dmitry Olshansky wrote:

What features you'd highlight to enterprise-ish user?


Interfacing to existing C and C++ code.


If they were a PHP shop, then this wouldn't matter much to them.


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Walter Bright via Digitalmars-d

On 3/5/2016 3:05 AM, Dmitry Olshansky wrote:

What features you'd highlight to enterprise-ish user?


Interfacing to existing C and C++ code.



Re: Uniform Function Call Syntax?

2016-03-05 Thread Walter Bright via Digitalmars-d

On 3/3/2016 5:56 PM, user001 wrote:

It may not add as much value but I think it'd be a bit better as now you no
longer have a global function with a simple name "dot". For mathematical
purposes it is a lot easier to understand "dot(a, b)" than "a.dot(b)", at least
in my opinion. Just curious that's all.


If that's how you want to call dot, add the following:

   float dot(Vec3 a, Vec3 b) { return a.dot(b); }


Re: Dub and unit-threaded import problem

2016-03-05 Thread Sebastiaan Koppe via Digitalmars-d-learn

On Saturday, 5 March 2016 at 15:05:50 UTC, Casey wrote:

{
"name": "unittest",
"preBuildCommands": [
"dub run unit-threaded -c gen_ut_main -- -f  bin/ut.d"
],
"mainSourceFile": "bin/ut.d",
"excludedSourceFiles": ["source/app.d"],
"dependences": {
"unit-threaded": "~>0.6.3"
}
}


If dub is complaining about not finding bin/ut.d, You need a 
"importPaths": ["bin"] in there. Dub by default only looks in the 
source folder, and it cannot find `bin/ut.d` in `./source`. If 
that is the case you also need to remove the `source` part from 
the excludedSourceFiles.


Here is a config that works for me

{
"name": "unittest",
"preBuildCommands": ["dub run unit-threaded -c gen_ut_main -- 
-f bin/ut.d"],

"importPaths": ["bin"],
"mainSourceFile": "bin/ut.d",
"excludedSourceFiles": ["app.d"],
"dependencies": {
"unit-threaded": "~>0.6.3"
}
}


Re: std.database

2016-03-05 Thread Jacob Carlborg via Digitalmars-d

On 2016-03-05 19:00, Erik Smith wrote:


I'm definitely going to start working in async capability (or more
accurately, non-blocking) into the interface.   Both models are
essential and there are strong use cases for both, but I know there is a
lot of interest in NBIO for vibe.d compatibility. This is challenging
and, as many are aware, the C clients for SQL databases have
traditionally been synchronous only.  One suggested approach is to fork
the driver source and change the I/O calls to be non-blocking. Another
is to implement a non-blocking driver directly against the wire protocol
(a "native" driver).  These are limited options, but to the extent this
approach is viable in some cases (mysql-native for example), they could
be adapted to a standard interface.  The good news is that some
databases do have (or are working on) non-blocking support in their C
clients. The webscalesql mysql fork, for example, has a non-blocking
client that is in production and their client works with regular mysql
databases.  That fork should eventually be merged back into mysql (or
may have been already).  Postgres also provides non-blocking support.
These are two cases that I'm targeting for initial reference
implementations.


Just for the record, there's already a native Postgres client that is 
non-blocking and vibe.d compatible. https://github.com/pszturmaj/ddb


--
/Jacob Carlborg


Re: A very interesting slide deck comparing sync and async IO

2016-03-05 Thread Sean Kelly via Digitalmars-d

On Friday, 4 March 2016 at 06:55:29 UTC, Shachar Shemesh wrote:

On 03/03/16 19:31, Andrei Alexandrescu wrote:

https://www.mailinator.com/tymaPaulMultithreaded.pdf


On a completely different note, me and a colleague started a 
proof of concept to disprove the claim that blocking+threads is 
slower. We did manage to service several tens of thousands of 
simultaneous connections using the one thread per client mode, 
proving that the mere context switch is not the problem here. 
Sadly, we never got around to bringing the code and the tests 
up to the level where we can publish something, but, at least 
in the case where a system call is needed in order to decide 
when to switch fibers, I dispute the claim that non-blocking is 
inherently faster.


It's not inherently faster. It just scales better in real-world 
scenarios, assuming a limited number of worker threads. Blocking 
IO is actually often fine in synthetic tests and in server to 
server, but in real world situations where some clients have 
modem-level bandwidth, a blocking write can ruin you.


[Issue 15738] Problem with std.experimental.ndslice empty()

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15738

--- Comment #3 from Илья Ярошенко  ---
(In reply to bearophile_hugs from comment #2)
> (In reply to Илья Ярошенко from comment #1)
> > This is feature, empty is empty!0, so it checks only first dimension. In
> > addition, this  is very important for optimization reasons. emptyAny method
> > may be added for desirable behavior.
> 
> I think it's a trap. empty === enoty!0 is not explicit. So it should be
> designed the other way, in an explicit way. If you want to add a empty()
> method, it should work on the whole tensor. If you want to see if one
> coordinate is empty, you can add a more specialized method, like emptySide,
> or something similar.

Slice is not a container, so there is no reason for such behavior.

`empty` must be as fast as possible because a user may use slices with
std.algorithm and std.range.

--


Re: Dub and unit-threaded import problem

2016-03-05 Thread Atila Neves via Digitalmars-d-learn

On Saturday, 5 March 2016 at 15:05:50 UTC, Casey wrote:

Hello,

I'm just starting a small project with dub and unit-threaded, 
but I'm getting an issue where the file "unit_threaded.d" 
cannot be found.


[...]


You mispelled "dependencies".

Atila


Re: std.database

2016-03-05 Thread Erik Smith via Digitalmars-d

On Saturday, 5 March 2016 at 13:13:09 UTC, Jacob Carlborg wrote:

On 2016-03-05 11:23, Saurabh Das wrote:

A little late to the party, nevertheless: Thanks for doing 
this, it will

be super-helpful!

My only feature request will be: please make it work with 
minimal effort

with Vibe.D! :)


Yeah, that's really important. Unfortunately it looks like a 
synchronous interface is prioritized :(.



I'm definitely going to start working in async capability (or 
more accurately, non-blocking) into the interface.   Both models 
are essential and there are strong use cases for both, but I know 
there is a lot of interest in NBIO for vibe.d compatibility.  
This is challenging and, as many are aware, the C clients for SQL 
databases have traditionally been synchronous only.  One 
suggested approach is to fork the driver source and change the 
I/O calls to be non-blocking. Another is to implement a 
non-blocking driver directly against the wire protocol (a 
"native" driver).  These are limited options, but to the extent 
this approach is viable in some cases (mysql-native for example), 
they could be adapted to a standard interface.  The good news is 
that some databases do have (or are working on) non-blocking 
support in their C clients. The webscalesql mysql fork, for 
example, has a non-blocking client that is in production and 
their client works with regular mysql databases.  That fork 
should eventually be merged back into mysql (or may have been 
already).  Postgres also provides non-blocking support.  These 
are two cases that I'm targeting for initial reference 
implementations.








[Issue 15738] Problem with std.experimental.ndslice empty()

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15738

--- Comment #2 from bearophile_h...@eml.cc ---
(In reply to Илья Ярошенко from comment #1)
> This is feature, empty is empty!0, so it checks only first dimension. In
> addition, this  is very important for optimization reasons. emptyAny method
> may be added for desirable behavior.

I think it's a trap. empty === enoty!0 is not explicit. So it should be
designed the other way, in an explicit way. If you want to add a empty()
method, it should work on the whole tensor. If you want to see if one
coordinate is empty, you can add a more specialized method, like emptySide, or
something similar.

--


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Chris Wright via Digitalmars-d
On Sat, 05 Mar 2016 14:05:09 +0300, Dmitry Olshansky wrote:

> What features you'd highlight to enterprise-ish user?

Go isn't bad from an enterprise perspective -- it's better than D, in 
fact. Go has a major company heavily invested in it, and a number of 
other companies are supporting it.

D is much more programmer-friendly, and that's where it tends to shine. 
C# is close enough that there's no order-of-magnitude difference, plus 
it's got corporate support, so for an enterprise crowd I'd sooner 
recommend it.

Things I might talk about:

Interacting with the fiber scheduler explicitly. Goroutines are 
hermetically sealed. D Fibers are much more open.
 * Need fiber-local storage? Subclass Fiber and you're a cast away from 
it. Need goroutine-local storage? There's a library for it, but it's a 
terribly ugly hack.
 * Need to shut down a goroutine and stop it from running? You have to 
have it explicitly check in every location another goroutine might want 
to stop it, and it's not a trivial check either. Plus you need to 
propagate a channel down the stack somehow. In D, it's almost trivial to 
stop a Fiber.
 * Need to schedule things precisely? Impossible. You can sleep, or you 
can wait on IO, but that's it. You can't rate-limit an operation, or add 
thread affinity so one set of goroutines is reliably scheduled 
independently of another. In D, you can implement all of that.

Templates vs interface{}. interface{} is nice to have sometimes, and 
we've got std.variant for those times. But almost always we want actual 
type safety and not to put casts everywhere.

Better control over the garbage collector. You can prevent collections 
from running in D and have the compiler enforce non-usage of the GC.

Then there are all the ways in which Go deviates from standard practices 
and gets things wrong. There's a giant list of them, and D doesn't give a 
specific advantage.


Re: Wrap array into a range.

2016-03-05 Thread Ilya Yaroshenko via Digitalmars-d-learn
On Saturday, 5 March 2016 at 16:28:51 UTC, Alexandru Ermicioi 
wrote:
I have to pass an array to a function that accepts an input 
range. Therefore I need to transform somehow array into an 
input range.


Is there a range that wraps an array in standard library?


You just need to import std.array. --Ilya


Wrap array into a range.

2016-03-05 Thread Alexandru Ermicioi via Digitalmars-d-learn
I have to pass an array to a function that accepts an input 
range. Therefore I need to transform somehow array into an input 
range.


Is there a range that wraps an array in standard library?


Re: Argon: an alternative parser for command-line arguments

2016-03-05 Thread karabuta via Digitalmars-d-announce

On Friday, 4 March 2016 at 17:34:08 UTC, Markus Laker wrote:

On Friday, 4 March 2016 at 12:21:25 UTC, Jacob Carlborg wrote:
No, I mean a longer description, more like documentation. Look 
at the help for git when using --help, it has different 
behavior than -h. The first one is more like a man page.


Ah, I see.  Sorry for the misunderstanding.

An app could do that trivially: have a --short-help option with 
shortcut -h and a --help option with no shortcut, and then 
respond to the two switches differently.  Mark the --short-help 
option as undocumented, and then it won't appear in an 
auto-generated syntax summary.


Markus


I think he meant: [git status --help], where you have three 
attributes with the last one being the flag. So in addition to: 
[status --help] by default, you also have: [git status --help] to 
get help on status only.


By the way, that styles used by git seems confusing. Why not make 
it show the default help when you do: [git --help], whilst you 
can do: [git --help=status] OR [git --help status] for help on 
status only?


git --help
git -h

git --help=status
git --help status
git -h=status


Re: std.xml2 (collecting features)

2016-03-05 Thread Craig Dillabaugh via Digitalmars-d
On Sunday, 3 May 2015 at 17:39:48 UTC, Robert burner Schadek 
wrote:
std.xml has been considered not up to specs nearly 3 years now. 
Time to build a successor. I currently plan the following 
featues for it:


- SAX and DOM parser
- in-situ / slicing parsing when possible (forward range?)
- compile time switch (CTS) for lazy attribute parsing
- CTS for encoding (ubyte(ASCII), char(utf8), ... )
- CTS for input validating
- performance

Not much code yet, I'm currently building the performance test 
suite https://github.com/burner/std.xml2


Please post you feature requests, and please keep the posts DRY 
and on topic.


Robert, we have had some student interest in GSOC for XML.  Would 
you be interested in mentoring a student to work with you on this.


Craig


Dub and unit-threaded import problem

2016-03-05 Thread Casey via Digitalmars-d-learn

Hello,

I'm just starting a small project with dub and unit-threaded, but 
I'm getting an issue where the file "unit_threaded.d" cannot be 
found.


Details:

DMD version: DMD64 2.070.0

Dub version: 0.9.24

Dub Config:

{
"name": "pst",
"targetType": "executable",
"targetPath": "bin",
"configurations": [
{
"name": "unittest",
"preBuildCommands": [
"dub run unit-threaded -c gen_ut_main -- -f 
bin/ut.d"

],
"mainSourceFile": "bin/ut.d",
"excludedSourceFiles": ["source/app.d"],
"dependences": {
"unit-threaded": "~>0.6.3"
}
}
]
}

I haven't created any tests at this time.  It's a bare project.  
I just wanted to make sure the dub config worked before I started 
coding.  I feel I'm missing something very simple.  I just don't 
see it.


[Issue 1238] Private identifiers in imported modules create conflicts with public ones

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1238

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

https://github.com/D-Programming-Language/dmd/commit/8839a6c8c24777b576e3594629804185cff21c0e
fix issue 1238

--


[Issue 10750] Strict aliasing semantics

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=10750

Ketmar Dark  changed:

   What|Removed |Added

 CC||ket...@ketmar.no-ip.org

--


[Issue 143] 'package' does not work at all

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=143

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

   What|Removed |Added

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

--


[Issue 340] [Tracker] Forward reference bugs and other order-of-declaration issues

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=340
Issue 340 depends on issue 3254, which changed state.

Issue 3254 Summary: [module] Module member visibility depends on declaration 
order
https://issues.dlang.org/show_bug.cgi?id=3254

   What|Removed |Added

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

--


[Issue 3254] [module] Module member visibility depends on declaration order

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3254

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

   What|Removed |Added

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

--


Re: Good project: stride() with constant stride value

2016-03-05 Thread kinke via Digitalmars-d
On Friday, 4 March 2016 at 20:14:41 UTC, Andrei Alexandrescu 
wrote:
This is just speculation. When the stride is passed to larger 
functions the value of the stride is long lost.


I understand the desire for nice and simple code but sadly the 
stdlib is not a good place for it - everything must be tightly 
optimized. The value of the project stands. -- Andrei


With that argument, we might end up with druntime and Phobos 
completely in manually-tweaked inline assembly to compensate for 
simpler back-ends. I'm obviously exaggerating, but unless you can 
show that a compile-time version really provides a significant 
boost for optimized GDC/LDC builds too, I don't see the project's 
value.


[Issue 2991] [module] Import within aggregate causes conflicts with private identifiers

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2991

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

https://github.com/D-Programming-Language/dmd/commit/2c371ceed6f17d58d67f2b1c34b175eec541e7f2
fix issue 2991

--


[Issue 1238] Private identifiers in imported modules create conflicts with public ones

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1238

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

   What|Removed |Added

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

--


[Issue 1754] module member visibility does not affect conflicts

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1754

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

   What|Removed |Added

 Resolution|DUPLICATE   |FIXED

--


[Issue 2991] [module] Import within aggregate causes conflicts with private identifiers

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=2991

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

   What|Removed |Added

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

--


[Issue 1754] module member visibility does not affect conflicts

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1754

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

https://github.com/D-Programming-Language/dmd/commit/054db4feac43ca997b88a56f3aac0664b513cb5c
fix issue 1754

--


[Issue 3254] [module] Module member visibility depends on declaration order

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=3254

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

https://github.com/D-Programming-Language/dmd/commit/e527108f9153cedab2ca658d053b2ac81610e55d
fix Issue 3254 - Module member visibility depends on declaration order

--


If stdout is __gshared, why does this throw / crash?

2016-03-05 Thread Atila Neves via Digitalmars-d-learn
With a small number of threads, things work as intended in the 
code below. But with 1000, on my machine it either crashes or 
throws an exception:



import std.stdio;
import std.parallelism;
import std.range;


void main() {
stdout = File("/dev/null", "w");
foreach(t; 1000.iota.parallel) {
writeln("Oops");
}
}



I get, depending on the run, "Bad file descriptor", "Attempting 
to write to a closed file", or segfaults. What am I doing wrong?


Atila


[Issue 143] 'package' does not work at all

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=143

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

https://github.com/D-Programming-Language/dmd/commit/431dd2028bb913db836cbc21d01989c19d5c363e
fix Issue 143

--


Re: Application with WinMain does not start

2016-03-05 Thread Mike Parker via Digitalmars-d-learn

On Saturday, 5 March 2016 at 14:01:11 UTC, Mike Parker wrote:


If you use WinMain, you do not need that flag.


Actually, I need to amend that. It isn't needed with WinMain when 
using the Microsoft linker, but it is when using OPTLINK. The MS 
linker recognizes WinMain and treats it as /SUBSYSTEM:WINDOWS by 
default.


Re: Application with WinMain does not start

2016-03-05 Thread Mike Parker via Digitalmars-d-learn

On Saturday, 5 March 2016 at 13:16:19 UTC, Minas Mina wrote:
I added a WinMain function to my application because I don't 
want it to open a console when running on windows.


But now it doesn't even start...

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  LPSTR lpCmdLine, int nCmdShow)
{
bool b = true;
while (b)
{
sync(Clock.currTime(utcTimeZone()));
Thread.sleep(getNextTimeToRun() - 
Clock.currTime(utcTimeZone()));

}

return 0;
}

And this is my DUB configuration:

name "..."
description "..."
copyright "..."
authors "..."
targetType "executable"
lflags "/SUBSYSTEM:windows" "/EXETYPE:NT" platform="windows"

I got those flags from here: http://wiki.dlang.org/D_for_Win32

Any ideas:


When using WinMain, you are bypassing the DRuntime entry point, 
meaning the runtime is never initialized. You need to do it 
manually. However, since you're passing /SUBSYSTEM:windows on the 
command line, you *don't need* WinMain. That flag is for when you 
want to use main, but don't want the console to popup. If you use 
WinMain, you do not need that flag. To keep things simple, I 
recommend you use the /SUBSYSTEM:windows flag together with a 
regular main and drop WinMain completely. You can drop the 
/EXETYPE flag as well.


Application with WinMain does not start

2016-03-05 Thread Minas Mina via Digitalmars-d-learn
I added a WinMain function to my application because I don't want 
it to open a console when running on windows.


But now it doesn't even start...

extern (Windows)
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  LPSTR lpCmdLine, int nCmdShow)
{
bool b = true;
while (b)
{
sync(Clock.currTime(utcTimeZone()));
Thread.sleep(getNextTimeToRun() - 
Clock.currTime(utcTimeZone()));

}

return 0;
}

And this is my DUB configuration:

name "..."
description "..."
copyright "..."
authors "..."
targetType "executable"
lflags "/SUBSYSTEM:windows" "/EXETYPE:NT" platform="windows"

I got those flags from here: http://wiki.dlang.org/D_for_Win32

Any ideas:


Re: Good project: stride() with constant stride value

2016-03-05 Thread Andrei Alexandrescu via Digitalmars-d

On 03/04/2016 11:34 PM, Jonathan M Davis wrote:

This makes me wonder if something like iota would benefit from a similar
optimization.


Certainly. -- Andrei


Re: Good project: stride() with constant stride value

2016-03-05 Thread Andrei Alexandrescu via Digitalmars-d

On 03/04/2016 09:50 PM, John Colvin wrote:

On Friday, 4 March 2016 at 23:33:40 UTC, Andrei Alexandrescu wrote:

On 03/04/2016 04:19 PM, H. S. Teoh via Digitalmars-d wrote:

Why not rather improve dmd optimization, so that such manual
optimizations are no longer necessary?


As I mentioned, optimizing the use of stride in large (non-inlined)
functions is a tall order. -- Andrei


It seems to me that if the stride is available in the calling scope as
usable for a stride template parameter (i.e. as a compile-time value )
then it would also be just as available to the optimiser after the
trivial inlining of stride (note not any arbitrarily complex code that
contains stride, just stride).

Sure, if you nest it away in un-inlineable constructs then it won't be
easily optimised, but you wouldn't be able to use it as a template
parameter then anyway.


Again, this is just speculation, and not very credible. Why push it? Of 
course we could sit all day discussing what a sufficiently smart or 
sufficiently dumb compiler is and is not liable to do. The matter of 
fact is (a) yes, specializing a function for a particular parameter 
value is a known optimization; (b) it is mostly used for virtual methods 
to avoid vcall overheads, and in particular the compiler won't generate 
two separate large-ish functions for two separate parameter values.



Do you have a concrete example where the optimisation(s) you want to
occur cannot be done with `stride` as it is?


Of course. I've been working on such for a month. I cannot make the 
samples public for the time being. Point is, there's no need to.



Andrei



Re: std.database

2016-03-05 Thread Jacob Carlborg via Digitalmars-d

On 2016-03-05 11:23, Saurabh Das wrote:


A little late to the party, nevertheless: Thanks for doing this, it will
be super-helpful!

My only feature request will be: please make it work with minimal effort
with Vibe.D! :)


Yeah, that's really important. Unfortunately it looks like a 
synchronous interface is prioritized :(.


--
/Jacob Carlborg


Re: Why don't you use the Github issue system?

2016-03-05 Thread Jacob Carlborg via Digitalmars-d

On 2016-03-04 00:54, cym13 wrote:


We'd still lose all pull requests though and all discussions about them.
Does any, hmm, "pullrequestzilla" thing exist?


There's GitLab, which is basically like GitHub but it's open source and 
you can host it yourself. They do have hosting as well.


GitLab supports pull requests (they call it merge requests), issues, 
wiki, all the stuff that GitHub supports, plus they have a built-in CI 
system as well. They even have the "auto merge" feature built-in.


We use it at my job and it works really well.

--
/Jacob Carlborg


[Issue 15766] New: extern(Objective-C) should result in compile error on OS X 32bit

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15766

  Issue ID: 15766
   Summary: extern(Objective-C) should result in compile error on
OS X 32bit
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: d...@me.com

--


[Issue 15765] New: TypeInfo for C++ classes uses wrong vtbl

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15765

  Issue ID: 15765
   Summary: TypeInfo for C++ classes uses wrong vtbl
   Product: D
   Version: D2
  Hardware: All
OS: Linux
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: c...@dawg.eu

cat > bug.d << CODE
extern (C++) class RootObject
{
bool equals(RootObject o)
{
return o is this;
}

int compare(RootObject)
{
assert(0);
}

void print()
{
assert(0, "Should not get called");
}
}

void main()
{
bool[RootObject] aa;
aa[new RootObject] = true;
}
CODE

dmd -run bug


Because TypeInfo_Class casts every void* to a standard Object, it ends up
calling the wrong vtable entries for operations like getHash.

I think we need a dedicated TypeInfo_CppClass that is similar to
TypeInfo_Struct with it's xopEquals and xopHash in order to fix this bug.
C++ classes don't inherit from the common Object class, so those methods must
not exist.

--


Re: Pitching D to a gang of Gophers

2016-03-05 Thread John Colvin via Digitalmars-d

On Saturday, 5 March 2016 at 11:05:09 UTC, Dmitry Olshansky wrote:
I'm having an opportunity to do a small tech-talk on things D 
in a eCommerce shop that is currently sold on Go (migrating to 
SOA from PHP monolith). I do not intend that to become Go vs D 
battle but it gives the context.


[...]


Have you seen this? 
http://www.jtolds.com/writing/2016/03/go-channels-are-bad-and-you-should-feel-bad/ I'm not sure if it's all correct and how to compare the situation to D, but it was interesting to read.


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Dmitry Olshansky via Digitalmars-d

On 05-Mar-2016 14:11, Jakob Bornecrantz wrote:

On Saturday, 5 March 2016 at 11:05:09 UTC, Dmitry Olshansky wrote:

What features you'd highlight to enterprise-ish user?


Have go solved stacktraces in gorutines, last I checked this was a big
pain point for go developers, otherwise its a good issue to bring up.

Cheers, Jakob.


Sort of, yes - there is a tool that trims down stacktraces from 
irrelevant goroutines on panic if that is what you refer to. Also it's 
done by default in the latest v1.6.


--
Dmitry Olshansky


Re: Pitching D to a gang of Gophers

2016-03-05 Thread Jakob Bornecrantz via Digitalmars-d

On Saturday, 5 March 2016 at 11:05:09 UTC, Dmitry Olshansky wrote:

What features you'd highlight to enterprise-ish user?


Have go solved stacktraces in gorutines, last I checked this was 
a big pain point for go developers, otherwise its a good issue to 
bring up.


Cheers, Jakob.


Pitching D to a gang of Gophers

2016-03-05 Thread Dmitry Olshansky via Digitalmars-d
I'm having an opportunity to do a small tech-talk on things D in a 
eCommerce shop that is currently sold on Go (migrating to SOA from PHP 
monolith). I do not intend that to become Go vs D battle but it gives 
the context.


What guys seem to like of Go from my observation:
- goroutines instead of direct asynchronous programming*
- fast runtime with state of the art GC
- host of ready-made libraries esp. http & networking**
- lightweight OOP that doesn't get in your way
- tooling, tooling, tooling (IDE plugins and build tools work great)

*Note: all of standard I/O is transparently handled with goroutines much 
like vibe.d but goroutines are migrating across thread pool

** That being said there are tons of 1-man projects of dubious quality,

So far I'd thought of a few big themes:
- little nice things (slices/maps, things like 1_000_000 and e.g. a < b 
&& d < e is parse error, UFCS)
- code reuse (templates & ranges, with examples like generic min and 
some algo)

- compile-time works (CTFE, need simpler example then regex)

I'm still pondering whether I should dive into UDA, I'd try to stay 
simple as simplicity is one of things Go guys known to love.


What features you'd highlight to enterprise-ish user?

--
Dmitry Olshansky


Re: std.database

2016-03-05 Thread Saurabh Das via Digitalmars-d

On Tuesday, 1 March 2016 at 21:00:30 UTC, Erik Smith wrote:
I'm back to actively working on a std.database specification & 
implementation.  It's still unstable, minimally tested, and 
there is plenty of work to do, but I wanted to share an update 
on my progress.


[...]


A little late to the party, nevertheless: Thanks for doing this, 
it will be super-helpful!


My only feature request will be: please make it work with minimal 
effort with Vibe.D! :)


~ sd


[Issue 15760] Segfault when compiling when using __gshared and selective import.

2016-03-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15760

ag0ae...@gmail.com changed:

   What|Removed |Added

   Keywords||ice
 CC||ag0ae...@gmail.com

--


Re: std.database

2016-03-05 Thread Sebastiaan Koppe via Digitalmars-d

On Friday, 4 March 2016 at 23:55:55 UTC, Erik Smith wrote:
I think some basic object serialization capabilities would be 
great although I'm not sure how the bare names can be accessed 
like that through the rowSet How would that work?


I did a project a while back using mysql-native (see 
code.dlang.org) and it has a `toStruct` function on its Row type. 
Maybe have a look there.


To access the bare named RowSet would have to be templated on the 
struct.


Follows code from said project:

template executeAs(Type)
{
struct TypedSQLSequence
{
ResultSequence rs;
alias rs this;
@property Type front()
{
Row r = rs.front;
Type temp;
r.toStruct!Type(temp);
return temp;
}
}
auto executeAs(ref mysql.connection.ResultSequence rs)
{
return TypedSQLSequence(rs);
}
}


Re: A very interesting slide deck comparing sync and async IO

2016-03-05 Thread Sönke Ludwig via Digitalmars-d

Am 03.03.2016 um 18:31 schrieb Andrei Alexandrescu:

https://www.mailinator.com/tymaPaulMultithreaded.pdf

Andrei


A few points that come to mind:

- Comparing random different high-level libraries is bound to give 
results that measure abstraction overhead/non-optimal system API use. 
Comparing on a JVM instead of bare-metal might skew the results further 
(e.g. some JIT optimizations not kicking in due to the use of callbacks, 
or something like that). It would be interesting to redo the benchmark 
in C/D using plain system APIs.


- Comparing single-thread NBIO to multi-threaded BIO is obviously wrong 
when measuring peak-performance. NBIO should use a pool of on thread per 
core, each running an event/select loop, or alternatively using one 
process per core. The "Make better use of multi-cores" pro-BIO argument 
is pointless for that same reason.


- Missing any hints about how the benchmark was performed (e.g. 
send()/recv() chunk size). For anything other than tiny packets, NBIO 
for sure is not measurably slower than BIO. Latency may be a bit worse, 
but that reverses once many connections come into play.


- The "simpler to write" argument also breaks down when adding fibers to 
the mix.


- Main argument for NBIO is that threads are relatively heavy system 
resources, context switches are rather expensive, and are limited in 
their number (irrespective of the amount of RAM). Depending on the 
kernel, the scheduler overhead may also grow with the number of threads. 
For small numbers of connections, IO for sure is perfectly fine, as long 
as synchronization overhead isn't an issue.


- AIO/NBIO+fibers also allows to further reduce memory footprint by 
detaching the connection from the fiber between requests (e.g. for a 
keep-alive HTTP connection). This isn't possible with blocking IO.


- The optimal approach always depends on the system being modelled, 
NBIO+fibers simply gives the maximum flexibility in that regard. You can 
let fibers run in isolation on different threads, use synchronization 
between then, or you can have concurrency without CPU-level 
synchronization overhead within the same thread. Especially the latter 
can become really interesting with thread-local memory allocators etc. 
It also becomes really interesting in situations where 
thread-synchronization gets difficult (lock-less structures).


Re: A very interesting slide deck comparing sync and async IO

2016-03-05 Thread Ola Fosheim Grøstad via Digitalmars-d

On Friday, 4 March 2016 at 23:10:28 UTC, deadalnix wrote:
Not if it is hyper-threaded, as pairs of threads are sharing 
resources.


Irrelevant.


I knew you would say that, but you are wrong.

async do not make any sense on a DB. You want async when you 
are bound by a 3rd party system.


Err... no. You want async when you are CPU-bound and are looking 
for better latency and more control. On linux you can use async 
to bypass the kernel caches and access disk blocks, basically 
reimplementing things that are usually done in kernel space in 
your user space application (at the cost of adding significant 
complexity to your application).


What you get out of it depends on what you want, if you use a 
distributed setup, the drivers, the hardware and many other 
factors.




Whether there is a same module likt C#'s "Windows.Storage" NameSpace?

2016-03-05 Thread FrankLike via Digitalmars-d-learn

Hi,everyone,
Whether there is a module, like C#'s "Windows.Storage" 
NameSpace, you can operate the Android phone or ios phone, you 
can open the phone's folder on windows7?


Thank you .

Frank.