Re: D/Objective-C 64bit

2014-11-05 Thread Christian Schneider via Digitalmars-d-announce

What happens if you declare doubleClickAction like this:

void doubleClickAction(NSTableView sender) { ... }

That will probably require a cast when passing the selector to 
setDoubleAction.


Hi Jacob

This just delegates the problem to another place. The
target/action paradigm in Cocoa programming gets a lot from the
fact that any object can be the sender of an action. In this
particular case I'd even prefer the conditional if the sender
is the local table view member var, which then basically has
the same effect as what you suggested above.

I think the best thing will be to fix the interface-to-class
casts in the compiler, as Michel suggests above.

Thanks again
Christian


porting nanomsg bindings to dlang

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-announce

Hi.

Everyone has heard of ZeroMQ, but the creator (or one of the main 
guys) has been working on a successor framework written in C.  
(He has an interesting paper on why using C++ was a mistake - 
perhaps we should get him to look at D if he has not done so 
already).


In any case, I could not see a set of D bindings so I wrote a 
very rough first draft of them last night.  I only picked up D a 
couple of months back, and it's been about twenty years since I 
wrote much C (I am not a developer by trade), so be kind if the 
results are not yet quite up to scratch.


Link to the repository is here - not even worthy of alpha status:
https://github.com/Laeeth/d-nanomsg/tree/master

So far I have tried the first example from here (which works), 
and am working my way down to test the others:


http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html



porting nanomsg bindings to dlang

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-announce

examples here all work:
https://github.com/dysinger/nanomsg-examples/blob/master/README.org

but I have not tried any larger projects.



Re: porting nanomsg bindings to dlang

2014-11-05 Thread Matt Soucy via Digitalmars-d-announce
On 11/05/2014 01:12 PM, Laeeth Isharc wrote:
 Hi.
 
 Everyone has heard of ZeroMQ, but the creator (or one of the main guys) has 
 been working on a successor framework written in C.  (He has an interesting 
 paper on why using C++ was a mistake - perhaps we should get him to look at D 
 if he has not done so already).
 
 In any case, I could not see a set of D bindings so I wrote a very rough 
 first draft of them last night.  I only picked up D a couple of months back, 
 and it's been about twenty years since I wrote much C (I am not a developer 
 by trade), so be kind if the results are not yet quite up to scratch.
 
 Link to the repository is here - not even worthy of alpha status:
 https://github.com/Laeeth/d-nanomsg/tree/master
 
 So far I have tried the first example from here (which works), and am working 
 my way down to test the others:
 
 http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html
 

A few small suggestions:

Use a .gitignore so you're not tracking the objects and executables
Convert to a dub package to make it easier for other people to incorporate into 
their projects
Split out the test code from the library code

-- 
Matt Soucy
http://msoucy.me/



signature.asc
Description: OpenPGP digital signature


Re: porting nanomsg bindings to dlang

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-announce

Thanks.

I am slowly getting to grips with all these post-stone age 
innovations...


On Wednesday, 5 November 2014 at 20:24:41 UTC, Matt Soucy wrote:

On 11/05/2014 01:12 PM, Laeeth Isharc wrote:

Hi.

Everyone has heard of ZeroMQ, but the creator (or one of the 
main guys) has been working on a successor framework written 
in C.  (He has an interesting paper on why using C++ was a 
mistake - perhaps we should get him to look at D if he has not 
done so already).


In any case, I could not see a set of D bindings so I wrote a 
very rough first draft of them last night.  I only picked up D 
a couple of months back, and it's been about twenty years 
since I wrote much C (I am not a developer by trade), so be 
kind if the results are not yet quite up to scratch.


Link to the repository is here - not even worthy of alpha 
status:

https://github.com/Laeeth/d-nanomsg/tree/master

So far I have tried the first example from here (which works), 
and am working my way down to test the others:


http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html



A few small suggestions:

Use a .gitignore so you're not tracking the objects and 
executables
Convert to a dub package to make it easier for other people to 
incorporate into their projects

Split out the test code from the library code




Re: GSOC Summer 2015 - Second call for Proposals

2014-11-05 Thread Jens Mueller via Digitalmars-d
Craig Dillabaugh via Digitalmars-d wrote:
 This is my second Call for Proposals for the 2015 Google Summer of
 Code. Anyone interested in mentoring, or who has good idea's for a
 project for 2015 please post here.  So far I have the following
 people who have expressed interest in mentoring:
 
 Mentor's with specific projects in mind:
 
 Mentor Project Area(s)
 Amaury Sechet (Deadalnix): SDC - D Compiler as a library
 Martin Nowak ARM Support and Bare Metal D
 Iain Buclaw  GDC
 
 I have a pretty good set of specific idea's from Deadalnix, but I
 could use more specific project ideas for Martin and Iain.
 
 A few others have volunteered to mentor, and have given general
 areas of interest, but I don't really have specific project
 suggestions from:
 
 Andrei Alexandrescu   Phobos
 Rikki Cattermole  Web Development
 Russel Winder Phobos/QML: std.parallelism, std.benchmark
 Jacob Ovrum   std.i18n
 Jens Mueller  std.socket, std.log, std.benchmark,
 std.numeric.matrix

Remove std.log from that list (as it is almost finished by Robert).
I still mentor for improving std.socket (though I would need community
input from what the community likes to be changed (preferably though
issues.dlang.org)) and std.benchmark (together with Russel if he
wants to share the work), and still interested in having
std.numeric.matrix (I believe others too).
Arguably the descriptions on http://wiki.dlang.org/GSOC_2014_Ideas are
very short.

snip more ideas /

 A few other questions for the community (and possible mentors).
 
 1. I was thinking that as a way of making our idea's/mentor's lists
 to stand out I would like to post short Bio's on each mentor -
 pictures would be nice too, but maybe some potential mentors would
 be put off by that.  If possible I would also like to post a link to
 the mentor's talks at DConf (espcially if the talk is related to the
 project idea(s)).   This should set our idea's list apart from most
 I have seen so far.  Of course I would only post a bio/picture with
 the potential mentor's consent.

Fine with me.

 2. I am supposed to have a backup GSOC administrator, in case I pass
 away unexpectedly or become otherwise incapacitated.  Any volunteers
 !
 
 3. We also should have backup mentors - if you feel comfortable
 serving as a backup mentor for one of the posted project ideas then
 please let me know.
 
 4. I am supposed to summarize our involvement and the successes and
 challenges of our participation for previous years, and  list our
 pass/fail rate for each year.  Can anyone on the forum fill me in on
 some of this information, especially if you have mentored in the
 past, or better yet are a past GSOC student still involved with D.

I believe you should get access to the past GSOC's on
http://www.google-melange.com/gsoc/homepage/google/gsoc2015?PageSpeed=noscript
Andrei should have access to these. You should find there everything.

I'd like to add that I firmly believe that we should strive for a short
list of important projects than a long list of anything. I say no more
than seven projects that the community likes to see addressed that allow
students getting involved in D. Make it few but exceptional strong.
It's fine to brainstorm now and cut down later. But I want to see that
cut down before polishing the project's description etc.

Thank you very much for the effort you are putting into it - invaluable.

Jens


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread via Digitalmars-d

On Wednesday, 5 November 2014 at 00:34:54 UTC, Meta wrote:

On Wednesday, 5 November 2014 at 00:32:32 UTC, Nordlöw wrote:

Has there been any proposals to add a sort-wrapper, say sortBy,

in cases such as

   struct X { double x, y, z; }
   auto r = new X[3];

used as

   r.sortBy!(x, y)

sorting r by value of x then y.

If not and anybody is interest I could write one and make PR 
in std.algorithm.


I think you're looking for multiSort.

http://dlang.org/phobos/std_algorithm.html#.multiSort


That's not the same, it requires to specify a comparison 
function. Nordlöw wants to specify an attribute.


This could also be an arbitrary expression, of course:

r.sortBy!x*x + y*y + z*z

The above could be implemented using `with` and 
`std.functional.unaryFun`. Alternatively, a lambda could be used:


r.sortBy!(a = a.norm);


Re: Fwd: Interfacing with C++

2014-11-05 Thread albatroz via Digitalmars-d

On Monday, 3 November 2014 at 20:32:34 UTC, Abdulhaq wrote:


You might find my project Smidgen
(https://github.com/alynch4047/smidgen) useful, It's not 
finished

but you might consider extending it rather than starting
elsewhere.


woe...
The first time I see this project mentioned.
You may consider publishing this in the announcement forum, it 
will give it more visibility, it looks very promising.


And now to play with it...

Thank you


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 11:18:56 UTC, Marc Schütz wrote:

This could also be an arbitrary expression, of course:

r.sortBy!x*x + y*y + z*z

The above could be implemented using `with` and 
`std.functional.unaryFun`. Alternatively, a lambda could be 
used:


r.sortBy!(a = a.norm);


Ok. Great. What do you think about the name sortBy?


Re: GSOC Summer 2015 - Second call for Proposals

2014-11-05 Thread CraigDillabaugh via Digitalmars-d

On Wednesday, 5 November 2014 at 10:46:20 UTC, Jens Mueller via
Digitalmars-d wrote:

Craig Dillabaugh via Digitalmars-d wrote:
This is my second Call for Proposals for the 2015 Google 
Summer of
Code. Anyone interested in mentoring, or who has good idea's 
for a

project for 2015 please post here.  So far I have the following
people who have expressed interest in mentoring:

Mentor's with specific projects in mind:

Mentor Project Area(s)
Amaury Sechet (Deadalnix): SDC - D Compiler as a library
Martin Nowak   ARM Support and Bare Metal D
Iain BuclawGDC

I have a pretty good set of specific idea's from Deadalnix, 
but I

could use more specific project ideas for Martin and Iain.

A few others have volunteered to mentor, and have given general
areas of interest, but I don't really have specific project
suggestions from:

Andrei Alexandrescu   Phobos
Rikki Cattermole  Web Development
Russel Winder Phobos/QML: std.parallelism, 
std.benchmark

Jacob Ovrum   std.i18n
Jens Mueller  std.socket, std.log, std.benchmark,
std.numeric.matrix


Remove std.log from that list (as it is almost finished by 
Robert).
I still mentor for improving std.socket (though I would need 
community
input from what the community likes to be changed (preferably 
though

issues.dlang.org)) and std.benchmark (together with Russel if he
wants to share the work), and still interested in having
std.numeric.matrix (I believe others too).
Arguably the descriptions on 
http://wiki.dlang.org/GSOC_2014_Ideas are

very short.

snip more ideas /


A few other questions for the community (and possible mentors).

1. I was thinking that as a way of making our idea's/mentor's 
lists

to stand out I would like to post short Bio's on each mentor -
pictures would be nice too, but maybe some potential mentors 
would
be put off by that.  If possible I would also like to post a 
link to
the mentor's talks at DConf (espcially if the talk is related 
to the
project idea(s)).   This should set our idea's list apart from 
most
I have seen so far.  Of course I would only post a bio/picture 
with

the potential mentor's consent.


Fine with me.

2. I am supposed to have a backup GSOC administrator, in case 
I pass
away unexpectedly or become otherwise incapacitated.  Any 
volunteers

!

3. We also should have backup mentors - if you feel comfortable
serving as a backup mentor for one of the posted project ideas 
then

please let me know.

4. I am supposed to summarize our involvement and the 
successes and
challenges of our participation for previous years, and  list 
our
pass/fail rate for each year.  Can anyone on the forum fill me 
in on
some of this information, especially if you have mentored in 
the
past, or better yet are a past GSOC student still involved 
with D.


I believe you should get access to the past GSOC's on
http://www.google-melange.com/gsoc/homepage/google/gsoc2015?PageSpeed=noscript
Andrei should have access to these. You should find there 
everything.


I did a bit of searching, and here are our entry's for 2012:

Project StudentMentor   
Mono-D  Alex Bothe LightBender

Removing the global gc
lock from common
allocations in D.   Antti-Ville Tuunainen  David Simcha

Extended unicode
support Dmitry Olshansky   Andrei Alexandrescu

That is a pretty promising list, as it seems that our past
students are still involved in the community.  I will do some
more searching, but need to get to work now :o)




I'd like to add that I firmly believe that we should strive for 
a short
list of important projects than a long list of anything. I say 
no more
than seven projects that the community likes to see addressed 
that allow
students getting involved in D. Make it few but exceptional 
strong.
It's fine to brainstorm now and cut down later. But I want to 
see that

cut down before polishing the project's description etc.

Thank you very much for the effort you are putting into it - 
invaluable.


Jens


Thanks, I agree that we should have a few well defined projects.
It seems that Google puts lots of emphasis on the Project Ideas
page, so I think over the next few months I will try to make that
the best possible.







Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread via Digitalmars-d

On Wednesday, 5 November 2014 at 14:07:10 UTC, Nordlöw wrote:
On Wednesday, 5 November 2014 at 11:18:56 UTC, Marc Schütz 
wrote:

This could also be an arbitrary expression, of course:

   r.sortBy!x*x + y*y + z*z

The above could be implemented using `with` and 
`std.functional.unaryFun`. Alternatively, a lambda could be 
used:


   r.sortBy!(a = a.norm);


Ok. Great. What do you think about the name sortBy?


It's intuitive and concise. Plus, Ruby uses `sort` and `sort_by` 
for the same functionality, exactly in parallel, so it will be 
familiar to many users.


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread bearophile via Digitalmars-d

Marc Schütz:


r.sortBy!(a = a.norm);


r.schwartzSort!(a = a.norm);

Bye,
bearophile


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 14:52:38 UTC, bearophile wrote:

Marc Schütz:


   r.sortBy!(a = a.norm);


r.schwartzSort!(a = a.norm);

Bye,
bearophile


Ok, but this doesn't support multi-sorting, right?


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread bearophile via Digitalmars-d

Nordlöw:


Ok, but this doesn't support multi-sorting, right?


If performance is not a top priority, you can use a tuple:

r.schwartzSort!(x = tuple(x.a, x.b, x.c));

Bye,
bearophile


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 14:36:11 UTC, Marc Schütz wrote:
It's intuitive and concise. Plus, Ruby uses `sort` and 
`sort_by` for the same functionality, exactly in parallel, so 
it will be familiar to many users.


Here's my first working but primitive version.

https://github.com/nordlow/justd/blob/master/sort_ex.d#L15

How do I extend it to support

- variadic number of extractors
- sortBy(x)

?


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread via Digitalmars-d

On Wednesday, 5 November 2014 at 16:07:40 UTC, Nordlöw wrote:
On Wednesday, 5 November 2014 at 14:36:11 UTC, Marc Schütz 
wrote:
It's intuitive and concise. Plus, Ruby uses `sort` and 
`sort_by` for the same functionality, exactly in parallel, so 
it will be familiar to many users.


Here's my first working but primitive version.

https://github.com/nordlow/justd/blob/master/sort_ex.d#L15

How do I extend it to support

- variadic number of extractors
- sortBy(x)


My idea was something along these lines (untested):

template extractorFun(alias extractor) {
static if(is(typeof(extractor) : string)) {
auto ref extractorFun(T)(auto ref T a) {
mixin(with(a) { return  ~ extractor ~ ; });
}
} else {
alias extractorFun = extractor;
}
}

alias fn = extractorFun!extractor;
r.sort!((a, b) = (fn(a)  fn(b)));


Re: Compiling druntime gives error messages

2014-11-05 Thread Domingo via Digitalmars-d
And what about of back ports of important fixes, changes that can 
be backward compatible.


In my point of view the 2.0.66.* is a dead release, because it 
can not compile lots of already existing code that the 2.0.65 and 
2.0.67 can.


A D language weakness pointed out on other posts no 
backports/fixes like gcc and others do.


Not a good thing to grow up the user base.

Cheers !


Re: Programming Language for Games, part 3

2014-11-05 Thread deadalnix via Digitalmars-d

On Wednesday, 5 November 2014 at 07:33:37 UTC, Jacob Carlborg
wrote:

On 2014-11-04 23:18, deadalnix wrote:


Yes, I have yet to implement a check for ctfeability.


Cool, perhaps you should not add it :)


My plan is to add the check for CTFE, but at the point in the
semantic analysis, not in the JIT part, so it is still possible
to run it without the check if wanted from 3rd party code (REPL
anyone ?).


Re: Fwd: Interfacing with C++

2014-11-05 Thread Abdulhaq via Digitalmars-d

On Wednesday, 5 November 2014 at 12:39:16 UTC, albatroz wrote:

On Monday, 3 November 2014 at 20:32:34 UTC, Abdulhaq wrote:


You might find my project Smidgen
(https://github.com/alynch4047/smidgen) useful, It's not 
finished

but you might consider extending it rather than starting
elsewhere.


woe...
The first time I see this project mentioned.
You may consider publishing this in the announcement forum, it 
will give it more visibility, it looks very promising.


And now to play with it...

Thank you


Please ask me any questions direct to alynch4...@gmail.com, I'll 
do my best to help you. You might be interested in my progress in 
wrapping Qt which can be seen at 
https://github.com/alynch4047/sqt . The example Qt wrapped 
program simply wraps a QLineEdit and overrides various virtual 
methods, however most of the *.sip format is implemented for D 
and I could probably wrap a fair amout of Qt now, but again it's 
on hold ATM.


Please do let me know how you get on, even if it doesn't work for 
you!


New reference type designed to handle templates better

2014-11-05 Thread Jonathan Marler via Digitalmars-d
I've been thinking about how to handle templates that have 
typically been using the 'ref' parameter attribute because they 
modify the parameter.  For example, the put/doPut functions in 
std.range use the 'ref' attribute for the output range, but in 
many cases the parameter doesn't need to be a reference type and 
the overhead that comes with it.


One idea I had is to have a different type of function argument 
attribute as opposed to ref.


A ref parameter is passed by reference.  Under the hood, a 
reference parameter is equivalent to a pointer to the variable.  
Then the function is free to modify the caller's version of the 
variable.  This new type of function parameter, let's call it 
pref, would instead care about what the variable is pointing 
to instead of the variable itself.  In some cases this means 
modifying the caller's version of the variable and in some cases 
it does not.  For example, if a basic value type like int was 
passed in, the variable isn't pointing to anything so a pointer 
to the variable itself would be passed in, but if an int* was 
passed in, then the int* would be passed by value.  I've included 
a table of common types and how pref would differ from ref.


pref: modifying the data the variable is pointing to.  This means 
that if the variable is itself a pointer, then the function won't 
modify the pointer but instead modify what it's pointing to.


BasicDataType (BDT) is bool, all integer types, all float types, 
and all char types


Type |  ref|  pref|  why

BDT  | BDT*  | BDT*  | A BDT is not a pointer, so 
pref must
 | modify the variable itself 
which you can
 | say is pointing to a location 
in memory
BDT* | BDT** | BDT*  | A BDT* is already a pointer, 
pref will
 | modify the memory BDT is 
pointing to
BDT[]| BDT[]*| BDT[]* or BDT[] | An argument can be made 
for both,
 | if the function is modifying 
the contents
 | of the array (maybe writing 
data to it),
 | then the function might need 
some way of
 | returning how much data was 
written so
 | it might want to modify the 
given array

 | to indicate it has changed.
struct   | struct*   | struct*   | A struct variable is not a 
pointer, so
 | pref is a reference type for 
the struct
struct*  | struct**  | struct*   | A struct pointer is already a 
pointer

class| class*| class | A class is already a pointer
function | function* | function  | A function is a pointer to 
code, a
 | function is usually used to 
modify data so pref treats the function as what is modifying the 
data.

delegate | delegate* | delegate  | Same as reason for function

Note: A pref modifer to a type that is a pointer to any of these 
types will not do anything to the type


D hackers requested. Dancing around postblit.

2014-11-05 Thread IgorStepanov via Digitalmars-d

Please try to solve this task:
We have a struct S.
S has a some kind of postblit (user-defined or inherited frome 
field) and destructor. S has a @disabled opAssign.
We have an unitialized allocated memory block whick mapped to a S 
array.

struct S
{
   //postblit and dtor here
}
S[] data; // contains a garbarge

void emplace()(ref S val, size_t i);

The task: we should write emplace function, which initializes 
i-th element of data with val;
This function shouldn't call any dtors for example for the old 
data[i] (which contains a garbarge).
This function should be transparent for attributes. For example, 
if S postblit is nothrow emplace should be nothrow too. If S 
postblit is not nothrow, S should't be nothrow.
This function should call postblit only one time and shouldn't 
call any other S special functions (opAssign, ctor etc.)


Re: Template Instantiation Bug

2014-11-05 Thread Jonathan Marler via Digitalmars-d

On Tuesday, 4 November 2014 at 21:48:29 UTC, Walter Bright wrote:

On 11/4/2014 9:51 AM, Jonathan Marler wrote:

given the
output of Transform, the compiler cannot deduce what the input 
of Transform was

EVEN IF THE TEMPLATE IS AS SIMPLE AS THIS ONE.


To answer a question not asked, why doesn't the compiler see 
the simple case and handle it?


The problem is that this becomes a special case in the language 
specification, making the language harder to understand. Cue 
bug reports of people confused about why the simpler cases work 
and the more complex ones do not, and they overall get a 
negative impression of the language. And I don't blame them.


Actually I just realized that this would be IMPOSSIBLE in the 
general case since a template transormation isn't necessarily a 
1-1 mapping. Consider,


template Normalize(T)
{
static if(isIntegral!T) {
alias Normalize = int;
} else {
alias Normalize = string;
}
}

Given the output of Normalize, say int, there's no way of knowing 
if T was ubyte, long, int or whatever.


Re: D hackers requested. Dancing around postblit.

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d
If you're willing to make it @system or @trusted, you can just 
copy the data and call postblit manually:


extern(C) @safe int printf(in char*);

struct S {
~this() { printf(dtor\n); }
this(this) { printf(postblit\n); }

@disable S opAssign(S s);
}

S[] data;
void emplace(Struct)(ref Struct val, size_t i) {
// just blit the struct contents over
// (same thing normal assign does anyway)
(cast(ubyte*)(data[i]))[0 .. Struct.sizeof] = 
(cast(ubyte*)val)[0 ..  Struct.sizeof];

// call postblit
data[i].__postblit();
}

void main() {
data.length = 1;
S s;

emplace(s, 0);
}



Since it is a template, attribute inference should take care of 
nothrow, etc.


Re: New reference type designed to handle templates better

2014-11-05 Thread Freddy via Digitalmars-d

On Wednesday, 5 November 2014 at 19:27:59 UTC, Jonathan Marler
wrote:
I've been thinking about how to handle templates that have 
typically been using the 'ref' parameter attribute because they 
modify the parameter.  For example, the put/doPut functions in 
std.range use the 'ref' attribute for the output range, but in 
many cases the parameter doesn't need to be a reference type 
and the overhead that comes with it.


One idea I had is to have a different type of function argument 
attribute as opposed to ref.


A ref parameter is passed by reference.  Under the hood, a 
reference parameter is equivalent to a pointer to the variable.
 Then the function is free to modify the caller's version of 
the variable.  This new type of function parameter, let's call 
it pref, would instead care about what the variable is 
pointing to instead of the variable itself.  In some cases 
this means modifying the caller's version of the variable and 
in some cases it does not.  For example, if a basic value type 
like int was passed in, the variable isn't pointing to anything 
so a pointer to the variable itself would be passed in, but if 
an int* was passed in, then the int* would be passed by value.  
I've included a table of common types and how pref would 
differ from ref.


pref: modifying the data the variable is pointing to.  This 
means that if the variable is itself a pointer, then the 
function won't modify the pointer but instead modify what it's 
pointing to.


BasicDataType (BDT) is bool, all integer types, all float 
types, and all char types


Type |  ref|  pref|  why

BDT  | BDT*  | BDT*  | A BDT is not a pointer, so 
pref must
 | modify the variable itself 
which you can
 | say is pointing to a 
location in memory
BDT* | BDT** | BDT*  | A BDT* is already a pointer, 
pref will
 | modify the memory BDT is 
pointing to
BDT[]| BDT[]*| BDT[]* or BDT[] | An argument can be 
made for both,
 | if the function is modifying 
the contents
 | of the array (maybe writing 
data to it),
 | then the function might need 
some way of
 | returning how much data was 
written so
 | it might want to modify the 
given array

 | to indicate it has changed.
struct   | struct*   | struct*   | A struct variable is not a 
pointer, so
 | pref is a reference type for 
the struct
struct*  | struct**  | struct*   | A struct pointer is already 
a pointer

class| class*| class | A class is already a pointer
function | function* | function  | A function is a pointer to 
code, a
 | function is usually used to 
modify data so pref treats the function as what is modifying 
the data.

delegate | delegate* | delegate  | Same as reason for function

Note: A pref modifer to a type that is a pointer to any of 
these types will not do anything to the type


Not sure what you mean, but can't you just def a pointer when
passing to ref function

void mycalle(ref int i){

}
int mycaller(){
 int* var=new int;
 mycalle(*var);
}



Re: D hackers requested. Dancing around postblit.

2014-11-05 Thread IgorStepanov via Digitalmars-d
On Wednesday, 5 November 2014 at 20:01:59 UTC, Adam D. Ruppe 
wrote:
If you're willing to make it @system or @trusted, you can just 
copy the data and call postblit manually:


extern(C) @safe int printf(in char*);

struct S {
~this() { printf(dtor\n); }
this(this) { printf(postblit\n); }

@disable S opAssign(S s);
}

S[] data;
void emplace(Struct)(ref Struct val, size_t i) {
// just blit the struct contents over
// (same thing normal assign does anyway)
(cast(ubyte*)(data[i]))[0 .. Struct.sizeof] = 
(cast(ubyte*)val)[0 ..  Struct.sizeof];

// call postblit
data[i].__postblit();
}

void main() {
data.length = 1;
S s;

emplace(s, 0);
}



Since it is a template, attribute inference should take care of 
nothrow, etc.


It was my first try :(
data[i].__postblit();
calls the user-defined postblit and only it.

struct Sx {
 ~this() { printf(dtor\n); }
 this(this) { printf(postblit\n); }

 @disable S opAssign(S s);
}

struct S
{
   Sx s;
}

data[i].__postblit(); //error: S hasn't __postblit member, but it 
need the postblit call for Sx
typeid(S).postblit(data[i]) works as needed, but doesn't save 
postblit attributes.


Easy to learn how a compiler works

2014-11-05 Thread Walter Bright via Digitalmars-d

A very nice, easy to understand example of a fully working compiler!

https://www.reddit.com/r/programming/comments/2latu2/c4_c_in_4_functions/


Re: D hackers requested. Dancing around postblit.

2014-11-05 Thread IgorStepanov via Digitalmars-d

FYI:
My second try:

void emplace(V1)(ref V1 dst, ref V1 src) @trusted if (is(V1 == 
struct))

{
static if (new_obj)
{
V1 tmp = cast(V1)src; //create copy and call postblit
static V1 init = V1.init;
//bitwise copy of object, which already postblitted
(cast(void*)dst)[0 .. V1.sizeof] = (cast(void*)tmp)[0 
.. V1.sizeof];


//initialize tmp with V1.init.
(cast(void*)tmp)[0 .. V1.sizeof] = (cast(void*)init)[0 
.. V1.sizeof];

}
}

This method do one extra dtor call for tmp, but it may be trivial 
because tmp is V.init.

However it is not a complete solution of the task.


Re: D hackers requested. Dancing around postblit.

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d

On Wednesday, 5 November 2014 at 20:19:03 UTC, IgorStepanov wrote:
data[i].__postblit(); //error: S hasn't __postblit member, but 
it need the postblit call for Sx


Hmm, we could perhaps do a recursive call with 
__traits(allMembers) and if it has a __postblit.


Re: D hackers requested. Dancing around postblit.

2014-11-05 Thread IgorStepanov via Digitalmars-d
On Wednesday, 5 November 2014 at 20:33:40 UTC, Adam D. Ruppe 
wrote:
On Wednesday, 5 November 2014 at 20:19:03 UTC, IgorStepanov 
wrote:
data[i].__postblit(); //error: S hasn't __postblit member, but 
it need the postblit call for Sx


Hmm, we could perhaps do a recursive call with 
__traits(allMembers) and if it has a __postblit.


Good point. I'll try it. Thanks.


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 16:54:38 UTC, Marc Schütz wrote:

My idea was something along these lines (untested):

template extractorFun(alias extractor) {
static if(is(typeof(extractor) : string)) {
auto ref extractorFun(T)(auto ref T a) {
mixin(with(a) { return  ~ extractor ~ ; });
}
} else {
alias extractorFun = extractor;
}
}

alias fn = extractorFun!extractor;
r.sort!((a, b) = (fn(a)  fn(b)));


Thanks, I'll use this!

Still, is it even possible to extend extractor to become variadic 
or do I have to write a number of explicit overloads


1: void sortBy(alias xtr, R)(R r)
2: void sortBy(alias xtrA, alias xtrB, R)(R r)
3: void sortBy(alias xtrA, alias xtrB, alias xtrC, R)(R r)
etc

?


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread via Digitalmars-d

On Wednesday, 5 November 2014 at 20:50:00 UTC, Nordlöw wrote:
On Wednesday, 5 November 2014 at 16:54:38 UTC, Marc Schütz 
wrote:

My idea was something along these lines (untested):

   template extractorFun(alias extractor) {
   static if(is(typeof(extractor) : string)) {
   auto ref extractorFun(T)(auto ref T a) {
   mixin(with(a) { return  ~ extractor ~ ; });
   }
   } else {
   alias extractorFun = extractor;
   }
   }

   alias fn = extractorFun!extractor;
   r.sort!((a, b) = (fn(a)  fn(b)));


Thanks, I'll use this!

Still, is it even possible to extend extractor to become 
variadic or do I have to write a number of explicit overloads


1: void sortBy(alias xtr, R)(R r)
2: void sortBy(alias xtrA, alias xtrB, R)(R r)
3: void sortBy(alias xtrA, alias xtrB, alias xtrC, R)(R r)
etc

?


Again untested:

private alias makePredicate(alias xtr) =
(a, b) = (extractorFun!xtr(a)  extractorFun!xtr(b));

auto sortBy(extractors..., R)(R r) {
alias preds = staticMap!(makePredicate, extractors);
return r.sort!preds;
}

(Variadic template parameters also accept aliases.)


Re: std.concurrency.Generator yieldAll?

2014-11-05 Thread bearophile via Digitalmars-d
Another problems of std.concurrency.Generator is that currently 
it's not pure, not nothrow, not @safe and not @nogc. So its usage 
turns clean code into something that much less guarantees. This 
is unfortunate because you want to use it mostly in the 
functional-style code where you want those well-behaving 
guarantees.


Bye,
bearophile


Re: Library inheritance

2014-11-05 Thread Felix via Digitalmars-d

On Tuesday, 4 November 2014 at 15:27:33 UTC, Adam D. Ruppe wrote:
A library may provide header files for this, or you can just 
use the source code itself to import and inherit from.


Okay, but that would mean to have the source available. Though
for me it seems like D is attempting to get rid of header files.
But when dealing with, lets say, some D compiled library there
seems to be now way to accomplish something like inheriting as
ELF doesn't provide you with the necessary data.


Re: Library inheritance

2014-11-05 Thread David Nadlinger via Digitalmars-d

On Wednesday, 5 November 2014 at 23:04:00 UTC, Felix wrote:
On Tuesday, 4 November 2014 at 15:27:33 UTC, Adam D. Ruppe 
wrote:
A library may provide header files for this, or you can just 
use the source code itself to import and inherit from.


Okay, but that would mean to have the source available.


You can still use a version of the source code without any of the 
function bodies (usually ending in .di). Same as in C++, more or 
less.


David


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 16:54:38 UTC, Marc Schütz wrote:

On Wednesday, 5 November 2014 at 16:07:40 UTC, Nordlöw wrote:
On Wednesday, 5 November 2014 at 14:36:11 UTC, Marc Schütz 
wrote:
It's intuitive and concise. Plus, Ruby uses `sort` and 
`sort_by` for the same functionality, exactly in parallel, so 
it will be familiar to many users.


Here's my first working but primitive version.

https://github.com/nordlow/justd/blob/master/sort_ex.d#L15

How do I extend it to support

- variadic number of extractors
- sortBy(x)


My idea was something along these lines (untested):

template extractorFun(alias extractor) {
static if(is(typeof(extractor) : string)) {
auto ref extractorFun(T)(auto ref T a) {
mixin(with(a) { return  ~ extractor ~ ; });
}
} else {
alias extractorFun = extractor;
}
}

alias fn = extractorFun!extractor;
r.sort!((a, b) = (fn(a)  fn(b)));


Works! Thanks!

One thing: I tried to add support for integer based member 
indexing via tupleof at


https://github.com/nordlow/justd/blob/master/sort_ex.d#L21

but it errors as

sort_ex.d(42,46): Error: function expected before (), not 0 of 
type int
sort_ex.d(43,46): Error: function expected before (), not 0 of 
type int
sort_ex.d(42,6):instantiated from here: sort!((a, b) = 
extractorFun!extractor(a)  extractorFun!extractor(b), 
cast(SwapStrategy)0, X[])

sort_ex.d(80,6):instantiated from here: sortBy!(0, X[])
/home/per/opt/x86_64-unknown-linux-gnu/dmd/linux/bin64/src/phobos/std/algorithm.d(10266,9): 
Error: static assert  Invalid predicate passed to sort: 
__lambda2
sort_ex.d(42,6):instantiated from here: sort!((a, b) = 
extractorFun!extractor(a)  extractorFun!extractor(b), 
cast(SwapStrategy)0, X[])

sort_ex.d(80,6):instantiated from here: sortBy!(0, X[])

when I uncomment the last three tests. What's wrong?


Re: Library inheritance

2014-11-05 Thread Chris Williams via Digitalmars-d

On Tuesday, 4 November 2014 at 15:03:08 UTC, Felix wrote:

Hi,
just wondering if it's possible, due to the lag of header 
files, to inherit from some class that exists within a library, 
that has been written in D?


How did you solve that?

Thanks in advance.


You can run the compiler to create library and header (.di) 
files. Anything that requires compile-time execution, like 
templates, will remain in the .di. Anything that can be compiled 
as-is, will go in the library and just be represented as a 
function/method declaration in the .di file.


So, basically, the same as C++ except you don't have to manually 
write your own header files.


Multiple Inhertiance?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d

So what's bothering me is that I can do this:

class NullType {}
class Monkey(T) : T {}
class Zombie(T) : Monkey!T {}
class Robot(T)  : Monkey!T {}
class Pirate(T) : Monkey!T {}
class Ninja(T)  : Monkey!T {}

class MultipleInheritance : 
Zombie!(Robot!(Pirate!(Ninja!NullType))) {};


To get mutliple inheritance.  I just don't understand what the 
purpose of not allowing multiple inheritance is if I can get 
around it this easily, and its far less managable than it would 
be if it had language support.


Re: sortOn: sorts range of aggregates by member name(s)

2014-11-05 Thread Nordlöw

On Wednesday, 5 November 2014 at 23:40:23 UTC, Nordlöw wrote:

when I uncomment the last three tests. What's wrong?


Solved it :)


Re: Multiple Inhertiance?

2014-11-05 Thread Justin Whear via Digitalmars-d
On Thu, 06 Nov 2014 00:39:11 +, Patrick Jeeves wrote:

 So what's bothering me is that I can do this:
 
 class NullType {}
 class Monkey(T) : T {}
 class Zombie(T) : Monkey!T {}
 class Robot(T)  : Monkey!T {}
 class Pirate(T) : Monkey!T {}
 class Ninja(T)  : Monkey!T {}
 
 class MultipleInheritance : Zombie!(Robot!(Pirate!(Ninja!NullType))) {};
 
 To get mutliple inheritance.  I just don't understand what the purpose
 of not allowing multiple inheritance is if I can get around it this
 easily, and its far less managable than it would be if it had language
 support.

Short answer: that's not multiple inheritance.  That hierarchy has a 
simple,
well-defined order of method lookup and overriding, so things like the 
diamond
problem are not possible.


Re: Multiple Inhertiance?

2014-11-05 Thread bearophile via Digitalmars-d

Patrick Jeeves:

To get mutliple inheritance.  I just don't understand what the 
purpose of not allowing multiple inheritance is if I can get 
around it this easily, and its far less managable than it would 
be if it had language support.


I think not giving language support means that D designers don't 
want it to be easy to do. And this is good.


Bye,
bearophile


alias foo = __traits(...)

2014-11-05 Thread Shammah Chancellor via Digitalmars-d
Is this fixed now?  I don't want to denigrate the work to get C++ 
compatibility and the GC improvements.  But, this is the biggest hurdle 
I have when introducing new people into D.   I'm a huge compile time 
reflection proponent, and having alias hack(T...) = T makes the code 
look very buggy to newcomers.


Please don't say where is the PR?  When I have time,  I will fix it.  
The learning curve on the frontend is non-trivial and I'm not a 
talented C++ dev.   I will definitely dig in and get at that bug, as 
it's my biggest nit at the moment.


-S.



Re: GSOC Summer 2015 - Second call for Proposals

2014-11-05 Thread Craig Dillabaugh via Digitalmars-d
Our 2011 GSOC projects, if any of the participants would like to 
report on how things went, it would be appreciated.


Project  Student   Mentor

Linear Algebra Library   Cristi Cobzarenco David Simcha
based on SciD

An Apache Thrift David Nadlinger   Nitay Joffe
Implementation for D

Enhance regular  Dmitry Olshansky  Fawzi Mohamed
expressions



Re: alias foo = __traits(...)

2014-11-05 Thread safety0ff via Digitalmars-d
On Thursday, 6 November 2014 at 01:31:40 UTC, Shammah Chancellor 
wrote:

Is this fixed now?


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


Re: Compiling druntime gives error messages

2014-11-05 Thread Joakim via Digitalmars-d

On Wednesday, 5 November 2014 at 17:40:54 UTC, Domingo wrote:
And what about of back ports of important fixes, changes that 
can be backward compatible.


In my point of view the 2.0.66.* is a dead release, because it 
can not compile lots of already existing code that the 2.0.65 
and 2.0.67 can.


A D language weakness pointed out on other posts no 
backports/fixes like gcc and others do.


Not a good thing to grow up the user base.


While it may be better for users if such backporting was done for 
stable releases, the D community doesn't have the resources to do 
that right now.  Perhaps users can post bounties on bountysource 
for specific features they'd like to see backported, as it's 
thankless work that nobody is incented to do otherwise:


https://www.bountysource.com/teams/d/issues


DerelictBgfx not shipping core libs.

2014-11-05 Thread olivier henley via Digitalmars-d

Hi,

May I ask what is the rational to not ship the core libs with the 
bgfx D wrapper? From my point of view it defies the main goal of 
using a D wrapper.


1. How can we promote the wrapper package if it implies to build 
not one, as of ... only bgfx, but two packages, bgfx and 
DerelictBgfx? Better stick to c/c++ then, and enjoy the path of 
least resistance. Don't you think?


2. Does the maintainer guaranty his wrapper will stay in sync 
with further changes of bgfx?


3. Is there anything in the license refraining from shipping 
precompiled libs of the original package? (e.g. To my knowledge 
tkd publishes similar binaries (tcl and tk) without further legal 
complications.)


4. Am I missing something except the fact that a neophyte to the 
DerelictBgfx package is left with an incomplete build, of both 
the lib and the examples, an anemic README.md and a dead forum 
(http://dblog.aldacron.net/forum/index.php?topic=841.0)?


Thank you,

olivier


Re: [SDL + TKD] Seg fault from creating DirectoryDialog

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn

On Tuesday, 4 November 2014 at 23:09:33 UTC, Jack wrote:
So there must be an incompatibility with the video subsystem 
and tcl/tk.


So it seems. Thank you very much for helping me.
You were a big help.


Sorry i can't do more. I'm the author of Tkd and would like to 
get to the bottom of it.


druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn

Greetings,

In core.varar. 
(https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), 
why is the X86 implementation singled out and written in D rather 
than leveraging the standard c library implementation like the 
others?


Mike


Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn
Is there any way to track down access violations, instead of me 
having to look through my source code manually.


I have a pretty big source code and an access violation happens 
at runtime, but it's going to be a nightmare looking through it 
all to find the access violation. Not to mention all the tests I 
have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


Re: Access Violation Tracking

2014-11-05 Thread thedeemon via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote:
Is there any way to track down access violations, instead of me 
having to look through my source code manually.


I have a pretty big source code and an access violation happens 
at runtime, but it's going to be a nightmare looking through it 
all to find the access violation. Not to mention all the tests 
I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


What OS are you using? Did you run any debugger?


Re: Access Violation Tracking

2014-11-05 Thread bearophile via Digitalmars-d-learn

Bauss:

Is there any way to track down access violations, instead of me 
having to look through my source code manually.


I have a pretty big source code and an access violation happens 
at runtime, but it's going to be a nightmare looking through it 
all to find the access violation. Not to mention all the tests 
I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


This was discussed some times, and Walter is against this, but I 
think he is wrong, and eventually things will change. So I think 
this discussion should be brought to the main D newsgroup again.


Ideally in non-release mode D should put asserts where a access 
violation could happen. But I don't know how much slowdown this 
will cause. If practical real tests show that the slowdown is 
excessive, then a compiler switch could be added to activate 
those asserts.


Bye,
bearophile


Re: Access Violation Tracking

2014-11-05 Thread via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote:
Is there any way to track down access violations, instead of me 
having to look through my source code manually.


I have a pretty big source code and an access violation happens 
at runtime, but it's going to be a nightmare looking through it 
all to find the access violation. Not to mention all the tests 
I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


If you're on Linux, you can turn SEGVs into Errors:

import etc.linux.memoryerror;
registerMemoryErrorHandler();


Re: Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 11:27:02 UTC, thedeemon wrote:

On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote:
Is there any way to track down access violations, instead of 
me having to look through my source code manually.


I have a pretty big source code and an access violation 
happens at runtime, but it's going to be a nightmare looking 
through it all to find the access violation. Not to mention 
all the tests I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


What OS are you using? Did you run any debugger?


I am running Windows, but I am not using any debugger.
I was more looking for a build in function.

On Wednesday, 5 November 2014 at 11:31:01 UTC, bearophile wrote:

Bauss:

Is there any way to track down access violations, instead of 
me having to look through my source code manually.


I have a pretty big source code and an access violation 
happens at runtime, but it's going to be a nightmare looking 
through it all to find the access violation. Not to mention 
all the tests I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


This was discussed some times, and Walter is against this, but 
I think he is wrong, and eventually things will change. So I 
think this discussion should be brought to the main D newsgroup 
again.


Ideally in non-release mode D should put asserts where a access 
violation could happen. But I don't know how much slowdown this 
will cause. If practical real tests show that the slowdown is 
excessive, then a compiler switch could be added to activate 
those asserts.


Bye,
bearophile
I agree with you completely thathe is wrong. There should 
definitely be a way to find access violations within the program. 
I cannot add asserts and checks everywhere since performance is 
my number one priority within my program, so I have to make sure 
that the access violation cannot happen in the first place.
However it's a bit hard to track down access violations in big 
programs if you don't know when exactly it occured and where 
exactly it occured.


Re: Access Violation Tracking

2014-11-05 Thread Bauss via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 11:39:21 UTC, Marc Schütz wrote:

On Wednesday, 5 November 2014 at 11:09:42 UTC, Bauss wrote:
Is there any way to track down access violations, instead of 
me having to look through my source code manually.


I have a pretty big source code and an access violation 
happens at runtime, but it's going to be a nightmare looking 
through it all to find the access violation. Not to mention 
all the tests I have to run.


So if there is a way to catch an access violation and find out 
where it occured it would be appreciated!


If you're on Linux, you can turn SEGVs into Errors:

import etc.linux.memoryerror;
registerMemoryErrorHandler();


I am on Windows, but thanks that might come in handy when I have 
to test my program on other platforms.


cannot sort an array of char

2014-11-05 Thread Ivan Kazmenko via Digitalmars-d-learn

Hi!

This gives an error (cannot deduce template function from 
argument types):


-
import std.algorithm;
void main () {
char [] c;
sort (c);
}
-

Why is char [] so special that it can't be sorted?

For example, if I know the array contains only ASCII characters, 
sorting it sounds no different to sorting an int [].


Ivan Kazmenko.


scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn

void openFile(string fname, string current_folder)
{
auto file = readText(current_folder ~ fname);
scope(failure)
{
writeln(failure);
}

//  writeln(file);

}

if file name do not exists, I want to rise scope exception. But 
it's do not rise, and I am getting only standard error like:


std.file.FileException@std\file.d(191): 
D:\code\d\App1\source\app.d1: ╨Э╨╡ ╤Г╨┤╨

░╨╡╤В╤Б╤П ╨╜╨░╨╣╤В╨╕ ╤Г╨║╨░╨╖╨░╨╜╨╜╤Л╨╣ ╤Д╨░╨╣╨╗.


what's wrong? if I use block success it's work fine.


Re: cannot sort an array of char

2014-11-05 Thread via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko 
wrote:

Hi!

This gives an error (cannot deduce template function from 
argument types):


-
import std.algorithm;
void main () {
char [] c;
sort (c);
}
-

Why is char [] so special that it can't be sorted?

For example, if I know the array contains only ASCII 
characters, sorting it sounds no different to sorting an int 
[].


Hmm... this doesn't work either:

import std.algorithm;
import std.utf;
void main () {
char [] c;
sort (c.byCodeUnit);
}

But IMO it should.


Re: cannot sort an array of char

2014-11-05 Thread via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote:
On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko 
wrote:

Hi!

This gives an error (cannot deduce template function from 
argument types):


-
import std.algorithm;
void main () {
char [] c;
sort (c);
}
-

Why is char [] so special that it can't be sorted?

For example, if I know the array contains only ASCII 
characters, sorting it sounds no different to sorting an int 
[].


Hmm... this doesn't work either:

import std.algorithm;
import std.utf;
void main () {
char [] c;
sort (c.byCodeUnit);
}

But IMO it should.


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


Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
I can't understand what I am missing. Try-catch block also do not 
handle exception:


void main()
{
string fname = app.d1; //file name with error
string current_folder = (getcwd() ~\\);
writeln(current_folder);
openFile(fname, current_folder);
}

void openFile(string fname, string current_folder)
{
try
{
auto file = readText(current_folder ~ fname);
if(exists(current_folder ~ fname))
scope(success)
writeln(success);
}

catch(Exception e)
{
writeln(e); //what class of error I am handling? any?
}


}


Re: scope exception do not rise

2014-11-05 Thread MadProgressor via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 12:56:41 UTC, Suliman wrote:

void openFile(string fname, string current_folder)
{
auto file = readText(current_folder ~ fname);
scope(failure)
{
writeln(failure);
}

//  writeln(file);

}

if file name do not exists, I want to rise scope exception. But 
it's do not rise, and I am getting only standard error like:


std.file.FileException@std\file.d(191): 
D:\code\d\App1\source\app.d1: ╨Э╨╡ ╤Г╨┤╨

░╨╡╤В╤Б╤П ╨╜╨░╨╣╤В╨╕ ╤Г╨║╨░╨╖╨░╨╜╨╜╤Л╨╣ ╤Д╨░╨╣╨╗.


what's wrong? if I use block success it's work fine.


Try:

scope(failure){writeln(failure);}
auto file = readText(current_folder ~ fname);


The scope(failure) is translated to a try catch after the 
satement you wann monitor.

So put it before


Re: scope exception do not rise

2014-11-05 Thread Gary Willoughby via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 14:04:26 UTC, MadProgressor 
wrote:
The scope(failure) is translated to a try catch after the 
satement you wann monitor.

So put it before


That shouldn't matter. See: http://dlang.org/exception-safe.html


Re: Access Violation Tracking

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 11:31:01 UTC, bearophile wrote:
This was discussed some times, and Walter is against this, but 
I think he is wrong, and eventually things will change.


An access violation already thrown on Win32. Just catch a 
Throwable in main and write out exception.toString. But you do 
need to have debugging info compiled in to get a readable 
backtrace with dmd -g.


Re: scope exception do not rise

2014-11-05 Thread ketmar via Digitalmars-d-learn
On Wed, 05 Nov 2014 14:09:20 +
Gary Willoughby via Digitalmars-d-learn
digitalmars-d-learn@puremagic.com wrote:

 That shouldn't matter. See: http://dlang.org/exception-safe.html
this indeed matter. and it should.


signature.asc
Description: PGP signature


Re: druntime vararg implementation

2014-11-05 Thread Sean Kelly via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote:

Greetings,

In core.varar. 
(https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), 
why is the X86 implementation singled out and written in D 
rather than leveraging the standard c library implementation 
like the others?


No idea.  It seems like a pointless duplication of code.  Maybe 
just to have some documented functions within the module?


Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
Am I right understand that keyword Exception is handle 
universal type of exceptions?


catch (Exception)
{
writeln(inner);
}

But in my example with try block can I change it's to something 
more informative?


How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn
So this is more a stackoverflow question, but I feel like later 
searchers will be more likely to find it if I put it here.


if I have the following C++ code:

class foo
{
static std::listfoo* foo_list;
typedef std::listfoo*::iterator iterator;
public:
foo()
{
   foo_list.push_back(this);
}
~foo()
{
   foo_list.remove(this);
}

static void DO_TASK()
{
for(iterator i = foo_list.begin(); i  foo_list.end(); 
++i)

{
(*i)-process();
}

for(iterator i = foo_list.begin(); i  foo_list.end(); 
++i)

{
(*i)-advance();
}
}

virtual void process() = 0;
virtual void advance() = 0;
}

How can I turn this into D?  Is there a way to register that 
static list with the garbage collector so it doesn't look into it 
or anything?


Similarly, I feel like this would be an interface in D, but 
interfaces don't have constructors.


Re: cannot sort an array of char

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 05:44 AM, Marc Schütz schue...@gmx.net wrote:

On Wednesday, 5 November 2014 at 13:34:05 UTC, Marc Schütz wrote:

On Wednesday, 5 November 2014 at 12:54:03 UTC, Ivan Kazmenko wrote:

Hi!

This gives an error (cannot deduce template function from argument
types):

-
import std.algorithm;
void main () {
char [] c;
sort (c);
}
-

Why is char [] so special that it can't be sorted?

For example, if I know the array contains only ASCII characters,
sorting it sounds no different to sorting an int [].


Hmm... this doesn't work either:

import std.algorithm;
import std.utf;
void main () {
char [] c;
sort (c.byCodeUnit);
}

But IMO it should.


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


It can't be a RandomAccessRange because it cannot satisfy random access 
at O(1) time.


Ali



Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 09:17 AM, Patrick Jeeves wrote:

 class foo
 {
 static std::listfoo* foo_list;
 typedef std::listfoo*::iterator iterator;
 public:
  foo()
  {
 foo_list.push_back(this);
  }
  ~foo()
  {
 foo_list.remove(this);
  }

Going completely off-topic, I recommend against objects registering 
themselves that way. That idiom has caused trouble in more than one 
project for us.


In general, I think a constructor should not have side-effects unless 
needed for the object's construction (e.g. allocating a resource for the 
object should obviously fine).


Ali



Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 10:07 AM, Ali Çehreli wrote:

 On 11/05/2014 09:17 AM, Patrick Jeeves wrote:

   class foo
   {
   static std::listfoo* foo_list;
   typedef std::listfoo*::iterator iterator;
   public:
foo()
{
   foo_list.push_back(this);
}

Argh! I forgot to add an important, perhaps philosophical, point. :) 
Continuing the off-topic, an object should be considered constructed 
only after hitting that closing curly bracket above. If so, then that 
push_back would be adding an incomplete object to the list.


Ali



Re: How to turn this C++ into D?

2014-11-05 Thread Adam D. Ruppe via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote:
If so, then that push_back would be adding an incomplete object 
to the list.


scope(success)?


But the D translation worries me too because the destructor won't 
run at the same time as the C++ version, unless you make it a 
scope class or something.


Re: How to turn this C++ into D?

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 10:12 AM, Adam D. Ruppe wrote:

 On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli wrote:
 If so, then that push_back would be adding an incomplete object to the
 list.

 scope(success)?

I really like that! :)

But still not for this case because in addition to the problem with the 
destruction order, I would like to feel free to remove unused objects 
like the following without worrying about side-effects:


// C++ code
void bar()
{
Foo seemingly_unused_here();
// ...
}

Ali



Re: scope exception do not rise

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 06:01 AM, Suliman wrote:

 I can't understand what I am missing. Try-catch block also do not handle
 exception:

I does. This turned out to be very tricky for me. :)

 void main()
 {
  string fname = app.d1; //file name with error
  string current_folder = (getcwd() ~\\);
  writeln(current_folder);
  openFile(fname, current_folder);
 }

 void openFile(string fname, string current_folder)
 {
  try
  {
  auto file = readText(current_folder ~ fname);
  if(exists(current_folder ~ fname))
  scope(success)
  writeln(success);

Unrelated to the problem, but did you really want that scope(success) 
under the if statement?


  }

  catch(Exception e)
  {
  writeln(e); //what class of error I am handling? any?
  }

Replace that with something like writeln(caught) and you will see that 
it is indeed caught. :) Printing the exception mimicks the default 
behavior and you (and I) think that the exception is not caught. :)


Ali



Re: cannot sort an array of char

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 10:01 AM, Ali Çehreli wrote:

 sort (c.byCodeUnit);
 }

 But IMO it should.

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

 It can't be a RandomAccessRange because it cannot satisfy random access
 at O(1) time.

Sorry, I misunderstood (again): code unit is random-access, code point 
is not.


Ali

P.S. I would like to have a word with the Unicode people who settled on 
the terms code unit and code point. Every time I come across one of 
those, I have to think at least 5 seconds to fool myself to think that I 
understood correctly which one was meant. :p




Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 18:18:18 UTC, Ali Çehreli wrote:

On 11/05/2014 10:12 AM, Adam D. Ruppe wrote:

 On Wednesday, 5 November 2014 at 18:10:38 UTC, Ali Çehreli
wrote:
 If so, then that push_back would be adding an incomplete
object to the
 list.

 scope(success)?

I really like that! :)

But still not for this case because in addition to the problem 
with the destruction order, I would like to feel free to remove 
unused objects like the following without worrying about 
side-effects:


// C++ code
void bar()
{
Foo seemingly_unused_here();
// ...
}

Ali


unless delete is explicitly called, I don't believe the 
destructor would ever be called, it would still have a reference 
in the static foo_list object that would stop it from being 
collected by the gc.


I could see the constructor situation being a problem in threaded 
code as well, tho it may be bad practice, I don't believe the 
insert(this) would actually break anything.


The scope(success) is a good idea either way however.


Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone wrote:
unless delete is explicitly called, I don't believe the 
destructor would ever be called, it would still have a 
reference in the static foo_list object that would stop it from 
being collected by the gc.


This is exactly why I asked about it, and even if delete is 
explicitly called-- which i believe is deprecated, wouldn't the 
runtime fill the space with the default construtor until the GC 
decides to remove it? meaning it would be immediatly added back 
into the list?


Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves 
wrote:
On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone 
wrote:
unless delete is explicitly called, I don't believe the 
destructor would ever be called, it would still have a 
reference in the static foo_list object that would stop it 
from being collected by the gc.


This is exactly why I asked about it, and even if delete is 
explicitly called-- which i believe is deprecated, wouldn't the 
runtime fill the space with the default construtor until the GC 
decides to remove it? meaning it would be immediatly added back 
into the list?


I don't believe that the default constructor is called. I am 
pretty sure delete immediately deallocates the object, 
deregistering its memory from the gc.


In fact I am 99% sure no constructor is called after delete, it 
would cause problems for objects with no default constructor, or 
for system related stuff done in constructors, and I haven't seen 
anything like that in my X11 work in d.




Re: accessing numeric template parameters

2014-11-05 Thread Dominikus Dittes Scherkl via Digitalmars-d-learn

On Monday, 3 November 2014 at 21:17:09 UTC, Philippe Sigaud via
Digitalmars-d-learn wrote:

struct polynomial(uint base)
{
private:
   uint[] N;
public:
   this(uint x) { base = x; }


base is part of the type. polynomial is just a 'recipe' for a 
type,
the real struct would be Polynomial!(0), Polynomial!(1), etc. 
Note

that Polynomial!0, Polynomial!1, ... are all different types.

Yes, that's what I intend.


Being part of the type means it's defined only at compile-time, 
you

cannot use a runtime value (like 'x') to initialize it.

Note that with your current code, `base' is not visible outside
Polynomial. You can alias it to a field to make it visible:

struct Polynomial(uint base)
{
alias b = base; // b is visible outside (but set at


Ah, ok. Thank you!


compile-time !)
...
}

You can create one like this:

Polynomial!2 poly;
poly.N = [0,1,0,0,1,1];

Ok, now I remember, struct doesn't need an explicit constructor.
(in this case)


Re: How to turn this C++ into D?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone wrote:
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves 
wrote:
On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone 
wrote:
unless delete is explicitly called, I don't believe the 
destructor would ever be called, it would still have a 
reference in the static foo_list object that would stop it 
from being collected by the gc.


This is exactly why I asked about it, and even if delete is 
explicitly called-- which i believe is deprecated, wouldn't 
the runtime fill the space with the default construtor until 
the GC decides to remove it? meaning it would be immediatly 
added back into the list?


I don't believe that the default constructor is called. I am 
pretty sure delete immediately deallocates the object, 
deregistering its memory from the gc.


In fact I am 99% sure no constructor is called after delete, it 
would cause problems for objects with no default constructor, 
or for system related stuff done in constructors, and I haven't 
seen anything like that in my X11 work in d.


I guess I got confused by something... I don't know.  But what 
I'd really like is for it to be garbage colleceted when no 
references outside of that static array exist, as i mentioned at 
the bottom of my first post.  I illustrated my example with that 
specific class because when i looked up weak pointers on the 
site I found discussions getting caught up with how to avoid 
dangling pointers when weak pointers are used; and I wanted to 
illustrate that that's a non-issue in this case, because I wasn't 
sure how much that contributed to the solutions given.


I suppose it doesn't matter because this is based on something I 
do with multiple inheritance in C++, I felt like I may be able to 
get it to work in D because the only public members of those 
classes were always pure virtual functions.


As an aside, how does scope(success) work in the context of a 
constructor? given:


abstract class foo
{
this()
{
   scope(success) onAdd();
}
~this()
{
   onRemove();
}

onAdd();
onRemove();
}

class bar : foo
{
int _a;

this(int a)
{
   _a = a;
}

void onAdd(){ writeln(_a); }
void onRemove() { writeln(_a); }
}

is _a defined as anything in either of writes? or would it be 
called at the wrong time relative to setting _a?


Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread Patrick Jeeves via Digitalmars-d-learn


When I tried to test out the following code the compiler 
segfaulted:



interface BarBase
{
void do_a_thing();
}

interface Bar(T) : BarBase
{
	static if(hasMember!(T, rotation)  is(typeof(T.rotation) == 
double))

{
@property
double rotation();

final void do_a_thing()
{
//do a thing with rotation;
}
}
else
{
final void do_a_thing()
{
//do a thing without rotation;
}
}
}

class Foo1 : Bar!Foo1
{
}

class Foo2 : Bar!Foo2
{
@property
double rotation() { return 1.0; };
}

Is there some rule against doing this or is it a glitch?


Re: Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread Justin Whear via Digitalmars-d-learn
On Wed, 05 Nov 2014 20:48:06 +, Patrick Jeeves wrote:

 When I tried to test out the following code the compiler segfaulted:
 
 Is there some rule against doing this or is it a glitch?

Please file a bug report on issues.dlang.org --any compiler crash is a bug
regardless of whether the source is valid D code or not.


Re: How to turn this C++ into D?

2014-11-05 Thread luminousone via Digitalmars-d-learn
On Wednesday, 5 November 2014 at 20:31:54 UTC, Patrick Jeeves 
wrote:
On Wednesday, 5 November 2014 at 19:44:57 UTC, luminousone 
wrote:
On Wednesday, 5 November 2014 at 19:05:32 UTC, Patrick Jeeves 
wrote:
On Wednesday, 5 November 2014 at 18:56:08 UTC, luminousone 
wrote:
unless delete is explicitly called, I don't believe the 
destructor would ever be called, it would still have a 
reference in the static foo_list object that would stop it 
from being collected by the gc.


This is exactly why I asked about it, and even if delete is 
explicitly called-- which i believe is deprecated, wouldn't 
the runtime fill the space with the default construtor until 
the GC decides to remove it? meaning it would be immediatly 
added back into the list?


I don't believe that the default constructor is called. I am 
pretty sure delete immediately deallocates the object, 
deregistering its memory from the gc.


In fact I am 99% sure no constructor is called after delete, 
it would cause problems for objects with no default 
constructor, or for system related stuff done in constructors, 
and I haven't seen anything like that in my X11 work in d.


I guess I got confused by something... I don't know.  But what 
I'd really like is for it to be garbage colleceted when no 
references outside of that static array exist, as i mentioned 
at the bottom of my first post.  I illustrated my example with 
that specific class because when i looked up weak pointers on 
the site I found discussions getting caught up with how to 
avoid dangling pointers when weak pointers are used; and I 
wanted to illustrate that that's a non-issue in this case, 
because I wasn't sure how much that contributed to the 
solutions given.


I suppose it doesn't matter because this is based on something 
I do with multiple inheritance in C++, I felt like I may be 
able to get it to work in D because the only public members of 
those classes were always pure virtual functions.


As an aside, how does scope(success) work in the context of a 
constructor? given:


abstract class foo
{
this()
{
   scope(success) onAdd();
}
~this()
{
   onRemove();
}

onAdd();
onRemove();
}

class bar : foo
{
int _a;

this(int a)
{
   _a = a;
}

void onAdd(){ writeln(_a); }
void onRemove() { writeln(_a); }
}

is _a defined as anything in either of writes? or would it be 
called at the wrong time relative to setting _a?


As of yet their are no built in weak references/pointers, you can 
jerry rig them however.


constructors will implicitly call super at the top of the 
function if no super call is made within the function body, so


this( int a ) {
//  super(); is called here if not defined below
_a = a;
}

I'd really like is for it to be garbage colleceted when no 
references outside of that static array exist, as i mentioned 
at the bottom of my first post.


Can't easily do this yet, would require you writing your own list 
class, as std.container, does not have any way of passing an 
allocator to it.


They are coming, slowly but surely we will eventually have them.

Allocators would allow container classes to create objects(nodes 
and such) that are in memory that is not scanned by the garbage 
collector.


You can in fact allocate memory manually right now, via 
std.c.memory or std.c.stdlib (don't member which one has c malloc 
and free).


Just be sure to familiarize your self with the manual gc 
registration and deregistration functions in core.memory.


Re: Curiously Cyclic Template Pattern causes segfault?

2014-11-05 Thread bearophile via Digitalmars-d-learn

Justin Whear:


--any compiler crash is a bug
regardless of whether the source is valid D code or not.


I suspect that in some cases those compiler crashes are a way for 
the compiler to tell the programmer that the code was too much 
hairy and too much hard to understand ;-)


Bye,
bearophile


Re: UDA failling to build when using delegate

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn

On Tuesday, 4 November 2014 at 22:06:03 UTC, Ali Çehreli wrote:

On 11/04/2014 01:58 PM, bioinfornatics wrote:

 test.d(40): Error: type Section!((letter) = letter == '',
 (letter) = letter == '\x0a') has no value

You have this line:

@Section!(/* ... */)

Although that is a type name, there is a bug somewhere and 
sometimes you have to use a 'value' as a UDA. (We talked about 
this recently but I don't remember the details.) So make it an 
object so that it is a 'value':


@Section!(/* ... */)()

(You have another instance of that.)

You will have to deal with the next set of error messages now. 
:-/


Ali


Thanks Ali

If i understand well, that is a dmdfe bug ?

i yes that is weird as using @Section!(/* ... */)() give to me
something type of void then I can't filter to the desired  uda


Re: UDA failling to build when using delegate

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 21:57:42 UTC, bioinfornatics
wrote:

On Tuesday, 4 November 2014 at 22:06:03 UTC, Ali Çehreli wrote:

On 11/04/2014 01:58 PM, bioinfornatics wrote:

 test.d(40): Error: type Section!((letter) = letter == '',
 (letter) = letter == '\x0a') has no value

You have this line:

   @Section!(/* ... */)

Although that is a type name, there is a bug somewhere and 
sometimes you have to use a 'value' as a UDA. (We talked about 
this recently but I don't remember the details.) So make it an 
object so that it is a 'value':


   @Section!(/* ... */)()

(You have another instance of that.)

You will have to deal with the next set of error messages now. 
:-/


Ali


Thanks Ali

If i understand well, that is a dmdfe bug ?

i yes that is weird as using @Section!(/* ... */)() give to me
something type of void then I can't filter to the desired  uda


Oh that is ok, I replaced

static if(is(attr : Section!T, T...))
by
static if(is(Section!(T, T)))


undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn

Dear,

maybe I'm too tired to see my errors or they are a bug. See below

I have this:
.
|-- fasta.d
`-- src
 `-- nicea
 |-- metadata.d
 |-- parser.d
 `-- range.d

when I try to build it:

$ dmd -I./src/  ./fasta.d 21
fasta.o:(.rodata+0x1f8): undefined reference to
`_D5nicea6parser12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1

If I merge all files in one that build!

What is it ?

I tried to minimize the problem with dustmite but it give to me 
at end an empty file …


thanks


Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread Justin Whear via Digitalmars-d-learn
On Wed, 05 Nov 2014 23:48:21 +, bioinfornatics wrote:

 Dear,
 
 maybe I'm too tired to see my errors or they are a bug. See below
 
 I have this:
 .
 |-- fasta.d `-- src
   `-- nicea
   |-- metadata.d |-- parser.d `-- range.d
 
 when I try to build it:
 
 $ dmd -I./src/  ./fasta.d 21 fasta.o:(.rodata+0x1f8): undefined
 reference to `_D5nicea6parser12__ModuleInfoZ'
 collect2: error: ld returned 1 exit status --- errorlevel 1
 
 If I merge all files in one that build!
 
 What is it ?
 
 I tried to minimize the problem with dustmite but it give to me at end
 an empty file …
 
 thanks

You have dmd only building the fasta.d file and the linker doesn't know 
where
to find the other objects.  If you've compiled the contents of nicea to a
static library (.a) with -lib, then you need to link that library by 
tacking a
`-Llibnicea.a` onto your compilation command.


Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread Ali Çehreli via Digitalmars-d-learn

On 11/05/2014 03:48 PM, bioinfornatics wrote:

Dear,

maybe I'm too tired to see my errors or they are a bug. See below

I have this:
.
|-- fasta.d
`-- src
  `-- nicea
  |-- metadata.d
  |-- parser.d
  `-- range.d

when I try to build it:

$ dmd -I./src/  ./fasta.d 21


Include all files no the command line:

$ dmd -I./src/  ./fasta.d ./src/nicea/metadata.d ./src/nicea/parser.d 
./src/nicea/range.d 21



fasta.o:(.rodata+0x1f8): undefined reference to
`_D5nicea6parser12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1

If I merge all files in one that build!

What is it ?

I tried to minimize the problem with dustmite but it give to me at end
an empty file …

thanks


Ali



Re: undefined reference to `_D5xxxx6yyyyy12__ModuleInfoZ'

2014-11-05 Thread bioinfornatics via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 23:53:57 UTC, Ali Çehreli wrote:

On 11/05/2014 03:48 PM, bioinfornatics wrote:

Dear,

maybe I'm too tired to see my errors or they are a bug. See 
below


I have this:
.
|-- fasta.d
`-- src
 `-- nicea
 |-- metadata.d
 |-- parser.d
 `-- range.d

when I try to build it:

$ dmd -I./src/  ./fasta.d 21


Include all files no the command line:

$ dmd -I./src/  ./fasta.d ./src/nicea/metadata.d 
./src/nicea/parser.d ./src/nicea/range.d 21



fasta.o:(.rodata+0x1f8): undefined reference to
`_D5nicea6parser12__ModuleInfoZ'
collect2: error: ld returned 1 exit status
--- errorlevel 1

If I merge all files in one that build!

What is it ?

I tried to minimize the problem with dustmite but it give to 
me at end

an empty file …

thanks


Ali


Oh yes , …

I need to sleep thanks a lot guys


Re: druntime vararg implementation

2014-11-05 Thread Mike via Digitalmars-d-learn

On Wednesday, 5 November 2014 at 14:24:00 UTC, Sean Kelly wrote:

On Wednesday, 5 November 2014 at 09:45:50 UTC, Mike wrote:

Greetings,

In core.varar. 
(https://github.com/D-Programming-Language/druntime/blob/master/src/core/vararg.d), 
why is the X86 implementation singled out and written in D 
rather than leveraging the standard c library implementation 
like the others?


No idea.  It seems like a pointless duplication of code.  Maybe 
just to have some documented functions within the module?


In that case, a better question is Why use the standard C 
implementation if we have working D code?.


Re: rndtonl

2014-11-05 Thread Laeeth Isharc via Digitalmars-d-learn

Thanks, Adam.

Should we perhaps make a pull to suggest updating the docs/wiki?  
As the point below is not what one would infer from the dlang.org 
library reference page.


(If I say we, it's because I don't know what the protocol is, or 
whether my perception is right).


On Tuesday, 4 November 2014 at 18:39:29 UTC, Adam D. Ruppe wrote:
I think rndtonl is a C library function that isn't always 
present in the system.


It doesn't work on my computer either and I can't find any 
documentation about it. It is probably not meant to be called 
by end users.




Complexity guaranties of array append operator

2014-11-05 Thread Dmitriy via Digitalmars-d-learn
Hello, I'm in the middle of learning D. I can't find any 
definitive information about what is the complexity of operator 
~= when used for adding an element to an array. Is it amortized 
O(1) or is it implementation defined? (I hope it at worst O(n) 
though I haven't seen any information about that either).


Also documentation to std.array.Appender says that it is more 
efficient to use Appender when appending many elements. Does 
it imply that Appender.put has amortized O(1)?


Re: Complexity guaranties of array append operator

2014-11-05 Thread Jonathan M Davis via Digitalmars-d-learn
On Thursday, November 06, 2014 03:48:26 Dmitriy via Digitalmars-d-learn wrote:
 Hello, I'm in the middle of learning D. I can't find any
 definitive information about what is the complexity of operator
 ~= when used for adding an element to an array. Is it amortized
 O(1) or is it implementation defined? (I hope it at worst O(n)
 though I haven't seen any information about that either).

 Also documentation to std.array.Appender says that it is more
 efficient to use Appender when appending many elements. Does
 it imply that Appender.put has amortized O(1)?

They should both be an amortized O(1). As I understand it, the problem with
~= over using Appender is the extra checks that the runtime has to do with
~= to see whether there's room to append anything without reallocating, and
because Appender is free to assume that the whole block of memory is for its
personal use rather than having to worry about other dynamic arrays which
are backed by slices of the same block of memory extending into that memory
first, it's able to check for available capacity much faster. So, it's the
coefficient that changes, not the overall complexity. For the complexity to
change, you'd have to get behavior like ~= _always_ reallocating (and thus
having to copy all of the elements every time) rather than just when there
isn't any extra capacity, and that's not the case at all.

- Jonathan M Davis



Re: scope exception do not rise

2014-11-05 Thread Suliman via Digitalmars-d-learn
Replace that with something like writeln(caught) and you will 
see that it is indeed caught. :) Printing the exception mimicks 
the default behavior and you (and I) think that the exception 
is not caught. :)


that's work, but I can not understand where I can to look at 
exception level. If I right understand every function have own 
exceptions. For example std.file.
Where I could look at what e will get? I mean catch(Exception 
e).




[Issue 13685] std.numeric.arrayShape

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13685

--- Comment #1 from bearophile_h...@eml.cc ---
If arrayShape returns a specialized struct instead of a generic tuple, then
it's possible to add a method to the struct (otherwise a free function that
takes a tuple is acceptable using UFCS), like allocate, that allows to create
an array of given shape:

auto a1 = new int[][](10, 5);
auto s1 = a1.arrayShape;
auto a2 = s1.allocate!double; // 2D matrix of NaNs doubles.
assert(a1.arrayShape == a2.arrayShape);
auto a3 = s1.allocate!double(5.0); // Initialized to 5.0.
assert(a1.arrayShape == a3.arrayShape);
auto a4 = s1.allocate!double((r, c) = r * c); // Initialized to r*c.
assert(a1.arrayShape == a4.arrayShape);

--


[Issue 9842] std.algorithm.hashGroup / hashGroupBy

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=9842

--- Comment #2 from bearophile_h...@eml.cc ---
(In reply to hsteoh from comment #1)
 Isn't this just the same as data.hashSort.group? For hash sort to work, the
 key must map to an integral value and must be bounded by known min/max
 values.

The output and working is different. The hashGroupBy doesn't return a range of
pairs as the function group.

If you write:

auto names = [Sam, Samuel, Samu, Ravi, Ratna, Barsha];
auto grps = names.hashGroupBy!(n = n.length);

Now grps is:

assert(grps == [3:[Sam], 4:[Samu, Ravi], 5:[Ratna], 6:[Samuel,
Barsha]]);

The keys can be anything, not just integers in an interval.

--


[Issue 13688] New: 'in' expression for AA not detected as GC usage

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13688

  Issue ID: 13688
   Summary: 'in' expression for AA not detected as GC usage
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Keywords: accepts-invalid
  Severity: normal
  Priority: P1
 Component: DMD
  Assignee: nob...@puremagic.com
  Reporter: sinkuup...@gmail.com

'in' expression for AA calls KeyType.toHash/opEquals if exist, but not detected
as GC usage even if these functions are not @nogc.

Example: (In this case, compiler should require that toHash/opEquals are
@nogc.)
struct KeyType
{
int x;

size_t toHash() const @safe nothrow
{
return x;
}

bool opEquals(in KeyType r) const
{
return x == r.x;
}
}

ulong func(ulong[KeyType] aa) @nogc
{
if (auto p = KeyType(10) in aa) // can call KeyType.toHash/opEquals
return *p;

return aa.length;
}

--


[Issue 13689] byCodeUnit is not sortable

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13689

bearophile_h...@eml.cc changed:

   What|Removed |Added

 CC||bearophile_h...@eml.cc

--- Comment #1 from bearophile_h...@eml.cc ---
This works:

void main() {
import std.algorithm: sort;
import std.string: representation;
char[] arr = ACBA.dup;
arr.representation.sort();
assert(arr == AABC);
}

--


[Issue 13689] byCodeUnit is not sortable

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13689

hst...@quickfur.ath.cx changed:

   What|Removed |Added

   Keywords||pull
 CC||hst...@quickfur.ath.cx

--- Comment #2 from hst...@quickfur.ath.cx ---
https://github.com/D-Programming-Language/phobos/pull/2656

--


[Issue 13689] byCodeUnit fails to be a random access range

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13689

hst...@quickfur.ath.cx changed:

   What|Removed |Added

Summary|byCodeUnit is not sortable  |byCodeUnit fails to be a
   ||random access range

--


[Issue 13689] byCodeUnit fails to be a random access range

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13689

hst...@quickfur.ath.cx changed:

   What|Removed |Added

   Severity|enhancement |normal

--


[Issue 13674] Internal error: backend/el.c 2882

2014-11-05 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=13674

hst...@quickfur.ath.cx changed:

   What|Removed |Added

   Keywords||ice
 CC||hst...@quickfur.ath.cx
   Severity|normal  |critical

--


  1   2   >