Mysql-native with LAMPP

2016-09-11 Thread Geert via Digitalmars-d-learn

Hi all!

I tried the client driver for MySQL/MariaDB "mysql-native".

https://github.com/mysql-d/mysql-native

Everything works well with an individually installed version of 
MySql. But I would like to know if there is a way to make D 
programms work with LAMPP/XAMPP. I'm getting this error message 
while executing the program:


host=localhost;port=3306;user=root;pwd=MY_testPa550;db=testdb
Failed: 
std.socket.SocketOSException@/build/ldc/src/ldc/runtime/phobos/std/socket.d(2822): Unable to connect socket: Connection refused




[Issue 16243] wrong C++ argument passing with empty struct and 6 integers

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16243

Martin Nowak  changed:

   What|Removed |Added

 CC||bra...@puremagic.com

--- Comment #7 from Martin Nowak  ---
(In reply to kinke from comment #4)
> clang doesn't pass empty structs at all for 32-bit, while GCC does. We have
> such a special case in LDC too for 32-bit OSX, where we assume clang, but
> not for 32-bit Linux, where we assume GCC. See
> https://github.com/ldc-developers/ldc/blob/master/gen/abi-x86.cpp#L214.

Thanks, assuming clang by default on OSX indeed seems like a reasonable
solution.
We also have that issue with GCC5's C++ ABI change
(http://developers.redhat.com/blog/2015/02/05/gcc5-and-the-c11-abi/), so
detecting the actual compiler might be helpful as well.

(In reply to Jacob Carlborg from comment #6)
> There's a long time since Apple switched to Clang. GCC is dead on Apple
> platforms. I've mentioned this several times that the autotester should
> switch to Clang.

Yes, would be good if we updated the auto-testers to use clang @Brad.

--


colour lib needs reviewers

2016-09-11 Thread Manu via Digitalmars-d
I think I'm about as happy with my colour lib as I'm going to be.
It really needs reviews.

I added packed-RGB support, including weird micro-float and
shared-exponent formats.
They're important for interacting with any real-time rendering libraries.
There is only one texture format I'm aware of that isn't supported,
and that is u7e3 floats, only available on Xbox360 ;)

Chromatic adaptation functions are in.
I've done a tidy/reorg pass.

I'm not sure what else should be in the scope of this lib.

PR: https://github.com/dlang/phobos/pull/2845
dub: https://code.dlang.org/packages/color
docs: 
http://dtest.thecybershadow.net/artifact/website-04a64e024cf75be39700bebd3a50d26f6c7bd163-7185c8ec7b15c9e785880cab6d512e6f/web/library-prerelease/std/experimental/color.html

- Manu


[Issue 16086] Imported function name shadows alias this member

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16086

Martin Nowak  changed:

   What|Removed |Added

   Priority|P1  |P2
   Severity|regression  |normal

--- Comment #2 from Martin Nowak  ---
This issue is not a result of the lookup change, but happens because tail was
newly added to std.range in 2.071.x.
Alias this and opDispatch was and still is resolved after an exhaustive search.
Might be worthwhile to think about performing alias this resolution before
searching imported modules, to avoid such breakage due to upstream library
changes.

--


Re: Struct default constructor - need some kind of solution for C++ interop

2016-09-11 Thread deadalnix via Digitalmars-d
On Sunday, 11 September 2016 at 12:11:43 UTC, David Nadlinger 
wrote:

On Sunday, 11 September 2016 at 11:33:14 UTC, Dicebot wrote:

On Sunday, 11 September 2016 at 08:37:56 UTC, deadalnix wrote:

On Sunday, 11 September 2016 at 06:09:01 UTC, Dicebot wrote:
Presence of compile-time valid T.init for any type T is 
absolutely critical for generic programming and must not be 
compromised.


WAT ?


Vast amount of traits operate on is(typeof(do stuff with 
T.init)) - all of them will return false negative for types 
with init disabled.


That's confusing an arbitrary implementation with necessity. 
lvalueOf!T/rvalueOf!T would be more than enough for these 
traits.


 — David


This.


[Issue 15897] private base class method not seen through derived class

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15897

Martin Nowak  changed:

   What|Removed |Added

 CC||renezwanenb...@gmail.com

--- Comment #20 from Martin Nowak  ---
*** Issue 15983 has been marked as a duplicate of this issue. ***

--


[Issue 15983] [REG 2.071] Symbol visibility in derived classes

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15983

Martin Nowak  changed:

   What|Removed |Added

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

--- Comment #1 from Martin Nowak  ---
You can get the base class like so.

void foo(T)(T t) if (is(T Base == super))
{
Base.Something something;
}

Still need to have all base classes in a the same module/package as the
function.
Would be interested to know, why you rely on duck typing of the base class.
Also maybe it's not worth to hide Something when it's a common property of your
class hierarchy.

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

--


[Issue 15897] private base class method not seen through derived class

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15897

--- Comment #19 from Martin Nowak  ---
(In reply to Sophie from comment #18)
> Isn't this what the "protected" access modifier is for?

Yes, protected would be the choice for inheriting a function.

Here the question was whether a private member of a base class, should be
visible for derived classes in the base class' module. Not revealing that
private member, b/c the derived class is in a different module, is a semantic
change introduced by DIP22, hence the deprecation.

--


[Issue 15903] [REG 2.071] module foo.bar is not accessible here, perhaps add 'static import foo.bar; (already there)

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15903

--- Comment #7 from Martin Nowak  ---
(In reply to Martin Nowak from comment #6)
> Comment 3 is clearly a duplicate of issue 15000.

issue 15900

--


[Issue 15903] [REG 2.071] module foo.bar is not accessible here, perhaps add 'static import foo.bar; (already there)

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15903

Martin Nowak  changed:

   What|Removed |Added

   Hardware|x86 |All
 OS|Mac OS X|All

--- Comment #6 from Martin Nowak  ---
Can't reproduce the issues of comment 0 and comment 4, please retest and
provide a complete test case.
Comment 3 is clearly a duplicate of issue 15000.

--


Re: Compiling vibe.d application for Amazon ec2 instance

2016-09-11 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, September 11, 2016 23:12:15 crimaniak via Digitalmars-d-learn 
wrote:
> Hi all!
>
> I made vibe-d application, and client give me already taken
> hosting for it on Amazon aws ec2, uname -a:
> Linux ip-xxx-xx-xx-xx 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1
> 22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>
> Compiled on my Ubuntu binary don't run because of different
> versions of libraries (on Amazon they older).
>
> I can try to install dmd to ec2 instance but don't think this is
> good idea. I want to compile binary on my developing machine (may
> be in specific OS in VirtualBox).
> How to resolve this problem by right way?
>
> Can I get VirtualBox image of ec2 version of Linux and use it on
> my machine?
> Can I compile all libraries used as static and make more
> independent binary?
> Something else?

I've never used EC2, so I don't know what it would take to be able to build
in the same environment locally (though I would certainly think that there
would be a way do to so, and I would assume that Amazon's documentation
talks about it somewhere). However, you can try just grabbing the .zip file
for dmd and putting that on your EC2 instance and using that to build your
program there - especially if you're in a hurry.

You can also try fully statically linking, but it's a bit of a pain, since
last time I checked it doesn't work right if you let dmd do the linking
command, which means that you have to use it to generate the object files
and then manually link them using gcc.

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

- Jonathan M Davis



iasm, unexpectedly slower than DMD production

2016-09-11 Thread Basile B. via Digitalmars-d-learn

I have this function, written in iasm:

°
T foo(T)(T x, T c)
if (is(T == float) || is(T == double))
{

version(none)
{
return x*x*x - x*x*c + x*c;
}
else asm
{
naked;
movsd   XMM3, XMM1;
mulsd   XMM0, XMM1;
mulsd   XMM1, XMM1;
movsd   XMM2, XMM1;
mulsd   XMM1, XMM3;
addsd   XMM1, XMM0;
mulsd   XMM0, XMM3;
subsd   XMM1, XMM0;
movsd   XMM0, XMM1;
ret;
}
}

void main()
{
// compile with -O -release
import std.datetime, std.stdio;
benchmark!({auto a = foo(0.2,0.2);})(1_000)[0].writeln;
}
°

The DMD production for the non-iasm version is

;--- SUB 004A7BD8h ---
004A7BD8h  sub rsp, 18h
004A7BDCh  movsd xmm5, xmm0
004A7BE0h  movsd xmm4, xmm1
004A7BE4h  movsd qword ptr [rsp], xmm1
004A7BE9h  movsd xmm0, qword ptr [rsp]
004A7BEEh  mulsd xmm0, xmm5
004A7BF2h  mulsd xmm1, xmm4
004A7BF6h  mulsd xmm1, xmm4
004A7BFAh  movsd xmm2, xmm4
004A7BFFh  mulsd xmm2, xmm4
004A7C03h  mulsd xmm2, xmm5
004A7C07h  subsd xmm1, xmm2
004A7C0Bh  addsd xmm0, xmm1
004A7C0Fh  add rsp, 18h
004A7C13h  ret
;-


When I change the version(none) to version(all), the benchmark is 
**7X** faster (e.g 410 against 3000 for the iasm version).


This difference doesn't look normal at all.
Does anyone know why ? The usage of the stack to move xmm1 in 
xmm0 is particularly strange...


Re: Writing Shared Libraries

2016-09-11 Thread Nicholas Wilson via Digitalmars-d

On Sunday, 11 September 2016 at 14:51:42 UTC, eugene wrote:

Hello everyone,
could you explain why here https://dlang.org/dll-linux.html 
says "Preliminary and subject to change." ?


see also http://dconf.org/2016/talks/thaut.html


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-11 Thread Joel via Digitalmars-d-announce

On Sunday, 11 September 2016 at 08:43:53 UTC, WebFreak001 wrote:

On Sunday, 11 September 2016 at 06:01:45 UTC, Joel wrote:
I just get this: Debug adapter process has terminated 
unexpectedly


can you run `gdb --interpreter=mi2` from the console? Or if you 
use lldb, can you run `lldb-mi` from the console? If not then 
vscode won't be able to. To be sure that it isn't anything 
because of the PATH, run vscode from the console where gdb and 
lldb-mi works and try again. If its crashing unexpectedly its 
didnt even run gdb or lldb. It might also be the unix domain 
sockets, but I don't think they should be the issue. Also check 
the debug console (console icon in debug menu) if there is any 
output at all


It says they're not found. How do I get them?


Re: @property Incorrectly Implemented?

2016-09-11 Thread Timon Gehr via Digitalmars-d

On 11.09.2016 14:02, Ethan Watson wrote:

On Sunday, 11 September 2016 at 07:19:54 UTC, John wrote:

...
The part I'm asking to be changed, you probably didn't even ever use.
C# is a managed language, I don't think you can even take the pointer
of anything unless you enable the unsafe switch.


... In C#
and in D, a property has *never* guaranteed the existence of a variable.
In both cases, they allow syntactic sugar for letting the getter/setter
pattern established by C++ look like variables.
...


His property returns by ref.



...

Take std.bitmanip for an example of what I was talking about. It
autogenerates properties for a bitfield. The types each property returns
and lets you set are not at all indicative of the datatype underneath as
it's literally just a bunch of bits. The property functions transform
the data types given/return to/from a bitfield. What exactly do you
suggest  return if it was to return a char starting at bit 13
of a bitfield?
...


Not a delegate. In a sane world, it would give you a compile error 
because 'property' is an rvalue.




But we can go one further. __traits( allMembers, Type ) and __traits(
getMember, Type ). Let's say you're writing an auto-serialisation
library (or take std.json as an example). Assuming a property is a
stand-in for another variable then what happens there when you're
checking for the type of a member is the delegate type, and later on
you'll get the actual variable. Now change it so that the type of a
property returns the actual type. Now you're serialising a piece of data
twice.
...


You do realize that typeof(property) is the type of the return value, 
right? Also, it's easy. Add __traits(isVariable,...) or 
__traits(isProperty,...), or just use .tupleof. Furthermore you can even 
get the property accessor function overload set using (a hypothetical) 
__traits(getPropertyAccessors,...).



But what if our @property function increments another variable inside a
class whenever you access it? That's pretty dangerous if you start
treating the property as an actual type instead of a function/delegate.

Thus, your example:

 // returns "ref int delegate()"
()   // ok returns "int*", but defeats purpose of @property
&(t.j = 10)  // shouldn't this return "ref int delegate(int)" ?

First one I'd expect.


Why? It's awful.


Second one I'd expect.


No, even more awful. typeof(t.x) is 'int'. You are not even supposed to 
be able to call an 'int'. The second one should be a compile error: 
"Error: function expected before (), not t.x of type int"



Third one I'd expect results in int*.


Agreed, that one is sane.


Compiling vibe.d application for Amazon ec2 instance

2016-09-11 Thread crimaniak via Digitalmars-d-learn

Hi all!

I made vibe-d application, and client give me already taken 
hosting for it on Amazon aws ec2, uname -a:
Linux ip-xxx-xx-xx-xx 4.4.11-23.53.amzn1.x86_64 #1 SMP Wed Jun 1 
22:22:50 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux


Compiled on my Ubuntu binary don't run because of different 
versions of libraries (on Amazon they older).


I can try to install dmd to ec2 instance but don't think this is 
good idea. I want to compile binary on my developing machine (may 
be in specific OS in VirtualBox).

How to resolve this problem by right way?

Can I get VirtualBox image of ec2 version of Linux and use it on 
my machine?
Can I compile all libraries used as static and make more 
independent binary?

Something else?



[Issue 16486] Compiler see template alias like a separate type in template function definition

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16486

ag0ae...@gmail.com changed:

   What|Removed |Added

 CC||ag0ae...@gmail.com

--- Comment #1 from ag0ae...@gmail.com ---
Reduced to the core:


struct TestType(T) {}
alias TestAlias(T) = TestType!T;
void testFunction(T)(TestAlias!T arg) {}

void main()
{
TestAlias!int testObj;
testFunction(testObj); /* "cannot deduce function from argument types
!()(TestType!int)" */
}


I don't think this is supposed to work.

It works when testFunction's parameter is TestType!T, because testObj's type
(TestType!int/TestAlias!int) carries the information that it's an instantiation
of template TestType with argument int.

But the compiler has no simple way of telling how TestType!int relates to
TestAlias!T. For example, TestAlias could be defined like this:


template TestAlias(T)
{
static if (is(T == float)) alias TestAlias = TestType!int;
else alias TestAlias = string;
}


With that, testFunction(TestType!int.init) would have to result in T = float.
And with testFunction("") the compiler would have multiple choices for T.

With the original TestAlias it's more straight-forward, but the compiler would
still have to analyze TestAlias's implementation. That's probably not feasible
(maybe impossible) in the general case.

Maybe simple cases could be supported. But that would be an enhancement
request, I think. And then there's always the question of where to draw the
line, and if it's not better to minimize surprises by just rejecting any such
code.

--


Re: Error while compiling and linking modules (mysql)

2016-09-11 Thread Geert via Digitalmars-d-learn

On Sunday, 11 September 2016 at 21:43:12 UTC, Geert wrote:

Hi!


I'm using a mysql wrapper (i don't even know how to use it yet) 
that i got from github:


https://github.com/adamdruppe/arsd


When i try to compile the code i get an error message:

Error: module mysql is in file 'mysql.d' which cannot be read


This is the folder structure i have:

/home/test/main.d
/home/test/arsd/mysql.d
/home/test/arsd/database.d

And the compile command:
ldc  main.d mysql.d database.d -I/home/test/arsd/


The main file contains a few lines just to test:

module compiling_test;
import arsd.mysql;
import arsd.database;


int main(string[] args) {


return 0;
}



I was passing the wrong paths. Te correct compile command is:

ldc  main.d arsd/mysql.d arsd/database.d 
-I/home/marduk/Proyectos/gtkd/sql/arsd


Virtual Methods hurting performance in the DMD frontend

2016-09-11 Thread Stefan Koch via Digitalmars-d

Hi,

As you may know I am currently optimizing template-related code 
inside of DMD.
Inside DMD code quality is quite high, there is little low 
hanging fruit.


However there is one thing that suspiciously often shows up the 
on profilers display.
Those are indirect class which have a high number of L2(!) 
i-cache misses.


These calls don't do a lot of work. They are needed either for 
downcasts or to verify the dynamic type of an AST-Node.
Even without the i-cache related stalls the call overhead alone 
is something to think about.


For template-heavy code matching template parameters is one of 
the most frequently operations.
Since Template Parameters can be types expressions or symbols the 
dynamic-types are heavily queried.


First experiments suggest that a speedup of around 12% is 
possible if the types where accessible directly.


Since dmd uses visitors for many things now the benefit of 
virtual methods is highly reduced.


Please share your thoughts.

Cheers,
Stefan


Error while compiling and linking modules (mysql)

2016-09-11 Thread Geert via Digitalmars-d-learn

Hi!


I'm using a mysql wrapper (i don't even know how to use it yet) 
that i got from github:


https://github.com/adamdruppe/arsd


When i try to compile the code i get an error message:

Error: module mysql is in file 'mysql.d' which cannot be read


This is the folder structure i have:

/home/test/main.d
/home/test/arsd/mysql.d
/home/test/arsd/database.d

And the compile command:
ldc  main.d mysql.d database.d -I/home/test/arsd/


The main file contains a few lines just to test:

module compiling_test;
import arsd.mysql;
import arsd.database;


int main(string[] args) {


return 0;
}



Bountysource salt

2016-09-11 Thread Nick via Digitalmars-d

Have you considered using Bountysource salt?
I can see there is a page on Bountysource salt, with the Dlang 
name on it[1], but it doesn't look like it's being used.


Nimlang[2] and Crystal[3] is using it with great success.

I think a lot of people would donate some money if you set some 
goals, made the page nice and posted an announcement about it ;)


Well, just a thought.

Regards, Nick

[1] - https://salt.bountysource.com/teams/d
[2] - https://salt.bountysource.com/teams/nim
[3] - https://salt.bountysource.com/teams/crystal-lang


[Issue 16487] New: Add function to obtain the available disk space

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16487

  Issue ID: 16487
   Summary: Add function to obtain the available disk space
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: jbc.enge...@gmail.com

Would be nice to have a function that returns the available disk space on a
given path (file, directory, server share).

Something like this:
```
// Returns ulong.max when the available disk space could not be determined.
ulong getAvailableDiskSpace(string path)
{
import std.string: toStringz;
version (WINDOWS)
{
import core.sys.windows.winbase;

ULARGE_INTEGER freeBytesAvailable;
auto pathCstr = (driveName(path) ~ dirSeparator).toStringz();
bool success = GetDiskFreeSpaceExW(path, , null,
null);
return success ? free_bytes.QuadPart : ulong.max;
}
else
{
import core.sys.posix.sys.statvfs;

statvfs_t stats;
int err = statvfs(path.toStringz(), );
return !err ? stats.f_bavail * stats.f_frsize : ulong.max;
}
}
```

--


[Issue 11331] Inefficient initialization of struct with members = void

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11331

gyroh...@gmail.com changed:

   What|Removed |Added

 CC||gyroh...@gmail.com

--- Comment #5 from gyroh...@gmail.com ---
Is anything being worked on to change this?

--


dub - load shared library (so) in example

2016-09-11 Thread MGW via Digitalmars-d-learn
I make a packet for dub in Linux. In a packet there is libQt.so 
which is loaded by an example of D. Usually I execute 
LD_LIBRARY_PATH='pwd'; export LD_LIBRARY_PATH, but now it is 
necessary to make it in dub. How to make it?


[Issue 16486] Compiler see template alias like a separate type in template function definition

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16486

b2.t...@gmx.com changed:

   What|Removed |Added

   Hardware|x86_64  |All
 OS|Windows |All

--


Re: [OT] Re: Let's kill 80bit real at CTFE

2016-09-11 Thread Stefan Koch via Digitalmars-d

On Sunday, 11 September 2016 at 14:52:18 UTC, Manu wrote:


That's cool, but surely unnecessary; the compiler should just 
hook

these and do it directly... They're intrinsics in every
compiler/language I've ever used! Just not DMD.
If your results are compatible, why not PR this implementation 
for

when ctfe in std.math?
Incidentally, this is how we used to do these operations in 
early
shader code, except cutting some corners for speed+imprecision 
;)


Hey I just made another PR, to fix PowExp!
It might as well depend on phobos :)


Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 11 September 2016 at 16:10:04 UTC, Mike Parker wrote:

And here, no memory is allocated. barSlice.ptr is the same as 
bar.ptr and barSlice.length is the same as bar.length. However, 
if you append a new element:


barSlice ~= 10;

The GC will allocate memory for a new array and barSlice will 
no longer point to bar. It will now have four elements.


I should clarify that this holds true for all slices, not just 
slices of static arrays. The key point is that appending to a 
slice will only allocate if the the .capacity property of the 
slice is 0. Slices of static arrays will always have a capacity 
of 0. Slices of slices might not, i.e. there may be room in the 
memory block for more elements.


Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 11 September 2016 at 15:15:09 UTC, Neurone wrote:

Hi,

Are there universal rules that I can apply to determine what 
types have reference or value semantics? I know that for the 
basic primitive C types (int, bool, etc) has value semantics.


Primitive types (int, bool, etc) and structs are passed by value 
unless a function parameter is annotated with 'ref'.


Classes are reference types, so given instance foo of class Foo, 
foo itself is a reference.


For arrays, it's easiest to think of one as a struct with two 
fields: length and ptr. The ptr field points to the memory where 
the array data is stored. When you pass an array to a function, 
the length & ptr are passed by value (it's a "slice"). That means 
that modifying the length of the array by adding or removing 
elements or attempting to change where ptr is pointing will only 
modify the local copy. You can modify the array elements in the 
original array (manipulate their fields, overwrite them, and 
such), but you can't modify the structure (length or pointer) of 
the original array unless the parameter is annotated with ref.


Although AAs don't have a length or ptr, they work similarly: you 
can modify the contents without ref, but can only modify the 
structure with.


In particular, I'm still trying to understand  stack vs 
GC-managed arrays, and slices.


Steven's article on slices should help [1]. It also helps if you 
just think of all dynamic arrays as slices.


int[] foo; // slice with length & ptr, no memory allocated for 
elements
int[3] bar; // static array with length & ptr, three ints 
allocated on the star


The memory for foo needs to be allocated somewhere. It might be 
the GC-managed heap, it might be malloc, it might even be stack 
memory. Doesn't matter.


You cannot modify the length of bar, but you can slice it:

auto barSlice = bar[];

And here, no memory is allocated. barSlice.ptr is the same as 
bar.ptr and barSlice.length is the same as bar.length. However, 
if you append a new element:


barSlice ~= 10;

The GC will allocate memory for a new array and barSlice will no 
longer point to bar. It will now have four elements.




Finally, I have an associative array, and I want to pass it 
into a function. The function is only reading data. Would 
putting ref on in function parameter pass it by reference?


You can easily test this:

```
void addElem(int[string] aa, string key, int val) {
aa[key] = val;
}

void main()
{
int[string] map;
map.addElem("key", 10);
import std.stdio : writeln;
writeln("The aa was modified: ", ("key" in map) != null);
}
```

AAs behave like arrays. The meta data (like the array length and 
ptr) is passed by value, the data by reference. The above should 
print false. Add ref to the function parameter, it will print 
true. However, if a key already exists in the aa, then you can 
modify it without ref as it isn't changing the structure of the 
aa. The following will print 10 whether the aa parameter is ref 
or not.


```
void addElem(int[string] aa, string key, int val) {
aa[key] = val;
}

void main()
{
int[string] map;
map["key"] = 5;
map.addElem("key", 10);
import std.stdio : writeln;
writeln("The value of key is ", map["key"]);
}
```
[1] https://dlang.org/d-array-article.html




[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

--- Comment #8 from Sky Thirteenth  ---
(In reply to b2.temp from comment #7)
> (In reply to Sky Thirteenth from comment #6)
> > (In reply to b2.temp from comment #5)
> > > I confirm the misunderstanding. If you permit I would suggest you to close
> > > this one but to open a new issue using your second example. The first one
> > > really represented issue 6082. The second is perfectly clear.
> > 
> > Yes, sure.
> > But, you will create new one, or should I?
> 
> I wont, you will.

OK, thank you.

Here the new one https://issues.dlang.org/show_bug.cgi?id=16486

--


[Issue 16486] New: Compiler see template alias like a separate type in template function definition

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16486

  Issue ID: 16486
   Summary: Compiler see template alias like a separate type in
template function definition
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: major
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: sky.13th...@gmail.com

For example, here the type:
```
struct TestType(T, size_t size)
{
T[size] data;
}
```

And, for some reason, We want to have some aliases on it:
```
alias TestAliasA= TestType;
alias TestAliasB(T) = TestType!(T, 3);
```

Then We, obviously, somehow use them:
```
void testFunctionA(T)(TestType!(T, 3) arg)
{
writeln( arg );
}

void testFunctionB(T)(TestAliasA!(T, 3) arg)
{
writeln( arg );
}

void testFunctionC(T)(TestAliasB!T arg)
{
writeln( arg );
}
```

But there is the problem with usage of `testFunctionC`.
It cause compiler error. It just simply can not recognize
that TestAliasB!T and TestType!(int, 3) is the same type, 
rather than different.

Here complete example: https://dpaste.dzfl.pl/2c8e1c350182

--


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

--- Comment #7 from b2.t...@gmx.com ---
(In reply to Sky Thirteenth from comment #6)
> (In reply to b2.temp from comment #5)
> > I confirm the misunderstanding. If you permit I would suggest you to close
> > this one but to open a new issue using your second example. The first one
> > really represented issue 6082. The second is perfectly clear.
> 
> Yes, sure.
> But, you will create new one, or should I?

I wont, you will.

--


Re: Confusion over what types have value vs reference semantics

2016-09-11 Thread rikki cattermole via Digitalmars-d-learn

On 12/09/2016 3:15 AM, Neurone wrote:

Hi,

Are there universal rules that I can apply to determine what types have
reference or value semantics? I know that for the basic primitive C
types (int, bool, etc) has value semantics.

In particular, I'm still trying to understand  stack vs GC-managed
arrays, and slices.

Finally, I have an associative array, and I want to pass it into a
function. The function is only reading data. Would putting ref on in
function parameter pass it by reference?


Ok two questions here:
1) What constitutes value vs reference passing
2) Allocation location

So basically you have two "locations" where something can be stored, on 
the stack or the heap.
Now I put it in quotes because they are both in RAM somewhere so it 
doesn't matter too much. The only difference is only a subset of the 
stack is readily allocatable at any single function call.


So in regarding to what gets passed by value, well that is simple.
If it is a class, you're passing a few pointers as your reference.
All primal types including pointers are passed as values.

If you use ref, you turn a type into a pointer auto magically (a 
location in the stack most likely).


Just so you're aware, arrays are slices in D (excluding static arrays). 
They are simply a pointer + length.
So I suppose you can think of references and slices as a container of 
sorts for other values which get passed in.


Confusion over what types have value vs reference semantics

2016-09-11 Thread Neurone via Digitalmars-d-learn

Hi,

Are there universal rules that I can apply to determine what 
types have reference or value semantics? I know that for the 
basic primitive C types (int, bool, etc) has value semantics.


In particular, I'm still trying to understand  stack vs 
GC-managed arrays, and slices.


Finally, I have an associative array, and I want to pass it into 
a function. The function is only reading data. Would putting ref 
on in function parameter pass it by reference?


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

--- Comment #6 from Sky Thirteenth  ---
(In reply to b2.temp from comment #5)
> I confirm the misunderstanding. If you permit I would suggest you to close
> this one but to open a new issue using your second example. The first one
> really represented issue 6082. The second is perfectly clear.

Yes, sure.
But, you will create new one, or should I?

--


Re: Writing Shared Libraries

2016-09-11 Thread eugene via Digitalmars-d
On Sunday, 11 September 2016 at 14:54:00 UTC, rikki cattermole 
wrote:
This is why: 
https://github.com/dlang/dlang.org/commits/master/dll-linux.dd

thank you for the link


Total 4 commits including creation in 2013.

this is lol)))


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

--- Comment #5 from b2.t...@gmx.com ---
I confirm the misunderstanding. If you permit I would suggest you to close this
one but to open a new issue using your second example. The first one really
represented issue 6082. The second is perfectly clear.

--


Re: mysql-native v0.1.5

2016-09-11 Thread Nick Sabalausky via Digitalmars-d-announce

On 09/11/2016 07:02 AM, Emre Temelkuran wrote:

There is absolutely no proper documentation (only original's 2011 one).
This is why it's not popular.


Yea, I agree, it's an embarrassment. It's a top priority for 
mysqln-native at this point.


Re: Writing Shared Libraries

2016-09-11 Thread rikki cattermole via Digitalmars-d

On 12/09/2016 2:51 AM, eugene wrote:

Hello everyone,
could you explain why here https://dlang.org/dll-linux.html says
"Preliminary and subject to change." ?


This is why: https://github.com/dlang/dlang.org/commits/master/dll-linux.dd

Total 4 commits including creation in 2013.


Re: Should debug{} allow GC?

2016-09-11 Thread John Colvin via Digitalmars-d

On Sunday, 11 September 2016 at 07:46:09 UTC, Manu wrote:
I'm having a lot of trouble debugging @nogc functions. I have a 
number of debug functions that use GC, but I can't call them 
from @nogc code... should debug{} allow @nogc calls, the same 
as impure calls?


Yes please.


Writing Shared Libraries

2016-09-11 Thread eugene via Digitalmars-d

Hello everyone,
could you explain why here https://dlang.org/dll-linux.html says 
"Preliminary and subject to change." ?


Re: [OT] Re: Let's kill 80bit real at CTFE

2016-09-11 Thread Manu via Digitalmars-d
On 12 September 2016 at 00:31, Marco Leise via Digitalmars-d
 wrote:
> Am Sun, 11 Sep 2016 15:00:12 +1000
> schrieb Manu via Digitalmars-d :
>
>> On 9 September 2016 at 21:50, Stefan Koch via Digitalmars-d
>>  wrote:
>> > Hi,
>> >
>> > In short 80bit real are a real pain to support cross-platform.
>> > emulating them in software is prohibitively slow, and more importantly hard
>> > to get right.
>> > 64bit floating-point numbers are supported on more architectures and are
>> > much better supported.
>> > They are also trivial to use at ctfe.
>> > I vote for killing the 80bit handling at constant folding.
>> >
>> > Destroy!
>>
>> I just want CTFE '^^'. Please, can we have that?
>> It's impossible to CTFE any non-linear function. It's ridiculous, I
>> constantly want to generate a curve at compile time!
>
> I have experimented with a few iterative algorithms from
> around the web that are now in my module for "random stuff not
> in Phobos":
>
> /***
>  *
>  * Computes the arcus tangens at compile time.
>  *
>  **/
> enum ctfeAtan(real x)
> in
> {
> assert(x == x && abs(x) != real.infinity);
> }
> body
> {
> if (abs(x) == 0)
> return x;
>
> // Reduce x to <0.5 for effective convergence of the Taylor series.
> x /= 1 + sqrt(1 + x * x);
> x /= 1 + sqrt(1 + x * x);
>
> // Sum up Taylor series to compute atan().
> immutable xSqr = -x * x;
> real mul = x;
> real div = 1;
> real x_old;
> do
> {
> x_old = x;
> mul *= xSqr;
> div += 2;
> x += mul / div;
> }
> while (x !is x_old);
>
> // Compensate for the initial reduction by multiplying by 4.
> return 4 * x;
> }
>
>
> /***
>  *
>  * Computes the arcs sinus at compile time.
>  *
>  **/
> enum ctfeAsin(real x)
> in
> {
> assert(x.isWithin(-1,+1));
> }
> body
> {
> if (abs(x) == 0)
> return x;
>
> immutable div = 1 - x * x;
> return x / abs(x) * (div == 0 ? PI / 2 : ctfeAtan(sqrt(x * x / div)));
> }
>
>
> /***
>  *
>  * Computes `x` to the power of `y` at compile-time.
>  *
>  * Params:
>  *   x = The base value.
>  *   y = The power.
>  *
>  * Source:
>  *   http://stackoverflow.com/a/7710097/4038614
>  *
>  **/
> @safe @nogc pure nothrow
> real ctfePow(real x, real y)
> {
> if (y >= 1)
> {
> real temp = ctfePow( x, y / 2 );
> return temp * temp;
> }
>
> real low = 0, high = 1;
> real sqr = sqrt( x );
> real acc = sqr;
> real mid = high / 2;
>
> while (mid != y)
> {
> sqr = sqrt( sqr );
>
> if (mid <= y)
> {
> low = mid;
> acc *= sqr;
> }
> else
> {
> high = mid;
> acc *= 1 / sqr;
> }
>
> mid = (low + high) / 2;
> }
>
> return acc;
> }
>
>
> /***
>  *
>  * Computes the natural logarithm of `x`at compile time.
>  *
>  **/
> @safe @nogc pure nothrow
> FloatReg ctfeLog(FloatReg x)
> {
> if (x != x || x <= 0)
> return -FloatReg.nan;
> else if (x == 0)
> return -FloatReg.infinity;
> else if (x == FloatReg.infinity)
> return +FloatReg.infinity;
>
> uint m = 0;
> while (x <= ulong.max)
> {
> x *= 2;
> m++;
> }
>
> @safe @nogc pure nothrow
> static FloatReg agm(FloatReg x, FloatReg y)
> in
> {
> assert(x >= y);
> }
> body
> {
> real a, g;
> do
> {
> a = x; g = y;
> x = 0.5 * (a+g);
> y = sqrt(a*g);
> }
> while(x != a || y != g);
> return x;
> }
>
> return PI_2 / agm(1, 4/x) - m * LN2;
> }
>
>
> Especially the `log` function seemed like a good compromise
> between execution speed and accuracy. FloatReg is "the native
> float register type", but the way CTFE works it should be
> `real` anyways. The code is mostly not by me, but from
> StackOVerflow comments and Wikipedia. Most of 

Re: Should debug{} allow GC?

2016-09-11 Thread Manu via Digitalmars-d
On 11 September 2016 at 21:26, Q. Schroll via Digitalmars-d
 wrote:
> On Sunday, 11 September 2016 at 07:46:09 UTC, Manu wrote:
>>
>> I'm having a lot of trouble debugging @nogc functions. I have a number of
>> debug functions that use GC, but I can't call them from @nogc code... should
>> debug{} allow @nogc calls, the same as impure calls?
>
>
> Generally, there is more to consider. It makes no sense to allow impure
> debug inside a pure function and not to do so for other attributes. For
> nothrow, it is also quite annoying.

I'd make the same argument for nothrow, except that it's easy to just
wrap that in a `try{ mayThrow(); }catch{}`, so I don't think it needs
the same hack because a proper workaround exists.


[OT] Re: Let's kill 80bit real at CTFE

2016-09-11 Thread Marco Leise via Digitalmars-d
Am Sun, 11 Sep 2016 15:00:12 +1000
schrieb Manu via Digitalmars-d :

> On 9 September 2016 at 21:50, Stefan Koch via Digitalmars-d
>  wrote:
> > Hi,
> >
> > In short 80bit real are a real pain to support cross-platform.
> > emulating them in software is prohibitively slow, and more importantly hard
> > to get right.
> > 64bit floating-point numbers are supported on more architectures and are
> > much better supported.
> > They are also trivial to use at ctfe.
> > I vote for killing the 80bit handling at constant folding.
> >
> > Destroy!  
> 
> I just want CTFE '^^'. Please, can we have that?
> It's impossible to CTFE any non-linear function. It's ridiculous, I
> constantly want to generate a curve at compile time!

I have experimented with a few iterative algorithms from
around the web that are now in my module for "random stuff not
in Phobos":

/***
 * 
 * Computes the arcus tangens at compile time.
 *
 **/
enum ctfeAtan(real x)
in
{
assert(x == x && abs(x) != real.infinity);
}
body
{
if (abs(x) == 0)
return x;

// Reduce x to <0.5 for effective convergence of the Taylor series. 
x /= 1 + sqrt(1 + x * x);
x /= 1 + sqrt(1 + x * x);

// Sum up Taylor series to compute atan().
immutable xSqr = -x * x;
real mul = x;
real div = 1;
real x_old;
do
{
x_old = x;
mul *= xSqr;
div += 2;
x += mul / div;
}
while (x !is x_old);

// Compensate for the initial reduction by multiplying by 4.
return 4 * x;
}


/***
 * 
 * Computes the arcs sinus at compile time.
 *
 **/
enum ctfeAsin(real x)
in
{
assert(x.isWithin(-1,+1));
}
body
{
if (abs(x) == 0)
return x;

immutable div = 1 - x * x;
return x / abs(x) * (div == 0 ? PI / 2 : ctfeAtan(sqrt(x * x / div)));
}


/***
 * 
 * Computes `x` to the power of `y` at compile-time.
 *
 * Params:
 *   x = The base value.
 *   y = The power.
 * 
 * Source:
 *   http://stackoverflow.com/a/7710097/4038614
 *
 **/
@safe @nogc pure nothrow
real ctfePow(real x, real y)
{
if (y >= 1)
{
real temp = ctfePow( x, y / 2 );
return temp * temp;
}

real low = 0, high = 1;
real sqr = sqrt( x );
real acc = sqr;
real mid = high / 2;

while (mid != y)
{
sqr = sqrt( sqr );

if (mid <= y)
{
low = mid;
acc *= sqr;
}
else
{
high = mid;
acc *= 1 / sqr;
}

mid = (low + high) / 2;
}

return acc;
}


/***
 * 
 * Computes the natural logarithm of `x`at compile time.
 *
 **/
@safe @nogc pure nothrow
FloatReg ctfeLog(FloatReg x)
{
if (x != x || x <= 0)
return -FloatReg.nan;
else if (x == 0)
return -FloatReg.infinity;
else if (x == FloatReg.infinity)
return +FloatReg.infinity;

uint m = 0;
while (x <= ulong.max)
{
x *= 2;
m++;
}

@safe @nogc pure nothrow
static FloatReg agm(FloatReg x, FloatReg y)
in
{
assert(x >= y);
}
body
{
real a, g;
do
{
a = x; g = y;
x = 0.5 * (a+g);
y = sqrt(a*g);
}
while(x != a || y != g);
return x;
}

return PI_2 / agm(1, 4/x) - m * LN2;
}


Especially the `log` function seemed like a good compromise
between execution speed and accuracy. FloatReg is "the native
float register type", but the way CTFE works it should be
`real` anyways. The code is mostly not by me, but from
StackOVerflow comments and Wikipedia. Most of it is common
knowledge to every mathematician.

-- 
Marco



[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

Sky Thirteenth  changed:

   What|Removed |Added

 Status|RESOLVED|REOPENED
 Resolution|DUPLICATE   |---

--- Comment #4 from Sky Thirteenth  ---

(In addition to Sky Thirteenth from comment #3)
> (In reply to b2.temp from comment #2)
> > This is not a bug, this is issue 6082. IFTI doesn't support this yet.
> > 
> > *** This issue has been marked as a duplicate of issue 6082 ***
> 
> Sorry, but not we have some misunderstanding.
> 
> Question is not about a constructors. It about a types.
> 
> Here is more clear example: https://dpaste.dzfl.pl/2c8e1c350182

Template aliases does not work correct while it used with template functions.
Compiler just somehow can't understand that is the same type, rather than
different.

--


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

--- Comment #3 from Sky Thirteenth  ---
(In reply to b2.temp from comment #2)
> This is not a bug, this is issue 6082. IFTI doesn't support this yet.
> 
> *** This issue has been marked as a duplicate of issue 6082 ***

Sorry, but not we have some misunderstanding.

Question is not about a constructors. It about a types.

Here is more clear example: https://dpaste.dzfl.pl/2c8e1c350182

--


[Issue 6082] Constructors of templated types should be callable via IFTI

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6082

b2.t...@gmx.com changed:

   What|Removed |Added

 CC||sky.13th...@gmail.com

--- Comment #3 from b2.t...@gmx.com ---
*** Issue 16465 has been marked as a duplicate of this issue. ***

--


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

b2.t...@gmx.com changed:

   What|Removed |Added

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

--- Comment #2 from b2.t...@gmx.com ---
This is not a bug, this is issue 6082. IFTI doesn't support this yet.

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

--


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

b2.t...@gmx.com changed:

   What|Removed |Added

   Hardware|x86_64  |All
 OS|Windows |All

--- Comment #1 from b2.t...@gmx.com ---
1. I don't see the first function working.
(https://dpaste.dzfl.pl/2b462faf70b0). WHen you try to instantiate both gives
the same error.

2. If you don't do partial instantiation then your alias can be declared more
simply as 'alias TestAlias = TestType;'

3. The real problem you encounter here is that TestType template argument
cannot be deduced from the value passed to the constructor:

struct TestType(T)
{
T data;
}

void main()
{
auto a = TestType(0); // same error
}

This is exactly what happens when you call TestFunctionA.
For example you can replace the declaration by:

void testFunctionB(T)(T arg)
and if you call

testFunction(TestType(0));

you get exactly the same error.

--


Re: Voldemort Types on Reddit

2016-09-11 Thread Basile B. via Digitalmars-d

On Sunday, 11 September 2016 at 11:31:55 UTC, Walter Bright wrote:

On 9/11/2016 3:11 AM, Jack Stouffer wrote:

On Saturday, 10 September 2016 at 20:39:39 UTC, Walter Bright
I just like a D post with 1166 upvotes! I think that's a record 
for us, but maybe one of Andrei's got more?


And I do love that we coined the name "Voldemort Type" that has 
now entered the lexicon of programming jargon!


Curiously enough, almost the same post in 2012 only got 100 
upvotes:


https://www.reddit.com/r/programming/comments/telhj/voldemort_types_in_d/


Re: Templates do maybe not need to be that slow (no promises)

2016-09-11 Thread Stefan Koch via Digitalmars-d

There are more news.
I wrote about manual template in-lining before, which is a fairly 
effective in bringing down the compile-time.


Since templates are of course white-box, the compiler can do this 
automatically for you. Recursive templates will still incur a 
performance hit but the effects will be lessened. If that gets 
implemented.


I am currently extending dmds template-code to support more 
efficient template caching.





Re: Struct default constructor - need some kind of solution for C++ interop

2016-09-11 Thread David Nadlinger via Digitalmars-d

On Sunday, 11 September 2016 at 11:33:14 UTC, Dicebot wrote:

On Sunday, 11 September 2016 at 08:37:56 UTC, deadalnix wrote:

On Sunday, 11 September 2016 at 06:09:01 UTC, Dicebot wrote:
Presence of compile-time valid T.init for any type T is 
absolutely critical for generic programming and must not be 
compromised.


WAT ?


Vast amount of traits operate on is(typeof(do stuff with 
T.init)) - all of them will return false negative for types 
with init disabled.


That's confusing an arbitrary implementation with necessity. 
lvalueOf!T/rvalueOf!T would be more than enough for these traits.


 — David


Re: @property Incorrectly Implemented?

2016-09-11 Thread Ethan Watson via Digitalmars-d

On Sunday, 11 September 2016 at 07:19:54 UTC, John wrote:
You can't really take one sentence out of context, I didn't say 
it in the sense that it was completely broken to the point of 
being useless.


There's nothing out of context about it. Would it have made you 
feel better had I quoted your entire message knowing that I 
wouldn't have changed a word of the response?



But if that's how you want to play.

The part I'm asking to be changed, you probably didn't even 
ever use. C# is a managed language, I don't think you can even 
take the pointer of anything unless you enable the unsafe 
switch.


You're not showing a good grasp at all as to what a property is. 
In C# and in D, a property has *never* guaranteed the existence 
of a variable. In both cases, they allow syntactic sugar for 
letting the getter/setter pattern established by C++ look like 
variables.


This is important.

No, really.

Take std.bitmanip for an example of what I was talking about. It 
autogenerates properties for a bitfield. The types each property 
returns and lets you set are not at all indicative of the 
datatype underneath as it's literally just a bunch of bits. The 
property functions transform the data types given/return to/from 
a bitfield. What exactly do you suggest  return if it 
was to return a char starting at bit 13 of a bitfield?


But we can go one further. __traits( allMembers, Type ) and 
__traits( getMember, Type ). Let's say you're writing an 
auto-serialisation library (or take std.json as an example). 
Assuming a property is a stand-in for another variable then what 
happens there when you're checking for the type of a member is 
the delegate type, and later on you'll get the actual variable. 
Now change it so that the type of a property returns the actual 
type. Now you're serialising a piece of data twice.


But what if our @property function increments another variable 
inside a class whenever you access it? That's pretty dangerous if 
you start treating the property as an actual type instead of a 
function/delegate.


Thus, your example:

 // returns "ref int delegate()"
()   // ok returns "int*", but defeats purpose of 
@property
&(t.j = 10)  // shouldn't this return "ref int delegate(int)" 
?


First one I'd expect. Second one I'd expect. Third one I'd expect 
results in int*. You're getting the address of the results of the 
assign operation. Look at it this way: int val = (t.j = 10); 
You'd expect val and t.j to be 10, right? So why do you expect to 
get a ref int delegate(int) just because you ask for the address 
of it?


Like I said. Disagree. There's nothing that needs fixing here.


Re: Struct default constructor - need some kind of solution for C++ interop

2016-09-11 Thread Dicebot via Digitalmars-d

On Sunday, 11 September 2016 at 08:37:56 UTC, deadalnix wrote:

On Sunday, 11 September 2016 at 06:09:01 UTC, Dicebot wrote:
Presence of compile-time valid T.init for any type T is 
absolutely critical for generic programming and must not be 
compromised.


WAT ?


Vast amount of traits operate on is(typeof(do stuff with T.init)) 
- all of them will return false negative for types with init 
disabled.


Re: Voldemort Types on Reddit

2016-09-11 Thread Walter Bright via Digitalmars-d

On 9/11/2016 3:11 AM, Jack Stouffer wrote:

On Saturday, 10 September 2016 at 20:39:39 UTC, Walter Bright wrote:

https://www.reddit.com/r/programming/comments/523hm3/til_the_d_language_has_a_voldemort_type/



Boy oh boy, I just love in every D thread how we get the "my language can do
this too" arguments followed by everyone showing how they're not the same thing.

Mostly we leave it to the C++ people to do that in reddit threads (followed by
the C++ person posting some horrific macro and claiming victory), so it's nice
to see the C# people get in on the action.


I just like a D post with 1166 upvotes! I think that's a record for us, but 
maybe one of Andrei's got more?


And I do love that we coined the name "Voldemort Type" that has now entered the 
lexicon of programming jargon!


Re: Should debug{} allow GC?

2016-09-11 Thread Q. Schroll via Digitalmars-d

On Sunday, 11 September 2016 at 07:46:09 UTC, Manu wrote:
I'm having a lot of trouble debugging @nogc functions. I have a 
number of debug functions that use GC, but I can't call them 
from @nogc code... should debug{} allow @nogc calls, the same 
as impure calls?


Generally, there is more to consider. It makes no sense to allow 
impure debug inside a pure function and not to do so for other 
attributes. For nothrow, it is also quite annoying.


If no one has strong counterarguments, just file an enhancement 
request. Implementation of such should not be too difficult.


[Issue 16465] Template alias does not get unwrapped in templated functions

2016-09-11 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16465

Sky Thirteenth  changed:

   What|Removed |Added

   Severity|normal  |major

--


Re: mysql-native v0.1.5

2016-09-11 Thread Emre Temelkuran via Digitalmars-d-announce
There is absolutely no proper documentation (only original's 2011 
one).

This is why it's not popular.


Re: Should debug{} allow GC?

2016-09-11 Thread Jonathan M Davis via Digitalmars-d
On Sunday, September 11, 2016 17:46:09 Manu via Digitalmars-d wrote:
> I'm having a lot of trouble debugging @nogc functions. I have a number
> of debug functions that use GC, but I can't call them from @nogc
> code... should debug{} allow @nogc calls, the same as impure calls?

Probably. There might be some problems if a program relies on stuff being
@nogc, and it's compiled with -debug, and it uses code that uses the GC in
debug statements, but it _is_ -debug, and in most cases, I would expect
debug statements to be temporary rather than left in a library that was
distributed (which is the sort of place that it might actually become a
problem). Certainly, on the whole, I think that the reasons for disallowing
use of the GC in debug statements could just as easily be applied to using
impure code in debug statements, and we allow that precisely because it's so
useful for debugging.

- Jonathan M Davis



Re: Voldemort Types on Reddit

2016-09-11 Thread Jack Stouffer via Digitalmars-d
On Saturday, 10 September 2016 at 20:39:39 UTC, Walter Bright 
wrote:

https://www.reddit.com/r/programming/comments/523hm3/til_the_d_language_has_a_voldemort_type/


Boy oh boy, I just love in every D thread how we get the "my 
language can do this too" arguments followed by everyone showing 
how they're not the same thing.


Mostly we leave it to the C++ people to do that in reddit threads 
(followed by the C++ person posting some horrific macro and 
claiming victory), so it's nice to see the C# people get in on 
the action.


Re: Any video transcoding lib like this?

2016-09-11 Thread Guillaume Piolat via Digitalmars-d

On Saturday, 10 September 2016 at 11:03:44 UTC, Karabuta wrote:
Hello community, has anyone done a lib published/unpublihed in 
D like https://github.com/senko/python-video-converter . It was 
developed in python and uses ffmpeg behind the scene.


It works this way;

from converter import Converter
c = Converter()
info = c.probe('test1.ogg')

conv = c.convert('test1.ogg', '/tmp/output.mkv', {
'format': 'mkv',
'audio': {
'codec': 'mp3',
'samplerate': 11025,
'channels': 2
},
'video': {
'codec': 'h264',
'width': 720,
'height': 400,
'fps': 15
}})

for timecode in conv:
print "Converting (%f) ...\r" % timecode


Your best bet for now is to use ffmpeg directly: 
http://code.dlang.org/packages/ffmpeg-d


Re: Copy a struct and its context

2016-09-11 Thread Rene Zwanenburg via Digitalmars-d-learn

On Sunday, 11 September 2016 at 05:44:13 UTC, Yuxuan Shui wrote:
I recently noticed nested struct capture its context by 
reference (which, BTW, is not mentioned at all here: 
https://dlang.org/spec/struct.html#nested). And bliting a 
struct obviously doesn't do a deep copy of its context.


So my question is, is there a way to deep copy the context of a 
struct?


I've tried a few things, but I don't think you can. The root 
issue is that the context pointer is void*, so you can't do 
meaningful reflection on it.


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-11 Thread WebFreak001 via Digitalmars-d-announce

On Sunday, 11 September 2016 at 06:01:45 UTC, Joel wrote:
I just get this: Debug adapter process has terminated 
unexpectedly


can you run `gdb --interpreter=mi2` from the console? Or if you 
use lldb, can you run `lldb-mi` from the console? If not then 
vscode won't be able to. To be sure that it isn't anything 
because of the PATH, run vscode from the console where gdb and 
lldb-mi works and try again. If its crashing unexpectedly its 
didnt even run gdb or lldb. It might also be the unix domain 
sockets, but I don't think they should be the issue. Also check 
the debug console (console icon in debug menu) if there is any 
output at all


Re: Struct default constructor - need some kind of solution for C++ interop

2016-09-11 Thread deadalnix via Digitalmars-d

On Sunday, 11 September 2016 at 06:09:01 UTC, Dicebot wrote:
Presence of compile-time valid T.init for any type T is 
absolutely critical for generic programming and must not be 
compromised.


WAT ?


Should debug{} allow GC?

2016-09-11 Thread Manu via Digitalmars-d
I'm having a lot of trouble debugging @nogc functions. I have a number
of debug functions that use GC, but I can't call them from @nogc
code... should debug{} allow @nogc calls, the same as impure calls?


Re: @property Incorrectly Implemented?

2016-09-11 Thread John via Digitalmars-d
On Tuesday, 6 September 2016 at 19:37:26 UTC, Jonathan M Davis 
wrote:
On Tuesday, September 06, 2016 19:18:11 John via Digitalmars-d 
wrote:
Currently it seems that @property isn't implemented correctly. 
For some reason when you try to get the pointer of a property 
it returns a delegate for some reason. This just seems plain 
wrong, the whole purpose of a property is for a function to 
behave as if it weren't a function. There's also some 
inconsistencies in the behavior, "get" is implemented one way 
and then "set" is implemented another.


http://ideone.com/ZgGT2G

  // returns "ref int delegate()"
 ()   // ok returns "int*", but defeats purpose of
@property
 &(t.j = 10)  // shouldn't this return "ref int 
delegate(int)"

?

It would be nice to get this behavior fixed, so that it 
doesn't become set in stone. I think returning a delegate 
pointer is not what people would except nor is there really 
any use case for it.


Okay. How would it work to safely get a pointer to anything but 
the @property function when taking its address? () is just 
going to give you the address of the return value - which in 
most cases, is going to be a temporary, so if that even 
compiles in most cases, it's a bit scary. Sure, if the 
@property function returns by ref, then it can work, but an 
@property function which returns by ref isn't worth much, since 
you're then giving direct access to the member variable which 
is what an @property function is usually meant to avoid. If you 
wanted to do that, you could just use a public member variable.


So, given that most @property functions are not going to return 
by ref, how does it make any sense at all for taking the 
address of an @property function to do anything different than 
give you a delegate? Sure, that's not what happens when you 
take the address of a variable, but you're not dealing with a 
variable. You're dealing with an @property function which is 
just trying to emulate a variable.


The reality of the matter is that an @property function is 
_not_ a variable. It's just trying to emulate one, and that 
abstraction falls apart _really_ fast once you try and do much 
beyond getting and setting the value - e.g. passing by ref 
falls flat on its face. We could do better than currently do 
(e.g. making += lower to code that uses both the getter and the 
setter when the getter doesn't return by ref), but there are 
some areas where a property function simply can't act like a 
variable, because it isn't one. There isn't even a guarantee 
that an @property function is backed by memory. It could be a 
completely calculated value, in which case, expecting to get an 
address of a variable when taking the address of the @property 
function makes even less sense.


- Jonathan M Davis


I don't see how that would be a problem, you can't take the 
address of an rvalue... The problem you describe would be true 
for functions as well. What's not true is that it is compilable 
(see: http://ideone.com/MXhkXC ). Any problem you can conjure up 
about references, temporary values and pointers, all of that 
would be true for a regular function as well.


Obviously it is not a variable, but if you use a function and it 
returns a reference and you take the address of it. What you get 
is the address of the returned value not of the function. int v = 
obj.prop; if you look at that "prop" is a called function 
pretending to be a variable. If you take the address of a called 
function, you get the address of the returned variable, not the 
function. If you take the address of a variable, you get the 
address of the variable.


On Wednesday, 7 September 2016 at 07:44:05 UTC, Ethan Watson 
wrote:

On Tuesday, 6 September 2016 at 19:18:11 UTC, John wrote:

It would be nice to get this behavior fixed.


Disagree. I've used properties before in C# to transform to and 
from data sets required for network multiplayer. It works 
functionally the same way in D. Behaviour is as I would expect 
for the wider implications of how properties can work.


You can't really take one sentence out of context, I didn't say 
it in the sense that it was completely broken to the point of 
being useless. The part I'm asking to be changed, you probably 
didn't even ever use. C# is a managed language, I don't think you 
can even take the pointer of anything unless you enable the 
unsafe switch.



On Tuesday, 6 September 2016 at 19:34:59 UTC, ag0aep6g wrote:

On 09/06/2016 09:18 PM, John wrote:
&(t.j = 10)  // shouldn't this return "ref int 
delegate(int)" ?


`` should and does. With `= 10`, it's definitely a call, 
just like `()`.


It would be nice to get this behavior fixed, so that it 
doesn't become

set in stone.


Unfortunately, it already kinda is. Just flipping the switch 
would break circa all D code in existence. That's deemed 
unacceptable by the leadership, as far as I know.


Don't really see that to be true. I don't see any use case for 
taking the address of the 

Re: From the D Blog -- GSoC Report: Step

2016-09-11 Thread Yuxuan Shui via Digitalmars-d-announce

On Friday, 9 September 2016 at 18:46:30 UTC, jmh530 wrote:

On Friday, 9 September 2016 at 18:22:02 UTC, ciechowoj wrote:


I'm not sure about any special syntax which is expected for 
languages which have built-in sets. It would probably be 
overkill to add syntax support, but I'm not sure how often 
people use set literals or not.


E.g. Python has build in literals for sets. C++ has sets in 
standard library. I see the points against adding something 
like this to the core of language, but it should be at least 
in the standard library.


You might find the following SO question informative.

http://stackoverflow.com/questions/7162274/why-is-d-missing-container-classes


That was 5 years ago! Why do things move so slowly...


Re: Struct default constructor - need some kind of solution for C++ interop

2016-09-11 Thread Dicebot via Digitalmars-d
Presence of compile-time valid T.init for any type T is 
absolutely critical for generic programming and must not be 
compromised.


Re: workspace-d 2.7.2 & code-d 0.10.14

2016-09-11 Thread Joel via Digitalmars-d-announce

On Friday, 9 September 2016 at 19:45:37 UTC, WebFreak001 wrote:

On Friday, 9 September 2016 at 09:39:23 UTC, Joel wrote:
On Tuesday, 6 September 2016 at 21:05:43 UTC, WebFreak001 
wrote:
I just pushed a new release of workspace-d (bridge between 
DCD, DScanner, dfmt and dub with some utility stuff) and 
code-d (my vscode D extension using workspace-d).


[...]


With OSX. I can't seem to get the debug and autocompletion 
(import std.a..). I just have a bit of text highlighting 
working. I've installed the programs and have them in the PATH.


OSX is known to not work because it hangs up somewhere in 
workspace-d. See this issue for more infos: 
https://github.com/Pure-D/code-d/issues/29


However debug (using native debug -> ext install 
webfreak.debug) should work because it just uses gdb or lldb-mi


I just get this: Debug adapter process has terminated unexpectedly