Re: DConf 2014 Keynote: High Performance Code Using D by Walter Bright

2014-07-20 Thread simendsjo via Digitalmars-d-announce
On 07/19/2014 08:37 PM, Andrei Alexandrescu wrote:
 On 7/16/14, 3:22 AM, bearophile wrote:
 Andrei Alexandrescu:
 http://www.reddit.com/r/programming/comments/2aruaf/dconf_2014_keynote_high_performance_code_using_d/



 Despite Walter is used to pipeline programming, so the next step is to
 also handle failures and off-band messages in a functional way (without
 exceptions and global error values) with two parallel pipelines, here
 named Railway-Oriented Programming. This is one of the simplest
 introductions (and he can skip the slides 19-53) that I have found of
 this topic (that in the Haskell community is explained on the base of
 monads):

 http://www.slideshare.net/ScottWlaschin/railway-oriented-programming
 
 Just read the slides, very interesting.
(...)

Didn't look at the slides, but I remember finding the following article
a very nice introduction:
http://fsharpforfunandprofit.com/posts/recipe-part2/

(...)


Re: DConf 2014 Keynote: High Performance Code Using D by Walter Bright

2014-07-20 Thread bearophile via Digitalmars-d-announce

Andrei Alexandrescu:


Just read the slides, very interesting.


There are many papers, books and articles around that explain the 
same things, but that explanation is easy to understand even for 
people not used to functional programming (as I still partially 
am).



I think it would be interesting to experiment with an 
Expected!T that holds an Algebraic!(T, Exception) as state,


In those slides as other member of the sum type they have used an 
enumeration of possible error conditions (or at first even just 
strings of the error messages), sometimes augmented with more 
information, like:


| EmailNotValid of EmailAddress
| DbAuthorizationError of ConnectionString * Credentials
| SmtpTimeout of SmtpConnection
| SmtpBadRecipient of EmailAddress



template bind(alias fun) { ... }

such that given a function e.g.

int fun(string a, double b);

bind!fun is this function:

Expected!int bind!fun(Expected!string a, Expected!double b) {
  if (a.sux || b.sux) return composeExceptions(a, b);
  return fun(a.rox, b.rox);
}

There would also be bindNothrow:

Expected!int bindNothrow!fun(Expected!string a, Expected!double 
b) {

  if (a.sux || b.sux) return composeExceptions(a, b);
  try return fun(a.rox, b.rox);
  catch (Exception e) return e;
}


One of the main points of using those two railways is to avoid 
exceptions.



but of course built-in tuple syntax and basic forms of pattern 
matching
in switch (https://d.puremagic.com/issues/show_bug.cgi?id=596 
) improve
the syntax and make the code more handy, handy enough to push 
more D

programmers in using it.


No :o).


Are you saying you don't want built-in tuples and that you also 
don't agree with the proposal in issue 596 and that you don't 
agree that a better syntax doesn't make monads like those 
actually handy to use? I don't understand what's controversial in 
what I have written there.


From a syntax point of view issue 596 asks for an optional 
onMatch method, and if you want a syntax to create variables in 
switch cases. Plus support for structs and classes as variables 
to switch on.


The use of Algebraic, Nullable and Expected is very different 
(and safer) if you use them through pattern matching. The point 
is not to ape the functional languages: currently in D Nullable 
is not much safer (and not more handy) than using a null pointer.


Bye,
bearophile


Re: Software Assurance Reference Dataset

2014-07-20 Thread bearophile via Digitalmars-d

Andrew Godfrey:


1) A function annotation that means I will call myself
recursively, and when I do, I expect the tail recursion
optimization. I have seen code which allocates something big on
the stack and depends on the optimization. So this intent should
be expressible.


A @tailrec annotation seems good, and will improve the functional 
usages of D. It should stop compilation with a error if the 
function doesn't call itself or if the compiler is not able to 
remove the recursive call. This means it has to be fully enforced.




2) Annotations about when a function does not expect re-entrancy
to be possible based on call-graph analysis.


I don't understand. Assuming I know this 
(http://en.wikipedia.org/wiki/Reentrancy_%28computing%29 ) can 
you show an example?


Bye,
bearophile


Re: [OT] Empire

2014-07-20 Thread Meta via Digitalmars-d

On Sunday, 20 July 2014 at 05:03:51 UTC, Joakim wrote:
Heh, Walter wrote a game that inspired a great deal of the 
strategic gaming genre, most notably including Civilization:


http://en.wikipedia.org/wiki/Classic_Empire

Other than a couple mentions in this newsgroup, I'd never heard 
of this game, now available in D:


http://www.classicempire.com/

Pretty cool reading the article about how the game got around 
back then, seems like an early version of open source and maybe 
the first software to ever go viral, albeit in the much smaller 
computer-using community back in the '70s and '80s.


Any big errors or gaps in the historical account on Wikipedia, 
Walter?  I see that its descendant is now available on iOS and 
Android too. :)


It's neat to see the connections between things sometimes. I've 
been playing the Civilization series since I was 10 years old, 
and then later in life I've come to use the programming language 
designed by the same person whose almost 40 year old game 
originally inspired Civilization. I didn't know that Walter made 
such a large contribution to the turn based strategy video game 
genre. I have to ask now, what features of other games (probably 
tabletop based, given the time) did YOU take inspiration from for 
the first version of Empire, Walter?


Re: Software Assurance Reference Dataset

2014-07-20 Thread bearophile via Digitalmars-d

Andrew Godfrey:


1) A function annotation that means I will call myself
recursively, and when I do, I expect the tail recursion
optimization. I have seen code which allocates something big 
on
the stack and depends on the optimization. So this intent 
should

be expressible.


A @tailrec annotation seems good, and will improve the 
functional usages of D. It should stop compilation with a error 
if the function doesn't call itself or if the compiler is not 
able to remove the recursive call. This means it has to be 
fully enforced.


Perhaps a @cps (or @continuation) annotation is better and more 
general.


Bye,
bearophile


Re: Software Assurance Reference Dataset

2014-07-20 Thread Walter Bright via Digitalmars-d

On 7/19/2014 11:06 PM, bearophile wrote:

A @tailrec annotation seems good, and will improve the functional usages of D.
It should stop compilation with a error if the function doesn't call itself or
if the compiler is not able to remove the recursive call. This means it has to
be fully enforced.


If you want to guarantee replacement of a recursive call with a loop, just write 
a loop.




Re: Software Assurance Reference Dataset

2014-07-20 Thread bearophile via Digitalmars-d

Walter Bright:

If you want to guarantee replacement of a recursive call with a 
loop, just write a loop.


There are cases where a recursive algorithm is nicer. And people 
that want to use D functionally, may also be used to writing code 
recursively.


What about the @continuation 
(http://en.wikipedia.org/wiki/Continuation-passing_style )?


Bye,
bearophile


Re: Software Assurance Reference Dataset

2014-07-20 Thread Walter Bright via Digitalmars-d

On 7/19/2014 11:55 PM, bearophile wrote:

Walter Bright:


If you want to guarantee replacement of a recursive call with a loop, just
write a loop.


There are cases where a recursive algorithm is nicer. And people that want to
use D functionally, may also be used to writing code recursively.


I doubt they'll want to use an @tailrec attribute.



What about the @continuation
(http://en.wikipedia.org/wiki/Continuation-passing_style )?


I doubt they'll want to use that attribute, either.


In any case, D supports more styles of programming than any other language I can 
think of. I doubt adding even more will be that helpful.


Re: GCs in the news

2014-07-20 Thread safety0ff via Digitalmars-d

On Saturday, 19 July 2014 at 21:12:44 UTC, Walter Bright wrote:


3. slices become mostly unworkable, and slices are a fantastic 
way to speed up a program


They are even more fantastic for speeding up programming.
I think that programmer time isn't included often enough in 
discussions.


I have a program which I used D to quickly prototype and form my 
baseline implementation.
After getting a semi-refined implementation I converted the 
performance critical part to C++.
The D code that survived the rewrite uses slices + ranges, and 
it's not worth converting that to C++ code (it would be less 
elegant and isn't worth the time.)


The bottom line is that without D's slices, I might not have 
bothered bringing that small project to the level of completion 
it has today.


Re: Why are the nogc crowed labeled as alarmists?!?!

2014-07-20 Thread Jonathan M Davis via Digitalmars-d
On Thursday, 17 July 2014 at 18:57:51 UTC, Andrei Alexandrescu 
wrote:


To paraphrase a common phrase used among Facebook engineers: 
Nothing in D is someone else's problem.


That would make a good motto.

- Jonathan M Davis


Re: GCs in the news

2014-07-20 Thread Iain Buclaw via Digitalmars-d
On 17 Jul 2014 13:40, w0rp via Digitalmars-d digitalmars-d@puremagic.com
wrote:

 The key to making D's GC acceptable lies in two factors I believe.

 1. Improve the implementation enough so that you will only be impacted by
GC in extermely low memory or real time environments.
 2. Defer allocation more and more by using ranges and algorithms more,
and trust that compiler optimisations will make these fast.


How about
1. Make it easier to select which GC you want to use at runtime init.
2. Write an alternate GC aimed at different application uses (ie: real-time)

We already have (at least) three GC implementations for D.

Regards
Iain


[Dangerously OT] Re: D logo copyright

2014-07-20 Thread Alix Pexton via Digitalmars-d
On 19/07/2014 8:43 PM, Ola Fosheim Grøstad 
ola.fosheim.grostad+dl...@gmail.com wrote:

Not sure why you want a citation. Fair use differs from country to
country. Mona Lisa is in the public domain, but photos of it that has
been enhanced are not. Many novels and poems are in the public domain,
but a book that contains a collection of novels is not, i.e. the
selection of novels or poems constitutes a work protected by copyright.


I perhaps wasn't specific enough about what you had written that was 
contrary to what I had read, specifically it was this...


 The copyright will be held by BOTH the original author and the author 
 of the derivative work


Fair use, public domain and collective works legislation have nothing to 
do with the case in hand.


I have found no cases where a derived work has copyright shared with the 
owner of the original. In the UK, US and France at least the protection 
follows the guidance of the Berne Convention whereby the derived work is 
the parts added to the original and its copyright belongs entirely to 
the deriving artist. By virtue of the fact that permission for the 
derivative to be made was granted by the original artist, the derived 
work can freely incorporate original but there is no sharing of 
copyright. The caveat to this is that the additions of the derived work 
have to be substantial and copyrightable on their own.


Many open licenses give permission to make derivatives with restrictions 
which may require attribution, transitive licensing or non-commercial 
use, but those are the terms of the license and are separate from the 
protection of copyright law.


As has been mentioned, the Berne convention is the minimum requirement 
of the signed up nations and it is entirely possible that some countries 
offer greater protection than others. I have not been able to discover 
if Germany is one of those countries or not.


As interesting as I found this investigation, it has turned out to be a 
dead end anyway. Almost entirely because of the definition of what a 
counts as a derivative work.


A...


Re: function default arguments depending on other arguments

2014-07-20 Thread Tove via Digitalmars-d

On Friday, 18 July 2014 at 17:40:23 UTC, Timon Gehr wrote:

On 07/18/2014 12:00 AM, Trass3r wrote:

void foo(int a, int b = a)
{
}
is illegal in C++ because order of evaluation is undefined.

But since D defines the order to be left to right couldn't it 
also allow

this?


It could, and I think it is an unnecessary limitation that it 
currently does not. (This can also be useful if that parameter 
is the hidden 'this' reference.)


This request keeps popping up, I've seen it at least 3 times 
before and there's even an enhancement request for it:

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

IIRC:
Walter's stance was that he needs compelling examples, which 
proves the utility of this new feature.


Re: Integer overflow and underflow semantics?

2014-07-20 Thread via Digitalmars-d
On Saturday, 19 July 2014 at 19:49:24 UTC, Ola Fosheim Grøstad 
wrote:

On Saturday, 19 July 2014 at 08:34:39 UTC, Kagamin wrote:
Can't it simply generate code as is? Seems wasteful to spend 
compilation time on this.


Not if you want fast code, consider a template with:

if (a.length+M  b.length+N) {}

then you alias b = a in the template instantiation:

if(a.length+M  a.length+N){}

you want this reduced to:

if (MN){
}

which can be resolved at compile time.


Yes, but that is the optimizer's job. The front-end doesn't need 
to spend time on it, if the back-end then anyway does the same 
optimization again.


Re: Copying parameter lists verbatim

2014-07-20 Thread Jakob Ovrum via Digitalmars-d
On Saturday, 19 July 2014 at 17:40:01 UTC, Andrei Alexandrescu 
wrote:

On 7/19/14, 9:36 AM, Jakob Ovrum wrote:
On Saturday, 19 July 2014 at 06:13:10 UTC, Manu via 
Digitalmars-d wrote:

Anyway, does anybody know a nice tidy way to do it?


Unfortunately the only way to create perfect forwarding 
functions

completely generically is still using an ugly string mixin that
generates the forwarding function. A subset of forwarding 
functions can
be created using templates and auto-ref, but of course a 
function

template has many disadvantages to a concrete function (virtual
functions being a good example).


How can this be encapsulated as a library artifact? -- Andrei


Since the key parts of the forwarding function - the parameter 
list and attribute list - are part of the signature, the entire 
function declaration has to be mixed in. That means the function 
body has to be provided as a string argument. This tends to cause 
some seriously unreadable code. It may be a lost cause but I'm 
hoping we can amend the language to avoid that.


GC on Unreal Engine

2014-07-20 Thread Paulo Pinto via Digitalmars-d

Since this theme keeps being discussed.

Here is some info how Unreal Engine makes use of GC in C++.

https://wiki.unrealengine.com/Garbage_Collection_Overview

--
Paulo


Re: Naming of new lazy versions of existing Phobos functions

2014-07-20 Thread Jonathan M Davis via Digitalmars-d

On Saturday, 19 July 2014 at 00:05:55 UTC, Brad Anderson wrote:

To summarize what I think are the best ideas so far:

std.string
--

  EagerLazy
  -
  capitalize   capitalized
  center   centered
  detabdetabbed
  entabentabbed
  format   formatted
  leftJustify  leftJustified
  munchmunched
  outdent  outdented
  removechars  charsRemoved
  rightJustify rightJustified
  splitLines   (none, uses splitter)
  squeeze  squeezed
  stripstripped
  stripLeftleftStripped
  stripRight   rightStripped
  succ successor
  toLower  lowercased
  toStringznullTerminated
  toUpper  uppercased
  translatetranslated
  wrap wrapped

std.path


  EagerLazy
  -
  absolutePath absolutePathOf *
  buildNormalizedPath  asNormalizedPath *
  buildPathasPath *
  defaultExtension withDefaultExtension *
  dirName  dirNameOf *
  driveNamedriveNameOf *
  expandTilde  tildeExpanded
  relativePath relativePathOf *
  setExtension withExtension
  stripDrive   driveStripped
  stripExtension   extensionStripped

* - not terribly happy with these but I'd say it's the best of 
what's been proposed


Generally it seems like past tense works when the function has 
a verb, with prefix when there is no verb but you are 
modifying something about the input, and Of suffix when you 
are pulling something out. Also, the verb should come last 
because it has a better ring to it.


Do we really want to be naming functions which aren't properties 
with adjectives instead of verbs? That seems very wrong to me. 
I'd much rather see stuff like setExt or setExtLazy than 
withExtension or extensionSet. Function names are supposed to be 
verbs unless they're emulating variables. They _do_ something, 
even if it's lazy.


- Jonathan M Davis


Re: Software Assurance Reference Dataset

2014-07-20 Thread Dmitry Olshansky via Digitalmars-d

20-Jul-2014 10:45, Walter Bright пишет:

On 7/19/2014 11:06 PM, bearophile wrote:

A @tailrec annotation seems good, and will improve the functional
usages of D.
It should stop compilation with a error if the function doesn't call
itself or
if the compiler is not able to remove the recursive call. This means
it has to
be fully enforced.


If you want to guarantee replacement of a recursive call with a loop,
just write a loop.



Functional programming is full of simple recursion and it would be nice 
not to stack overflow in debug builds.


Another use case is so-called threaded code interpreter, that can be 
done with either computed gotos (and bunch of labels) or forced tail 
calls (and bunch of functions). In both cases computed jump or tail call 
is indirect.


--
Dmitry Olshansky


Re: Integer overflow and underflow semantics?

2014-07-20 Thread Tobias Müller via Digitalmars-d
Marc Schütz schue...@gmx.net wrote:
 On Saturday, 19 July 2014 at 19:49:24 UTC, Ola Fosheim Grøstad wrote:
 On Saturday, 19 July 2014 at 08:34:39 UTC, Kagamin wrote:
 Can't it simply generate code as is? Seems wasteful to spend  compilation 
 time on this.
 
 Not if you want fast code, consider a template with:
 
 if (a.length+M  b.length+N) {}
 
 then you alias b = a in the template instantiation:
 
 if(a.length+M  a.length+N){}
 
 you want this reduced to:
 
 if (MN){
 }
 
 which can be resolved at compile time.
 
 Yes, but that is the optimizer's job. The front-end doesn't need to spend
 time on it, if the back-end then anyway does the same optimization again.

I don't think anyone has said that the frontend does that.
But the language semantics forbid such optimizations if overflow is defined
as wrapping.
If the optimizer respects that is a different chapter, as the experiment
with GDC shows.

Tobi


Re: GCs in the news

2014-07-20 Thread Mike via Digitalmars-d
On Sunday, 20 July 2014 at 08:41:16 UTC, Iain Buclaw via 
Digitalmars-d wrote:

On 17 Jul 2014 13:40, w0rp via Digitalmars-d
The key to making D's GC acceptable lies in two factors I 
believe.


1. Improve the implementation enough so that you will only be 
impacted by

GC in extermely low memory or real time environments.
2. Defer allocation more and more by using ranges and 
algorithms more,

and trust that compiler optimisations will make these fast.




How about
1. Make it easier to select which GC you want to use at runtime 
init.
2. Write an alternate GC aimed at different application uses 
(ie: real-time)




Yes, Please!

Being able to specify an alternate memory manager at 
compile-time, link-time and/or runtime would be most 
advantageous, and probably put an end to the GC-phobia.


DIP46 [1] also proposes and interesting alternative to the GC by 
creating regions at runtime.


And given the passion surrounding the GC in this community, if 
runtime hooks and/or a suitable API for custom memory managers 
were created and documented, it would invite participation and an 
informal, highly competitive contest for the best GC would likely 
ensue.


Mike

[1] http://wiki.dlang.org/DIP46


Re: function default arguments depending on other arguments

2014-07-20 Thread bearophile via Digitalmars-d

Tove:


IIRC:
Walter's stance was that he needs compelling examples, which 
proves the utility of this new feature.


Recently I have had a desire for that feature, to write a 
function like this:


int[][] generateTable(in uint nx, in uint ny=nx) {...}

If you give just one argument to this function, it generates a 
square table, otherwise it uses both the given sizes.


Bye,
bearophile


Re: GCs in the news

2014-07-20 Thread Kagamin via Digitalmars-d

On Sunday, 20 July 2014 at 11:44:56 UTC, Mike wrote:
Being able to specify an alternate memory manager at 
compile-time, link-time and/or runtime would be most 
advantageous, and probably put an end to the GC-phobia.


AFAIK, GC is not directly referenced in druntime, so you already 
should be able to link with different GC implementation. If you 
provide all symbols requested by the code, the linker won't link 
default GC module.


Re: Software Assurance Reference Dataset

2014-07-20 Thread bearophile via Digitalmars-d

Walter Bright:


I doubt they'll want to use an @tailrec attribute.


In Scala there is @tailrec:
http://www.scala-lang.org/api/current/scala/annotation/tailrec.html

In both F# and OcaML there is the rec keyword:
http://msdn.microsoft.com/en-us/library/dd233232.aspx

http://caml.inria.fr/pub/docs/manual-ocaml-400/manual003.html#toc4

In Clojure there is recur (that is not an annotation):
http://clojure.org/special_forms?responseToken=08ea4841337f67bb8f07663aa70b03aca#recur

I think functional programmers are willing to use @tailrec 
attribute if it's well designed and it does what's written on its 
tin.




What about the @continuation
(http://en.wikipedia.org/wiki/Continuation-passing_style )?


I doubt they'll want to use that attribute, either.


I don't know. It's more general than the @tailrec, but probably 
many C and C++ and Java programmers don't even know what it is. 
But it allows a programming style that in some case is 
interesting (far cleaner than computed gotos).



In any case, D supports more styles of programming than any 
other language I can think of. I doubt adding even more will be 
that helpful.


I think a basic form of pattern matching implemented with the 
switch construct is a good idea for D.


Bye,
bearophile


Re: GCs in the news

2014-07-20 Thread Mike via Digitalmars-d

On Sunday, 20 July 2014 at 12:07:47 UTC, Kagamin wrote:

On Sunday, 20 July 2014 at 11:44:56 UTC, Mike wrote:
Being able to specify an alternate memory manager at 
compile-time, link-time and/or runtime would be most 
advantageous, and probably put an end to the GC-phobia.


AFAIK, GC is not directly referenced in druntime, so you 
already should be able to link with different GC 
implementation. If you provide all symbols requested by the 
code, the linker won't link default GC module.


Yes, I believe you are correct.  I also believe there is even a 
GCStub in the runtime that uses malloc without free.  What's 
missing is API documentation and examples that makes such 
features accessible.


Also missing, are language/runtime hooks that could allow users 
to try alternative memory management schemes such as ARC and find 
what works best for them through experimentation.


In short, IMO, D should not embrace one type of automatic memory 
management, they should make it extensible.  In time two ore 
three high quality memory managers will prevail.


Mike


Re: Can't Link DWT in Linux 64-bit

2014-07-20 Thread Jacob Carlborg via Digitalmars-d-dwt

On 2014-07-20 02:46, Mike wrote:


What do you mean by native type?  I thought the only native types in D
were `size_t` and `ptrdiff_t`.  What's the actual syntax you use in the
OSX port?


External C functions that take pointers are declared to take int/long in 
the Java code. I would prefer that the original type is used.



If you're looking for alternative names for `size_t` and `ptrdiff_t` how
about:

alias native_int = ptrdiff_t;
alias native_uint = size_t;


Hmm, I don't know. Perhaps ptrdiff_t is good enough.

--
/Jacob Carlborg


Re: shared and nonshared dtor

2014-07-20 Thread Vlad Levenfeld via Digitalmars-d-learn

On Sunday, 20 July 2014 at 08:29:55 UTC, Jonathan M Davis wrote:
What you will probably need to do is to not try and use the 
same type as both shared and non-shared if it has a destructor.


Unfortunately this option would require an unrealistic lot of 
refactoring for me. I'm basically using this thing as a drop-in 
replacement for arrays, so they go everywhere. I use array-based 
swap buffers to transfer data between threads. I have to declare 
the buffers shared, which makes the arrays shared.
This problem only emerged when I decided I wanted them to free on 
destruction, so it looks like I'll be sticking with manual free 
for awhile longer.


I would however suggest that you report this as a bug, since it 
really should be able to distinguish between shared and 
unshared destructors.


Would it be considered a duplicate of 
https://issues.dlang.org/show_bug.cgi?id=12004 ? At least, all of 
my use cases agree with the bug filer's argument against having 
any shared dtors.


shared is a great concept, but we are going to need a few 
adjustments to its design in order to make it properly, fully 
useable.


Agreed. It's given me a few headaches in the past, but I do like 
the idea of a transitive qualifier that helps me identify 
potentially racy data.


Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't look 
like anything along the lines of an OS thread handle is exposed 
in the API.


What do you need the OS thread handle for?


Re: get os thread handles

2014-07-20 Thread Sean Campbell via Digitalmars-d-learn

On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote:

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't look 
like anything along the lines of an OS thread handle is exposed 
in the API.


What do you need the OS thread handle for?


sonce the standard so i can get pause/resume support for d threads


Re: get os thread handles

2014-07-20 Thread Jonathan M Davis via Digitalmars-d-learn

On Sunday, 20 July 2014 at 10:03:47 UTC, Sean Campbell wrote:

On Sunday, 20 July 2014 at 09:53:52 UTC, Jonathan M Davis wrote:

On Sunday, 20 July 2014 at 09:34:46 UTC, Sean Campbell wrote:

How do i get an os thread handle from a thread object.
or are d thread not wrapped os threads.


They do wrap OS threads, but they encapsulate them in a 
cross-platform manner, and looking over Thread, it doesn't 
look like anything along the lines of an OS thread handle is 
exposed in the API.


What do you need the OS thread handle for?


sonce the standard so i can get pause/resume support for d 
threads


I'd suggest opening up an enhancement request. Assuming that that 
functionality exists across all of the various OSes, it can 
probably be added:


https://issues.dlang.org

You can also open an enhancement request for getting access to 
the OS thread handles, but my guess is that that wouldn't happen, 
because it makes it so that the Thread class no longer has full 
control, which would make it impossible to have any kind of 
@safety for Thread (though it doesn't seem to currently have any 
such annotations).


But if what you're looking for is thread functionality that is 
common across OSes, then there's a good chance that it's 
reasonable to add it to Thread, making it unnecessary to provide 
access to its innards.


In the meantime, I expect that you'll have to either use the C 
APIs directly or create your own class  which is a copy of Thread 
and tweak it to do what you need.


How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-20 Thread Uranuz via Digitalmars-d-learn

The question is in the header:
How to say to compiler that I want to inherit final template 
bethod of base interface into derived class?


I have the following example. I know that it is maybe 
overcomplicated but still I need this feature in my code.


import std.stdio;

interface IBase
{

template getStr(string fieldName)
{
final string getStr()
{
return George;
}
}


string getStr(string fieldName);
}


class Derived: IBase
{
override string getStr(string fieldName)
{
return Sam;
}

}


void main()
{
auto obj = new Derived;

writeln( obj.getStr!(aaa)() );

}

Compilation output:
/d907/f266.d(33): Error: obj.getStr isn't a template


When I have all of these methods having the same name compiler 
shadows template method from the base interface. So the question 
is how to inherit template method without reimplementing it in 
derived class?


Re: How to say to compiler that I want to inherit final template bethod of base interface into derived class

2014-07-20 Thread anonymous via Digitalmars-d-learn

import std.stdio;

interface IBase
{

template getStr(string fieldName)
{
final string getStr()
{
return George;
}
}


string getStr(string fieldName);
}


class Derived: IBase
{
alias getStr = IBase.getStr; /* order matters, see below */
override string getStr(string fieldName)
{
return Sam;
}
/* alias getStr = IBase.getStr; /* doesn't work here, I guess
that's a compiler bug */
}


void main()
{
auto obj = new Derived;

assert( obj.getStr!(aaa)() == George );
assert( obj.getStr(aaa) == Sam );

}


[Issue 13164] ICE: backend/cgcod.c 1589

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13164

yebblies yebbl...@gmail.com changed:

   What|Removed |Added

   Keywords||ice
 CC||yebbl...@gmail.com
   Severity|enhancement |critical

--


[Issue 13152] [REG2.064.2] Compiler high cpu usage and never ends

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13152

Vladimir Panteleev thecybersha...@gmail.com changed:

   What|Removed |Added

 CC||thecybersha...@gmail.com
Summary|Compiler high cpu usage and |[REG2.064.2] Compiler high
   |never ends  |cpu usage and never ends

--- Comment #2 from Vladimir Panteleev thecybersha...@gmail.com ---
Domingo, can you try removing public from the imports in each module? I think
that's what's causing the slowdown.

I can reproduce the problem (and arrive at the same bisect result) with the
following synthetic test case:

// a.d /
public import a;
public import b;
.
public import y;
public import z;


Then copy a.d to b.d, c.d, ..., z.d.

You can use the following program to generate the test files:

/ gen.d 
import std.stdio;

enum last = 'z';

void main()
{
for (char c = 'a'; c=last; c++)
{
auto f = File(c ~ .d, w);
for (char c2 = 'a'; c2=last; c2++)
f.writefln(public import %s;, c2);
}
}


Running `dmd a.d` will take a very long time.

Introduced in https://github.com/D-Programming-Language/dmd/pull/2448 (between
2.063 and 2.064.2).

--


[Issue 13158] D:YAML broken by 2.066

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13158

Vladimir Panteleev thecybersha...@gmail.com changed:

   What|Removed |Added

 CC||thecybersha...@gmail.com

--- Comment #1 from Vladimir Panteleev thecybersha...@gmail.com ---
Introduced in https://github.com/D-Programming-Language/dmd/pull/3400

--


[Issue 12004] shared ~this() should not exist

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12004

Vlad Levenfeld vlevenf...@gmail.com changed:

   What|Removed |Added

 CC||vlevenf...@gmail.com

--


[Issue 12192] Wrong interface file content generated that crashes compiler

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12192

Vlad Levenfeld vlevenf...@gmail.com changed:

   What|Removed |Added

 CC||vlevenf...@gmail.com

--


[Issue 12192] Wrong interface file content generated that crashes compiler

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=12192

Vlad Levenfeld vlevenf...@gmail.com changed:

   What|Removed |Added

 CC|vlevenf...@gmail.com|

--


[Issue 13163] std.conv.parse misses overflow when it doesn't result in a smaller value

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13163

Nils nilsboss...@googlemail.com changed:

   What|Removed |Added

Summary|std.conv.parse misses   |std.conv.parse misses
   |overflow when it results in |overflow when it doesn't
   |the same value  |result in a smaller value

--- Comment #2 from Nils nilsboss...@googlemail.com ---
Another test case by monarchdodra showing that the overflowed value can be
greater than the original (duh):

import std.conv;
import std.exception;
void main()
{
auto s = 123;
assertThrown!ConvOverflowException(s.parse!ubyte(16)); /* fails */
}

--


[Issue 13152] [REG2.064.2] Compiler high cpu usage and never ends

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13152

--- Comment #3 from Domingo Alvarez Duarte mingo...@gmail.com ---
Yes removing the public attribute seems to allow dmd to work as expected.

I saw that you've marked the commit that create this bug with a comment about
this.

So this will be a bug ? How can we describe it better ?

--


[Issue 13166] New: pause and resume threads

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13166

  Issue ID: 13166
   Summary: pause and resume threads
   Product: D
   Version: D2
  Hardware: x86_64
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: Phobos
  Assignee: nob...@puremagic.com
  Reporter: sycam@gmail.com

the core.thread class should have some mechanism for pausing or resuming
threads or alternately should expose the OS thread handles so we can use OS
specific thread functions (Not Advised)

on windows it would be a wrapper for suspendthread and ResumeThread
however on POSIX you would have to implement your own mechanism for doing so as
pthread doesn't provide any such mechanism.

--


[Issue 13152] [REG2.064.2] Compiler high cpu usage and never ends

2014-07-20 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13152

Vladimir Panteleev thecybersha...@gmail.com changed:

   What|Removed |Added

   Keywords||performance
   Hardware|x86_64  |All
 OS|Linux   |All

--- Comment #4 from Vladimir Panteleev thecybersha...@gmail.com ---
Yes, this is a compiler performance regression. I think this issue contains
enough information now.

--