Re: Adding pointers to GC with destructers

2015-04-20 Thread Ali Çehreli via Digitalmars-d-learn

On 04/20/2015 02:48 PM, Freddy wrote:

On Monday, 20 April 2015 at 02:56:35 UTC, Ali Çehreli wrote:

Not automatically. Check out addRange and addRoot:

  http://dlang.org/phobos/core_memory.html

Ali

The destructor doesn't seem to be running


Sorry, I misunderstood you. You can use a RAII object as ketmar said:

import std.stdio;
import std.c.stdlib;

struct Test{
void* ptr;

~this(){
writeln(free: ,this);
free(ptr);
}
}

void main(){
auto ptr=cast(Test*)malloc(4);
writeln(create: ,ptr);

auto test = Test(ptr);  // -- The dtor of this object will free
}

Ali



[Issue 14462] cannot instantiate redBlackTree!int(); anymore

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14462

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||c...@dawg.eu
 Resolution|--- |DUPLICATE

--- Comment #1 from Martin Nowak c...@dawg.eu ---


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

--


[Issue 14468] [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14468

Martin Nowak c...@dawg.eu changed:

   What|Removed |Added

 CC||r.sagita...@gmx.de

--- Comment #1 from Martin Nowak c...@dawg.eu ---
*** Issue 14462 has been marked as a duplicate of this issue. ***

--


Re: Reuse object memory?

2015-04-20 Thread Ali Çehreli via Digitalmars-d-learn

On 04/20/2015 02:44 PM, Namespace wrote:

 Thank you. Do you mean this is worth a PR, to add this
 functionality to Phobos?

I am not familiar with such a need so I don't have a strong opinion.

However, if an object needs to be emplaced on top of an existing one, I 
can imagine that the original object was emplaced on some piece of 
memory anyway. In that case, the problem becomes emplacing an object on 
a piece of memory, which is already supported by std.conv.emplace.


Your idea seems to be for the case where the original object is created 
by some third party code, and that they want us to replace it with 
another object. If they are aware of the wholesale change in the object, 
fine. :)


Ali



Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread rumbu via Digitalmars-d

On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:

On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:

..



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, 
GetRole, Name);


D (Atila):
auto roleName = ?


These API look overly complex. Why not simply:

maybe(userManager).CurrentUser.GetRole().Name ?

Also, CAPITAL LETTER ARE THE BEST !


Because CurrentUser, GetRole() and Name can also return null in 
this scenario.




Re: Trial migration of Dsource bindings project to Github

2015-04-20 Thread Stewart Gordon via Digitalmars-d-announce

On 20/04/2015 00:37, Vladimir Panteleev wrote:

On Sunday, 19 April 2015 at 23:14:13 UTC, Stewart Gordon wrote:

For those of you who are still unfamiliar with GitHub,


Stewart, I haven't seen an active D project that WASN'T hosted on GitHub for 
years now.


That doesn't mean absolutely none of us are just doing personal projects which we keep on 
our own computers.



Could people please try checking out the project on GitHub, and committing a 
change?


Git commits are local, and will always succeed.


I committed some updates the other day and they seem they have gone straight into the 
online repository.



I'm guessing you actually want to allow
anyone to push their commits to your repository, which is not how collaboration 
on GitHub
works. You may want to read up on pull requests:

https://help.github.com/articles/using-pull-requests/


That mentions a 'shared repository model'.  What is that if not a way of enabling any user 
to push changes?  (That said, it isn't clear at the moment how to control whether a given 
repository is fork-pull or shared, or even whether the distinction is at the repository 
setup level or some other.)


It's too late in the day for me to take much in at the moment, but another page 
I've found
http://stackoverflow.com/questions/5010754/github-collaborators-have-commit-access
seems to say that, if I make somebody a 'collaborator', then that somebody will be able to 
commit to my repository.


snip

The module list has no value these days. Most people in that list no longer use 
D.


?? The module list is a list of modules, not a list of people.


Git allows quickly checking the history of any one file. Contributions to the 
project itself
have been so few that it makes no sense to partition out module ownership.


That isn't the sole purpose of the module list.  It also serves to document the status of 
each file.



If the decision is made to relocate Bindings permanently to GitHub, the wiki 
pages will
be migrated in due course.


Given that SVN is going the way of RCS and CVS, it's not really an if.


What do you mean by this?

Stewart.

--
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


Re: dsource.org moved

2015-04-20 Thread Stewart Gordon via Digitalmars-d-announce

On 20/04/2015 00:25, Vladimir Panteleev wrote:
snip

Even if he had, what would be the point?  It would greatly slow down the whole 
process.
We have SVN repositories so that people can just put their updates straight in,


Only those who have access can do that. Getting patches into the bindings 
repository has
been historically difficult. Committers have had to commit patches on behalf of 
other people.

snip

?? When I worked on the project on dsource, until it stopped working recently I generally 
had no trouble just committing my updates using SVN.  I didn't have to create patches at 
all.  As I understood it, neither did anybody else who helped out (after all, it wasn't 
_my_ dsource project).


Stewart.

--
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


Re: Excluding symbols

2015-04-20 Thread H. S. Teoh via Digitalmars-d
On Mon, Apr 20, 2015 at 09:00:34PM +, extrawurst via Digitalmars-d wrote:
 On Monday, 20 April 2015 at 20:36:06 UTC, ketmar wrote:
 On Mon, 20 Apr 2015 20:31:36 +, extrawurst wrote:
 
 static if(__ctfe){}
 
 small fix: simply `if (__ctfe)`, `static if (__ctfe)` is error. ;-)
 
 __ctfe is not readable at compile time ? thats unfortunate..

Compile time is actually a broad term that is not precise enough to
describe the distinction between template expansion / static if and
CTFE.

Basically, static if and template expansion happens at an earlier stage
of the compilation process -- conceptually speaking, somewhere between
parsing and semantic analysis. Perhaps one could think of it as AST
transformation prior to the AST being interpreted by the compiler. At
this stage, no semantic values (e.g., the state of variables, etc.) are
available, because the AST is not being interpreted yet.

CTFE, on the other hand, conceptually sits between semantic analysis and
code generation, which is at a later stage than the AST transformation
of templates / static if. Basically, at this point the AST is fixed and
the compiler is ready to emit object code, but instead of doing so, runs
it through an interpreter instead. So at this stage the compiler has
enough information to keep track of the values of variables and stuff,
and can simulate the effect of executing code at runtime. However, in
order for this simulation to have well-defined semantics, AST
transformations are no longer possible, so you cannot evaluate static
ifs in the CTFE stage.

This is why the __ctfe magic variable cannot be read at compile-time,
or, to be more precise, at AST transformation time. It can only be read
at CTFE-time.

Of course, this is a greatly simplified picture of how things actually
work in the compiler. The compiler isn't confined to a single AST
tranformation stage followed by a single CTFE stage; the whole point of
CTFE is that the result of the CTFE is fed back into the compiler to
influence AST transformation in another part of the code. This can be
done by running semantic analysis on the code to be CTFE-'d first, so
that it's ready for interpretation when another part of the code that
needs the CTFE value is still in the AST transformation stage.
Everything is eventually resolvable, as long as there are no circular
dependencies.

Nevertheless, the distinction between AST transformation and CTFE is an
important one (at least conceptually).  The function being CTFE'd must
be fully compiled before it can be CTFE'd (even if the rest of the code
isn't fully compiled yet), so static if must already be evaluated by the
time CTFE runs. Conversely, a static if / template expansion is by
definition not yet fully compiled, so it cannot evaluate references to
variables, even if said variables exist in CTFE (since CTFE hasn't
started yet at that point).


T

-- 
I'm still trying to find a pun for punishment...


Re: Reuse object memory?

2015-04-20 Thread Namespace via Digitalmars-d-learn
Thank you. Do you mean this is worth a PR, to add this 
functionality to Phobos?
My current code looks like this: 
http://dpaste.dzfl.pl/19b78a600b6c


Re: Vectorization examples

2015-04-20 Thread Panke via Digitalmars-d
No that's not true. On modern x86 processors using unaligned 
loading instructions on aligned data does not incur additional 
overhead, therefore you can always use unaligned load for 
everything, but loading unaligned data is still slower than 
aligned data.


Thanks for clarifying.


Re: SDC needs you -- redux

2015-04-20 Thread Brian Schott via Digitalmars-d

On Sunday, 19 April 2015 at 06:01:14 UTC, weaselcat wrote:
gofmt, much like python's standardized formatting, made 
contributing to go projects much easier IMO. While the same 
can't be done for D, hopefully dfmt becomes a standard tool and 
each dub project can just include a dfmt.conf or something to 
make contributing easier.


dfmt options go in .editorconfig with the rest of your project's 
style decisions like tabs/spaces and line length.


I agree with the OP on the tooling point, just look at C++. C++ 
had historically zero(okay, some - but it sucked! ctags were 
awful, etc.) tooling before clang hit the scene. IMO clang/LLVM 
was a complete game changer for C++ tooling, and I hope D can 
do the same.


For what it's worth, D-Scanner can output ctags information for D 
files.



Clang has a static analyzer, a formatter, a modernizer...
Hell, clang(and obv. libclang) can dump the AST right from its 
driver, and even has autocompletion built into 
it(-code-completion-at)


We now have a formatter. D-Scanner can perform some static 
analysis and dump an AST from its parser, DCD provides 
autocompletion. dfix can perform syntax upgrades.


[Issue 14463] [REG2.067] DMD crashes compiling module level immutable struct that takes an array in ctor

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14463

Martin Krejcirik m...@krej.cz changed:

   What|Removed |Added

 CC||m...@krej.cz
   Hardware|x86 |All
Summary|DMD crashes compiling   |[REG2.067] DMD crashes
   |module level immutable  |compiling module level
   |struct that takes an array  |immutable struct that takes
   |in ctor |an array in ctor
 OS|Windows |All
   Severity|minor   |regression

--


Re: Trial migration of Dsource bindings project to Github

2015-04-20 Thread Vladimir Panteleev via Digitalmars-d-announce

On Monday, 20 April 2015 at 22:57:51 UTC, Stewart Gordon wrote:
I committed some updates the other day and they seem they have 
gone straight into the online repository.


Committing is a local (non-network) operation in git, so you must 
have pushed them afterwards, or your GUI has done this for you.



https://help.github.com/articles/using-pull-requests/


That mentions a 'shared repository model'.  What is that if not 
a way of enabling any user to push changes?  (That said, it 
isn't clear at the moment how to control whether a given 
repository is fork-pull or shared, or even whether the 
distinction is at the repository setup level or some other.)


The shared repository model rarely applies to open-source 
projects, and I don't think it applies to the bindings project.


The module list has no value these days. Most people in that 
list no longer use D.


?? The module list is a list of modules, not a list of people.


Sorry, I was talking about the Assigned to column. I was 
misremembering, I agree it might be worth migrating to the GitHub 
wiki.


Given that SVN is going the way of RCS and CVS, it's not 
really an if.


What do you mean by this?


SVN use, especially in open-source projects, has heavily declined 
in the past years. People have begun maintaining their own forks 
and mirrors of the bindings project just so they wouldn't have to 
muck with SVN. The bindings project needs to move away from SVN 
if it is to avoid fragmentation and be friendly to contributions.


Re: Excluding symbols

2015-04-20 Thread Dicebot via Digitalmars-d

On Monday, 20 April 2015 at 20:04:04 UTC, Sönke Ludwig wrote:

Am 20.04.2015 um 15:22 schrieb Etienne:
I've been using a lot of CTFE in my libraries and this has had 
the side
effect of increasing my link time beyond 13 seconds. There's a 
pretty
big chunk of those symbols being exported that are used only 
for

evaluating mixins.

Would there be a way to specify something in the lines of 
`extern

(none):` or `intern:`?


Any reason why private couldn't be used for this? If a 
private function is only used for CTFE, there is no need to 
generate code at all.


Need much more powerful flow analysis than DMD frontend is 
currently capable of. Specifically, it needs to ensure that this 
function is also not taken address of and not aliased via any of 
public templates (transitively), as well as not aliased to 
something available as public.


Re: dsource.org moved

2015-04-20 Thread Vladimir Panteleev via Digitalmars-d-announce

On Monday, 20 April 2015 at 23:27:58 UTC, Stewart Gordon wrote:

On 21/04/2015 00:19, Stewart Gordon wrote:
snip
?? When I worked on the project on dsource, until it stopped 
working recently I generally
had no trouble just committing my updates using SVN.  I didn't 
have to create patches at
all.  As I understood it, neither did anybody else who helped 
out (after all, it wasn't

_my_ dsource project).


OK, so come to think about it, maybe those who were 
collaborating were given commit access on dsource as and when.


I believe this is the case. That, or they simply didn't have SVN 
installed. They sent a PR to my GitHub mirror instead.



In the other thread I referred to this
http://stackoverflow.com/questions/5010754/github-collaborators-have-commit-access
which makes it sound as though it's possible to do the same 
thing in GitHub.  Is that page wrong?


This question pertains to private GitHub repositories (a feature 
of paid plans).


Regardless, I do not recommend attempting to shoehorn your 
previous SVN workflow into git and GitHub. The usual way 
contributions are done with GitHub is that anyone with a GitHub 
account can create a pull request (a series of commits, initially 
published on their own fork of the repository), which the 
repository owner (or collaborators) can then accept (merge) into 
the main repository. Instead of designating a group of committers 
as in SVN, you would simply need to review pull requests and 
click the merge button to accept them. If you do not foresee 
yourself being available often enough to review/accept pull 
requests, you can designate a few collaborators who can do it as 
well.


[Issue 14474] New: Use UTF-8 encoding for @cmdfile

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14474

  Issue ID: 14474
   Summary: Use UTF-8 encoding for @cmdfile
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: normal
  Priority: P1
 Component: DMD
  Assignee: nob...@puremagic.com
  Reporter: davis...@gmail.com

Currently `dmd @cmdfile` will read file as simple char string. But when DUB is
compiling and creating this file it always saves it in UTF-8.

This makes a problem when cmdfile contains paths (source files) with non-ASCII
paths/names and thus DMD interprets them incorrectly (it always uses WinAPI
ANSI functions which expects them to be encoded in Windows default ANSI code
page)

Such cmdfile file with non-ASCII paths encoded as UTF-8 will produce Error:
cannot read file

One solution could be to change DUB to save it in Windows default ANSI code
page, but I think that's a very bad idea because then that file won't be
portable.

So best would be to enforce it being in UTF-8 encoding and then decode in DMD
for respective code page which is used for WinAPI calls.

--


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread deadalnix via Digitalmars-d

On Monday, 20 April 2015 at 22:18:31 UTC, rumbu wrote:

On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:

On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:

..



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, 
GetRole, Name);


D (Atila):
auto roleName = ?


These API look overly complex. Why not simply:

maybe(userManager).CurrentUser.GetRole().Name ?

Also, CAPITAL LETTER ARE THE BEST !


Because CurrentUser, GetRole() and Name can also return null in 
this scenario.


No, they all return a maybe, that is the nature of maybe monad.


Re: User defined properties signatures

2015-04-20 Thread dvic via Digitalmars-d-learn

On Monday, 20 April 2015 at 20:22:40 UTC, Jonathan M Davis wrote:
On Monday, April 20, 2015 19:42:30 dvic via Digitalmars-d-learn 
wrote:
Thanks for your answer Jonathan. But does the return type part 
of

a method
signature? I don't know what theory is claiming about that, but
for me they
are 2 different methods. So contextually, the best fit should
prevail.


The return type is not considered in overloading. And it would 
complicate
things considerably if it were. Some basic cases are pretty 
obvious, like


int foo();
string foo();
int a = foo()

But what about something like

int foo();
float foo();
auto a = foo() + foo();

or

int foo();
string foo();
void bar(int);
void bar(string);
bar(foo());

It's far simpler for the language to not consider return types 
in
overloading and to simply use it for the type of the resulting 
expression.
Then it's generally straightforward for it to determine what 
the type of

complex expressions are. But if the return type is considered in
overloading, then it gets _way_ more complicated, especially 
when the

expressions get at all complicated.

At best, the compiler would be able to work in the simple cases 
and error
out in the complex ones, but it wouldn't take much before it 
would have to

give up and give an error due to ambiguity.

There may be languages out there which take the the return type 
into account

when overloading, but I've never seen one.

- Jonathan M Davis



Thanks Johnathan for the detailed explanation !


Re: Adding pointers to GC with destructers

2015-04-20 Thread Freddy via Digitalmars-d-learn

On Monday, 20 April 2015 at 02:56:35 UTC, Ali Çehreli wrote:

Not automatically. Check out addRange and addRoot:

  http://dlang.org/phobos/core_memory.html

Ali

The destructor doesn't seem to be running

import std.stdio;
import std.c.stdlib;
import core.memory;
struct Test{
~this(){
writeln(free: ,this);
free(this);
}
}

void main(){
auto ptr=cast(Test*)malloc(4);
writeln(create: ,ptr);
GC.addRange(ptr,0,typeid(Test));
ptr=null;
GC.collect();
}

$ rdmd test
create: 1EEC730


[Issue 14431] [REG 2.067.0] huge slowdown of compilation speed

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14431

--- Comment #9 from Martin Nowak c...@dawg.eu ---
(In reply to Iain Buclaw from comment #8)
 Maybe the speculative devirtualization in gcc-4.9 is in some part
 responsible for that.  Just thinking out loud...

We should probably update the compilers across the bank to build releases.
Especially replacing DMC with VS would result in a huge speedup.

--


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread Ali Çehreli via Digitalmars-d

On 04/20/2015 03:18 PM, rumbu wrote:

On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:

On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:

..



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, GetRole,
Name);

D (Atila):
auto roleName = ?


These API look overly complex. Why not simply:

maybe(userManager).CurrentUser.GetRole().Name ?

Also, CAPITAL LETTER ARE THE BEST !


Because CurrentUser, GetRole() and Name can also return null in this
scenario.



The solution linked elsewhere in this thread solves that issue as well:


http://forum.dlang.org/thread/lnsc0c$1sip$1...@digitalmars.com?page=6#post-mailman.2584.1403213951.2907.digitalmars-d:40puremagic.com

Ali



Re: Vectorization examples

2015-04-20 Thread Walter Bright via Digitalmars-d

On 4/20/2015 1:09 PM, bearophile wrote:

Walter Bright:


Use arrays of double2, float4, int4, etc., declared in core.simd. Those will
be aligned appropriately.


Is the GC able to give memory aligned to 32 bytes for new architectures with 512
bits wide SIMD?


When the CPU requires 32 byte alignment, the compiler/GC will support it.

And even if it doesn't, it is trivial to manually align things.


and a way to tell
the type system that some array slices are fully distinct (the __restrict seen
here, I think this information doesn't need to be part of a type).


A runtime test is sufficient.


One of the points of having a type system is to rule out certain classes of bugs
caused by programmers. The compiler could use the type system to add those
runtime tests where needed. And even better sometimes is to avoid the time used
by run time tests, as shown in that video, using the static information inserted
in the code (he shows assembly code that contains run time tests).


this information doesn't need to be part of a type

Besides, you can create a 'restrict' template that checks for overlap at 
runtime, checking that can be turned on and off at compile time (i.e. assert). 
The runtime check overhead should be insignificant if using large arrays.




Another example of missing static information in D is shown near the end of the
video, where he shows an annotation to compile functions for different CPUs,
where the compiler updates function pointers inside the binary according to the
CPU you are using, making the code safe and efficient.


Come on, bearophile. I've done that stuff in C based on the runtime CPU. No 
compiler support is needed.




Re: Excluding symbols

2015-04-20 Thread ketmar via Digitalmars-d
On Mon, 20 Apr 2015 20:31:36 +, extrawurst wrote:

 static if(__ctfe){}

small fix: simply `if (__ctfe)`, `static if (__ctfe)` is error. ;-)

signature.asc
Description: PGP signature


Re: Today's programming challenge - How's your Range-Fu ?

2015-04-20 Thread rumbu via Digitalmars-d

On Monday, 20 April 2015 at 19:24:01 UTC, Panke wrote:

On Monday, 20 April 2015 at 18:03:50 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 17:48:17 UTC, Panke wrote:
To measure the columns needed to print a string, you'll need 
the number of graphemes. (d|)?string.length gives you the 
number of code units.


Even that's not really true.


Why? Doesn't string.length give you the byte count?


You'll also need the unicode character display width:
Even if the font is monospaced, there are characters (Katakana, 
Hangul and even in Latin script) with variable width.



ABCDEFGH
ABCDEFGH (unicode 0xff21 through 0xff27).

If the text above is not correctly displayed on your computer, a 
Korean console can be viewed here:


http://upload.wikimedia.org/wikipedia/commons/1/14/KoreanDOSPrompt.png





Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread Daniel N via Digitalmars-d

On Monday, 20 April 2015 at 14:19:06 UTC, Meta wrote:

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement the 
same thing in nim in 2 lines of code


template `?.`(a, b): expr =
 if a != nil: a.b else: nil

template `??`(a, b): expr =
 if a != nil: a else: b


HS Teoh came up with a beautiful solution using opDispatch, but 
I can't find the thread right now. That also reminds me that I 
meant to make a PR for it and completely forgot.


http://forum.dlang.org/thread/lnsc0c$1sip$1...@digitalmars.com?page=6#post-mailman.2584.1403213951.2907.digitalmars-d:40puremagic.com


Re: Reuse object memory?

2015-04-20 Thread Ali Çehreli via Digitalmars-d-learn

On 04/20/2015 12:05 PM, Namespace wrote:

 I'm sorry if I annoy you

Not at all! :) Sorry for not responding earlier.

, but I would really like to know how you would
 reuse already instantiated storage of an existing object.

 Example code:
 
 final class Foo {
  uint id;

  @nogc
  this(uint id) {
  this.id = id;
  }
 }

 Foo f = new Foo(42);
 

Something like the following works. I chose to set the old object to 
null but it is not necessary:


final class Foo {
uint id;

@nogc
this(uint id) {
this.id = id;
}
}

C reuse(C, T...)(ref C old, T ctorParams)
{
import std.conv;
import std.typetuple;

enum objectSize = __traits(classInstanceSize, C);

void* oldPlace = cast(void*)old;
C newObject = emplace!C(oldPlace[0..objectSize], ctorParams);

old = null;

return newObject;
}

void main()
{
Foo f = new Foo(42);

auto f2 = f.reuse(43);

assert(f is null);
assert(f2.id == 43);
}

Ali



[Issue 14474] Use UTF-8 encoding for @cmdfile

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14474

--- Comment #1 from Dāvis davis...@gmail.com ---
Created a quick PR https://github.com/D-Programming-Language/dmd/pull/4602

--


[Issue 14468] [Reg 2.068.0-devel] overload mismatch for template instance with typesafe variadic parameter

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14468

--- Comment #2 from Martin Nowak c...@dawg.eu ---
Temporary workaround is to explicitly pass null as typesafe variadic argument.

--


Re: [hackathon] One week left to the first D Hackathon!

2015-04-20 Thread Darkfeign via Digitalmars-d-announce
On Monday, 20 April 2015 at 12:17:13 UTC, Andrei Alexandrescu 
wrote:

On 4/19/15 9:03 AM, ANtlord wrote:
Good day! May be it is silly question, but I can't understand. 
Can I

take a part in hackaton remotely?


Yes! The hackathon is exclusively online and distributed!


And second question. Will hackaton's
projects be published?


It's the choice of each author! My hope is that out of this 
we'll have some good bugfixes, good stuff in 
http://code.dlang.org, and maybe a good couple of articles.



Andrei


This would be a great outcome. Some more links/ideas for starter 
projects might be nice for those interested in getting involved 
but not knowing the best places to begin.


Re: Duplicate another function's parameters in a template function

2015-04-20 Thread Tofu Ninja via Digitalmars-d-learn

On Monday, 20 April 2015 at 23:20:07 UTC, Justin Whear wrote:

See std.functional.forward:
http://dlang.org/phobos/std_functional.html#.forward


Sweet beans, thanks


Re: dfmt 0.3.0

2015-04-20 Thread Idan Arye via Digitalmars-d-announce

On Monday, 20 April 2015 at 17:40:48 UTC, Brian Schott wrote:

https://github.com/Hackerpilot/dfmt
https://github.com/Hackerpilot/dfmt/releases/tag/v0.3.0

dfmt is a D source code formatter. Version 0.3.0 fixes several 
bugs and introduces the ability to place configuration options 
in your projects' .editorconfig files.


Random stats:

9000 possible bike shed colours

2555 lines (according to wc)
1477 lines of code (according to D-Scanner)
98 regression tests
11 issues closed in this release
2 ways to spell color


Looks nice. BTW, it looks like the editorconfig format has 
something called Domain-Specific 
Properties(https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#ideas-for-domain-specific-properties) 
- configurations that only make sense for a limited number of 
languages or file formats. Some of dfmt-specific properties can 
fit there - for example dfmt_brace_style can be 
indent_brace_style. The other dfmt-specific properties can not be 
mapped to that list, but most of them are not really D-specific, 
so you can make PRs for properties you want to reserve the name.


Re: dfmt 0.3.0

2015-04-20 Thread Brian Schott via Digitalmars-d-announce

On Monday, 20 April 2015 at 20:59:43 UTC, Idan Arye wrote:
Looks nice. BTW, it looks like the editorconfig format has 
something called Domain-Specific Properties


I didn't use those because they're not standardized. Anything 
prefixed with dfmt_ is a domain-specific property.


I'm also avoiding those because it doesn't say what to do when 
you specify curly_bracket_next_line = true and 
indent_brace_style = KR at the same time.


Re: Reuse object memory?

2015-04-20 Thread Namespace via Digitalmars-d-learn

On Monday, 20 April 2015 at 21:58:59 UTC, Ali Çehreli wrote:

On 04/20/2015 02:44 PM, Namespace wrote:

 Thank you. Do you mean this is worth a PR, to add this
 functionality to Phobos?

I am not familiar with such a need so I don't have a strong 
opinion.


However, if an object needs to be emplaced on top of an 
existing one, I can imagine that the original object was 
emplaced on some piece of memory anyway. In that case, the 
problem becomes emplacing an object on a piece of memory, 
which is already supported by std.conv.emplace.


Your idea seems to be for the case where the original object is 
created by some third party code, and that they want us to 
replace it with another object. If they are aware of the 
wholesale change in the object, fine. :)


Ali


I have currently an array of objects which may be reloaded (it's 
a tilemap). If the array is reused, I can do that with:


arr.length = 0;
arr.assumeSafeAppend();

But then I thought: why not reuse the memory of the objects?
In C++ you can do that very elegant, but in D I have to produce 
garbage since the old object stays alive until the GC collects it 
and I have to allocate new GC memory.


Re: Adding pointers to GC with destructers

2015-04-20 Thread Freddy via Digitalmars-d-learn

On Monday, 20 April 2015 at 22:24:53 UTC, Ali Çehreli wrote:

On 04/20/2015 02:48 PM, Freddy wrote:

On Monday, 20 April 2015 at 02:56:35 UTC, Ali Çehreli wrote:

Not automatically. Check out addRange and addRoot:

 http://dlang.org/phobos/core_memory.html

Ali

The destructor doesn't seem to be running


Sorry, I misunderstood you. You can use a RAII object as ketmar 
said:


import std.stdio;
import std.c.stdlib;

struct Test{
void* ptr;

~this(){
writeln(free: ,this);
free(ptr);
}
}

void main(){
auto ptr=cast(Test*)malloc(4);
writeln(create: ,ptr);

auto test = Test(ptr);  // -- The dtor of this object will 
free

}

Ali
I believe your original understanding was right.I want to have 
HiddenType* be garbage collected and finalized(freed,destructed) 
when no more references to it are found(stack or heap). I could 
use reference counting but it seems inefficient for a program 
rarely collecting and constantly coping.


Re: Duplicate another function's parameters in a template function

2015-04-20 Thread Justin Whear via Digitalmars-d-learn
On Mon, 20 Apr 2015 22:50:52 +, Tofu Ninja wrote:

 I am trying to write a template function that can take another function
 as an alias template argument and duplicate its parameters for it self.
 
 I tried..
 
 auto pass(alias f, T...)(T t)
 {
  // other stuff... return f(t);
 }
 
 but that does not work if there is a ref parameter.
 
 Thanks

See std.functional.forward:
http://dlang.org/phobos/std_functional.html#.forward


Re: Excluding symbols

2015-04-20 Thread extrawurst via Digitalmars-d

On Monday, 20 April 2015 at 13:22:15 UTC, Etienne wrote:
I've been using a lot of CTFE in my libraries and this has had 
the side effect of increasing my link time beyond 13 seconds. 
There's a pretty big chunk of those symbols being exported that 
are used only for evaluating mixins.


Would there be a way to specify something in the lines of 
`extern (none):` or `intern:`?


what happens with totally empty functions ? can't they be removed 
on compilation ? static if(__ctfe){} could be used to make those 
empty for non-ctfe then..


Re: druntime unit test failures on FreeBSD

2015-04-20 Thread Dan Olson via Digitalmars-d

On Sunday, 19 April 2015 at 07:36:13 UTC, Jonathan M Davis wrote:
I am consistently seeing this when I try and run druntime's 
unit tests on

FreeBSD for either 2.067 or master:

0.000s PASS release64 object
0.000s PASS release64 core.atomic
0.008s PASS release64 core.bitop
0.000s PASS release64 core.checkedint
0.000s PASS release64 core.demangle
0.000s PASS release64 core.exception
0.000s PASS release64 core.math
0.000s PASS release64 core.memory
posix.mak:230: recipe for target 'obj/64/core/thread' failed
gmake: *** [obj/64/core/thread] Illegal instruction
gmake: *** Deleting file 'obj/64/core/thread'


 Do you know what thread.d unittest this happens in?  I am 
betting it is Fiber related.




Re: Excluding symbols

2015-04-20 Thread extrawurst via Digitalmars-d

On Monday, 20 April 2015 at 20:36:06 UTC, ketmar wrote:

On Mon, 20 Apr 2015 20:31:36 +, extrawurst wrote:


static if(__ctfe){}


small fix: simply `if (__ctfe)`, `static if (__ctfe)` is error. 
;-)


__ctfe is not readable at compile time ? thats unfortunate..


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread deadalnix via Digitalmars-d

On Monday, 20 April 2015 at 20:09:59 UTC, rumbu wrote:

On Monday, 20 April 2015 at 15:37:02 UTC, Atila Neves wrote:

On Monday, 20 April 2015 at 12:16:21 UTC, Jakob Ovrum wrote:

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement 
the same thing in nim in 2 lines of code


template `?.`(a, b): expr =
if a != nil: a.b else: nil

template `??`(a, b): expr =
if a != nil: a else: b


This is what I came up with for D:

  https://gist.github.com/JakobOvrum/7e3a7bc130ab7db28de3

Meh.


Here's mine:

https://gist.github.com/atilaneves/727d63f0a7029032d7ac



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, 
GetRole, Name);


D (Atila):
auto roleName = ?


These API look overly complex. Why not simply:

maybe(userManager).CurrentUser.GetRole().Name ?

Also, CAPITAL LETTER ARE THE BEST !


Re: Excluding symbols

2015-04-20 Thread ketmar via Digitalmars-d
On Mon, 20 Apr 2015 21:00:34 +, extrawurst wrote:

 On Monday, 20 April 2015 at 20:36:06 UTC, ketmar wrote:
 On Mon, 20 Apr 2015 20:31:36 +, extrawurst wrote:

 static if(__ctfe){}

 small fix: simply `if (__ctfe)`, `static if (__ctfe)` is error.
 ;-)
 
 __ctfe is not readable at compile time ? thats unfortunate..

it will have no sense. DMD is able to eliminate dead code in this case, 
so `if (__ctfe)` will generate plain function. and there is no sense in 
do `static if` for functions, as functions is not instantiating, i.e. 
that will be processed only once, and you will be unable to use function 
both in CTFE and in run time.

signature.asc
Description: PGP signature


Duplicate another function's parameters in a template function

2015-04-20 Thread Tofu Ninja via Digitalmars-d-learn
I am trying to write a template function that can take another 
function as an alias template argument and duplicate its 
parameters for it self.


For example, something like this...

void foo(ref int x){x = 7;}

auto pass(alias f)(/* ??? */)
{
// other stuff...
return f( /* ??? */ );
}

void main()
{
int y = 0;
pass!foo(y);
assert(y==7);
}


I tried..

auto pass(alias f, T...)(T t)
{
// other stuff...
return f(t);
}

but that does not work if there is a ref parameter.

Thanks


Re: [hackathon] One week left to the first D Hackathon!

2015-04-20 Thread Darkfeign via Digitalmars-d
On Monday, 20 April 2015 at 12:17:13 UTC, Andrei Alexandrescu 
wrote:

On 4/19/15 9:03 AM, ANtlord wrote:
Good day! May be it is silly question, but I can't understand. 
Can I

take a part in hackaton remotely?


Yes! The hackathon is exclusively online and distributed!


And second question. Will hackaton's
projects be published?


It's the choice of each author! My hope is that out of this 
we'll have some good bugfixes, good stuff in 
http://code.dlang.org, and maybe a good couple of articles.



Andrei


This would be a great outcome. Some more links/ideas for starter 
projects might be nice for those interested in getting involved 
but not knowing the best places to begin.


Re: dsource.org moved

2015-04-20 Thread Stewart Gordon via Digitalmars-d-announce

On 21/04/2015 00:19, Stewart Gordon wrote:
snip

?? When I worked on the project on dsource, until it stopped working recently I 
generally
had no trouble just committing my updates using SVN.  I didn't have to create 
patches at
all.  As I understood it, neither did anybody else who helped out (after all, 
it wasn't
_my_ dsource project).


OK, so come to think about it, maybe those who were collaborating were given commit access 
on dsource as and when.  And maybe one or two projects were completely open read/write 
access.  My memory of how access control worked is blurred.


In the other thread I referred to this
http://stackoverflow.com/questions/5010754/github-collaborators-have-commit-access
which makes it sound as though it's possible to do the same thing in GitHub.  Is that page 
wrong?


Stewart.

--
My email address is valid but not my primary mailbox and not checked regularly.  Please 
keep replies on the 'group where everybody may benefit.


[Issue 14475] New: man page is outdated

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14475

  Issue ID: 14475
   Summary: man page is outdated
   Product: D
   Version: unspecified
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: trivial
  Priority: P1
 Component: DMD
  Assignee: nob...@puremagic.com
  Reporter: r9shacklef...@gmail.com

dmd --help details options not discussed on neither the man pages nor
http://dlang.org/dmd-linux.html

examples:
-allinst
-dip25
-gx
etc

--


Re: Valgrind

2015-04-20 Thread Vladimir Panteleev via Digitalmars-d-learn

On Monday, 20 April 2015 at 13:29:58 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote:
On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch 
wrote:
Hi, I just found quite old posts about Valgrind and D. Can 
someone give me a short update, what the state of support for 
D is and if there is anythings special to take into account. 
Thanks a lot.


The only special thing to take in to account is that valgrind 
will choke on DMD generated floating point code, so really you 
have to use GDC or LDC if you want to use valgrind.


Correction: The only special thing I know of.


AFAIK, this has been fixed a long time ago.


Re: Reading whitespace separated strings from stdin?

2015-04-20 Thread weaselcat via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 01:31:58 UTC, TheGag96 wrote:
Hi guys! I had this homework assignment for data structures 
that has a pretty easy solution in C++. Reading input like 
this...


1 2 3 # $
4 3 * ! #
20 3 / # $ #
62 # $
2 3 8 * + #
4 48 4 2 + / #
SUM # $
1 2 3 4 5 #
R #
@

...where @ denotes the end of input is fairly simple in C++:

string token = ;
while (token != @) {
  //handle input
}

Note that having newlines doesn't matter at all; every token is 
just assumed to be separated by whitespace. However in D, I 
looked around could not find a solution better than this:


foreach (line; stdin.byLine) {
  foreach (token; line.split) {
//handle input
  }
}

Is there any way to do this without two loops/creating an 
array? readf( %d, token); wasn't cutting it either.


Thanks.


import std.stdio;
import std.array;
void main(){
auto tokens = stdin.readln('@').split;
writeln(tokens);
}

[1, 2, 3, #, $, 4, 3, *, !, #, 20, 3, 
/, #, $, #, 62, #, $, 2, 3, 8, *, +, #, 
4, 48, 4, 2, +, /, #, SUM, #, $, 1, 2, 
3, 4, 5, #, R, #, @]


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread thedeemon via Digitalmars-d
On Tuesday, 21 April 2015 at 03:35:49 UTC, Vladimir Panteleev 
wrote:

On Monday, 20 April 2015 at 12:16:21 UTC, Jakob Ovrum wrote:
Mine:

http://dump.thecybershadow.net/f8a172455ca239c35146f5dafdc7d1bc/test.d


And we have a winner!


Reading whitespace separated strings from stdin?

2015-04-20 Thread TheGag96 via Digitalmars-d-learn
Hi guys! I had this homework assignment for data structures that 
has a pretty easy solution in C++. Reading input like this...


1 2 3 # $
4 3 * ! #
20 3 / # $ #
62 # $
2 3 8 * + #
4 48 4 2 + / #
SUM # $
1 2 3 4 5 #
R #
@

...where @ denotes the end of input is fairly simple in C++:

string token = ;
while (token != @) {
  //handle input
}

Note that having newlines doesn't matter at all; every token is 
just assumed to be separated by whitespace. However in D, I 
looked around could not find a solution better than this:


foreach (line; stdin.byLine) {
  foreach (token; line.split) {
//handle input
  }
}

Is there any way to do this without two loops/creating an array? 
readf( %d, token); wasn't cutting it either.


Thanks.


Re: 64bit linking on Windows without Visual Studio

2015-04-20 Thread Joakim via Digitalmars-d

On Monday, 20 April 2015 at 18:26:16 UTC, Jeremiah DeHaan wrote:

Oh, huh. For some reason I thought that DMD was doing its own
code generation and only needed a linker for putting it all
together. I didn't know that it needed another compiler to work.
It looks like I have more to learn about the D compiler.


DMD does do all its own code generation, the C compiler is only 
needed for a few C files that are bundled with druntime and 
phobos, such as zlib.  Since the C compiler is only needed to 
build druntime/phobos for Win64 and not when distributing dmd for 
Win64, it's not as important as the COFF64 linker and C library.


The D devs can always download Visual Studio when building the 
dmd release, compile those C files, and not require users to get 
Visual Studio.  Of course, this assumes that there aren't any 
incompatibilities between COFF64 code generated by the Microsoft 
C compiler and your COFF64 linker and C library.



The toolchain I am suggesting does include a C compiler that
works for both 32 and 64 bit MSCOFF, so it sounds like it could
be feasible, but whether it is worth it or not is a different
story.


Huh, looks like you have everything you need then. :)


Re: SDC needs you -- redux

2015-04-20 Thread Shammah Chancellor via Digitalmars-d

On 2015-04-20 22:40:10 +, Brian Schott said:


On Sunday, 19 April 2015 at 06:01:14 UTC, weaselcat wrote:
gofmt, much like python's standardized formatting, made contributing to 
go projects much easier IMO. While the same can't be done for D, 
hopefully dfmt becomes a standard tool and each dub project can just 
include a dfmt.conf or something to make contributing easier.


dfmt options go in .editorconfig with the rest of your project's style 
decisions like tabs/spaces and line length.


I agree with the OP on the tooling point, just look at C++. C++ had 
historically zero(okay, some - but it sucked! ctags were awful, etc.) 
tooling before clang hit the scene. IMO clang/LLVM was a complete game 
changer for C++ tooling, and I hope D can do the same.


For what it's worth, D-Scanner can output ctags information for D files.


Clang has a static analyzer, a formatter, a modernizer...
Hell, clang(and obv. libclang) can dump the AST right from its driver, 
and even has autocompletion built into it(-code-completion-at)


We now have a formatter. D-Scanner can perform some static analysis and 
dump an AST from its parser, DCD provides autocompletion. dfix can 
perform syntax upgrades.


Can D-Scanner really provide you with autocompletion for code that is 
from a mixin generated by CTFE?


-Shammah



Re: SDC needs you -- redux

2015-04-20 Thread Shammah Chancellor via Digitalmars-d

On 2015-04-18 20:39:55 +, weaselcat said:


On Saturday, 18 April 2015 at 17:21:28 UTC, Shammah Chancellor wrote:

...


Are there any plans for the LDC and SDC team to work together once SDC matures?


I have not had an opportunity to speak with them, but LDC is written in 
C++.   But, I'm sure they have the skills to help us if they want to :)


I was am interested to know if their custom runtime code would be 
something both projects could share.


-Shammah



Re: Valgrind

2015-04-20 Thread Nick B via Digitalmars-d-learn

On Monday, 20 April 2015 at 17:25:55 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 16:58:18 UTC, Robert M. Münch wrote:

On 2015-04-20 13:29:57 +, John Colvin said:






Were the causes ever analyzed? I'm a bit wondering why it 
happens on floating point stuff...


valgrind doesn't have full support for x87 code, which dmd 
emits all over the place.


There is company is Germany, which does Valgrind consultancy,

http://www.open-works.net/contact.html

which could fix this issue, if you are prepared to throw some 
money their way.


Nick


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread Vladimir Panteleev via Digitalmars-d

On Monday, 20 April 2015 at 12:16:21 UTC, Jakob Ovrum wrote:

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement the 
same thing in nim in 2 lines of code


template `?.`(a, b): expr =
 if a != nil: a.b else: nil

template `??`(a, b): expr =
 if a != nil: a else: b


This is what I came up with for D:

https://gist.github.com/JakobOvrum/7e3a7bc130ab7db28de3

Meh.


Mine:

http://dump.thecybershadow.net/f8a172455ca239c35146f5dafdc7d1bc/test.d


[Issue 13972] Make scoped, Unique, and RefCounted @nogc

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13972

--- Comment #6 from weaselcat r9shacklef...@gmail.com ---
RefCounted almost done.
https://github.com/D-Programming-Language/phobos/pull/3171 made it possible to
make @nogc refcounted types, but destroy still doesn't infer attributes as per
https://github.com/D-Programming-Language/druntime/pull/1181

--


Re: druntime unit test failures on FreeBSD

2015-04-20 Thread Jonathan M Davis via Digitalmars-d
On Monday, April 20, 2015 20:44:48 Dan Olson via Digitalmars-d wrote:
 On Sunday, 19 April 2015 at 07:36:13 UTC, Jonathan M Davis wrote:
  I am consistently seeing this when I try and run druntime's
  unit tests on
  FreeBSD for either 2.067 or master:
 
  0.000s PASS release64 object
  0.000s PASS release64 core.atomic
  0.008s PASS release64 core.bitop
  0.000s PASS release64 core.checkedint
  0.000s PASS release64 core.demangle
  0.000s PASS release64 core.exception
  0.000s PASS release64 core.math
  0.000s PASS release64 core.memory
  posix.mak:230: recipe for target 'obj/64/core/thread' failed
  gmake: *** [obj/64/core/thread] Illegal instruction
  gmake: *** Deleting file 'obj/64/core/thread'

   Do you know what thread.d unittest this happens in?  I am
 betting it is Fiber related.

It looks like it's happening in the last unittest block in core.thread:

unittest
{
auto thr = new Thread(function{}, 10).start();
thr.join();
}

And if I remove the , 10 from the constructor call, then the problem goes
away - though then I get this failure later

Testing link
Testing load
Testing linkD
Testing linkDR
Testing loadDR
Testing host
Testing finalize
Testing link_linkdep
Makefile:28: recipe for target 'obj/freebsd/64/link_linkdep.done' failed
gmake[1]: *** [obj/freebsd/64/link_linkdep.done] Segmentation fault
gmake[1]: Leaving directory 
'/usr/home/jmdavis/Programming/github/druntime/test/shared'
posix.mak:242: recipe for target 'test/shared/.run' failed
gmake: *** [test/shared/.run] Error 2

No idea whether that's related or not. But regardless, that does narrow down
the problem some. Still, given how consistent it is on my box (I've _never_
seen it succeed on 2.067 or master), I really have to wonder what the
difference betwen my box and the autotesters are.

- Jonathan M Davis



Re: Reading whitespace separated strings from stdin?

2015-04-20 Thread Adam D. Ruppe via Digitalmars-d-learn

I think this should work:

import std.stdio;

void main() {
string token;
while(readf(%s , token))
writeln(token);
}


Have you tried that? What is wrong with it if you have?


Re: druntime unit test failures on FreeBSD

2015-04-20 Thread Jonathan M Davis via Digitalmars-d
On Monday, April 20, 2015 22:33:00 Brad Roberts via Digitalmars-d wrote:
 On 4/20/2015 10:24 PM, Jonathan M Davis via Digitalmars-d wrote:
 
  No idea whether that's related or not. But regardless, that does narrow down
  the problem some. Still, given how consistent it is on my box (I've _never_
  seen it succeed on 2.067 or master), I really have to wonder what the
  difference betwen my box and the autotesters are.
 
  - Jonathan M Davis

 The biggest difference is likely that the auto-testers are running
 freebsd 8.x (whatever's most recent (a relative term), either 3 or 4).

Ah. That's quite a bit older, since the latest FreeBSD is 10.1. So, that
probably explains it and likely means that the problem has nothing to do
with my local setup and more to do with changes in FreeBSD since 8 - though
since dmd/druntime 2.066 didn't have the problem, either our code changed in
a way that broke on newer FreeBSD systems, or we got a new test that just
happens to expose an existing bug. I'll probably have to find time to at
least narrow down the problem, and maybe I'll get lucky and actually know
enough about the problem code to fix it, though I question that, given where
it seems like the problem is. :|

- Jonathan M Davis



Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread JT via Digitalmars-d

On Monday, 20 April 2015 at 21:22:53 UTC, deadalnix wrote:

...
maybe(userManager).CurrentUser.GetRole().Name ?
...


Where can I find this maybe monad implementation?




Re: Reading whitespace separated strings from stdin?

2015-04-20 Thread TheGag96 via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 01:46:53 UTC, Adam D. Ruppe wrote:

I think this should work:

import std.stdio;

void main() {
string token;
while(readf(%s , token))
writeln(token);
}


Have you tried that? What is wrong with it if you have?


It'll just leave some trailing whitespace, which I don't want. 
And somehow doing token = token.stip STILL leaves that whitespace 
somehow...


Re: Reading whitespace separated strings from stdin?

2015-04-20 Thread Adam D. Ruppe via Digitalmars-d-learn

On Tuesday, 21 April 2015 at 02:04:24 UTC, TheGag96 wrote:

It'll just leave some trailing whitespace, which I don't want.


oh it also keeps the newlines attached. Blargh.

Well, forget the D functions, just use the C functions:

import core.stdc.stdio;

void main() {
char[16] token;
while(scanf(%15s, token) != EOF)
printf(**%s**\n, token.ptr);
}



You could convert to a string if needed with import std.conv; 
to!string(token.ptr), but if you can avoid that, you should, this 
loop has no allocations which is a nice thing.


Re: Valgrind

2015-04-20 Thread Martin Nowak via Digitalmars-d-learn

On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote:
The only special thing to take in to account is that valgrind 
will choke on DMD generated floating point code


I actually fixed this problem a while ago.
https://github.com/D-Programming-Language/dmd/pull/4368

An actual problem with valgrind is the GC, because most of it's 
operations appear to valgrind as memory corruptions.
You can GC.disable() collections, use gcstub.d, or help Vladimir 
with his valgrind/GC support to make things work.


http://dlang.org/phobos/core_memory.html#.GC.disable
https://github.com/D-Programming-Language/druntime/blob/master/src/gcstub/gc.d
https://github.com/CyberShadow/druntime/commits/valgrind


[Issue 14461] Header generation fails for definitions of string,wstring and dstring

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14461

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

https://github.com/D-Programming-Language/dmd/commit/be8f360dce82e5619625296183d74bb7d0e69892
Merge pull request #4594 from rainers/hdrgen_string

Issue 14461 - Header generation fails for definitions of string,wstring and
dstring

--


Re: Valgrind

2015-04-20 Thread Brad Roberts via Digitalmars-d-learn
Valgrind has a mechanism for teaching it how to ignore certain patterns. 
 A long time ago I setup suppressions for the gc, but the code has 
changed out from under that version so the work would need to be redone.


On 4/20/2015 7:23 PM, Martin Nowak via Digitalmars-d-learn wrote:

On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote:

The only special thing to take in to account is that valgrind will
choke on DMD generated floating point code


I actually fixed this problem a while ago.
https://github.com/D-Programming-Language/dmd/pull/4368

An actual problem with valgrind is the GC, because most of it's
operations appear to valgrind as memory corruptions.
You can GC.disable() collections, use gcstub.d, or help Vladimir with
his valgrind/GC support to make things work.

http://dlang.org/phobos/core_memory.html#.GC.disable
https://github.com/D-Programming-Language/druntime/blob/master/src/gcstub/gc.d

https://github.com/CyberShadow/druntime/commits/valgrind


Re: Adding pointers to GC with destructers

2015-04-20 Thread Martin Nowak via Digitalmars-d-learn

On Sunday, 19 April 2015 at 23:38:49 UTC, Freddy wrote:

C libraries have a pattern of

HiddenType* getObj();
void freeObj(HiddenType*);

Is there any way I can make the GC search for a HiddenType* 
and run freeObj when the pointer is not found.


You can't turn an arbitrary pointer into a garbage collected 
object.

What you can do, is putting the pointer into a GCed object.

class Wrapper {
  this(HiddenType* p) { _p = p; } }
  ~this() { freeObj(_p); }
  alias _p this;
}

auto obj = new Wrapper(getObj());

Since 2.067.0 we also finalize heap allocated structs, so the 
wrapper can also be a struct.


Re: This week in D #14: job opening, Silicon Valley meetup, Dsource on GitHub

2015-04-20 Thread Meta via Digitalmars-d-announce

On Monday, 20 April 2015 at 06:39:00 UTC, weaselcat wrote:

On Monday, 20 April 2015 at 06:23:36 UTC, ketmar wrote:
as Adam didn't post announce for current TWiD, i'll try to do 
that

instead, as i like to see that announcements here.

http://arsdnet.net/this-week-in-d/apr-19.html

the notable thing is Job Opening part. let's hope that it 
will become

regular. not with the same content each week, of course.


no tip/trick  :(


Here's a useless trick: Peano numbers and type-level lists.

http://dpaste.dzfl.pl/9f92af9d97f4


Re: druntime unit test failures on FreeBSD

2015-04-20 Thread Brad Roberts via Digitalmars-d

On 4/20/2015 10:24 PM, Jonathan M Davis via Digitalmars-d wrote:


No idea whether that's related or not. But regardless, that does narrow down
the problem some. Still, given how consistent it is on my box (I've _never_
seen it succeed on 2.067 or master), I really have to wonder what the
difference betwen my box and the autotesters are.

- Jonathan M Davis


The biggest difference is likely that the auto-testers are running 
freebsd 8.x (whatever's most recent (a relative term), either 3 or 4).


Re: Formatted output ranges

2015-04-20 Thread Dennis Ritchie via Digitalmars-d-learn

On Monday, 20 April 2015 at 17:16:21 UTC, Ivan Kazmenko wrote:

writeln(wrap(a, 30, ;; , ;; ));

Works with dmd 2.066.1 and 2.067.0.


Thanks.


Re: Vectorization examples

2015-04-20 Thread bearophile via Digitalmars-d

Walter Bright:

Use arrays of double2, float4, int4, etc., declared in 
core.simd. Those will be aligned appropriately.


Is the GC able to give memory aligned to 32 bytes for new 
architectures with 512 bits wide SIMD?




and a way to tell
the type system that some array slices are fully distinct (the 
__restrict seen
here, I think this information doesn't need to be part of a 
type).


A runtime test is sufficient.


One of the points of having a type system is to rule out certain 
classes of bugs caused by programmers. The compiler could use the 
type system to add those runtime tests where needed. And even 
better sometimes is to avoid the time used by run time tests, as 
shown in that video, using the static information inserted in the 
code (he shows assembly code that contains run time tests).


Another example of missing static information in D is shown near 
the end of the video, where he shows an annotation to compile 
functions for different CPUs, where the compiler updates function 
pointers inside the binary according to the CPU you are using, 
making the code safe and efficient.


Bye,
bearophile


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread rumbu via Digitalmars-d

On Monday, 20 April 2015 at 15:37:02 UTC, Atila Neves wrote:

On Monday, 20 April 2015 at 12:16:21 UTC, Jakob Ovrum wrote:

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement 
the same thing in nim in 2 lines of code


template `?.`(a, b): expr =
if a != nil: a.b else: nil

template `??`(a, b): expr =
if a != nil: a else: b


This is what I came up with for D:

   https://gist.github.com/JakobOvrum/7e3a7bc130ab7db28de3

Meh.


Here's mine:

https://gist.github.com/atilaneves/727d63f0a7029032d7ac



I fail to understand Atila example. Just to be sure:

C#:
var roleName = userManager.CurrentUser?.GetRole()?.Name;

D (Jakob):
auto roleName = userManager.getOrNull!(CurrentUser, GetRole, 
Name);


D (Atila):
auto roleName = ?


Re: User defined properties signatures

2015-04-20 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 20, 2015 19:42:30 dvic via Digitalmars-d-learn wrote:
 Thanks for your answer Jonathan. But does the return type part of
 a method
 signature? I don't know what theory is claiming about that, but
 for me they
 are 2 different methods. So contextually, the best fit should
 prevail.

The return type is not considered in overloading. And it would complicate
things considerably if it were. Some basic cases are pretty obvious, like

int foo();
string foo();
int a = foo()

But what about something like

int foo();
float foo();
auto a = foo() + foo();

or

int foo();
string foo();
void bar(int);
void bar(string);
bar(foo());

It's far simpler for the language to not consider return types in
overloading and to simply use it for the type of the resulting expression.
Then it's generally straightforward for it to determine what the type of
complex expressions are. But if the return type is considered in
overloading, then it gets _way_ more complicated, especially when the
expressions get at all complicated.

At best, the compiler would be able to work in the simple cases and error
out in the complex ones, but it wouldn't take much before it would have to
give up and give an error due to ambiguity.

There may be languages out there which take the the return type into account
when overloading, but I've never seen one.

- Jonathan M Davis



Re: [hackathon] One week left to the first D Hackathon!

2015-04-20 Thread Andrei Alexandrescu via Digitalmars-d

On 4/19/15 9:03 AM, ANtlord wrote:

Good day! May be it is silly question, but I can't understand. Can I
take a part in hackaton remotely?


Yes! The hackathon is exclusively online and distributed!


And second question. Will hackaton's
projects be published?


It's the choice of each author! My hope is that out of this we'll have 
some good bugfixes, good stuff in http://code.dlang.org, and maybe a 
good couple of articles.



Andrei


Valgrind

2015-04-20 Thread Robert M. Münch via Digitalmars-d-learn
Hi, I just found quite old posts about Valgrind and D. Can someone give 
me a short update, what the state of support for D is and if there is 
anythings special to take into account. Thanks a lot.


--
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



Re: Valgrind

2015-04-20 Thread John Colvin via Digitalmars-d-learn

On Monday, 20 April 2015 at 13:28:57 UTC, John Colvin wrote:

On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote:
Hi, I just found quite old posts about Valgrind and D. Can 
someone give me a short update, what the state of support for 
D is and if there is anythings special to take into account. 
Thanks a lot.


The only special thing to take in to account is that valgrind 
will choke on DMD generated floating point code, so really you 
have to use GDC or LDC if you want to use valgrind.


Correction: The only special thing I know of.


Re: Valgrind

2015-04-20 Thread John Colvin via Digitalmars-d-learn

On Monday, 20 April 2015 at 13:16:23 UTC, Robert M. Münch wrote:
Hi, I just found quite old posts about Valgrind and D. Can 
someone give me a short update, what the state of support for D 
is and if there is anythings special to take into account. 
Thanks a lot.


The only special thing to take in to account is that valgrind 
will choke on DMD generated floating point code, so really you 
have to use GDC or LDC if you want to use valgrind.


[Issue 14432] move construction for RefCounted

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14432

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

https://github.com/D-Programming-Language/phobos/commit/a6a6870beb69537f2ccd3d50289594ebae30ad15
fix Issue 14432 - move construction for RefCounted

- add RefCounted!T.this(T) which takes an RValue or a copy
  and use move to initialized the refcounted store

- add refCounted to infer T from the argument and disable
  RefCounted's autoInit, also move initializes the store

https://github.com/D-Programming-Language/phobos/commit/f7498ad8ec147114b1bcbc61d0e4db3e033417f5
Merge pull request #3171 from MartinNowak/refCounted

fix Issue 14432 - move construction for RefCounted

--


Re: build vibe-d-0.7.23 error on win7 x86?

2015-04-20 Thread Etienne via Digitalmars-d-learn

On Monday, 20 April 2015 at 07:58:40 UTC, mzf wrote:

win 7 x86,3GB ram:

1. dmd 2.066 vibe-d-0.7.23, it's ok.

2. dmd 2.067 vibe-d-0.7.23,
   show error msg out of memory

why?


http://forum.dlang.org/thread/mghqlf$10l2$1...@digitalmars.com#post-ybrtcxrcmrrsoaaksdbj:40forum.dlang.org


Re: [hackathon] One week left to the first D Hackathon!

2015-04-20 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 4/19/15 9:03 AM, ANtlord wrote:

Good day! May be it is silly question, but I can't understand. Can I
take a part in hackaton remotely?


Yes! The hackathon is exclusively online and distributed!


And second question. Will hackaton's
projects be published?


It's the choice of each author! My hope is that out of this we'll have 
some good bugfixes, good stuff in http://code.dlang.org, and maybe a 
good couple of articles.



Andrei


[Issue 14467] arr.capacity sometimes erroneously returns 0

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14467

--- Comment #6 from Steven Schveighoffer schvei...@yahoo.com ---
PR: https://github.com/D-Programming-Language/druntime/pull/1226

Note, the issue is strictly with the bits retrieved. The other aspects of the
info block are correct, just the bits retrieved was not correct.

Thanks, Ketmar for finding the root cause, it would have been much more
difficult to find without that legwork!

--


Re: [OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread Jakob Ovrum via Digitalmars-d

On Monday, 20 April 2015 at 08:24:08 UTC, weaselcat wrote:

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement the 
same thing in nim in 2 lines of code


template `?.`(a, b): expr =
  if a != nil: a.b else: nil

template `??`(a, b): expr =
  if a != nil: a else: b


This is what I came up with for D:

https://gist.github.com/JakobOvrum/7e3a7bc130ab7db28de3

Meh.


std.experimental.testing PR review

2015-04-20 Thread Atila Neves via Digitalmars-d

Original library: http://code.dlang.org/packages/unit-threaded
PR: https://github.com/D-Programming-Language/phobos/pull/3207

It's my first Phobos PR, I tried reading the wiki and doing 
what's required but bear with me if I've screwed up somehow.


I wasn't sure whether or not to split the PR. In the end I just 
took the existing library, edited it a lot and got it ready for 
review.


Unit test blocks can be named with @Name. They execute in 
parallel by default but that's only if the default runner is used.


Atila


[Issue 14418] D-style Variadic Function example does not compile

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14418

Gary Willoughby d...@nomad.so changed:

   What|Removed |Added

   Keywords||pull
 CC||d...@nomad.so

--- Comment #1 from Gary Willoughby d...@nomad.so ---
https://github.com/D-Programming-Language/dlang.org/pull/969

--


Re: SysTime.toISOExtString with timezone offset

2015-04-20 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/20/15 4:47 AM, Jonathan M Davis via Digitalmars-d-learn wrote:


Perhaps, LocalTime should be changed so that it prints the time zone out
(and just make it so that the lack of time zone is read in as local time
rather than treating it that way in both directions), but that's not how it
works currently.


Yeah, I think so. Otherwise you have the case where a time printed in 
one local timezone is interpreted differently in a program running in 
another time zone.


I'll also note that one can always do:

t.toISOExtString()[0..$-6];

If you know you don't want the time zone there.

-Steve


[Issue 14399] std.json cannot parse its own output for nan

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14399

bb.t...@gmx.com changed:

   What|Removed |Added

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

--


Excluding symbols

2015-04-20 Thread Etienne via Digitalmars-d
I've been using a lot of CTFE in my libraries and this has had the side 
effect of increasing my link time beyond 13 seconds. There's a pretty 
big chunk of those symbols being exported that are used only for 
evaluating mixins.


Would there be a way to specify something in the lines of `extern 
(none):` or `intern:`?


Re: Excluding symbols

2015-04-20 Thread ketmar via Digitalmars-d
On Mon, 20 Apr 2015 09:22:17 -0400, Etienne wrote:

 I've been using a lot of CTFE in my libraries and this has had the side
 effect of increasing my link time beyond 13 seconds. There's a pretty
 big chunk of those symbols being exported that are used only for
 evaluating mixins.
 
 Would there be a way to specify something in the lines of `extern
 (none):` or `intern:`?

i think you should make ER for this. it will be fine if there will be the 
way to tell compiler to skip code generation for some functions which 
used only in CTFE.

signature.asc
Description: PGP signature


[Issue 14432] move construction for RefCounted

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14432

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

   What|Removed |Added

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

--


Re: Vectorization examples

2015-04-20 Thread finalpatch via Digitalmars-d

On Monday, 20 April 2015 at 11:01:28 UTC, Panke wrote:

On Monday, 20 April 2015 at 09:41:09 UTC, bearophile wrote:
Utilizing the other 80% of your system's performance: 
Starting with Vectorization by Ulrich Drepper:


https://www.youtube.com/watch?v=DXPfE2jGqg0

It shows two still missing parts of the D type system: a way 
to define strongly typed byte alignments for arrays (something 
better than the aligned() shown here, because I prefer the 
alignment to be part of the type), and a way to tell the type 
system that some array slices are fully distinct (the 
__restrict seen here, I think this information doesn't need to 
be part of a type).


Bye,
bearophile


Aren't unaligned loads as fast as aligned loads on modern x86?


No that's not true. On modern x86 processors using unaligned 
loading instructions on aligned data does not incur additional 
overhead, therefore you can always use unaligned load for 
everything, but loading unaligned data is still slower than 
aligned data.


[Issue 14467] arr.capacity sometimes erroneously returns 0

2015-04-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=14467

--- Comment #5 from Steven Schveighoffer schvei...@yahoo.com ---
Thank you, that is indeed the root cause.

I have to investigate why that change was made, as most of the lifetime.d
assumes GC.query will get the correct block info. Doing a double-lookup does
not sound appealing to me as a fix, we need a function that finds the block
info even for interior pointers. At this point, the array runtime is going to
be severely broken performance-wise.

--


Re: Excluding symbols

2015-04-20 Thread ketmar via Digitalmars-d
On Mon, 20 Apr 2015 13:34:47 +, ketmar wrote:

 On Mon, 20 Apr 2015 09:22:17 -0400, Etienne wrote:
 
 I've been using a lot of CTFE in my libraries and this has had the side
 effect of increasing my link time beyond 13 seconds. There's a pretty
 big chunk of those symbols being exported that are used only for
 evaluating mixins.
 
 Would there be a way to specify something in the lines of `extern
 (none):` or `intern:`?
 
 i think you should make ER for this. it will be fine if there will be
 the way to tell compiler to skip code generation for some functions
 which used only in CTFE.

by the way, maybe it will be good to add `extern(CTFE)` too, so hdrgen 
can emit source code for such functions to .di file. i.e.

`extern(none)` -- don't generate code, don't emit to .di
`extern(CTFE)` -- don't generate code, emit to .di


signature.asc
Description: PGP signature


[OT] C# 6.0 ?. null propagation operator

2015-04-20 Thread weaselcat via Digitalmars-d

http://www.reddit.com/r/programming/comments/335b1s/the_new_operator_in_c_6/

of interesting note was the nim sample on how to implement the 
same thing in nim in 2 lines of code


template `?.`(a, b): expr =
  if a != nil: a.b else: nil

template `??`(a, b): expr =
  if a != nil: a else: b


Re: Today's programming challenge - How's your Range-Fu ?

2015-04-20 Thread Jacob Carlborg via Digitalmars-d

On 2015-04-20 08:04, Nick B wrote:


Perhaps a new Unicode standard, could start that way as well ?


https://xkcd.com/927/

--
/Jacob Carlborg


Re: D vs nim

2015-04-20 Thread bearophile via Digitalmars-d

Russel Winder:


it is all part of
guerilla marketing undertaken by anyone with anything to market.


It's still not a correct behavour, regardless how many do it.

Bye,
bearophile


Re: Templates: Array slices not recognized

2015-04-20 Thread via Digitalmars-d-learn

On Monday, 20 April 2015 at 09:07:54 UTC, Chris wrote:

On Saturday, 18 April 2015 at 17:59:19 UTC, ketmar wrote:

On Sat, 18 Apr 2015 17:50:56 +, Chris wrote:

Doh! You're right! My bad. However, this makes the function 
less

generic, but it doesn't matter here.


maybe `auto ref` can help here?


Yes, auto ref does the trick. I prefer it to passing the slice 
by value, because I can extend the function to cater for more 
types. My implementation (which is different from the one 
posted above) works also with strings, for example. Anyway, it 
gave me a performance boost of ~2.7 times as compared to the 
workarounds I had. This was well worth it!


Strings are slices, too. `string` is equivalent to 
`immutable(char)[]`.


Re: Templates: Array slices not recognized

2015-04-20 Thread Chris via Digitalmars-d-learn

On Saturday, 18 April 2015 at 17:59:19 UTC, ketmar wrote:

On Sat, 18 Apr 2015 17:50:56 +, Chris wrote:

Doh! You're right! My bad. However, this makes the function 
less

generic, but it doesn't matter here.


maybe `auto ref` can help here?


Yes, auto ref does the trick. I prefer it to passing the slice by 
value, because I can extend the function to cater for more types. 
My implementation (which is different from the one posted above) 
works also with strings, for example. Anyway, it gave me a 
performance boost of ~2.7 times as compared to the workarounds I 
had. This was well worth it!


Re: Today's programming challenge - How's your Range-Fu ?

2015-04-20 Thread Chris via Digitalmars-d

On Saturday, 18 April 2015 at 17:04:54 UTC, Tobias Pankrath wrote:
Isn't this solved commonly with a normalization pass? We 
should have a normalizeUTF() that can be inserted in a 
pipeline.


Yes.

Then the rest of Phobos doesn't need to mind these combining 
characters. -- Andrei


I don't think so. The thing is, even after normalization we 
have to deal with combining characters because in all 
normalization forms there will be combining characters left 
after normalization.


Yes, again and again I encountered length related bugs with 
Unicode characters. Normalization is not 100% reliable. I don't 
know anyone who works with non English characters who doesn't 
have problems with Unicode related issues sometimes.


Re: Trial migration of Dsource bindings project to Github

2015-04-20 Thread John Colvin via Digitalmars-d-announce
On Sunday, 19 April 2015 at 23:37:58 UTC, Vladimir Panteleev 
wrote:

On Sunday, 19 April 2015 at 23:14:13 UTC, Stewart Gordon wrote:

For those of you who are still unfamiliar with GitHub,


Stewart, I haven't seen an active D project that WASN'T hosted 
on GitHub for years now.


There's a few on bitbucket.


Re: Templates: Array slices not recognized

2015-04-20 Thread ketmar via Digitalmars-d-learn
On Mon, 20 Apr 2015 10:14:25 +, Chris wrote:

 string a = bla;
 string b = blub;
 
 auto res = doSomething(a, b);
 
 If I didn't use auto ref or ref, string would get copied, wouldn't
 it?

no, it wont -- not unless you'll append something to it. slicing arrays 
(and string is array too) will never copy anything.

signature.asc
Description: PGP signature


Re: Request for testers: GDC-5.1 Release Candidate branched

2015-04-20 Thread Iain Buclaw via Digitalmars-d
On 19 April 2015 at 20:39, Brian via Digitalmars-d
digitalmars-d@puremagic.com wrote:
 On Sunday, 19 April 2015 at 12:04:19 UTC, Stefan Frijters wrote:

 On Sunday, 19 April 2015 at 07:13:16 UTC, Iain Buclaw wrote:

 Hi,

 GCC-5.1 has hit RC, and so it's all rush again to get bug fixes in
 quick before the window closes.

 Packages are up on Debian: https://packages.debian.org/experimental/gdc-5

 Latest changes however are on github:
 https://github.com/D-Programming-GDC/GDC/tree/gdc-5

 Updates/Fixes from gdc-4.9 include:
 - Front-end updated from 2.065.0 to 2.066.1
 - Added goto support for GDC Extended Inline Assembler
 - Added -fbounds-check=safe compiler option
 - Added Runtime support for EMUTLS targets
 - Added new gcc.attributes section, weak and alias
 - Partially fixed thunk support for externally referenced methods
 (only variadic methods now don't work)
 - Improved Closure/Frame chaining, all tests now passing in the
 testsuite[1]
 - Improved NRVO support to take advantage of Return Slot Optimisation
 (RSO), all tests now passing in the testsuite[2]

 Last feature I am working on getting in is runtime exception chaining
 support.  If anyone has any grand ideas, they'd be more than welcome.

 [1]:
 https://github.com/D-Programming-GDC/GDC/commit/84e77850a4e9184526d9b571fb8bdfda4dc103a1#diff-cbd05be6883e1f976bc2eee00b1e6bcaL2442
 [2]:
 https://github.com/D-Programming-GDC/GDC/commit/b9bbf568c20d806bc8570c8cefe41bf57c729bb1#diff-2a4fd18a3f136c982c89e12064e0b6baL551


 Regards
 Iain.


 I don't have too much to report (which is a good thing in this case): I
 did a fresh install from source, following [1], and I didn't encounter any
 problems. I was already compiling my code with an earlier GDC version that
 used the 2.066.1 front-end (which is required for my code) because it gives
 me a 2.5x speed increase for my code execution (in my Linux VM at least), so
 I love the new release already :-D

 Cheers,

 Stefan

 [1] http://wiki.dlang.org/GDC/Installation/Generic


 thank you for work, i like it :)
 but, this version support android?

There should be no reason for compiler not to support Android, but as
far as I know, D runtime support is still missing.  This is in the
hands of upstream library development.

See: https://github.com/D-Programming-Language/druntime/pull/1010

Regards
Iain.


Nissan recalls 76,000 Rogues

2015-04-20 Thread Allen Scott via Digitalmars-d-announce
Nissan has issued a recall of the 2014 model Rogue manufactured 
between June 11, 2013 and June 7, 2014 due to a problem with the 
fuel pump. In all, the recall affects 76,242 vehicles. According 
to the National Highway Traffic Safety Administration, the nickel 
plating on the fuel pump can come loose and bind the impeller 
which can, over time, cause the car to stall while driving, or 
not start up at all.
Owners of a Nissan Rogue manufactured between the dates listed 
above can bring in their vehicle to get the defective fuel pump 
replaced with a new one at no charge.


Auto news brought to you by aaaratedinsurance .com
Source: autoblog 
.com/2015/04/10/nissan-recall-76k-rogue-faulty-fuel-pump/


Tags: Nissan Rogue, vehicle recalls, car insurance, auto 
insurance, insurance quotes




Re: Input ranges

2015-04-20 Thread Jonathan M Davis via Digitalmars-d
On Monday, April 20, 2015 07:54:32 via Digitalmars-d wrote:
 Hi,

 I tried to learn about input ranges and got some anonymous advice
 http://forum.dlang.org/thread/dezlxxygufocmafvl...@forum.dlang.org
 , still the topic seems to warrant broader attention.

 The question is how pure input ranges (as in non-forward) should
 be build. Algorithms like take and groupBy require reference
 semantics. I did not find that communicated. Now I am looking for
 the official ruling. As in: What the D rule book says.

Honestly, the cleanest behavior is that all ranges be reference types, and
save be required to copy the range. However, there are no actual
requirements that that be the case, and structs and arrays are what is most
frequently used for ranges, and they tend to be half-reference types or
value types. So, passing a range to a function usually ends up being
equivalent to a call to save, which makes it so that many range-based
functions don't work properly with class ranges, since they usually aren't
tested with them. And since arrays certainly aren't going to be full
reference types, it just isn't possible to require that a forward range be a
full reference type, so we need to support value type ranges, half reference
type ranges, and full reference type ranges when it comes to forward ranges,
and we have to deal with the fact that copying them _can_ be equivalent to
saving them without assuming that it is. :|

So, as far as forward ranges go, you shouldn't rely on copying a range being
equivalent to save (otherwise save wouldn't need to exist), but
realistically, if you pass a range to a function, you can't simply use that
range after. Many ranges will have saved themselves in the process, but not
all of them will have. The range in the caller is still valid (fortunately),
but whether it's in the same state that it was before calling the other
function depends entirely on whether copying the range is equivalent to save
or not, meaning that you just can't use a range after you've passed it to
another function unless you called save on it (forcing copy semantics) or
passed it by ref (forcing reference semantics). Unfortunately, there are
almost certainly lingering bugs in Phobos due to functions which assume that
passing range to another function implicitly saves it, simply because that's
what happens with such a large percentage of ranges.

With regard to pure input ranges, they're not forward ranges, because what
they're iterating over cannot be saved. So, by their very nature, they have
to be at least partially reference types and folks will often assume that
they are full reference types. The problem is that they can also be half
reference types in that they could have saved some state internally (e.g.
front) but still not be able to actually have a proper save function which
saves all of their state. So, if you pass a pure input range to a function,
then just like forward ranges, you cannot assume that you can use it again
without passing it by reference, even though by definition, their internal
state will have changed at least partially due to whatever iteration is done
within the function that it's passed to (since it has to be at least a
partial reference type to be a pure input range). However, unlike with a
forward range, the input range is not a full reference type, then it won't
be left in a valid state, since it won't have be saved, just had some of its
contents passed by reference and some of them by value.

All in all, I think that input ranges are incredibly annoying to work with,
and I'm frequently tempted to argue that they just shouldn't exist. They're
just too restrictive and tend to have weird behaviors, but unfcortunately,
there are cases where it's prohibitively expensive to have a forward range.
:|

In any case, all that is presently _required_ of ranges is what the traits
isInputRange, isForwardRange, etc. test for. We can't actually require more
than that, because the compiler can't check for more. What we _can_ do (and
has been discussed but never fully sorted out) is write up some additional
rules about what is expected by Phobos and encourage the community at large
to follow them with their ranges, but those can't actually be enforced, and
we've never been able to agree on those rules (particularly since, in most
cases, they aren't necessary, meaning that it only comes up in the corner
cases and hasn't been enough of a pain point to force change). For instance,
many of us argued that it should not be legal for empty to do any work, but
counter-examples were given where it was necessary. So, it becomes very
difficult to place additional requirements beyond what the API itself says -
even as guidelines with regards to what the standard library expects.

Now, as to pure input ranges and reference semantics, allowing half
reference type ranges is very dangerous, because any time that they're
copied, and the copy is iterated at all, the original will be left in an
invalid state (unlike 

  1   2   >