Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn

On 23.04.2016 03:11, Ramon wrote:

mmm, I figured the problem, but don't know how to solve it.
my struct has a destructor which clears itself:

struct json_value
{
   ~this() { .ValueClear(); }
}


So the struct is destroyed at the end of DoDirSearch, despite there 
being a closure for it. Is the compiler doing the right thing here? 
Shouldn't the struct be considered alive until the closure gets garbage 
collected?


Re: How do you use D to launch/open a window?

2016-04-22 Thread rikki cattermole via Digitalmars-d-learn

On 23/04/2016 9:29 AM, anonymousuer wrote:

On Friday, 22 April 2016 at 21:26:25 UTC, ciechowoj wrote:

On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote:

What code is needed to tell D to open a window? Thank you in advance.


Could you specify what kind of window do you need?


As in a regular Windows window, for example when you open up IE or a
program. The container of the program itself, non-command-line.


So a GUI window?
If so I am working on a library for that for Phobos.
Only problem is, its a long way off. Although Windows support is more or 
less done.


https://github.com/rikkimax/alphaPhobos/tree/master/source/std/experimental/ui/window

Otherwise you're stuck with c libraries such as SDL.


Re: Google Summer of Code

2016-04-22 Thread rikki cattermole via Digitalmars-d-announce

On 23/04/2016 10:43 AM, CraigDillabaugh wrote:

I am pleased to announce that the D Foundation has been awarded 4 slots
for the 2016 Google Summer of Code.

https://summerofcode.withgoogle.com/organizations/5078256051027968/

Congratulations to

Lodovico Giaretta
A replacement of std.xml for the Phobos standard library


YUS!


Sebastian Wilzbach
Science for D - a non-uniform RNG

Jeremy DeHaan
Precise Garbage Collector


YUS!


Wojciech Szęszoł
Improvements for dstep

on their successful proposals.

They faced very stiff competition, and unfortunately we had to turn down
a number of very good proposals.  Perhaps we should have been more
greedy and asked for six or seven slots.

I hope the community will extend a warm welcome to these students, and
we welcome all of your efforts in helping these students achieve success
in the coming months.

Finally, thanks to all our mentors who put in hours of work in
evaluating the proposals to this point.


To the students, please post github repos when ready!
I want to keep track.



Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread ed via Digitalmars-d-learn

On Saturday, 23 April 2016 at 01:11:49 UTC, Ramon wrote:

mmm, I figured the problem, but don't know how to solve it.
my struct has a destructor which clears itself:

struct json_value
{
  ~this() { .ValueClear(); }
}

so how I can I put a struct in the heap? (not in the stack, as 
is the default..)


new or make with arg or new or make then opAssign or this(this).

but have you tried

__ghsared immutable json_value cbk = json_value(prms.argv[3]);

? without __gshared cbk might be on the TLS. (see with -vtls 
switch on DMD)


Re: DlangUI on Android

2016-04-22 Thread Vadim Lopatin via Digitalmars-d-announce

On Friday, 22 April 2016 at 18:49:24 UTC, Laeeth Isharc wrote:
This is a very exciting development.  (And impressive in the 
'consequent' department, as the Germans say - you said you 
would have DlangUI ported to Android some weeks after the 
working compiler, and that's what you did!).


It took about one week to make DlangUI android backend once I 
managed to build NativeActivity example by Joakim's instructions.


I would say it will take a week or too to make iOS backend once 
we have working compiler for iOS (in my estimations it will have 
1K-2K lines of D code and 1K-2K lines of obj-c code.


Unfortunately, I have no experience with objective C neither with 
iOS programming.


Android port was easy for me because DlangUI was a kind of 
port/reimplementation of my C++ cross platform GUI library I used 
for my CoolReader GL project (e-book reader).


Might be useful for me to port some D code for internal 
enterprise apps to Android that currently runs on linux (I 
recognise how experimental it is, but I'm okay with that since 
mobile is just nice to have, and not yet necessary).
Please let me know issue you face when using DlangUI for mobile 
development.



Will you be at dconf?

No, I'm not planning to participate.
D is just a hobby for me.




Re: DlangUI on Android

2016-04-22 Thread Vadim Lopatin via Digitalmars-d-announce

On Friday, 22 April 2016 at 18:48:26 UTC, David Nadlinger wrote:

This is a reality now mostly due to Joakim's great LDC work.


Yes, it's really GREAT work!
I just took his NativeActivity example and modified a bit to make 
dlangui's platform class implementation.


I would be nice to have all Joakim's patches in upstream LDC and 
druntime/phobos.




[Issue 11169] __traits(isAbstractClass) prematurely sets a class to be abstract

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11169

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

   What|Removed |Added

 CC||b2.t...@gmx.com

--


Re: Are structs saved in multi-thread delegate call?

2016-04-22 Thread Ramon via Digitalmars-d-learn

mmm, I figured the problem, but don't know how to solve it.
my struct has a destructor which clears itself:

struct json_value
{
  ~this() { .ValueClear(); }
}

so how I can I put a struct in the heap? (not in the stack, as is 
the default..)


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/15/2016 11:33 AM, Johan Engelen wrote:

The culprit is the linear search at the end of appendToModuleMember, because the
members list with Dsymbols gets pretty large (50k+ members).
https://github.com/D-Programming-Language/dmd/blob/master/src/dtemplate.d#L8012-L8026


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


Are structs saved in multi-thread delegate call?

2016-04-22 Thread Ramon via Digitalmars-d-learn

I have something along this way:

struct json_value
{
..
}

function DoDirSearch(..)
{
immutable json_value cbk = json_value(prms.argv[3]);
assert(cbk != json_value.init); // OK, pass

import core.thread;
new Thread({
assert(cbk != json_value.init); // FAIL!
}).start();
}

the problem is, my struct value is not saved in the spawned tread 
context, so this assert fails while at the start it passed:


assert(cbk != json_value.init);


Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread rcorre via Digitalmars-d-learn

On Friday, 22 April 2016 at 10:25:34 UTC, Chris wrote:

On Friday, 22 April 2016 at 09:49:02 UTC, Rene Zwanenburg wrote:

On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote:
- What happens when you compile a binary without phobos and 
druntime, and with a custom entry point? I've never done 
that myself and don't remember how to do that off the top of 
my head, but the info should be somewhere on dlang.org.


I'll look into it.


Declaring a C-like main and the -defaultlib switch do the 
trick:


 cmain.d
extern(C) void main() nothrow {}
---

dmd cmain.d -defaultlib=""


If even that fails to link I honestly wouldn't know where to 
look next..


This seems odd. Have you tried to reinstall dmd? You could use 
dvm [1] to install different versions of dmd and see what 
happens. It seems as if there's something wrong with your 
installation. I have Ubuntu at work and ArchLinux at home. It 
works fine, there shouldn't be any problem with compiling your 
program.


[1] https://github.com/jacob-carlborg/dvm


No luck with cmain.d.
Its definitely an environmental problem -- I have an almost 
identical Archlinux desktop that is fine.
I thought I'd try my dev DMD, but realized I can't even compile 
it now that DMD is written in D >.<


[Issue 15323] Module.members and .deferred3 should use data structure with fast lookup

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15323

--- Comment #3 from Walter Bright  ---
https://github.com/dlang/dmd/pull/5693

--


[Issue 15323] Module.members and .deferred3 should use data structure with fast lookup

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15323

--- Comment #2 from Walter Bright  ---
A better solution is have the template instance contain a field which has a
pointer to which members[] it is contained in (since it is never contained in
more than one).

--


Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Ivan Kazmenko via Digitalmars-d-learn

On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote:

Have anybody implement Ada-style modulo types

https://en.wikibooks.org/wiki/Ada_Programming/Types/mod


I've implemented a proof-of-concept for algorithmic programming 
competitions [1]. In these competitions, quite a few problems ask 
to calculate the result modulo some large prime number.  The 
usual idea is that, this way, you still have to solve the 
underlying algorithmic problem, but the magnitude of calculated 
values does not affect your algorithmic complexity.  Disclaimer: 
it is incomplete and tuned for the competitions, and thus not 
ready for general use.


For the record, there is also an implementation of modulo integer 
for the same problem in C++ by Vladislav Isenbaev.  Note that the 
solutions themselves are not the same, so the timing can't be 
compared directly.


Ivan Kazmenko.

[1] http://codeforces.com/contest/628/submission/16212299
[2] http://codeforces.com/contest/628/submission/16610362



Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/22/2016 4:31 PM, Walter Bright wrote:

On 4/22/2016 3:16 PM, David Nadlinger wrote:

One of them is
https://github.com/dlang/dmd/blob/5ea445c68451152d43595c9de4797b6ec1e4f57d/src/dtemplate.d#L6503,

I think.


Definitely one.



BTW, this looks like a particularly bad piece of engineering. The trouble is, it 
saves an index to the member, then does a bunch of semantic processing, then 
deletes what is on that index. But what if the members[] in the meantime shifts 
around?


There is an assert for that case, so it at least won't cause corruption, but it 
looks bad.


std.experimental.allocator example wanted

2016-04-22 Thread Danni Coy via Digitalmars-d-learn
Can somebody give me a quick example of how to combine the
MMapAllocator with the AllocatorList and the BitmapBlock objects
together?


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/22/2016 3:07 PM, David Nadlinger wrote:

On Friday, 22 April 2016 at 21:48:09 UTC, Walter Bright wrote:

Why not just use a hash table? D's builtin one?


Apparently, some parts rely on the insertion order, although I'm not convinced
they should. Module::importAll is one of them, but in a way that's trivial to
avoid. I didn't check any other locations.

If order is not important, a hash set should be fine.


The linear search is checking for membership. Another way is to have the 'this' 
have a field that says which says which members[] it is in, if any. Voila, the 
membership becomes an O(1) search.




Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/22/2016 3:16 PM, David Nadlinger wrote:

One of them is
https://github.com/dlang/dmd/blob/5ea445c68451152d43595c9de4797b6ec1e4f57d/src/dtemplate.d#L6503,
I think.


Definitely one.



[Issue 15803] std.file should support sub-second file time precision on POSIX

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15803

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

https://github.com/dlang/phobos/commit/c3f0469b2bc341ae7068529d2bad68b97da07306
fix Issue 15803 - std.file should support sub-second file time precision on
POSIX

https://github.com/dlang/phobos/commit/29b0c559f77c3e7379781df8d7fd2fb023908843
Merge pull request #4089 from
CyberShadow/pull-20160316-181610-std-file-subsecond

fix Issue 15803 - std.file should support sub-second file time precision on
POSIX

--


Re: Google Summer of Code

2016-04-22 Thread Bill Baxter via Digitalmars-d-announce
Well done!  Congrats to you all!

--bb

On Fri, Apr 22, 2016 at 3:43 PM, CraigDillabaugh via Digitalmars-d-announce
 wrote:

> I am pleased to announce that the D Foundation has been awarded 4 slots
> for the 2016 Google Summer of Code.
>
> https://summerofcode.withgoogle.com/organizations/5078256051027968/
>
> Congratulations to
>
> Lodovico Giaretta
> A replacement of std.xml for the Phobos standard library
>
> Sebastian Wilzbach
> Science for D - a non-uniform RNG
>
> Jeremy DeHaan
> Precise Garbage Collector
>
> Wojciech Szęszoł
> Improvements for dstep
>
> on their successful proposals.
>
> They faced very stiff competition, and unfortunately we had to turn down a
> number of very good proposals.  Perhaps we should have been more greedy and
> asked for six or seven slots.
>
> I hope the community will extend a warm welcome to these students, and we
> welcome all of your efforts in helping these students achieve success in
> the coming months.
>
> Finally, thanks to all our mentors who put in hours of work in evaluating
> the proposals to this point.
>
>
>
>
>
>
>


Google Summer of Code

2016-04-22 Thread CraigDillabaugh via Digitalmars-d-announce
I am pleased to announce that the D Foundation has been awarded 4 
slots for the 2016 Google Summer of Code.


https://summerofcode.withgoogle.com/organizations/5078256051027968/

Congratulations to

Lodovico Giaretta
A replacement of std.xml for the Phobos standard library

Sebastian Wilzbach  
Science for D - a non-uniform RNG

Jeremy DeHaan   
Precise Garbage Collector

Wojciech Szęszoł
Improvements for dstep

on their successful proposals.

They faced very stiff competition, and unfortunately we had to 
turn down a number of very good proposals.  Perhaps we should 
have been more greedy and asked for six or seven slots.


I hope the community will extend a warm welcome to these 
students, and we welcome all of your efforts in helping these 
students achieve success in the coming months.


Finally, thanks to all our mentors who put in hours of work in 
evaluating the proposals to this point.









Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 22 April 2016 at 21:38:41 UTC, Johan Engelen wrote:
I don't understand exactly what you mean; do you propose to […] 
do a linear search when the shadow data structure says the item 
is present?


That's the idea. As long as you can reduce the need to do a full 
linear search by, say, 1 : 1000, it would be enough to make the 
quadratic behaviour disappear into the noise.


That being said, I did some estimates, and since the keys are 
only 8 bytes in size, Bloom filters in particular might not be 
worth it in this case, unfortunately. Quite sad, actually. I like 
Bloom filters.


 — David


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 22 April 2016 at 22:10:47 UTC, Walter Bright wrote:

On 4/22/2016 2:38 PM, Johan Engelen wrote:
I don't understand exactly what you mean; do you propose to 
resort to linear
search after a removal happened? Or only do a linear search 
when the shadow data

structure says the item is present?
I don't know how often removals happen, but for the 140k 
elements list removals
happens _very_ often. While compiling phobos, removals happen 
not for all

modules, but for quite a few of them.


I did a grep for "members.remove" and got no hits. Where are 
the removes happening?


One of them is 
https://github.com/dlang/dmd/blob/5ea445c68451152d43595c9de4797b6ec1e4f57d/src/dtemplate.d#L6503, I think.


 — David


Re: stc.experimental.ndslice -> sci.ndslice

2016-04-22 Thread Joseph Rushton Wakeling via Digitalmars-d

On Sunday, 17 April 2016 at 09:09:52 UTC, Ilya Yaroshenko wrote:

On Sunday, 17 April 2016 at 08:49:53 UTC, Seb wrote:
On Sunday, 17 April 2016 at 07:35:19 UTC, Ilya Yaroshenko 
wrote:

On Sunday, 17 April 2016 at 07:30:38 UTC, Vladimir Panteleev

I don't understand, what's wrong with std.sci or etc.sci?


I am ok with std.sci for example. I just want to exclude 
dances with transaction between stable <->`experimental`. So, 
if all `std.sci` would be marked as experimental during few 
years this would what i want.


Another idea would be to go with std.experimental.sci.*, if 
that has a higher consensus.


Just with std.sci.* without `experimental`. Otherwise this 
would be the same problem.


Why ... ?  Just keep everything in std.experimental.sci until all 
the details are worked out, and only transition to std.sci in one 
go once it's all done.


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/22/2016 2:38 PM, Johan Engelen wrote:

I don't understand exactly what you mean; do you propose to resort to linear
search after a removal happened? Or only do a linear search when the shadow data
structure says the item is present?
I don't know how often removals happen, but for the 140k elements list removals
happens _very_ often. While compiling phobos, removals happen not for all
modules, but for quite a few of them.


I did a grep for "members.remove" and got no hits. Where are the removes 
happening?



Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 22 April 2016 at 21:48:09 UTC, Walter Bright wrote:

Why not just use a hash table? D's builtin one?


Apparently, some parts rely on the insertion order, although I'm 
not convinced they should. Module::importAll is one of them, but 
in a way that's trivial to avoid. I didn't check any other 
locations.


If order is not important, a hash set should be fine.

 — David


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Walter Bright via Digitalmars-d

On 4/22/2016 11:55 AM, David Nadlinger wrote:

On Friday, 22 April 2016 at 18:51:57 UTC, David Nadlinger wrote:

As long as elements are not removed too frequently (what do your numbers
say?), the performance impact of doing a full linear search in those cases
shouldn't be too bad.


Note that a (properly tuned) probabilistic data structure like a Bloom filter
allows you to avoid having to keep a full second copy of the list around,
hopefully making it possible to keep the optimisation on by default without
regrets. (For tiny modules with only a small number of members, you can still do
the linear search to skip the hash lookup.)

  — David


Why not just use a hash table? D's builtin one?


[Issue 15323] Module.members and .deferred3 should use data structure with fast lookup

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15323

Walter Bright  changed:

   What|Removed |Added

 CC||bugzi...@digitalmars.com

--- Comment #1 from Walter Bright  ---
More information here:

http://www.digitalmars.com/d/archives/digitalmars/D/DMD_internal_appendToModuleMember_performance_283463.html

--


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread Johan Engelen via Digitalmars-d

On Friday, 22 April 2016 at 18:51:57 UTC, David Nadlinger wrote:

On Saturday, 16 April 2016 at 13:58:28 UTC, Johan Engelen wrote:


In rare cases, symbols are removed from the members list, so 
the shadow data structure needs the ability to delete elements.


Bloom filters can have false positives anyway. As long as 
elements are not removed too frequently (what do your numbers 
say?), the performance impact of doing a full linear search in 
those cases shouldn't be too bad.


The false-positive nature of Bloom filters makes them unsuited, I 
think, unless we can make the chance of a false-positive very low 
for lists that are very big, my testcase has a list size of 140k 
elements. It needs something scalable, otherwise there is no 
size-benefit. Wikipedia leads me to this: 
http://gsd.di.uminho.pt/members/cbm/ps/dbloom.pdf


I don't understand exactly what you mean; do you propose to 
resort to linear search after a removal happened? Or only do a 
linear search when the shadow data structure says the item is 
present?
I don't know how often removals happen, but for the 140k elements 
list removals happens _very_ often. While compiling phobos, 
removals happen not for all modules, but for quite a few of them.


In any case, I wrote the code such that it is easy to change the 
underlying data structure and test the impact.


Re: How do you use D to launch/open a window?

2016-04-22 Thread anonymousuer via Digitalmars-d-learn

On Friday, 22 April 2016 at 21:26:25 UTC, ciechowoj wrote:

On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote:
What code is needed to tell D to open a window? Thank you in 
advance.


Could you specify what kind of window do you need?


As in a regular Windows window, for example when you open up IE 
or a program. The container of the program itself, 
non-command-line.


Re: How do you use D to launch/open a window?

2016-04-22 Thread ciechowoj via Digitalmars-d-learn

On Friday, 22 April 2016 at 21:13:31 UTC, anonymousuer wrote:
What code is needed to tell D to open a window? Thank you in 
advance.


Could you specify what kind of window do you need?


How do you use D to launch/open a window?

2016-04-22 Thread anonymousuer via Digitalmars-d-learn
What code is needed to tell D to open a window? Thank you in 
advance.


[Issue 15144] Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere.

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15144

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

   What|Removed |Added

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

--


[Issue 15144] Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere.

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15144

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

https://github.com/dlang/dmd/commit/2a74f6c70f335a6b46494ce684dcdbac9825a21b
fix Issue 15144 - Bad operand size in asm { movdqa ... } produces bogus ubyte16
initializer error elsewhere

https://github.com/dlang/dmd/commit/2f402fdc5b22020ccfc1f7d45b36f796825cd280
Merge pull request #5689 from WalterBright/fix15144

fix Issue 15144 - Bad operand size in asm { movdqa ... } produces bog…

--


Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Timon Gehr via Digitalmars-d-learn

On 22.04.2016 21:52, Nordlöw wrote:

On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote:

Have anybody implement Ada-style modulo types

https://en.wikibooks.org/wiki/Ada_Programming/Types/mod


Here's my first try

https://github.com/nordlow/phobos-next/blob/master/src/modulo.d

Is there a way to use

alias _value this;

except mutation of _value which should check that _value is within value
range (0 .. m-1)?


Why do you want to perform a range check? Shouldn't it just take the 
appropriate remainder?


Anyway, the following will do what you request:

struct Mod(int M){
private int x;
@property int prop(int x)in{assert(0<=x&

Re: Ada-Style Modulo Integer Types

2016-04-22 Thread Nordlöw via Digitalmars-d-learn

On Friday, 22 April 2016 at 17:37:44 UTC, Nordlöw wrote:

Have anybody implement Ada-style modulo types

https://en.wikibooks.org/wiki/Ada_Programming/Types/mod


Here's my first try

https://github.com/nordlow/phobos-next/blob/master/src/modulo.d

Is there a way to use

   alias _value this;

except mutation of _value which should check that _value is 
within value range (0 .. m-1)?


Re: GSoC 2016

2016-04-22 Thread ciechowoj via Digitalmars-d

List of accepted projects : D:

https://summerofcode.withgoogle.com/organizations/5078256051027968/#projects





Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread David Nadlinger via Digitalmars-d-learn

On Thursday, 21 April 2016 at 14:47:55 UTC, Nick Treleaven wrote:
I found std.meta.ApplyLeft but it doesn't seem to work here. 
I've needed this before and ended up doing a workaround with a 
template block and temporary alias but it might be nice if 
Phobos had this. Or is there a simpler solution?


From std.meta:

---
/*
 * Instantiates the given template with the given list of 
parameters.

 *
 * Used to work around syntactic limitations of D with regard to 
instantiating
 * a template from an alias sequence (e.g. T[0]!(...) is not 
valid) or a template
 * returning another template (e.g. Foo!(Bar)!(Baz) is not 
allowed).

 */
// TODO: Consider publicly exposing this, maybe even if only for 
better

// understandability of error messages.
alias Instantiate(alias Template, Params...) = Template!Params;
---

;)

 — David


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 15 April 2016 at 18:33:44 UTC, Johan Engelen wrote:

I'm thinking about removing the old array all-together.
My question is: is it essential to keep an ordered list? (I see 
a `.shift(...)` call on the array, to put something in first 
position. If so, could that be solved by having *two* trees, 
where "in-order" iteration first iterates over the first one 
and then the second. The "high priority" symbols can then be 
put in the first tree, normal ones in the second tree (if that 
is how order matters...).


Did you have a closer look at where this is done? One place where 
order matters is for `object` in `importAll`, but that's 
trivially rewritten a different way.


 — David


Re: DlangUI on Android

2016-04-22 Thread David Nadlinger via Digitalmars-d-announce

On Friday, 22 April 2016 at 18:48:26 UTC, David Nadlinger wrote:

This is a reality now mostly due to Joakim's great LDC work.


(the fact that we can deploy stuff to Android in the first place, 
that is – obviously, the UI layer is a whole separate story)


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 22 April 2016 at 18:51:57 UTC, David Nadlinger wrote:
As long as elements are not removed too frequently (what do 
your numbers say?), the performance impact of doing a full 
linear search in those cases shouldn't be too bad.


Note that a (properly tuned) probabilistic data structure like a 
Bloom filter allows you to avoid having to keep a full second 
copy of the list around, hopefully making it possible to keep the 
optimisation on by default without regrets. (For tiny modules 
with only a small number of members, you can still do the linear 
search to skip the hash lookup.)


 — David


Re: DMD internal: appendToModuleMember performance

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Saturday, 16 April 2016 at 13:58:28 UTC, Johan Engelen wrote:

On Friday, 15 April 2016 at 19:32:46 UTC, David Nadlinger wrote:
Another "quick fix" if we have to keep the order would be to 
add a Bloom filter/… on the side to eliminate most array 
searches.


In rare cases, symbols are removed from the members list, so 
the shadow data structure needs the ability to delete elements.


Bloom filters can have false positives anyway. As long as 
elements are not removed too frequently (what do your numbers 
say?), the performance impact of doing a full linear search in 
those cases shouldn't be too bad.


 — David


Re: Distributor's whishlist and questions for D

2016-04-22 Thread David Nadlinger via Digitalmars-d

On Friday, 22 April 2016 at 09:18:48 UTC, Kagamin wrote:
RMW operations on shared data are deprecated. The template 
filter on atomicOp is a little different: 
https://dlang.org/phobos/core_atomic.html#.atomicOp

Looks like an LDC bug.


Yes, this was indeed an LDC issue. We have our own 
implementation, and apparently missed that the template 
constraint on the DMD version was updated: 
https://github.com/ldc-developers/ldc/pull/1456


 — David


Re: DlangUI on Android

2016-04-22 Thread Laeeth Isharc via Digitalmars-d-announce

On Thursday, 21 April 2016 at 13:28:18 UTC, Vadim Lopatin wrote:

I've implemented initial support of Android in DlangUI.


Congratulations, Vadim.

This is a very exciting development.  (And impressive in the 
'consequent' department, as the Germans say - you said you would 
have DlangUI ported to Android some weeks after the working 
compiler, and that's what you did!).


Might be useful for me to port some D code for internal 
enterprise apps to Android that currently runs on linux (I 
recognise how experimental it is, but I'm okay with that since 
mobile is just nice to have, and not yet necessary).


Will you be at dconf?


Re: DlangUI on Android

2016-04-22 Thread David Nadlinger via Digitalmars-d-announce

On Thursday, 21 April 2016 at 14:48:40 UTC, ANtlord wrote:
Am I sleeping? Can we develop UI applications for Android on D? 
It's great!


Yes – cool, right?

This is a reality now mostly due to Joakim's great LDC work.

 — David


Re: Enabling Only Top-Level Unittests

2016-04-22 Thread Basile B. via Digitalmars-d-learn

On Thursday, 21 April 2016 at 19:38:21 UTC, Nordlöw wrote:

On Thursday, 21 April 2016 at 12:35:42 UTC, Anonymouse wrote:

Then dmd -unittest -version=TestDeps if you want them run.


This doesn't make things easier. I want to disable the builtin 
unittests of the modules I've imported. This requires me to add 
a


version(test_MODULE) unittest

in each module named MODULE.

This is really inconvenient.


You could anotate your user/top level tests and select only those 
with __traits(getUnittest,...) and hasUDA(). Unfortunately it 
seems that there's a flaw because in a program all the tests will 
be automatically executed once then again those that are anotated.


---
#!runnable-flags: -unittest
module m;

import std.stdio;

enum USERTEST;

@USERTEST unittest // exeuted twice
{
writeln("bang");
}

unittest // executed once
{
writeln("bing");
}

void main(string[] args)
{
import std.traits;
foreach(t; __traits(getUnitTests, m))
{
static if (hasUDA!(t, USERTEST))
t();
}
}
---

But...
A solution that would work for both a library and a program is 
this:


---
module m;

import std.stdio;

enum USERTEST;

@USERTEST void test0()
{
writeln("bing");
}

@USERTEST void test1()
{
writeln("bang");
}

unittest
{
// not even compiled
}

void runUserTests(Modules...)()
{
import std.traits;
static if (Modules.length > 1)
runModuleTests!(Modules[1..$]);
else static if (Modules.length == 1)
{
foreach(member; __traits(allMembers, Modules[0]))
foreach(o; __traits(getOverloads, Modules[0], member))
static if (hasUDA!(o, USERTEST) && 
(Parameters!o).length == 0)

o();
}
}

void main()
{
runUserTests!m;
}
---

I think a DMD option should be added to allow the tests to be 
compiled but never called, something like -runTests. Because the 
first solution is much more attractive.


Re: DlangUI on Android

2016-04-22 Thread TheGag96 via Digitalmars-d-announce

On Thursday, 21 April 2016 at 13:28:18 UTC, Vadim Lopatin wrote:

(snip)


Wow, really nice stuff! I wasn't even aware we could write D for 
Android at all...




Ada-Style Modulo Integer Types

2016-04-22 Thread Nordlöw via Digitalmars-d-learn

Have anybody implement Ada-style modulo types

https://en.wikibooks.org/wiki/Ada_Programming/Types/mod

in D?

I'm thinking

modulo.d:

struct Mod(size_t m, Block = uint)
{
static assert(m <= 2^^(8*Block.sizeof));
Block value;
}

typically used as

Mod!(8, ubyte)
Mod!(256, ubyte)
Mod!(8, uint)

?


Re: VisualD + ZeroMQ

2016-04-22 Thread Chuck Moore via Digitalmars-d-learn

On Thursday, 21 April 2016 at 00:15:03 UTC, Chuck Moore wrote:

Hi Everyone,

Preamble: We're a Win7+VisualStudio development environment. 
This question involves integrating the GitHub-based

.


Chuck


Hi Everyone,

I finally got my compilation+linking to work using VisualD. In 
the event others might find my results useful, here are my notes:


1) It turns out that when using VisualD, the 
safest/guaranteed-way-to-make-things-visible-to-DMD is to load 
everything (as in anything one imports-from, or references with 
the linker) into the 'solution' using the Add > Existing Items 
option found by right-clicking the solution's name in  'Solution 
Explorer'.
2) So what I ended up having as additional items alongside 
'main.d' : libsodium.lib, libzmq-v110_xp_mt-4_0_4.lib, 
zeromq.lib, zmqd.d, and zmqd.lib. There is certainly some 
duplication of functions in this list, but VisualD wasn't happy 
until I had all of these items added.
3) Finally, prior to adding the 'lib' files, I also had to 
(download and) use the 'coffimpllib' utility on ALL the lib files.


My thanks to the author of zmqd for his quick response and 
encouragement.

Chuck


Re: Phobos posix.mak -> D file using reggae: round 2

2016-04-22 Thread Piotrek via Digitalmars-d

On Monday, 18 April 2016 at 15:15:26 UTC, Atila Neves wrote:
Here's[1] another attempt at converting the Makefile for POSIX 
systems to D using reggae[2].

...

Destroy!

Atila


I know you your intention was to keep it similar to makefile, but 
for me it looks unnecessarily complex.


What whould you say about different approach e.g.:

void configure()
{
with (targets["linux shared library"])
{
inheritConfig("linux 32");
sources = "lib/*.d";
dependency ~= "objects";
output = "somthing.so";
}
}


Piotrek


Re: DlangUI on Android

2016-04-22 Thread Vadim Lopatin via Digitalmars-d-announce

On Friday, 22 April 2016 at 15:02:32 UTC, FrankLike wrote:
You can downlowd sample APK: 
https://sourceforge.net/projects/crengine/files/DlangUI/


DlangUI Tetris example now works ok on Android (arm, 
android4.4+)


Android5.02 ,Not ok, sorry.


Does it crash instantly or shows app GUI for some time?
Is your smartphone arm-based?
Couldn't you collect logs with `adb logcat`?



Re: DlangUI on Android

2016-04-22 Thread FrankLike via Digitalmars-d-announce

On Friday, 22 April 2016 at 12:05:52 UTC, Vadim Lopatin wrote:

On Thursday, 21 April 2016 at 13:28:18 UTC, Vadim Lopatin wrote:

Hello,

I've implemented initial support of Android in DlangUI.

Only armv7a architecture is supported so far.

You can downlowd sample APK: 
https://sourceforge.net/projects/crengine/files/DlangUI/


DlangUI Tetris example now works ok on Android (arm, 
android4.4+)


Android5.02 ,Not ok, sorry.


Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn

On 22/04/2016 14:40, Steven Schveighoffer wrote:

OK, I get it. I think this used to work, but I think D has long since
disallowed direct access to eponymous members.

So what you really want to do is:

staticEx!(Exception, msg)!(file, line), but of course this doesn't
follow proper grammar.

I think you are right, this cannot be done without such a template. It
brings back access to the eponymous nested template, interesting. I
think we should add it.


OK, great :-)


Re: DlangUI on Android

2016-04-22 Thread FrankLike via Digitalmars-d-announce

On Thursday, 21 April 2016 at 13:28:18 UTC, Vadim Lopatin wrote:

Hello,

I've implemented initial support of Android in DlangUI.

[...]


Congratulations!


Re: DlangUI on Android

2016-04-22 Thread Vadim Lopatin via Digitalmars-d-announce

On Friday, 22 April 2016 at 13:41:52 UTC, Mike Parker wrote:
I was late, but I have since gotten this taken care of, so it's 
all golden.


FYI, for anyone facing a similar problem in the future and is 
hung up waiting on me to merge a pull request, the base loader 
in DerelictUtil allows overriding the default library names. So 
instead of a library like DLangUI requiring a patched Derelict 
package, you could do this:


version(Derelict_OS_Android)
DerelictFT.load("libft2.so");

You can pass multiple library names as a single, 
comma-separated string:


DerelictFT.load("libft2.so,libfreetype.so");

Or as an array (which is what the above is converted to 
internally anyway):


DerelictFT.load(["libft2.so", "libfreetype.so"]);


Thank you for your help! I've updated dlangui dub.json with 
latest DerelictFT.




Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/22/16 6:50 AM, Nick Treleaven wrote:

On 21/04/2016 18:03, Steven Schveighoffer wrote:

This doesn't work?

alias staticEx(string msg, string file = __FILE__, size_t line =
__LINE__) = staticEx!(Exception, msg).staticEx!(file, line);


No, nor using the module dot prefix `= .staticEx!(...).staticEx` either:

staticex.d(3): Error: template identifier 'staticEx' is not a member of
template 'staticex.staticEx!(Exception, "Look ma, @nogc
exception!").staticEx(string file = __FILE__, uint line = __LINE__)()'
staticex.d(20): Error: template instance staticex.staticEx!("Look ma,
@nogc exception!", "staticex.d", 20u) error instantiating


OK, I get it. I think this used to work, but I think D has long since 
disallowed direct access to eponymous members.


So what you really want to do is:

staticEx!(Exception, msg)!(file, line), but of course this doesn't 
follow proper grammar.


I think you are right, this cannot be done without such a template. It 
brings back access to the eponymous nested template, interesting. I 
think we should add it.



I would think something with AliasSeq could come in handy, it's the way
to alias a compile-time list.


Not sure how that would help.


I didn't realize what the issue was.

-Steve


Re: DlangUI on Android

2016-04-22 Thread Mike Parker via Digitalmars-d-announce

On Thursday, 21 April 2016 at 15:49:32 UTC, Vadim Lopatin wrote:

Forgot to add that DerelictFT patch is required for 
DlangUI/Android.

(Freetype library has name libft2.so on Android)

PR is submitted, but not yet integrated into DerelictFT:

https://github.com/DerelictOrg/DerelictFT/pull/9




I was late, but I have since gotten this taken care of, so it's 
all golden.


FYI, for anyone facing a similar problem in the future and is 
hung up waiting on me to merge a pull request, the base loader in 
DerelictUtil allows overriding the default library names. So 
instead of a library like DLangUI requiring a patched Derelict 
package, you could do this:


version(Derelict_OS_Android)
DerelictFT.load("libft2.so");

You can pass multiple library names as a single, comma-separated 
string:


DerelictFT.load("libft2.so,libfreetype.so");

Or as an array (which is what the above is converted to 
internally anyway):


DerelictFT.load(["libft2.so", "libfreetype.so"]);


[Issue 9626] More precise error message in some cases when failed template constraint

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9626

--- Comment #3 from Sobirari Muhomori  ---
Even better error message would be "Error: template instance f1!1 does not
match template declaration f1(int n)(int val) if (n == 0), because template
constraint is not satisfied".

--


[Issue 15950] New: Wish: __compressed_import("file.ext");

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15950

  Issue ID: 15950
   Summary: Wish: __compressed_import("file.ext");
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: alil...@gmail.com

I've an idea for a practical quality-of-life but non-orthogonal feature.

__compressed_import("file.ext") would be like import("file.ext"), but instead
giving the file ZIP-compressed or any other friendly format.


The use case is that using multiple import("file.exe") are really practical to
bundle resources with a program(fonts, images, any data).
It really does make builds easier and with less redundancy and it is
cross-platform alternatives to PE resources, Mac bundle resources, or something
else on *nix.

But the size of these resources can be critical for binary size. On Apple
platforms they could be duplicated within each executable of an Universal
Binary.

I've considered using CTFE to ZIP imported resources, but was advised not to.
It may be prohibitive and use a lot of memory. It's an option though, perhaps
the reasonable one.

--


[Issue 9626] More precise error message in some cases when failed template constraint

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9626

--- Comment #2 from Sobirari Muhomori  ---
void f(int n, T)(T val)if(n==0){}
void f1(int n)(int val)if(n==0){}
void g()
{
f!1(1);
f1!1(1);
}

The second instatiation gives good error message: "Error: template instance
f1!1 does not match template declaration f1(int n)(int val) if (n == 0)".

The first instatiation gives less helpful error message: "Error: template f
cannot deduce function from argument types !(1)(int), candidates are:...", but
it doesn't look like there's problem with deduction, should report no match.

See https://forum.dlang.org/post/gvzgecxrhdxrqchek...@forum.dlang.org

--


Re: "inline" conversion of array to immutable

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn

On 22.04.2016 13:46, Jeff Thompson wrote:

The function literal also works if I add
"function int[]()":
void main(string[] args) {
   immutable int[] array = function int[]() {
 int[] result = new int[10];
 result[0] = 1;
 return result;
   }();
}



I take it you're on 2.070 or older then. 2.071 accepts it without 
`function`, which seems a bit inconsistent when I think about it.


Anyway, just `function` should be enough. But of course you can specify 
return type and empty parameter list if you want.


Re: DlangUI and CL Tools

2016-04-22 Thread Chris via Digitalmars-d

On Friday, 22 April 2016 at 11:46:12 UTC, Dicebot wrote:

But who are those "we" you refer to? :) Or, to rephrase, do you 
really envision a volunteer abandoning any project/task he has 
current personal interest in to work on some third-party 
project (he doesn't need) because of its strategical value? 
Call be grumpy and skeptical but open-source pretty much never 
works like that. Specifically calls for arms like yours have 
been done many times before and always with exactly 0 effective 
outcome.


I am not saying that you shouldn't call for arms, just don't be 
surprised/offended if nothing happens as a result :)


Yes, yes. We all know that. We've been here long enough. I'm 
being neither idealistic nor naive. But still, D has improved 
drastically over just 3 r 4 years. So there is definitely a "we" 
out there somewhere. And there might be people out there who 
think that they would like to contribute to D but not necessarily 
to Phobos. It could be anything, from artwork (icons) for DlangUI 
to testing, creating themes, writing plugins. If people have the 
feeling there's a future for the project, they will contribute. 
It's not a call to arms. It's more like saying "Look, here's 
something that is good. And you can improve it." I just think the 
time has come to go beyond the language and add some bells and 
whistles. With DConf coming up, maybe it's worth talking about 
things like that too.


Re: XDG-APP and D

2016-04-22 Thread John Colvin via Digitalmars-d-announce

On Thursday, 21 April 2016 at 18:55:23 UTC, Gerald wrote:
For those not familiar, xdg-app is a Linux virtualization 
system targeted at desktop apps, it's been under pretty heavy 
development and is available for use in Gnome 3.20.


Mathias Clausen recently wrote a blog entry about creating his 
first xdg-app and the application he chose to play with was 
Terminix, a terminal emulator, which is written in D. He had 
some D specific challenges to deal with which may be 
interesting to others looking to support xdg-app.


You can read his blog entry here:

https://blogs.gnome.org/mclasen/2016/04/15/my-first-xdg-app.


Can someone explain to me how xdg-app provides a significantly 
different experience to static linking (in a language like C or 
D)? I guess there's the old "what about libc?".


Re: "inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn

On Friday, 22 April 2016 at 11:16:59 UTC, ag0aep6g wrote:
It's a nested function now. That means, it could reference 
local variables of main. Make func static and it works.


You can also use a function literal:

void main()
{
  immutable int[] array = {
int[] result = new int[10];
result[0] = 1;
return result;
  }();
}


Great! Making it static works. The function literal also works if 
I add "function int[]()":

void main(string[] args) {
  immutable int[] array = function int[]() {
int[] result = new int[10];
result[0] = 1;
return result;
  }();
}



Re: DlangUI and CL Tools

2016-04-22 Thread Dicebot via Digitalmars-d
On 04/22/2016 02:34 PM, Chris wrote:
>> Common misconception is that D team has any manpower it can
>> potentially invest into promising projects. It doesn't. Some
>> volunteers are more commited than others but there is no one (not even
>> Andrei or Walter) who can tell others what spend their time one. There
>> are both good and bad consequences from that but it is simply how
>> things work right now.
>>
>> As such, only thing that can attract more manpower to any project
>> (including DLangUI) is for author/maintainer to make it useful for
>> many people and to make it easy and pleasant for them to contribute
>> (see vibe.d case as an example).
> 
> We all know that. But we can at least try to keep projects going that
> are promising and important in the long run.

But who are those "we" you refer to? :) Or, to rephrase, do you really
envision a volunteer abandoning any project/task he has current personal
interest in to work on some third-party project (he doesn't need)
because of its strategical value? Call be grumpy and skeptical but
open-source pretty much never works like that. Specifically calls for
arms like yours have been done many times before and always with exactly
0 effective outcome.

I am not saying that you shouldn't call for arms, just don't be
surprised/offended if nothing happens as a result :)


Re: Distributor's whishlist and questions for D

2016-04-22 Thread Kagamin via Digitalmars-d

On Friday, 22 April 2016 at 09:18:48 UTC, Kagamin wrote:

Looks like an LDC bug.


Or not. If template constraint doesn't match, the error should be 
"template instance does not match template declaration".


Re: DlangUI and CL Tools

2016-04-22 Thread Chris via Digitalmars-d

D has taken some giant steps


s/taken/made




Re: DlangUI and CL Tools

2016-04-22 Thread Chris via Digitalmars-d

On Friday, 22 April 2016 at 10:59:16 UTC, Dicebot wrote:

On 04/22/2016 01:42 PM, Chris wrote:

I am referring to threads [1], [2] and [3].

1. DlangUI is making progress and looks very promising. Is 
there any chance that the DLang foundation/community would 
embrace this project (more manpower)?


Common misconception is that D team has any manpower it can 
potentially invest into promising projects. It doesn't. Some 
volunteers are more commited than others but there is no one 
(not even Andrei or Walter) who can tell others what spend 
their time one. There are both good and bad consequences from 
that but it is simply how things work right now.


As such, only thing that can attract more manpower to any 
project (including DLangUI) is for author/maintainer to make it 
useful for many people and to make it easy and pleasant for 
them to contribute (see vibe.d case as an example).


We all know that. But we can at least try to keep projects going 
that are promising and important in the long run. The thing is 
that D is gaining momentum and we should cease the opportunity to 
extend it beyond mere language features. If I compare D to where 
it was 2 or 3 years ago, D has taken some giant steps (look at 
the books that have been written about D).


I recently dabbled in Java, and I have to say that D is way ahead 
of it. Java, albeit nice, safe and cosy (safety helmets must be 
worn at all times), feels like a straight jacket and they've just 
now started to remove some of the laces (so that you can scratch 
yourself).


Imo, D is definitely on the right track, that's why it's time to 
extend it and add a GUI etc. to it, which of course is not the 
job of the core developers. But it wouldn't hurt to promote the 
development of DlangUI.


Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn

On Friday, 22 April 2016 at 11:07:47 UTC, Jeff Thompson wrote:

On Friday, 22 April 2016 at 09:40:14 UTC, FreeSlave wrote:

On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote:
Hello. The following code compiles OK where func creates a 
mutable array and main assigns it to an immutable variable:


[...]


Probably this is what you look for 
http://dlang.org/phobos/std_exception.html#.assumeUnique


OK, we lose the compiler check for correctness. What if I put 
func directly in main with the hopes that the compiler will 
check correctness and also inline the function? But it won't 
assign to the immutable array. Why not? It's the same function.


void main(string[] args) {
  int[] func(int x) pure {
int[] result = new int[10];
result[0] = x;
return result;
  }
  immutable int[] array = func(1);
}


Not sure why, but making func static fixes this:

void main(string[] args) {
  static int[] func(int x) pure {
int[] result = new int[10];
result[0] = x;
return result;
  }
  immutable int[] array = func(1);
}



Re: "inline" conversion of array to immutable

2016-04-22 Thread ag0aep6g via Digitalmars-d-learn

On 22.04.2016 13:07, Jeff Thompson wrote:

OK, we lose the compiler check for correctness. What if I put func
directly in main with the hopes that the compiler will check correctness
and also inline the function? But it won't assign to the immutable
array. Why not? It's the same function.

void main(string[] args) {
   int[] func(int x) pure {
 int[] result = new int[10];
 result[0] = x;
 return result;
   }
   immutable int[] array = func(1);
}


It's a nested function now. That means, it could reference local 
variables of main. Make func static and it works.


You can also use a function literal:

void main()
{
  immutable int[] array = {
int[] result = new int[10];
result[0] = 1;
return result;
  }();
}



Re: aliasing/referencing expressions in with statements

2016-04-22 Thread deed via Digitalmars-d-learn

On Friday, 22 April 2016 at 01:42:11 UTC, Yuxuan Shui wrote:

Maybe use something like:

auto a = () => instanceA.verboseFieldA.verboseFieldB;


You can certainly declare temporaries and rely on the compiler 
optimizing those away:


auto a = instanceA.verboseFieldA.verboseFieldB;
auto b = instanceA.aDescriptiveName;
auto value = intanceC.value;

// use a, b and value

If that were considered a sound solution, it would partly 
undermine the purpose of with statements, except for referring to 
multiple fields within the same instance, which I guess is common 
enough and makes it more convenient to express member functions 
as free functions. However, it seems simple for the compiler to 
lower such a with statement, so I wonder whether there are any 
technical reasons not to? I.e:


with (a = expressionA, b = expressionB, instanceC) {
  // access to instanceC's fields and replace a and b
  // with expressionA and expressionB, respectively.
}

That would make for very clear expressions while still allowing 
descriptive field names. Other solutions, as templates or mixins, 
seem a little too clumsy.


Re: "inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn

On Friday, 22 April 2016 at 09:40:14 UTC, FreeSlave wrote:

On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote:
Hello. The following code compiles OK where func creates a 
mutable array and main assigns it to an immutable variable:


[...]


Probably this is what you look for 
http://dlang.org/phobos/std_exception.html#.assumeUnique


OK, we lose the compiler check for correctness. What if I put 
func directly in main with the hopes that the compiler will check 
correctness and also inline the function? But it won't assign to 
the immutable array. Why not? It's the same function.


void main(string[] args) {
  int[] func(int x) pure {
int[] result = new int[10];
result[0] = x;
return result;
  }
  immutable int[] array = func(1);
}



[Issue 11517] Allow generic "BasicType" in alias this declaration

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=11517

Nick Treleaven  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=15892

--


[Issue 15892] Can't use alias this with static namespaces

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=15892

Nick Treleaven  changed:

   What|Removed |Added

   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=11517
Summary|Can't use alias this with   |Can't use alias this with
   |struct static member|static namespaces
   Severity|minor   |enhancement

--- Comment #2 from Nick Treleaven  ---
The pattern is probably more useful with named mixin members:

struct S
{
template T()
{
int i;
}
mixin T m;
//alias m.i this; //error
// workaround
alias get this;
alias get = m.i;
}

--


Re: stc.experimental.ndslice -> sci.ndslice

2016-04-22 Thread Dicebot via Digitalmars-d
On 04/18/2016 07:13 PM, Dejan Lekic wrote:
> On Sunday, 17 April 2016 at 06:10:34 UTC, Ilya Yaroshenko wrote:
>> We plan to add a set of numeric packages and this would be real pain
>> if they would be one-by-one moved from experimental to stable std. So
>> sci.* should be considered as experimental during few years.
>>
>>
>> https://github.com/dlang/phobos/pull/4207
> 
> As I have said many times on both IRC and NG, I would prefer to have
> `stdx` instead of ridiculously long (4x) `std.experimental`. Then you
> would have a nice package named `stdx.sci`.
> 
> PS. this is not my "invention" - Java community has `javax` for similar
> (but different, as nothing in javax is experimental) purpose!

Java is commonly mentioned as example of experimental package concept
that didn't work at all.


Re: Distributor's whishlist and questions for D

2016-04-22 Thread Dicebot via Digitalmars-d
FYI: I don't want to comment here for now because Debian packaging is
very different from Arch packaging but I am keeping my eyes on the thread :)



Re: DlangUI and CL Tools

2016-04-22 Thread Dicebot via Digitalmars-d
On 04/22/2016 01:42 PM, Chris wrote:
> I am referring to threads [1], [2] and [3].
> 
> 1. DlangUI is making progress and looks very promising. Is there any
> chance that the DLang foundation/community would embrace this project
> (more manpower)?

Common misconception is that D team has any manpower it can potentially
invest into promising projects. It doesn't. Some volunteers are more
commited than others but there is no one (not even Andrei or Walter) who
can tell others what spend their time one. There are both good and bad
consequences from that but it is simply how things work right now.

As such, only thing that can attract more manpower to any project
(including DLangUI) is for author/maintainer to make it useful for many
people and to make it easy and pleasant for them to contribute (see
vibe.d case as an example).


Re: XDG-APP and D

2016-04-22 Thread Anonymouse via Digitalmars-d-announce

On Friday, 22 April 2016 at 10:24:08 UTC, Dicebot wrote:

On 04/21/2016 11:30 PM, Karabuta wrote:
This whole sandbox apps seem interesting. Canonical also 
talking about snaps :)


Meh, I can see why this concept is tempting for desktop systems 
but it makes me feel that 5 years from now I'll have to build 
my own Linux-From-Scratch distro to preserve kind of user 
experience I initially loved Linux for (minimal overhead, 
running same system on both your tiny media server and power 
desktop). "A runtime can be thought of as a /usr filesystem 
with fixed contents. When a bundled app gets run, the runtime 
it needs gets mounted at /usr." :(


I don't know at what point dynamic libraries came to be 
considered harmful, but it certainly seems to be the case now. 
And even if they are dynamic inside the container, every program 
shipping an individual copy of the libs means they might as well 
be statically compiled into it.


Re: Instantiate!(Template, args) in Phobos?

2016-04-22 Thread Nick Treleaven via Digitalmars-d-learn

On 21/04/2016 18:03, Steven Schveighoffer wrote:

This doesn't work?

alias staticEx(string msg, string file = __FILE__, size_t line =
__LINE__) = staticEx!(Exception, msg).staticEx!(file, line);


No, nor using the module dot prefix `= .staticEx!(...).staticEx` either:

staticex.d(3): Error: template identifier 'staticEx' is not a member of 
template 'staticex.staticEx!(Exception, "Look ma, @nogc 
exception!").staticEx(string file = __FILE__, uint line = __LINE__)()'
staticex.d(20): Error: template instance staticex.staticEx!("Look ma, 
@nogc exception!", "staticex.d", 20u) error instantiating



I would think something with AliasSeq could come in handy, it's the way
to alias a compile-time list.


Not sure how that would help.


DlangUI and CL Tools

2016-04-22 Thread Chris via Digitalmars-d

I am referring to threads [1], [2] and [3].

1. DlangUI is making progress and looks very promising. Is there 
any chance that the DLang foundation/community would embrace this 
project (more manpower)? I've been fiddling around with GUIs a 
bit recently. GtkD is great and all the other wrappers are cool, 
but with wrappers you always lag behind and depend on other 
sources/libs. I played around with JavaFX+Scene Builder and it's 
pretty cool. Maybe we should consider our own GUI like JavaFX, 
and DlangUI could be the one.


2. D is a good option when it comes to CL utilities. Whenever I 
have to write one, it's in D. Maybe we should explore this more. 
Imagine if people started to write more and more CL tools in D. 
It'd be great PR. It would also help us to deal with the weak 
spots.



[1] 
http://forum.dlang.org/thread/cdekkumjynhqoxvmg...@forum.dlang.org
[2] 
http://forum.dlang.org/thread/yiguvkubszjgddgjy...@forum.dlang.org
[3] 
http://forum.dlang.org/thread/epjkkbbzdsxjlauzb...@forum.dlang.org


Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Chris via Digitalmars-d-learn

On Friday, 22 April 2016 at 09:49:02 UTC, Rene Zwanenburg wrote:

On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote:
- What happens when you compile a binary without phobos and 
druntime, and with a custom entry point? I've never done that 
myself and don't remember how to do that off the top of my 
head, but the info should be somewhere on dlang.org.


I'll look into it.


Declaring a C-like main and the -defaultlib switch do the trick:

 cmain.d
extern(C) void main() nothrow {}
---

dmd cmain.d -defaultlib=""


If even that fails to link I honestly wouldn't know where to 
look next..


This seems odd. Have you tried to reinstall dmd? You could use 
dvm [1] to install different versions of dmd and see what 
happens. It seems as if there's something wrong with your 
installation. I have Ubuntu at work and ArchLinux at home. It 
works fine, there shouldn't be any problem with compiling your 
program.


[1] https://github.com/jacob-carlborg/dvm


Re: XDG-APP and D

2016-04-22 Thread Dicebot via Digitalmars-d-announce
On 04/21/2016 11:30 PM, Karabuta wrote:
> This whole sandbox apps seem interesting. Canonical also talking about
> snaps :)

Meh, I can see why this concept is tempting for desktop systems but it
makes me feel that 5 years from now I'll have to build my own
Linux-From-Scratch distro to preserve kind of user experience I
initially loved Linux for (minimal overhead, running same system on both
your tiny media server and power desktop). "A runtime can be thought of
as a /usr filesystem with fixed contents. When a bundled app gets run,
the runtime it needs gets mounted at /usr." :(


Re: Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

2016-04-22 Thread Rene Zwanenburg via Digitalmars-d-learn

On Thursday, 21 April 2016 at 16:29:14 UTC, rcorre wrote:
- What happens when you compile a binary without phobos and 
druntime, and with a custom entry point? I've never done that 
myself and don't remember how to do that off the top of my 
head, but the info should be somewhere on dlang.org.


I'll look into it.


Declaring a C-like main and the -defaultlib switch do the trick:

 cmain.d
extern(C) void main() nothrow {}
---

dmd cmain.d -defaultlib=""


If even that fails to link I honestly wouldn't know where to look 
next..


Re: "inline" conversion of array to immutable

2016-04-22 Thread FreeSlave via Digitalmars-d-learn

On Friday, 22 April 2016 at 09:25:32 UTC, Jeff Thompson wrote:
Hello. The following code compiles OK where func creates a 
mutable array and main assigns it to an immutable variable:


[...]


Probably this is what you look for 
http://dlang.org/phobos/std_exception.html#.assumeUnique


Re: Whitch can replace std::bind/boost::bind ?

2016-04-22 Thread Dsby via Digitalmars-d-learn

On Friday, 18 March 2016 at 17:24:27 UTC, Ali Çehreli wrote:

On 03/18/2016 03:50 AM, Dsby wrote:


foreach (i ; 0..4) {
 auto th = new Thread(delegate(){listRun(i);});//this is 
erro

 _thread[i]= th;
 th.start();
}

void listRun(int i)
{
  writeln("i = ", i); // the value is not(0,1,2,3), it all 
is 2.

}


I want to know how to use it like std::bind.




A workaround is an intermediate function that returns the 
delegate:


import std.stdio;
import core.thread;

void listRun(int i)
{
 writeln("i = ", i); // the value is not(0,1,2,3), it all 
is 2.

}

auto makeClosure(int i) {
return delegate(){listRun(i);};
}

void main() {
Thread[4] _thread;

foreach (i ; 0..4) {
auto th = new Thread(makeClosure(i));
_thread[i]= th;
th.start();
}
}

Prints different values:

i = 1
i = 0
i = 2
i = 3

Ali


Thanks for your mind.
i write the bind function:

import std.stdio;
import core.thread;
import std.functional;

class AA
{
void show(int i)
{
writeln("i = ", i); // the value is not(0,1,2,3), it all 
is 2.

}

}


void listRun(int i)
{
 writeln("i = ", i);
}


void main() {
Thread[4] _thread;
Thread[4] _thread2;
 AA a = new AA();
foreach (i ; 0..4) {
auto th = new Thread(bindDg(,i));
_thread[i]= th;
auto th2 = new Thread(bindFun!listRun(i + 10));
_thread2[i]= th2;
}

foreach(i;0..4)
{
_thread[i].start();
}

foreach(i;0..4)
{
_thread2[i].start();
}

}


auto bindDg(T, Args...)(T fun,Args args) if (is(T == delegate) || 
is(T == function))

{
return delegate(){return fun(forward!args);};
}

auto bindFun(alias Fun,Args...)(Args args) {
return delegate(){return Fun(forward!args);};
}


my value  is :
i = 2
i = 0
i = 3
i = 11
i = 13
i = 10
i = 12
i = 1



"inline" conversion of array to immutable

2016-04-22 Thread Jeff Thompson via Digitalmars-d-learn
Hello. The following code compiles OK where func creates a 
mutable array and main assigns it to an immutable variable:


int[] func(int x) pure {
  int[] result = new int[10];
  result[0] = x;
  return result;
}

void main(string[] args)
{
  immutable int[] array = func(1);
}

I assume this works because func is pure so that the compiler 
knows that its return value won't be changed by some other code. 
But it doesn't compile when I put the same code from func 
"inline" into main:


void main(string[] args)
{
  int[] result = new int[10];
  result[0] = 1;
  immutable int[] array = result;
}

I could forcibly cast result to immutable int[], but that seems 
error-prone. How to tell the compiler that result will not be 
changed after assigning to array so that the immutable assignment 
compiles?


Re: XDG-APP and D

2016-04-22 Thread FreeSlave via Digitalmars-d-announce

On Thursday, 21 April 2016 at 18:55:23 UTC, Gerald wrote:
For those not familiar, xdg-app is a Linux virtualization 
system targeted at desktop apps, it's been under pretty heavy 
development and is available for use in Gnome 3.20.


Mathias Clausen recently wrote a blog entry about creating his 
first xdg-app and the application he chose to play with was 
Terminix, a terminal emulator, which is written in D. He had 
some D specific challenges to deal with which may be 
interesting to others looking to support xdg-app.


You can read his blog entry here:

https://blogs.gnome.org/mclasen/2016/04/15/my-first-xdg-app.


How did he get build that weighs less than megabyte? When 
building with dub -b release and after stripping binary terminix 
still weighs 9 MB on my debian. And it's just a single binary, 
without resources and dynamic dependencies.


Re: Distributor's whishlist and questions for D

2016-04-22 Thread Kagamin via Digitalmars-d

On Thursday, 21 April 2016 at 15:41:17 UTC, Matthias Klumpp wrote:
Asgen is super-boring code ;-) Mainly because the task it 
performs can be represented without using much black magic.


One interesting possibility with D is that you can test what 
performance impact boundschecking has on your code with just a 
compiler switch. Is asgen performance sensitive?



LDC also fails to compile asgen:
```
/usr/include/d/std/parallelism.d-mixin-3811(3837): Error: 
template core.atomic.atomicOp cannot deduce function from 
argument types !("+=")(shared(ulong), int), candidates are:
/usr/include/d/core/atomic.d(178):
core.atomic.atomicOp(string op, T, V1)(ref shared T val, V1 
mod) if (__traits(compiles, mixin("val" ~ op ~ "mod")))


RMW operations on shared data are deprecated. The template filter 
on atomicOp is a little different: 
https://dlang.org/phobos/core_atomic.html#.atomicOp

Looks like an LDC bug.


[Issue 13242] imported aliases should be analyzed lazily

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13242

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

https://github.com/dlang/dmd/commit/a0e89b14eadb295b8578df7f49c193bca1525526
fix Issue 13242 - imported aliases should be analyzed lazily

https://github.com/dlang/dmd/commit/e2dfb4a3d87dd6e4e4dc006064ddf4ac5b6880a4
Merge pull request #5690 from 9rnsr/fix13242

Issue 13242 - imported aliases should be analyzed lazily

--


[Issue 13242] imported aliases should be analyzed lazily

2016-04-22 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13242

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

   What|Removed |Added

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

--


Re: DConf 2016 offical presentation template

2016-04-22 Thread poliklosio via Digitalmars-d

On Wednesday, 20 April 2016 at 07:53:53 UTC, Benjamin Thaut wrote:
Is there a official presentation template for Dconf 2016? If 
not it would be greate if someone could create one. Many 
programmers (me included) are not good with picking colors and 
thus presentations usually don't look as good as they could.


Kind Regards
Benjamin Thaut


As a guy who is going to watch the recordings on-line, I would 
like to remind you not to rely on laser pointers too much.

Its never visible on the recordings!
I think its best (mileage may vary) to have little enough on a 
slide so that you can comfortably describe what to look at, with 
words.


[Issue 15897] base class method not seen w/ circular import

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

Vladimir Panteleev  changed:

   What|Removed |Added

 CC||thecybersha...@gmail.com

--- Comment #7 from Vladimir Panteleev  ---
(In reply to Martin Nowak from comment #6)
> Could anyone Digger the commit that introduced the problem?

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

--


[Issue 15897] base class method not seen w/ circular import

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

Martin Nowak  changed:

   What|Removed |Added

Summary|private base functions not  |base class method not seen
   |callable from base class|w/ circular import
   |module without type change  |

--- Comment #6 from Martin Nowak  ---
Interestingly this only fails when compiling both modules or only module b, but
not when only compiling module a.
It also fails w/ a public instead of a private create method, so this is likely
a forward reference issue due to the circular import. At best you resolve the
issue by taking the base class (Animal) as parameter to foo, rather than the
imported derived class (Cat).
Could anyone Digger the commit that introduced the problem?

--


Re: GC allocation

2016-04-22 Thread Alex via Digitalmars-d-learn

On Friday, 22 April 2016 at 01:55:36 UTC, Adam D. Ruppe wrote:

On Thursday, 21 April 2016 at 22:59:58 UTC, Alex wrote:
Ok... I make slices of them, carefully avoiding to make 
copies...


Yeah, that shouldn't make a difference..


Wait, wait... I try to make slices of the array of delegates, 
because I thought the slicing operation is cheaper, then another 
possibilities... And I try to make them as little as possible.




Huh? I think, this is the place, where I lack some 
background... So, I bind my delegates via


Can you post any more of your code?


Sure. Which part? ;)
the delegate is defined directly in a model as
uint dDelegate(uint id, MM p);

and the method delegateDefinition inside the binding responsible 
class has a form like

uint delegateDefinition(uint id, MM p)
{
uint retVal;
final switch(p) with(MM)
{
case first: return callSomeFuncFromThisObject(id); break;
case second: return id; break; // this the one and only 
case, which is unusual
case third: return 
knownObjectByThisObject.callAnotherFunc(id); break;

}
}

And a slice returning method inside the responsible class has a 
form like

typeof(.delegates) getSlice(uint i)
{
uint first = someLogic(i);
uint last = someOtherLogic(i);
return .delegates[first .. last];
}

Indeed, the getSlice operation is the slowest, because of the 
getting the first and the last operations. So I reduce the calls 
to slice returning methods to this one and only method. And I 
call it as rare as possible.
But I hope the slicing itself does not copy anything which is 
seen anyway by every other object. The getSlice method should 
just return the proper, well, slice, based on the given input.




return iota(delegatesAmount).map!(a => (MM p) => 
.dDelegate(a, p));


This would indeed allocate a new heap block for each one, but 
there might be other ways to do it.


Yes. I'm sure the object is alive till the very end. As 
mentioned above, do you think it is worth to make a struct to 
save a result from iota?
Nevertheless, my intention here is speed, so a fast solution 
is much better, then any slow one, even if the speed gain is 
10% only... But the construction effort is almost negligible.


I don't know yet, if construction is allowed to be slower, what 
you have is fine though.


Cool :)
Thanks!


Re: DConf 2016 offical presentation template

2016-04-22 Thread Johannes Pfau via Digitalmars-d
Am Fri, 22 Apr 2016 01:53:02 +
schrieb Adam D. Ruppe :

> On Friday, 22 April 2016 at 00:35:21 UTC, Mithun Hunsur wrote:
> > supporting the presentation rather than _being_ the 
> > presentation).  
> 
> Powerpoints have a bad habit of damaging presentations rather 
> than supporting them...
> 
> 
> I hate slides. Focus on making interesting content and consider 
> doing a hand out with actual details.
> 
> A slide has less information on it than a tweet perhaps best 
> is to think of it as a series of suggested tweets - brief 
> marketing information rather than anything useful.

Slides =/= slides. Lecture slides are completely different when
compared to talk slides. It's always fascinating how much text can fit
on a slide. And in many courses slides completely replace scripts. How
much information you provide on slides is mostly a convention / personal
habit and target audience thing:

It's basically:
* Do you only want to sell something?
* Or do you want to convey information?
* Do you want the slides to convey information 'stand-alone' without
  the talk?
* If the topic is complicated, more text (or more slides) is sometimes a
  good idea. It reminds the speaker to spend more time on the topic.
  Additionally you don't want to require the audience to take notes
  only to be able to follow the presentation.

As an example, marketing slides are different from technology /
programming slides and the TV / media guys often have the best designed
slides (Well, they've got paid artists for that...).