Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn

On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote:

On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote:
On Windows 7 it's work fine. On Windows 10 (clean install) 
it's do not start and require MSVCR120.dll


D doesn't make particularly heavy use of the C runtime, so 
there's a good chance you can link against a different C 
runtime DLL — preferably one that's always available by default 
like msvcrt.dll.


How can I link with msvcrt.dll ?


Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 09:54:43 UTC, Suliman wrote:

On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote:

On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote:
On Windows 7 it's work fine. On Windows 10 (clean install) 
it's do not start and require MSVCR120.dll


D doesn't make particularly heavy use of the C runtime, so 
there's a good chance you can link against a different C 
runtime DLL — preferably one that's always available by 
default like msvcrt.dll.


How can I link with msvcrt.dll ?


Or maybe there is way to statically link with MSVCR120.dll?


Best Object storage/cloud file storage for vibe.d

2017-01-18 Thread aberba via Digitalmars-d

There are s3, Rackspace(restful api), ...

Which one will you recommended for easy and flexible usuage in 
D(vibe.d) app hosted on Heroku? Pros and cons.


Re: GNU License warning:

2017-01-18 Thread Kagamin via Digitalmars-d

On Friday, 13 January 2017 at 02:25:03 UTC, Ignacious wrote:
Licenses should be more specific in their terminology and their 
behaviors and effects rather than using arbitrary divisions.


If your plugin uses contrived API riddled with all good C(++) 
misfeatures to customize like 80% of program's functionality - it 
thus creates a competing proprietary product, which is what GPL 
tries to prevent. AFAIK it doesn't allow you to use complex API 
with out of process plugins either. With this division of API GPL 
tries to control what a plugin can do to the host application, 
namely it tries to keep degree of integration and complexity of 
the plugin API low. If you know a better way to do it, you can 
propose it to FSF, that's also why GPL addresses automatic 
license upgrade.


[Issue 17065] [REG2.072] Unique does not work with private members

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

--- Comment #6 from dran...@gmail.com ---
(In reply to Martin Nowak from comment #5)
> I'm for reverting this change (the Proxy part).

I agree.

But I suggest reverting all of PR #4763: the Proxy part and the destroy part.
The latter also because it introduces undeterministic destruction of
Unique!structs (see [1], there is no bug report for this yet, I guess).

[1] http://forum.dlang.org/post/ixxkijrdlffflfzkk...@forum.dlang.org

--


Re: Gui in D: I miss this project

2017-01-18 Thread aberba via Digitalmars-d

On Monday, 16 January 2017 at 07:38:31 UTC, Jacob Carlborg wrote:

On 2017-01-16 07:28, Vadim Lopatin wrote:

Windows support in DlangUI is not native since it does not use 
native

controls.
DlangUI draws widgets itself on all platforms. But on Win32 
it's
possible to build app which uses Win32 API only, and no 
additional DLLs
will be required to run it. On Linux and Mac, there is extra 
dependency

- libSDL2.


For most application on macOS, a non-native GUI library is not 
interesting.


What about Photoshop? Is it native? No.


Re: Printing a floats in maximum precision

2017-01-18 Thread kinke via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 03:36:39 UTC, Nicholas Wilson 
wrote:
Alternatively use %a to print in hex to verify exact bit 
patterns.


+1, if it doesn't have to be human-readable.


Language server protocol implementation for D

2017-01-18 Thread xtreak via Digitalmars-d
Rust is making good progress on the IDE aspect with the 
announcement : 
http://www.jonathanturner.org/2017/01/rls-alpha-release.html. HN 
discussion : https://news.ycombinator.com/item?id=1348


It will be good to see the protocol implemented so that many 
tools and IDEs can use the interface to provide better tooling 
for development.


https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations


Berlin D Meetup January 2017

2017-01-18 Thread Ben Palmer via Digitalmars-d-announce

Hi All,

Apologies again for the late notice but the first D meetup of 
2017 in Berlin is happening this Friday (20th) at 19:30 at Berlin 
Co-Op (http://co-up.de/) on the fifth floor.


Nemanja Boric is going to be talking about his experience 
exploring Phobos while implementing a Postgresql on-wire protocol 
and client API. This is a pioneer D2 project for a D1 programmer 
(https://github.com/Burgos/postgres-native).


More details are available on the meetup page here: 
https://www.meetup.com/Berlin-D-Programmers/events/236895809/


Thanks,
Ben.


Plugin for 1C:Enterprise in dmd

2017-01-18 Thread MGW via Digitalmars-d-announce
I managed to create plugin for 1C:Enterprise 
(http://1c.ru/eng/title.htm).
The major difficulty in realization C++ interfaces is 
successfully overcome.
I need a more detailed description of compatibility of 
structures, classes and interfaces between C++ and D.


For clarity you can see this short video 
https://www.youtube.com/watch?v=apLppufZulI




Cannot use auto ref passing in expression template operator overloads

2017-01-18 Thread Nordlöw via Digitalmars-d

I'm currently writing a high-level GMP-wrapper at

https://github.com/nordlow/gmp-d

In order to get efficient scheduling of calls to C API 
__gmpz-functions, I want expressions such as


MpZ(3) + MpZ(4)

to return an instance of a lazy expression `MpzAddExpr` if and 
only if *both* it's arguments are passed by move to the 
`MpzAddExpr`-constructor. This is possible to statically detect 
in `auto-ref`-passing *free* functions such as


auto add()(auto ref const MpZ a, auto ref const MpZ b)
{
static if (!isRef!a && !isRef!b) // both r-values
{
// PROBLEM!!!: this case cannot be implemented
// in operator overloads because
// __traits(isRef, this) is incorrectly always true

// safe @nogc and no-RC lazy evaluation is possible
return MpZAddExpr!(MpZ, MpZ)(move(a), move(b));
}
else static if (!isRef!a) // r-value a
{
// `a` is an r-value and can be added in-place as
mpz_add(a._ptr, a._ptr, b._rhs)
return move(a); of type MpZ
}
else static if (!isRef!b) // r-value b
{
// `b` is an r-value and can be added in-place as
mpz_add(b._ptr, b._ptr, a._rhs) // commutative
return move(b); // of type MpZ
}
else // both references
{
// direct evaluation is needed
Z c; // separate allocation needed
mpz_add(c._ptr, a._ptr, b._ptr);
return c; // of type MpZ
}
}

because parameters are passed by D's clever `auto-ref` semantics. 
But the same behaviour *cannot* be implemented using operator 
overloads for, in this case, `opBinary`-plus.


The problem boils down to the fact that

__traits(isRef, this)

in members such as

struct S
{
opUnary(string)() if (s == "-")
{
pragma(msg, __traits(isRef, this));
}
}

evaluates to true in expressions such as

-(S.init)

eventhough `S` here clearly is an r-value.

This blocks the library from applying nice optimizations during 
the evaluation of these lazily-evaluted expressions if operator 
oveloading is to be used.


I expected this to be fixed by qualifying the member as `auto ref`

opUnary(string)() auto ref if (s == "-")

but that errors.

Is this by design or by accident?

Is there a way around this problem?

For details see

MpZ at https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L38
MpZAddExpr 
https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L1835


Re: Cannot use auto ref passing in expression template operator overloads

2017-01-18 Thread Eugene Wissner via Digitalmars-d

On Wednesday, 18 January 2017 at 10:49:43 UTC, Nordlöw wrote:

Is there a way around this problem?


I had the same problem with opSliceAssign, opIndexAssign lately.


Re: iterating through members of bitfields

2017-01-18 Thread Nestor via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 01:15:05 UTC, Ali Çehreli wrote:
Not available but it should be possible to parse the produced 
code:


import std.bitmanip;

string makeBitFieldPrinter(string fieldImpl) {
return q{
void printBitFields() const {
import std.stdio: writeln;
writeln("Please improve this function by parsing 
fieldImpl. :)");

}
};
}

struct S {
enum myFields = bitfields!(int, "a", 24,
   byte, "b", 8);

pragma(msg, "This is the mixed-in bit field 
code\n-\n",

   myFields, "\n--");


mixin (myFields);
mixin (makeBitFieldPrinter(myFields));
}

void main() {
const s = S();
s.printBitFields();
}

Of course that would depend on the implementation of 
bitfields(), which can change without notice.


Ali


Thanks Ali, I was using bitfields according to documentation, but 
now I see that way I can't access the mixin string:


struct S {
mixin(bitfields!(
bool, "f1",1,
uint, "f2",4,
uint, "f3",3)
);
}




Re: iterating through members of bitfields

2017-01-18 Thread drug via Digitalmars-d-learn
I've "solved" the same problem by using AliasSeq to generate bitfields 
so that for iterating over bitfields I can iterate over alias sequence 
and mixin code. Not very good but it works.


[Issue 8471] std.stdio.readf should be @trusted

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

--- Comment #6 from Jakub Łabaj  ---
Currently I see one way to break the safety, which is to not pass a real
pointer, but a structure with unary '*' overloaded:

@safe unittest
{
struct Unsafe
{
int* x;
ref int opUnary(string s)() if (s == "*")
{
int y;
// int* ptr =  // not @safe
return *x;
}
}
static int x;
static Unsafe unsafe;
unsafe.x = 
string text = "10";
formattedRead(text, "%d ", unsafe); // called by readf
assert(*unsafe.x == 10);
}

Probably I can't mess up assignment operator nor constructor, because only
builtin types are parsable (constrained by function unformatValue). So I think
making formattedRead / readf accepting only pointers to builtin types is a way
to make them @trusted.

--


Re: Language server protocol implementation for D

2017-01-18 Thread Atila Neves via Digitalmars-d

On Wednesday, 18 January 2017 at 09:31:49 UTC, xtreak wrote:
Rust is making good progress on the IDE aspect with the 
announcement : 
http://www.jonathanturner.org/2017/01/rls-alpha-release.html. 
HN discussion : https://news.ycombinator.com/item?id=1348


It will be good to see the protocol implemented so that many 
tools and IDEs can use the interface to provide better tooling 
for development.


https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations


I saw that today and was considering making a D implementation my 
next pet project.


Atila


Re: Where is floating point next{Up,Down}?

2017-01-18 Thread pineapple via Digitalmars-d-learn

On Tuesday, 17 January 2017 at 23:41:27 UTC, Nordlöw wrote:

On Tuesday, 17 January 2017 at 23:38:46 UTC, Ali Çehreli wrote:

Found'em! :)

  https://dlang.org/phobos/std_math.html#.nextUp


Thanks!


(Shouts into the soundless void) 
https://github.com/pineapplemachine/mach.d/blob/master/mach/math/floats/neighbors.d


Re: Language server protocol implementation for D

2017-01-18 Thread Guillaume Piolat via Digitalmars-d

On Wednesday, 18 January 2017 at 09:31:49 UTC, xtreak wrote:
Rust is making good progress on the IDE aspect with the 
announcement : 
http://www.jonathanturner.org/2017/01/rls-alpha-release.html. 
HN discussion : https://news.ycombinator.com/item?id=1348


It will be good to see the protocol implemented so that many 
tools and IDEs can use the interface to provide better tooling 
for development.


https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations


This is very important, this protocol is used by Eclipse, VSCode, 
and will take over tooling. This will decorrelate language 
services and IDEs.

Meetings with people from many code editors led to this standard.


Re: Cannot use auto ref passing in expression template operator overloads

2017-01-18 Thread Nordlöw via Digitalmars-d

On Wednesday, 18 January 2017 at 10:49:43 UTC, Nordlöw wrote:

https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L1835


Should be

https://github.com/nordlow/gmp-d/blob/master/src/gmp.d#L1853


Re: Language server protocol implementation for D

2017-01-18 Thread rikki cattermole via Digitalmars-d

On 19/01/2017 1:29 AM, Atila Neves wrote:

On Wednesday, 18 January 2017 at 09:31:49 UTC, xtreak wrote:

Rust is making good progress on the IDE aspect with the announcement :
http://www.jonathanturner.org/2017/01/rls-alpha-release.html. HN
discussion : https://news.ycombinator.com/item?id=1348

It will be good to see the protocol implemented so that many tools and
IDEs can use the interface to provide better tooling for development.

https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations



I saw that today and was considering making a D implementation my next
pet project.

Atila


That would be absolutely amazing!


[Issue 12125] Win64 phobos has hard references to LIBCMT

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

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

https://github.com/dlang/druntime/commit/0dc5d1dd68c2bcffb9a501f2e37ff28be3abd87e
Merge pull request #1691 from rainers/nodefaultlib

--


Re: Language server protocol implementation for D

2017-01-18 Thread Guillaume Piolat via Digitalmars-d
On Wednesday, 18 January 2017 at 11:46:10 UTC, Guillaume Piolat 
wrote:

https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations


This is very important, this protocol is used by Eclipse, 
VSCode, and will take over tooling. This will decorrelate 
language services and IDEs.
Meetings with people from many code editors led to this 
standard.


And it's unclear if workspace-d is an implementation of LSP or 
not (but it seems close).

https://github.com/Pure-D/workspace-d


Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?


Re: Returning Arrays from Functions

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 22:51:17 UTC, Samwise wrote:

numbs[] = getInp(help, file, inp, args);


This is wrong, try just `numbs = getImp(...);`

numbs[] = xxx will copy stuff into the existing array, which is 
empty right now. You want to jut keep the slice the function 
passes back.


Re: Gui in D: I miss this project

2017-01-18 Thread rikki cattermole via Digitalmars-d

On 19/01/2017 10:00 AM, aberba wrote:

On Wednesday, 18 January 2017 at 17:51:18 UTC, Jacob Carlborg wrote:

On 2017-01-18 10:24, aberba wrote:


What about Photoshop? Is it native? No.


Last time I used it it didn't look very native.


So it will be incorrect to say native gui is a requirement to fain
higher adoption.


Photoshop is one of the oldest programs still in use today commercially.
It has more holes in its licensing then a sieve. I wouldn't look towards 
it for best practices.


__traits(isRef, this) cannot distinguish l-value- from r-value-passed this

2017-01-18 Thread Nordlöw via Digitalmars-d-learn

A compilation of


struct T
{
int x;

@disable this(this); // this has no effect on the issue

ref inout(T) memberFun() inout
{
pragma(msg, "memberFun:", __traits(isRef, this) ? "ref" : 
"non-ref", " this");

return this;
}
}

void freeFun()(auto ref const T x)
{
pragma(msg, "freeFun:", __traits(isRef, x) ? "ref" : 
"non-ref", " this");

}

unittest
{
T t;

freeFun(t); // `param` passed by reference
freeFun(T.init); // `param` passed by move

t.memberFun(); // `this` passed by what?
T.init.memberFun(); // `this` passed by what?
}


currently prints


memberFun:non-ref this
freeFun:ref this
freeFun:non-ref this


That is, we cannot distinguish an l-value-call to `memberFun` 
from an r-value-call. Opposite to what we can when combining 
`auto ref`-parameters with `__traits(isRef)` as shown with 
function `freeFun` in the code example above.


Disabling the postblit has no effect on the issue.

I need this for enabling efficient delayed evaluation for unary 
and binary arithmetic operators in my GNU MP wrapper described 
earlier at


http://forum.dlang.org/thread/plqysfanwuoiuslfy...@forum.dlang.org

Any clues on how to retrieve this information?


Re: switch statement with variable branches

2017-01-18 Thread Ali Çehreli via Digitalmars-d-learn

On 01/18/2017 05:22 PM, Yuxuan Shui wrote:

Somehow I can't use ubyte variables behind 'case', but ulong works fine.
Why is that?

void main() {
alias TestType = ulong; // won't compile if = ubyte
import std.stdio;
TestType a,b,c;
readf("%s %s %s ", , , );
switch(c){
case a: writeln("a");break;
case b: writeln("b");break;
default: assert(false);
}
}


case expressions must be constants:

  "The case expressions must all evaluate to a constant value or
   array, or a runtime initialized const or immutable variable of
   integral type."

  https://dlang.org/spec/statement.html#SwitchStatement

The fact that it compiles for ulong looks like a bug to me. It compiles 
probably because switch is most likely implemented in terms of a chained 
if-else-if statements by the compiler and it just works because there is 
no explicit check whether they are constant or not.


Ali



Re: Intelligent enums

2017-01-18 Thread Nicholas Wilson via Digitalmars-d-learn

On Thursday, 19 January 2017 at 03:47:34 UTC, Ignacious wrote:

On Thursday, 19 January 2017 at 02:59:04 UTC, Ignacious wrote:
I have the need to create an enum flag like structure to 
specify certain properties of a type easily.


e.g.,

enum properties
{
   Red,
   Blue,
   Hot,
   Sexy,
   Active,
   ...
}

But some properties will be mutually exclusive. I would like 
to contain all those rules for in the enum itself for obvious 
reasons(encapsulation).


I guess I'm going to be told to use static and structs, but 
I'm hoping for a more elegant solution.


I should be clear that I'm using these as flags using 
EumToFlags and I want to prevent certain flags from betting set 
in certain combinations that are invalid.


If their only use is for Enum to flags (i.e. you don't care at 
all about the enum)
then you can use std.bitmanip.bitfields to logically group the 
combinations.
i.e. have all the mutually exclusive combination in the same 
field.


e.g.

struct properties
{
enum colour { red, blue }
// any other mutually exclusive combinations.
mixin(bitfields!(colour, "colour" , 1
bool  , "hot" , 1));
}


Re: Gui in D: I miss this project

2017-01-18 Thread Jacob Carlborg via Digitalmars-d

On 2017-01-18 22:00, aberba wrote:


So it will be incorrect to say native gui is a requirement to fain
higher adoption.


Of course there will be applications that does not look native but still 
is popular.


If I'm looking for a new type of application I'll dismiss those that 
don't look native very quickly. Unless I know beforehand that the 
application is very good, then I'll give it some more time.


Example, I'm using Eclipse for Scala related coding. Although Eclipse is 
written using SWT, that uses native drawing, it still looks a bit alien. 
Non-native tabs, non-native preferences and so on. But I don't know of 
any other IDE for Scala that looks more native. Also I used Eclipse on 
other platforms before I used it on macOS.


--
/Jacob Carlborg


Re: DMD Refuses to Compile Multiple Source Files

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

On Wednesday, 18 January 2017 at 23:12:15 UTC, Mike Parker wrote:

(source files), then use the import statement to make the 
declarations in other modules.


Sorry, this should read "make the implementations available to 
other modules".


Re: Assigning in constructor.

2017-01-18 Thread NotSpooky via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:08:07 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote:
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?


Yes:

http://dlang.org/spec/struct.html
"A struct is defined to not have an identity; that is, the 
implementation is free to make bit copies of the struct as 
convenient."


That means it might copy and/or move it without giving you a 
chance to update the pointer. Updating in postblit can help 
sometimes but still the compiler and library are allowed to 
move structs without notice.


You already answered on the IRC so thanks X2.
So, it's problematic to have pointers to structs in all cases 
according to spec?


Re: Plugin for 1C:Enterprise in dmd

2017-01-18 Thread Nick B via Digitalmars-d-announce

On Wednesday, 18 January 2017 at 12:00:53 UTC, MGW wrote:

For clarity you can see this short video 
https://www.youtube.com/watch?v=apLppufZulI


The short video is in Russian only :(


alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}


Yet X ~= 3; fails.

3 should be implicitly convertible to Y and then ~ should assign 
it.


?





Re: Release Candidate 2.073.0-rc1

2017-01-18 Thread Suliman via Digitalmars-d-announce

On Wednesday, 18 January 2017 at 13:48:06 UTC, Martin Nowak wrote:

First release candidate for 2.073.0.

http://dlang.org/download.html#dmd_beta 
http://dlang.org/changelog/2.073.0.html


Comes with a couple of more fixes: 
https://github.com/dlang/dmd/compare/v2.073.0-b2...v2.073.0-rc1 
https://github.com/dlang/druntime/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/phobos/compare/v2.073.0-b2...v2.073.0-rc1 https://github.com/dlang/dub/compare/v1.2.0-beta.2...v1.2.0-rc.1


Please report any bugs at https://issues.dlang.org

-Martin


http://dlang.org/changelog/2.073.0.html#mscrtlib-option
How can I set this flag in dub.json? I tried:
"dflags": [ "-mscrt=msvcrt" ]
but got error:
Error: unrecognized switch '-mscrt=msvcrt'


cannot alias array ;/

2017-01-18 Thread Jot via Digitalmars-d-learn

alias a = myarray[k];

fails

myarray is a multidimensial array that I want to reduce writing 
it every time but D complains that it can't alias it.


I simply want it to do a direct substitution, nothing fancy, just 
to reducing typing.




Re: Release Candidate 2.073.0-rc1

2017-01-18 Thread Jacob Carlborg via Digitalmars-d-announce

On 2017-01-18 14:48, Martin Nowak wrote:

First release candidate for 2.073.0.

http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.073.0.html


About the new -mscrt=libname flag. Could we have a more generic name of 
the flag that would fit for other platforms to specify the C library, 
i.e. Musl instead of GNU? Or is this something different?


--
/Jacob Carlborg


Function template advice

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

I have a simple comparison function:

struct Foo {
string bar;
}

auto sameGroup(T,S) (T a, S b) {
static assert (is(T == string) || is(T == Foo));
static assert (is(S == string) || is(S == Foo));

string aStr;
string bStr;
static if (is(T == string)){
aStr = a;
} else {
aStr = a.bar;
}
static if (is(S == string)){
bStr = b;
} else {
bStr = b.bar;
}
return equal (aStr,bStr);
}

This works, but just wondered if there was an easier way?

Is there a way to do "static if" in shorthand, like:
auto aStr = (static if (is(T==string)) ? a : a.bar


Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
I've done a whole bunch of looking around, and I don't see any 
mention of returning a dynamic array from a function. When I try 
it though, it just returns the .length value of the array, rather 
than the contents of the array. Does anyone know why this is, and 
what I can do to make it behave the way I want it to?


Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Nicholas Wilson via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 19:28:20 UTC, Samwise wrote:
On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker 
wrote:


extern(C), not simply extern. It turns off the name mangling. 
But really, the proper thing to do is to drop the prototype 
and import the module with the implementation. It's tge way 
modules are intended to be used. Unless you're doing something 
specidic like writing a library that calls an arbitrary user 
function.


Alright, so I misunderstood what ketmar was saying. His 
solution did work. I'm just not sure I understand what you are 
trying to say here:


But really, the proper thing to do is to drop the prototype 
and import the module with the implementation.


This will still preserve my multiple source files, without 
worrying about the headers, right? Thanks,

~Sam


Yes. Take a look at some random projects from code.dlang.org and 
look at the way they have laid out their modules and what they 
import and from where.


Re: Plugin for 1C:Enterprise in dmd

2017-01-18 Thread Dmitry Olshansky via Digitalmars-d-announce

On 1/18/17 1:00 PM, MGW wrote:

I managed to create plugin for 1C:Enterprise (http://1c.ru/eng/title.htm).
The major difficulty in realization C++ interfaces is successfully
overcome.
I need a more detailed description of compatibility of structures,
classes and interfaces between C++ and D.

For clarity you can see this short video
https://www.youtube.com/watch?v=apLppufZulI



OMG!
I mean I'm both frightened and excited of the opportunities this create. :)

---
Dmitry Olshansky


Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn

Thanks loads. I got it working using those modules.
~Sam




Re: __traits(isRef, this) cannot distinguish l-value- from r-value-passed this

2017-01-18 Thread Nordlöw via Digitalmars-d-learn

On Thursday, 19 January 2017 at 00:44:51 UTC, Nordlöw wrote:

Any clues on how to retrieve this information?


Another much more common use case:

Chained property setters could be optimized iff the property 
setter is called on an r-value, that is when


`__traits(isRef,this)` is `false`

Typically usages such as

f(S.init.setX(2).setY(3))

and

auto s = S.init.setX(2).setY(3)

should all result in only *one* single construction of `S` (in 
the `S.init` expression).


Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}


Yet X ~= 3; fails.

3 should be implicitly convertible to Y and then ~ should assign it.

?


This should not fail:

X x = new X;
x ~= 3;

This should fail as x is a member of an instance of class X:

X ~= 3;


Re: Function template advice

2017-01-18 Thread Ali Çehreli via Digitalmars-d-learn

On 01/18/2017 02:02 PM, Jordan Wilson wrote:

I have a simple comparison function:

struct Foo {
string bar;
}

auto sameGroup(T,S) (T a, S b) {
static assert (is(T == string) || is(T == Foo));
static assert (is(S == string) || is(S == Foo));

string aStr;
string bStr;
static if (is(T == string)){
aStr = a;
} else {
aStr = a.bar;
}
static if (is(S == string)){
bStr = b;
} else {
bStr = b.bar;
}
return equal (aStr,bStr);
}

This works, but just wondered if there was an easier way?

Is there a way to do "static if" in shorthand, like:
auto aStr = (static if (is(T==string)) ? a : a.bar


Yes, can be better with something similar to the following:

struct Foo {
string bar;
}

string value(U : Foo)(U u) {
return u.bar;
}

string value(U : string)(U u) {
return u;
}

auto sameGroup(T,S) (T a, S b) {
static assert (is(T == string) || is(T == Foo));
static assert (is(S == string) || is(S == Foo));

import std.algorithm;
return equal (value(a), value(b));
}

void main() {
assert(sameGroup("a", "b") == false);
assert(sameGroup("a", Foo("a")) == true);
assert(sameGroup(Foo("x"), "b") == false);
assert(sameGroup(Foo("z"), Foo("z")) == true);
}

Ali



Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 22:37:25 UTC, Adam D. Ruppe 
wrote:

What code do you have now?


This is the basic function. It takes all those boolean arguments 
and does things depending on them, and then takes any extra args 
that getopt didn't parse and reads them into numbs. That code 
works fine, because I write it out after that's done but before I 
pass it back to main().


ulong[] getInp (bool help, bool file, bool inp, string[] args) {
//...
writeln(numbs);
return numbs;
}

Here is what I've got in main (Minus some more stuff). Right now 
it's just printing out what it gets, but it will use other 
functions to apply operations to numbs later.


int main(string[] args) {
ulong[] numbs;
//...
numbs[] = getInp(help, file, inp, args);

writeln(numbs);
return 0;
}

That prints out an empty array. If I initialize one element, 
(numbs[0] ~= 0;) then it prints out numbs.length. Really kinda 
weird... Thanks,

~Sam


Re: Assigning in constructor.

2017-01-18 Thread pineapple via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:08:07 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote:
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?


Yes:

http://dlang.org/spec/struct.html
"A struct is defined to not have an identity; that is, the 
implementation is free to make bit copies of the struct as 
convenient."


That means it might copy and/or move it without giving you a 
chance to update the pointer. Updating in postblit can help 
sometimes but still the compiler and library are allowed to 
move structs without notice.


Practically speaking I've found that if the struct was allocated 
on the heap, then  acquires that pointer and seems not to 
break anything, e.g. how it's used in the uncopyable struct here 
https://github.com/pineapplemachine/mach.d/blob/master/mach/collect/linkedlist.d#L165


Re: switch statement with variable branches

2017-01-18 Thread Yuxuan Shui via Digitalmars-d-learn

On Thursday, 19 January 2017 at 02:00:10 UTC, Ali Çehreli wrote:

On 01/18/2017 05:22 PM, Yuxuan Shui wrote:
Somehow I can't use ubyte variables behind 'case', but ulong 
works fine.

Why is that?



case expressions must be constants:

  "The case expressions must all evaluate to a constant value or
   array, or a runtime initialized const or immutable variable 
of

   integral type."

  https://dlang.org/spec/statement.html#SwitchStatement

The fact that it compiles for ulong looks like a bug to me. It 
compiles probably because switch is most likely implemented in 
terms of a chained if-else-if statements by the compiler and it 
just works because there is no explicit check whether they are 
constant or not.


Ali


If you try:

void main() {
alias TestType = ulong; // won't compile if = ubyte
import std.stdio;
TestType a,b,c;
readf("%s %s %s ", , , );
final switch(c){
case a: writeln("a");break;
case b: writeln("b");break;
default: assert(false);
}
}

Then the error message:

test.d(7): Error: case variables not allowed in final switch 
statements
test.d(8): Error: case variables not allowed in final switch 
statements


Makes it looks like that "case variable" is an intended feature.



Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn

On 19/01/2017 3:25 PM, Adam D. Ruppe wrote:

On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote:

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}



This should not fail:

X x = new X;
x ~= 3;



Yes, it should fail. 3 is not implicitly convertible to Y under any
circumstance. D does not support implicit constructors.

alias this only works if you ALREADY HAVE a Y, then it will implicitly
convert Y to int. It will never go the other way around.


Oh Y, I read it as int, my bad.
Yes should fail.


Re: alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn

On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote:
On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole 
wrote:

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}



This should not fail:

X x = new X;
x ~= 3;



Yes, it should fail. 3 is not implicitly convertible to Y under 
any circumstance. D does not support implicit constructors.


alias this only works if you ALREADY HAVE a Y, then it will 
implicitly convert Y to int. It will never go the other way 
around.


Huh?

But this is alias this, the whole point of alias this is to treat 
the type as as the alias?


You are saying it basically only works one way, seems to make 
alias this quite useless(50% at least). Is there any real reason 
why this doesn't work?


X x;
Y y;
y = 3;

x ~= y; works fine
x ~= 3; fails.

Yet, logically, 3 is convertible to Y(3rd line above) and Y is 
appendable to X.


Seems to me that D simply hasn't added the logic to handle the 
case for implicit construction for alias this, why not add it?




Re: Returning Arrays from Functions

2017-01-18 Thread Samwise via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 23:09:15 UTC, Adam D. Ruppe 
wrote:

On Wednesday, 18 January 2017 at 22:51:17 UTC, Samwise wrote:

numbs[] = getInp(help, file, inp, args);


This is wrong, try just `numbs = getImp(...);`

numbs[] = xxx will copy stuff into the existing array, which is 
empty right now. You want to jut keep the slice the function 
passes back.


Huh. I thought I tried that. I guess I didn't, since it worked 
like a charm. Thanks loads.

~Sam


Re: Assigning in constructor.

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 19 January 2017 at 00:55:42 UTC, NotSpooky wrote:

You already answered on the IRC so thanks X2.
So, it's problematic to have pointers to structs in all cases 
according to spec?


Maybe... though in practice (and with C compatibility), pointers 
to ones where you know the memory management scheme is fine.


So if you declare a local, and get a pointer to it, you're OK. Or 
if you new it, or malloc it, or something like that.


The big problem with a pointer to itself in the constructor or as 
a member is that the struct itself doesn't know where it is going 
or how it was allocated, just the code outside does.


Re: Returning Arrays from Functions

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn

What code do you have now?


Re: Assigning in constructor.

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 22:57:22 UTC, NotSpooky wrote:
Is it undefined behavior to assign  to a pointer in the 
constructor of a struct?


Yes:

http://dlang.org/spec/struct.html
"A struct is defined to not have an identity; that is, the 
implementation is free to make bit copies of the struct as 
convenient."


That means it might copy and/or move it without giving you a 
chance to update the pointer. Updating in postblit can help 
sometimes but still the compiler and library are allowed to move 
structs without notice.


Re: Function template advice

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

On Wednesday, 18 January 2017 at 22:39:02 UTC, Ali Çehreli wrote:

On 01/18/2017 02:02 PM, Jordan Wilson wrote:

[...]


Yes, can be better with something similar to the following:

struct Foo {
string bar;
}

string value(U : Foo)(U u) {
return u.bar;
}

string value(U : string)(U u) {
return u;
}

auto sameGroup(T,S) (T a, S b) {
static assert (is(T == string) || is(T == Foo));
static assert (is(S == string) || is(S == Foo));

import std.algorithm;
return equal (value(a), value(b));
}

void main() {
assert(sameGroup("a", "b") == false);
assert(sameGroup("a", Foo("a")) == true);
assert(sameGroup(Foo("x"), "b") == false);
assert(sameGroup(Foo("z"), Foo("z")) == true);
}

Ali


Nice, yes looks better thanks.
Jordan


Re: Language server protocol implementation for D

2017-01-18 Thread MakersF via Digitalmars-d

On Wednesday, 18 January 2017 at 12:29:38 UTC, Atila Neves wrote:

On Wednesday, 18 January 2017 at 09:31:49 UTC, xtreak wrote:
Rust is making good progress on the IDE aspect with the 
announcement : 
http://www.jonathanturner.org/2017/01/rls-alpha-release.html. 
HN discussion : https://news.ycombinator.com/item?id=1348


It will be good to see the protocol implemented so that many 
tools and IDEs can use the interface to provide better tooling 
for development.


https://github.com/Microsoft/language-server-protocol
https://github.com/Microsoft/language-server-protocol/wiki/Protocol-Implementations


I saw that today and was considering making a D implementation 
my next pet project.


Atila


I saw it quite ago and I was thinking to just write a translation 
layer for DCD. It would be the most pragmatic choice ( have one 
almost official completion tool which can speak in many 
protocols, not many different tools) but it's not the most 
exciting projec ever..


switch statement with variable branches

2017-01-18 Thread Yuxuan Shui via Digitalmars-d-learn
Somehow I can't use ubyte variables behind 'case', but ulong 
works fine. Why is that?


void main() {
alias TestType = ulong; // won't compile if = ubyte
import std.stdio;
TestType a,b,c;
readf("%s %s %s ", , , );
switch(c){
case a: writeln("a");break;
case b: writeln("b");break;
default: assert(false);
}
}


Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole 
wrote:

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}



This should not fail:

X x = new X;
x ~= 3;



Yes, it should fail. 3 is not implicitly convertible to Y under 
any circumstance. D does not support implicit constructors.


alias this only works if you ALREADY HAVE a Y, then it will 
implicitly convert Y to int. It will never go the other way 
around.


Intelligent enums

2017-01-18 Thread Ignacious via Digitalmars-d-learn
I have the need to create an enum flag like structure to specify 
certain properties of a type easily.


e.g.,

enum properties
{
   Red,
   Blue,
   Hot,
   Sexy,
   Active,
   ...
}

But some properties will be mutually exclusive. I would like to 
contain all those rules for in the enum itself for obvious 
reasons(encapsulation).


I guess I'm going to be told to use static and structs, but I'm 
hoping for a more elegant solution.





Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:51:03 UTC, rikki cattermole 
wrote:

Now, lets say Y was a struct, then yeah it can work.


In theory, it can work with either (the compiler could just 
insert the function call to alloc+construct), but it won't in D 
since we don't have implicit construction.


Re: alias not valid with ~

2017-01-18 Thread rikki cattermole via Digitalmars-d-learn

On 19/01/2017 3:35 PM, Ignacious wrote:

On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe wrote:

On Thursday, 19 January 2017 at 02:15:04 UTC, rikki cattermole wrote:

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}



This should not fail:

X x = new X;
x ~= 3;



Yes, it should fail. 3 is not implicitly convertible to Y under any
circumstance. D does not support implicit constructors.

alias this only works if you ALREADY HAVE a Y, then it will implicitly
convert Y to int. It will never go the other way around.


Huh?

But this is alias this, the whole point of alias this is to treat the
type as as the alias?

You are saying it basically only works one way, seems to make alias this
quite useless(50% at least). Is there any real reason why this doesn't
work?

X x;
Y y;
y = 3;

x ~= y; works fine
x ~= 3; fails.

Yet, logically, 3 is convertible to Y(3rd line above) and Y is
appendable to X.

Seems to me that D simply hasn't added the logic to handle the case for
implicit construction for alias this, why not add it?


It is not implicitly convertible in any form.
An integer is just a value, probably stored in a register or directly 
encoded into an instruction.


A class instance is always allocated into memory, in pretty much all 
cases the heap (stack is explicit in D). So what you're suggesting would 
require an allocation + calling of a constructor to make it equal.


Now, lets say Y was a struct, then yeah it can work. Because a struct is 
nothing more than a set of values that go together. Which are commonly 
allocated on the stack and for smaller ones, be passed around by only 
registers.





Re: alias not valid with ~

2017-01-18 Thread Adam D. Ruppe via Digitalmars-d-learn

On Thursday, 19 January 2017 at 02:35:08 UTC, Ignacious wrote:
But this is alias this, the whole point of alias this is to 
treat the type as as the alias?


No, alias this is for subtyping. Similar to a child class, a 
subtype can be used as its parent type, but must be constructed.


class A {}
class B : A {}

A a = new B(); // legal, B will convert to A
B a = new A(); // illegal, A is not B

alias this is the same concept, just outside of class inheritance.

https://en.wikipedia.org/wiki/Subtyping

Yet, logically, 3 is convertible to Y(3rd line above) and Y is 
appendable to X.


Wrong. Implicit construction and implicit conversion are 
different concepts in theory and in practice in every language I 
know. You often want them separately as construction may need 
additional state, may just not be logical, and may have a 
different runtime cost than substitution.


D does not support implicit construction under any circumstance 
except the typesafe variadic syntax in function calls that take a 
single class.


(I'd like to add it, but Walter doesn't agree..)


Re: alias not valid with ~

2017-01-18 Thread Ignacious via Digitalmars-d-learn
On Thursday, 19 January 2017 at 02:51:03 UTC, rikki cattermole 
wrote:

On 19/01/2017 3:35 PM, Ignacious wrote:
On Thursday, 19 January 2017 at 02:25:44 UTC, Adam D. Ruppe 
wrote:
On Thursday, 19 January 2017 at 02:15:04 UTC, rikki 
cattermole wrote:

On 19/01/2017 3:08 PM, Ignacious wrote:


class Y
{
   int y;
   alias y this;
}

class X
{
   Y[] x;
   alias x this;
}



This should not fail:

X x = new X;
x ~= 3;



Yes, it should fail. 3 is not implicitly convertible to Y 
under any

circumstance. D does not support implicit constructors.

alias this only works if you ALREADY HAVE a Y, then it will 
implicitly

convert Y to int. It will never go the other way around.


Huh?

But this is alias this, the whole point of alias this is to 
treat the

type as as the alias?

You are saying it basically only works one way, seems to make 
alias this
quite useless(50% at least). Is there any real reason why this 
doesn't

work?

X x;
Y y;
y = 3;

x ~= y; works fine
x ~= 3; fails.

Yet, logically, 3 is convertible to Y(3rd line above) and Y is
appendable to X.

Seems to me that D simply hasn't added the logic to handle the 
case for

implicit construction for alias this, why not add it?


It is not implicitly convertible in any form.
An integer is just a value, probably stored in a register or 
directly encoded into an instruction.




so? An integer is just a type. Where it is stored or how is 
irrelevant.



A class instance is always allocated into memory, in pretty 
much all cases the heap (stack is explicit in D). So what 
you're suggesting would require an allocation + calling of a 
constructor to make it equal.




So.

Now, lets say Y was a struct, then yeah it can work. Because a 
struct is nothing more than a set of values that go together. 
Which are commonly allocated on the stack and for smaller ones, 
be passed around by only registers.


So. If it worked for a struct as you suggest it should for for 
any type.


What you are suggesting is that the compiler(or maybe the 
compiler programmer) is not able to create a rewrite rule. It 
obviously can. So your reasons are flawed.


The reason question you should ask yourself is is there any 
reason not to do it, instead of trying to find reasons it can't 
be done(sounds more like you are grasping at straws/guessing).


You should realize any time one can program something explicit 
the compiler can be made to do it implicit. The question is the 
consequences of such actions. In this case, regardless if we use 
3 and convert explicitly or not ~ requires an allocation, so 
allocations alone are not enough to prevent it.






[Issue 16278] [REG2.067] undefined reference when class template is instantiated only in 'is' expression

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

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

https://github.com/dlang/dmd/commit/bdf0df926f90b9243932e2ff76f79de644224b26
Fix issue #16278 - Do not emit TypeInfo for speculative instantiations.

https://github.com/dlang/dmd/commit/d7101f3e636d7aa970ddbab8623e5bebd7b96212
Merge pull request #6351 from LemonBoy/b16278

--


[Issue 17087] [REG2.072] Wrong generated with cfloat and creal when casting from int

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

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

https://github.com/dlang/dmd/commit/7cf3c764da8b85f9d7054b0895384f3a86ce2684
fix Issue 17087 - [REG2.072] Wrong generated with cfloat and creal when casting
from int

https://github.com/dlang/dmd/commit/3c0b76985ea1cc4c32a213975a4b7702bcb9d90c
Merge pull request #6460 from WalterBright/fix17087

--


[Issue 17105] New: [ICE] SIMD Internal error with optimizations: backend\cod3.c 6807

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

  Issue ID: 17105
   Summary: [ICE] SIMD Internal error with optimizations:
backend\cod3.c 6807
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: simen.kja...@gmail.com

Test case:

module foo;
import core.simd;

struct bug {
float4 value;
auto normalize() {
value = __simd(XMM.DPPS, value, value);
}
}


Compiled with dmd -m64 -O foo.d

--


Release Candidate 2.073.0-rc1

2017-01-18 Thread Martin Nowak via Digitalmars-d-announce
First release candidate for 2.073.0.

http://dlang.org/download.html#dmd_beta
http://dlang.org/changelog/2.073.0.html

Comes with a couple of more fixes:
https://github.com/dlang/dmd/compare/v2.073.0-b2...v2.073.0-rc1
https://github.com/dlang/druntime/compare/v2.073.0-b2...v2.073.0-rc1
https://github.com/dlang/phobos/compare/v2.073.0-b2...v2.073.0-rc1
https://github.com/dlang/dub/compare/v1.2.0-beta.2...v1.2.0-rc.1

Please report any bugs at https://issues.dlang.org

-Martin


[Issue 17072] [REG 2.073.0-b1] missing symbols with -inline

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

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

https://github.com/dlang/dmd/commit/575e6d130d10410e3845a9df1ee2f7e13e84cd9a
fix Issue 17072 - [REG 2.073.0-b1] missing symbols with -inline

https://github.com/dlang/dmd/commit/661be50c59cc83a9376776598ff63fb84b08bb55
Merge pull request #6452 from WalterBright/fix17072

--


Re: Getters/setters generator

2017-01-18 Thread Nemanja Boric via Digitalmars-d-announce

On Wednesday, 18 January 2017 at 15:29:43 UTC, Mark wrote:
On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei 
Alexandrescu wrote:

On 1/17/17 12:08 PM, Mark wrote:
On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei 
Alexandrescu wrote:

[...]


Given that D supports class invariants, is there a real need 
for

predicated setters?


The invariant is evaluated after the setter has taken place, 
i.e. after the object has been corrupted. The setter guard 
prevents corruption from happening.  -- Andrei


I see. Is there a way to call invariant() of a class/struct 
directly? That would obviate the need for a particular 
predicate (copy the class state, run the setter, check if 
invariants are satisfied and restore previous state if they 
aren't).


You can call invariant directly with `assert(this);` IIRC.


[Issue 17106] New: [ICE] SIMD Internal error with optimizations: Internal error: backend\cgcod.c 1666

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

  Issue ID: 17106
   Summary: [ICE] SIMD Internal error with optimizations: Internal
error: backend\cgcod.c 1666
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: simen.kja...@gmail.com

Test case:

module foo;
import core.simd;

struct bug {
float4 value;

this(float4 ) {
}

auto normalize() {
bug t1 = __simd(XMM.DPPS, value, value);
value = __simd(XMM.MULPS, value);
return this;
}
}


command line: dmd -m64 -O foo.d

--


Re: Getters/setters generator

2017-01-18 Thread Mark via Digitalmars-d-announce
On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei Alexandrescu 
wrote:

On 1/17/17 12:08 PM, Mark wrote:
On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei 
Alexandrescu wrote:

On 1/17/17 9:32 AM, Eugene Wissner wrote:
Ah, well thanks. I don't think it makes much sense since it 
would be
easier to write a complete setter if the user needs extra 
checks.
Accessors are there only for the generation of the standard 
methods,

that just get or set some object property.


Hmmm... that's a bit of a bummer because it helps only the 
degenerate
case (accessors are there as placeholders for future 
extensions, and
otherwise offer no protection whatsoever compared to a public 
value).
The question would be then what would be use cases for the 
accessors.
Predicated setters are not just a random thing one might want 
out of

many possibilities, it's a frequent pattern. -- Andrei


Given that D supports class invariants, is there a real need 
for

predicated setters?


The invariant is evaluated after the setter has taken place, 
i.e. after the object has been corrupted. The setter guard 
prevents corruption from happening.  -- Andrei


I see. Is there a way to call invariant() of a class/struct 
directly? That would obviate the need for a particular predicate 
(copy the class state, run the setter, check if invariants are 
satisfied and restore previous state if they aren't).


[Issue 13958] RangeError with impure map

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

Jack Stouffer  changed:

   What|Removed |Added

 CC||j...@jackstouffer.com
   Hardware|x86_64  |All
 OS|Mac OS X|All

--


[Issue 16169] nWayUnion assertion failure

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

Jack Stouffer  changed:

   What|Removed |Added

 CC||j...@jackstouffer.com
   Hardware|x86_64  |All
 OS|Linux   |All

--


[Issue 16234] ICE on opEquals

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

bitter.ta...@gmx.com changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bitter.ta...@gmx.com
 Resolution|--- |FIXED

--


Re: Gui in D: I miss this project

2017-01-18 Thread Jacob Carlborg via Digitalmars-d

On 2017-01-18 10:24, aberba wrote:


What about Photoshop? Is it native? No.


Last time I used it it didn't look very native.

--
/Jacob Carlborg


Re: Gui in D: I miss this project

2017-01-18 Thread aberba via Digitalmars-d
On Wednesday, 18 January 2017 at 17:51:18 UTC, Jacob Carlborg 
wrote:

On 2017-01-18 10:24, aberba wrote:


What about Photoshop? Is it native? No.


Last time I used it it didn't look very native.


So it will be incorrect to say native gui is a requirement to 
fain higher adoption.


Re: It is still not possible to use D on debian/ubuntu

2017-01-18 Thread deadalnix via Digitalmars-d

On Wednesday, 11 January 2017 at 00:33:41 UTC, Martin Nowak wrote:

But it is not clear if anyone cares at this stage.


are rather frustrating to read.


Alright, sentence like this come from extreme frustration at 
things being almost constantly broken. For instance:


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

As it turns out, this problem is not quite fixed.


[Issue 17107] New: Runnign phobos unittests do not work with PIE

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

  Issue ID: 17107
   Summary: Runnign phobos unittests do not work with PIE
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: deadal...@gmail.com

$ make -f posix.mak
[...]
/usr/bin/ld: generated/linux/debug/64/unittest/test_runner.o: relocation
R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a
shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status

--


Re: DMD Refuses to Compile Multiple Source Files

2017-01-18 Thread Samwise via Digitalmars-d-learn

On Wednesday, 18 January 2017 at 04:25:42 UTC, Mike Parker wrote:


extern(C), not simply extern. It turns off the name mangling. 
But really, the proper thing to do is to drop the prototype and 
import the module with the implementation. It's tge way modules 
are intended to be used. Unless you're doing something specidic 
like writing a library that calls an arbitrary user function.


Alright, so I misunderstood what ketmar was saying. His solution 
did work. I'm just not sure I understand what you are trying to 
say here:


But really, the proper thing to do is to drop the prototype and 
import the module with the implementation.


This will still preserve my multiple source files, without 
worrying about the headers, right? Thanks,

~Sam


[Issue 4957] std.concurrency does not allow to pass Tid in struct fields

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

Paolo Invernizzi  changed:

   What|Removed |Added

 CC||paolo.inverni...@gmail.com

--


Problems with stored procedure using the mysql-native library.

2017-01-18 Thread TheFlyingFiddle via Digitalmars-d-learn

Hi

I am having problems using stored procedures that return results.

Example procedure:
CREATE PROCEDURE GetUsers()
  SELECT * FROM users;

When I use this procedure from the MySQL command line everything 
works fine. However, when I use it from the mysql-native library 
i get into problems.


int main()
{
   auto con = new Connection(...); //
   auto cmd = Command(con);
   cmd.execProcedure("GetUsers");
}

This returns the error:
MySQL error: PROCEDURE db.getusers can't return a result set in 
the given context.


Other SQL queries work fine over the connection and procedure 
calls that do not return anything also works.


How would i go about solving this problem?



Re: Problems with stored procedure using the mysql-native library.

2017-01-18 Thread TheFlyingFiddle via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 19:40:12 UTC, TheFlyingFiddle 
wrote:

Hi

I am having problems using stored procedures that return 
results.


Update: I am using the SvrCapFlags.MULTI_RESULTS flag when 
initiating the connection and have also tried using the 
SvrCapFlags.MULTI_STATEMENTS flag.


Unfortunately these flags do not solve the problem.




Re: Getters/setters generator

2017-01-18 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 1/18/17 5:29 PM, Mark wrote:

I see. Is there a way to call invariant() of a class/struct directly?
That would obviate the need for a particular predicate (copy the class
state, run the setter, check if invariants are satisfied and restore
previous state if they aren't).


It seems painfully obvious the right way is a guarded assignment and 
anything else would be a more or less painful workaround. -- Andrei