Re: What the hell is wrong with D?

2017-09-19 Thread nkm1 via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta 
wrote:
Your an idiot, I know about how operator precedence works far 
more than you do. Wanna bet? how much? Your house? your wife? 
Your life? It's about doing things correctly, you seem to fail 
to understand, not your fault, can't expect a turd to 
understand logic.


Ok, you win. I see now that you're very smart :)



Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn

On Wednesday, 20 September 2017 at 02:57:21 UTC, jmh530 wrote:
On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M 
Davis wrote:


Please try to be civil. It's fine if you're unhappy about some 
aspect of how D works and want to discuss it, but we do not 
condone personal attacks here.


- Jonathan M Davis


He seemed to be threatening the guy's life over operator 
precedence. Ridiculous...


Are you an idiot? Seriously, you must be. You just want to create 
drama instead of supply an actual logical argument(which I read 
your argument and it is pathetic). Show me where I threatened the 
guys life! Fucking moron. You must be some TSA goon or DHS 
wannabe.




Re: How to list all process directories under /proc/

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 18:32:06 UTC, Matt Jones wrote:
On Tuesday, 19 September 2017 at 13:32:29 UTC, Ky-Anh Huynh 
wrote:




Btw, is that a bit weird that range is not supported in glob 
pattern :) Is there a design reason for this?


That is strange. But then again, every glob library I've seen 
works a little bit differently.


I see. Maybe I'm using Linux and Ruby too much. Missing character 
range doesn't really hurt, but the feature should be documented. 
Should we improve the documentation? To be fair, the syntax 
specification is clear after I read it twice, but the link to 
Wiki page is confusing, because Wiki page mentions the popular 
(FIXME) implementation with character range.


Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis 
wrote:
On Wednesday, September 20, 2017 02:16:16 EntangledQuanta via 
Digitalmars-d- learn wrote:

On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
> On Tuesday, 19 September 2017 at 17:40:20 UTC, 
> EntangledQuanta

>
> wrote:
>> [...]
>
> There are two issues there; operator precedence and booleans
> (_win[0] == '@') being a valid operands to +.
> If someone is too stupid to learn how precedence works, they
> should consider a different career instead of blaming others.
> OTOH, booleans converting to numbers is a very questionable
> feature. I certainly have never seen any good use for it. 
> This

> is just an unfortunate legacy of C, which didn't even have
> booleans for a long time.

Your an idiot, I know about how operator precedence works far 
more than you do. Wanna bet? how much? Your house? your wife? 
Your life? It's about doing things correctly, you seem to fail 
to understand, not your fault, can't expect a turd to 
understand logic.


Please try to be civil. It's fine if you're unhappy about some 
aspect of how D works and want to discuss it, but we do not 
condone personal attacks here.


- Jonathan M Davis



But, of course, It's ok for him to come me an idiot. Let me 
quote, not that it matters, since you are biased and a hypocrite:


">> > If someone is too stupid to learn how precedence works, they
> should consider a different career instead of blaming 
> others."


But when I call him an idiot, I'm put in the corner.

I see how it works around here. What a cult!


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis 
wrote:


Please try to be civil. It's fine if you're unhappy about some 
aspect of how D works and want to discuss it, but we do not 
condone personal attacks here.


- Jonathan M Davis


He seemed to be threatening the guy's life over operator 
precedence. Ridiculous...


Re: What the hell is wrong with D?

2017-09-19 Thread B4s1L3 via Digitalmars-d-learn
On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta 
wrote:
Your an idiot, I know about how operator precedence works far 
more than you do. Wanna bet? how much? Your house? your wife? 
Your life? It's about doing things correctly, you seem to fail 
to understand, not your fault, can't expect a turd to 
understand logic.


You should swallow your ego a bit. In first place you've made an 
error. Just recognize this error, it's not so serious finally. 
You are discrediting yourself for nothing.


Re: What the hell is wrong with D?

2017-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Wednesday, September 20, 2017 02:16:16 EntangledQuanta via Digitalmars-d-
learn wrote:
> On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
> > On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta
> >
> > wrote:
> >> Yeah, that is really logical! No wonder D sucks and has so
> >> many bugs! Always wants me to be explicit about the stuff it
> >> won't figure out but it implicitly does stuff that makes no
> >> sense. The whole point of the parenthesis is to inform the
> >> compiler about the expression to use. Not use everything to
> >> the left of ?.
> >
> > There are two issues there; operator precedence and booleans
> > (_win[0] == '@') being a valid operands to +.
> > If someone is too stupid to learn how precedence works, they
> > should consider a different career instead of blaming others.
> > OTOH, booleans converting to numbers is a very questionable
> > feature. I certainly have never seen any good use for it. This
> > is just an unfortunate legacy of C, which didn't even have
> > booleans for a long time.
>
> Your an idiot, I know about how operator precedence works far
> more than you do. Wanna bet? how much? Your house? your wife?
> Your life? It's about doing things correctly, you seem to fail to
> understand, not your fault, can't expect a turd to understand
> logic.

Please try to be civil. It's fine if you're unhappy about some aspect of how
D works and want to discuss it, but we do not condone personal attacks here.

- Jonathan M Davis



Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 22:11:44 UTC, Jesse Phillips 
wrote:
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:
The D community preaches all this safety shit but when it 
comes down to it they don't seem to really care(look at the 
other responses like like "Hey, C does it" or "Hey, look up 
the operator precedence"... as if those responses are 
meaningful).



jmh530 points out why you're met with such non-agreement of the 
issue. You're not open do discussion of why it is implemented 
in the fashion it is. Instead it is an attack on the community 
and Walter as though there is no logical reason it is 
implemented in the way that it is.


I'm not open to discussion because it is not a discussion. There 
is no point. What could would it do to explain the short 
commings? You see the responses, the mentality. People think 
doing something wrong is valid because it was done. Two wrongs 
don't make a right no matter how you justify it. When someone 
takes on the task of doing a job and pretends the results to a 
community then refuse to accept responsibility for the failure to 
do the job properly and perpetuate ignorance(invalid logic that 
creates confusing, wastes peoples times, etc) then they deserve 
to be criticized, it's a two way street. When they then make up 
excuses to try to justify the wrong and turn it in to a right, 
they deserved to be attacked. It not just a harmless mistake. 
Peoples lives could be a jeopardy, but do they care? Do they 
REALLY care? Of course not. They don't see it as a significant 
issue. Simply learn how D works exactly and you'll be fine! Of 
course, for someone that programs in about 20 different languages 
regularly, having logical consistency is important.


It's one thing to say "Well, I made a mistake, lets try to remedy 
it the best we can" than to say "Well, too bad, we can't break 
backwards compatibility!". People want to perpetuate 
insanity(which is what being illogical is).



Sure you can express that it is illogical to have made that 
choice, but that requires first know what used to make that 
decision.


No, it doesn't logic is not based on circumstances, it's based on 
something that is completely independent of us... which is why it 
is called logic... because it is something we can all agree on 
regardless of our circumstances or environment... it is what math 
and hence all science is based on and is the only real thing that 
has made steady progress in the world. Illogic is what all the 
insanity is based on... what wars are from, and just about 
everything else, when you actually spend the time to think about 
it, which most people don't.



For example one of the original principles for D was:
If it looks like C it should have the same semantics or be a 
compiler error (note this was not completely achieved)


Now if we look at other languages we see, they implement it the 
same as C or they don't implement it at all. Just based on this 
it would make sense to choose to implement it like C if it is 
desired to have.


The suggestion I made fulfills this, but it also slightly 
defeats one purpose of the operator, being terse.


We also now need to keep backwards compatibility, this fails.


Again, two wrongs don't make a right. What is the point of 
reimplementing C exactly as C is done? There is already a C, why 
have two? Was the whole point of D not to improve upon C? Doesn't 
D claim to be a "better C"? So, if you are claiming that the 
choice for the ternary operator's issue of ambiguity was to be 
consistent with C then that directly contradicts the statements 
that D is suppose to be safer and better. I'm fine with this AS 
long as it is clearly stated as such and people don't try to 
justify or pretend that it is a good thing, which is exactly the 
opposite of what they. Most are followers of the cult and cannot 
make any rational decision on their own but simply parrot the 
elders. So, when they do that, I have no desire or reason to be 
logical with them(again, it takes two to tango).


For example, you have been rational, so I will be rational with 
you. To be rational, you must argue logically which you have 
done. Even though you haven't really argued the issue(of course, 
I didn't state it clear on purpose because this isn't really a 
discussion thread... I knew that the trolls/cult members would 
spew there stupid shit so I was just trolling them. Of course, I 
always hope that there would be some light in the tunnel, which 
you provided a glimmer... still all meaningless, nothing will 
change, at least not with the cult members, but someone that is 
not so brainwashed might be semi-enlightened if they implement 
their own language and not make the same mistakes).


e.g., my attack is on the claims that D attempts to be *safe* and 
a *better C* and yet this(the ternary if) is just another 
instance of them contradicting themselves. Presenting something 
as safer when it is not gives the perception of 

Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:
Yeah, that is really logical! No wonder D sucks and has so 
many bugs! Always wants me to be explicit about the stuff it 
won't figure out but it implicitly does stuff that makes no 
sense. The whole point of the parenthesis is to inform the 
compiler about the expression to use. Not use everything to 
the left of ?.


There are two issues there; operator precedence and booleans 
(_win[0] == '@') being a valid operands to +.
If someone is too stupid to learn how precedence works, they 
should consider a different career instead of blaming others.
OTOH, booleans converting to numbers is a very questionable 
feature. I certainly have never seen any good use for it. This 
is just an unfortunate legacy of C, which didn't even have 
booleans for a long time.


Your an idiot, I know about how operator precedence works far 
more than you do. Wanna bet? how much? Your house? your wife? 
Your life? It's about doing things correctly, you seem to fail to 
understand, not your fault, can't expect a turd to understand 
logic.


Re: What the hell is wrong with D?

2017-09-19 Thread rikki cattermole via Digitalmars-d-learn

On 19/09/2017 9:22 PM, Neia Neutuladh wrote:

On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta wrote:


writeln(x + ((_win[0] == '@') ? w/2 : 0));
writeln(x + (_win[0] == '@') ? w/2 : 0);

The first returns x + w/2 and the second returns w/2!


Yeah, it sucks to have bugs like this crop up. I have enough trouble 
remembering operator precedence, so I end up using parentheses 
everywhere and pretending the ternary operator doesn't exist. I also 
tend to break up complex expressions a lot. It's just safer, and usually 
clearer.


Agreed, no surprises is the best surprise!



Re: floating point value rounded to 6digits

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 8:04 PM, Jonathan M Davis wrote:

On Tuesday, September 19, 2017 19:35:15 Steven Schveighoffer via
Digitalmars-d-learn wrote:

On 9/19/17 7:28 PM, Ivan Kazmenko wrote:

On Tuesday, 19 September 2017 at 22:44:06 UTC, greatsam4sure wrote:

On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko wrote:

On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure wrote:

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write or
format. How do I change this default


The default when printing floating-point numbers is to show six most
significant digits.
You can specify the formatting manually with writefln, for example,

 writefln ("%.10f", value);

will print the value with 10 digits after the decimal point.
The writef/writefln function behaves much like printf in C.

See here for a reference on format strings:
https://dlang.org/library/std/format/formatted_write.html#format-strin
g

Ivan Kazmenko.


I don't  want to use write,writefln or format. I just want to change
the default


Unlikely to be possible.  The built-in data types, such as float or
double, by definition should not be customizable to such degree.

Anyway, under the hood, write uses format with the default format
specifier "%s" for the values it takes.  So perhaps I'm not quite
getting what exactly are you seeking to avoid.


What he's looking for is a way to globally set "I want all floating
point values to print this way, unless a more specific specifier is
given."

It's not a terrible idea, as any code that's using %s most of the time
doesn't really care what the result looks like.

I imagine an API like this:

import std.format: setDefaultFormat;
setDefaultFormat!float("%.10f");


The big problem with that is that it does not play nicely at all with pure.
For writeln, that doesn't matter much, since it can't be pure anyway,
because it's doing I/O, but it would matter for stuff like format or
formattedWrite, which IIRC, writeln uses internally.


That's a perfectly acceptable tradeoff. So:

stdout.setDefaultFormat!float("%.10f");

-Steve


Re: floating point value rounded to 6digits

2017-09-19 Thread Jonathan M Davis via Digitalmars-d-learn
On Tuesday, September 19, 2017 19:35:15 Steven Schveighoffer via 
Digitalmars-d-learn wrote:
> On 9/19/17 7:28 PM, Ivan Kazmenko wrote:
> > On Tuesday, 19 September 2017 at 22:44:06 UTC, greatsam4sure wrote:
> >> On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko wrote:
> >>> On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure wrote:
>  double  value = 20.89766554373733;
>  writeln(value);
>  //Output =20.8977
> 
>  How do I output the whole value without using writfln,write or
>  format. How do I change this default
> >>>
> >>> The default when printing floating-point numbers is to show six most
> >>> significant digits.
> >>> You can specify the formatting manually with writefln, for example,
> >>>
> >>> writefln ("%.10f", value);
> >>>
> >>> will print the value with 10 digits after the decimal point.
> >>> The writef/writefln function behaves much like printf in C.
> >>>
> >>> See here for a reference on format strings:
> >>> https://dlang.org/library/std/format/formatted_write.html#format-strin
> >>> g
> >>>
> >>> Ivan Kazmenko.
> >>
> >> I don't  want to use write,writefln or format. I just want to change
> >> the default
> >
> > Unlikely to be possible.  The built-in data types, such as float or
> > double, by definition should not be customizable to such degree.
> >
> > Anyway, under the hood, write uses format with the default format
> > specifier "%s" for the values it takes.  So perhaps I'm not quite
> > getting what exactly are you seeking to avoid.
>
> What he's looking for is a way to globally set "I want all floating
> point values to print this way, unless a more specific specifier is
> given."
>
> It's not a terrible idea, as any code that's using %s most of the time
> doesn't really care what the result looks like.
>
> I imagine an API like this:
>
> import std.format: setDefaultFormat;
> setDefaultFormat!float("%.10f");

The big problem with that is that it does not play nicely at all with pure.
For writeln, that doesn't matter much, since it can't be pure anyway,
because it's doing I/O, but it would matter for stuff like format or
formattedWrite, which IIRC, writeln uses internally.

If what the OP wants is to change what writeln does for floating point
values, the easiest way would be for them to create their own writeln and
use that instead. Then, it can forward to std.stdio.writeln for everything
but floating point values, and for floating point values, it can call
writefln with whatever format specifier gives the desired number of decimal
places.

- Jonathan M Davis



Re: floating point value rounded to 6digits

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 7:28 PM, Ivan Kazmenko wrote:

On Tuesday, 19 September 2017 at 22:44:06 UTC, greatsam4sure wrote:

On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko wrote:

On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure wrote:

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write or 
format. How do I change this default


The default when printing floating-point numbers is to show six most 
significant digits.

You can specify the formatting manually with writefln, for example,

    writefln ("%.10f", value);

will print the value with 10 digits after the decimal point.
The writef/writefln function behaves much like printf in C.

See here for a reference on format strings:
https://dlang.org/library/std/format/formatted_write.html#format-string

Ivan Kazmenko.


I don't  want to use write,writefln or format. I just want to change 
the default


Unlikely to be possible.  The built-in data types, such as float or 
double, by definition should not be customizable to such degree.


Anyway, under the hood, write uses format with the default format 
specifier "%s" for the values it takes.  So perhaps I'm not quite 
getting what exactly are you seeking to avoid.


What he's looking for is a way to globally set "I want all floating 
point values to print this way, unless a more specific specifier is given."


It's not a terrible idea, as any code that's using %s most of the time 
doesn't really care what the result looks like.


I imagine an API like this:

import std.format: setDefaultFormat;
setDefaultFormat!float("%.10f");

-Steve


Re: floating point value rounded to 6digits

2017-09-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 22:44:06 UTC, greatsam4sure 
wrote:
On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko 
wrote:
On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure 
wrote:

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write 
or format. How do I change this default


The default when printing floating-point numbers is to show 
six most significant digits.
You can specify the formatting manually with writefln, for 
example,


writefln ("%.10f", value);

will print the value with 10 digits after the decimal point.
The writef/writefln function behaves much like printf in C.

See here for a reference on format strings:
https://dlang.org/library/std/format/formatted_write.html#format-string

Ivan Kazmenko.


I don't  want to use write,writefln or format. I just want to 
change the default


Unlikely to be possible.  The built-in data types, such as float 
or double, by definition should not be customizable to such 
degree.


Anyway, under the hood, write uses format with the default format 
specifier "%s" for the values it takes.  So perhaps I'm not quite 
getting what exactly are you seeking to avoid.


For example, consider a helper function to convert the values, 
like the following:


import std.format, std.stdio;
string fmt (double v) {return v.format !("%.10f");}
void main () {
double x = 1.01;
writeln (x.fmt); // 1.01
}

Alternatively, you can wrap your floating-point numbers in a thin 
struct with a custom toString():


import std.format, std.stdio;
struct myDouble {
double v;
alias v this;
this (double v_) {v = v_;}
string toString () {return v.format !("%.10f");}
}
void main () {
myDouble x = 1.01, y = 2.02, z = x + y;
writeln (z); // 3.03
}

Ivan Kazmenko.



Re: floating point value rounded to 6digits

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 6:44 PM, greatsam4sure wrote:


I don't  want to use write,writefln or format. I just want to change the 
default


It's not a bad idea for an enhancement request -- provide default format 
specifiers for a given type.


Currently, there isn't a mechanism for that.

-Steve


Re: opEquals code generation

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 4:28 PM, Neia Neutuladh wrote:


Could be a bit simpler than that, depending on your needs:

bool opEquals(Object other) const nothrow @nogc
{
     auto f = cast(typeof(this)) other;
     if (f is null) return false;
     return this.tupleof == other.tupleof;
}


That doesn't compare floating point in the way he wants.

-Steve


Re: formattedRead can't work with tab delimiter input

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 20:04:36 UTC, kdevel wrote:
On Tuesday, 19 September 2017 at 13:28:22 UTC, Ky-Anh Huynh 
wrote:

Hi,

I want to read two fields from STDIN

string key;
double value;
line_st.formattedRead!"%s %f"(key, value);


Well it's so different from C. I would use this:

---
auto t = line_st.split.join (' ');
t.formattedRead!"%s %f"(key, value);
---


Yes it's possible.

It's a little weird and it seems the "feature" (or bug) is not 
documented on https://dlang.org/phobos/std_format.html. Why a tab 
(`\t`) isn't considered as a space?


Re: floating point value rounded to 6digits

2017-09-19 Thread greatsam4sure via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 21:52:57 UTC, Ivan Kazmenko 
wrote:
On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure 
wrote:

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write or 
format. How do I change this default


The default when printing floating-point numbers is to show six 
most significant digits.
You can specify the formatting manually with writefln, for 
example,


writefln ("%.10f", value);

will print the value with 10 digits after the decimal point.
The writef/writefln function behaves much like printf in C.

See here for a reference on format strings:
https://dlang.org/library/std/format/formatted_write.html#format-string

Ivan Kazmenko.


I don't  want to use write,writefln or format. I just want to 
change the default


Re: What the hell is wrong with D?

2017-09-19 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:
The D community preaches all this safety shit but when it comes 
down to it they don't seem to really care(look at the other 
responses like like "Hey, C does it" or "Hey, look up the 
operator precedence"... as if those responses are meaningful).



jmh530 points out why you're met with such non-agreement of the 
issue. You're not open do discussion of why it is implemented in 
the fashion it is. Instead it is an attack on the community and 
Walter as though there is no logical reason it is implemented in 
the way that it is.


Sure you can express that it is illogical to have made that 
choice, but that requires first know what used to make that 
decision.


For example one of the original principles for D was:
If it looks like C it should have the same semantics or be a 
compiler error (note this was not completely achieved)


Now if we look at other languages we see, they implement it the 
same as C or they don't implement it at all. Just based on this 
it would make sense to choose to implement it like C if it is 
desired to have.


The suggestion I made fulfills this, but it also slightly defeats 
one purpose of the operator, being terse.


We also now need to keep backwards compatibility, this fails.


Re: floating point value rounded to 6digits

2017-09-19 Thread Ivan Kazmenko via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 20:47:02 UTC, greatsam4sure 
wrote:

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write or 
format. How do I change this default


The default when printing floating-point numbers is to show six 
most significant digits.
You can specify the formatting manually with writefln, for 
example,


writefln ("%.10f", value);

will print the value with 10 digits after the decimal point.
The writef/writefln function behaves much like printf in C.

See here for a reference on format strings:
https://dlang.org/library/std/format/formatted_write.html#format-string

Ivan Kazmenko.



Re: What the hell is wrong with D?

2017-09-19 Thread nkm1 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:
Yeah, that is really logical! No wonder D sucks and has so many 
bugs! Always wants me to be explicit about the stuff it won't 
figure out but it implicitly does stuff that makes no sense. 
The whole point of the parenthesis is to inform the compiler 
about the expression to use. Not use everything to the left of 
?.


There are two issues there; operator precedence and booleans 
(_win[0] == '@') being a valid operands to +.
If someone is too stupid to learn how precedence works, they 
should consider a different career instead of blaming others.
OTOH, booleans converting to numbers is a very questionable 
feature. I certainly have never seen any good use for it. This is 
just an unfortunate legacy of C, which didn't even have booleans 
for a long time.




Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 20:00:40 UTC, Brad Anderson 
wrote:


If you want to help, I suggest trying to come up with a DIP 
that addresses it while being conscious of how to avoid 
breaking an enormous amount of code. I suspect it's a hard and 
maybe impossible problem but if you are up for the challenge 
I'm sure your efforts would be welcome.


Changing the operator precedence would certainly lead to enormous 
breakage.


Most use of the ternary operator is something like
result = a > b ? x : y;
and what he wants is to be forced to say
result = (a + b) ? x : y;
instead of
result = a + b ? x : y;

The problem is that addition/multiplication is above logical 
operators in the operator precedence. So if you were to do 
something like move conditional ternary above 
addition/multiplication, then you also move it above logical 
operators and you'd have to use

result = (a > b) ? x : y;
instead of
result = a > b ? x : y;
which kind of defeats the purpose.


floating point value rounded to 6digits

2017-09-19 Thread greatsam4sure via Digitalmars-d-learn

double  value = 20.89766554373733;
writeln(value);
//Output =20.8977

How do I output the whole value without using writfln,write or 
format. How do I change this default


Re: opEquals code generation

2017-09-19 Thread Neia Neutuladh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 13:18:04 UTC, drug wrote:

19.09.2017 15:38, Steven Schveighoffer пишет:

On 9/19/17 8:01 AM, drug wrote:
I iterate over struct members and check against equality 
depending on member type. is there more simple/cleaner/better 
way to achieve this functionality? Especially without string 
mixins?


Why not just use tupleof directly instead of having to find 
the member name and using mixins?


-Steve


Hmm, I'm sure I had tried it before and failed, but now I've 
managed to do so and it's really simpler


Could be a bit simpler than that, depending on your needs:

bool opEquals(Object other) const nothrow @nogc
{
auto f = cast(typeof(this)) other;
if (f is null) return false;
return this.tupleof == other.tupleof;
}


Re: What the hell is wrong with D?

2017-09-19 Thread Neia Neutuladh via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


writeln(x + ((_win[0] == '@') ? w/2 : 0));
writeln(x + (_win[0] == '@') ? w/2 : 0);

The first returns x + w/2 and the second returns w/2!


Yeah, it sucks to have bugs like this crop up. I have enough 
trouble remembering operator precedence, so I end up using 
parentheses everywhere and pretending the ternary operator 
doesn't exist. I also tend to break up complex expressions a lot. 
It's just safer, and usually clearer.


Re: How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Rainer Schuetze via Digitalmars-d-learn



On 19.09.2017 13:47, Timothy Foster wrote:
I'm trying to compile my project as a Win64 application but this is 
happening:


Building C:\Users\me\test\test.exe...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 183: Extension not .RES : 
obj\debug\dummy\test\..\source\c.obj

obj\debug\dummy\test\..\source\b.obj(1) : Error 52: .DEF Syntax Error
d†šöñÀY$@

^
Building C:\Users\me\test\test.exe failed!


I'm on a Win64 machine and compiling Win32 works fine. I'm using Visual 
Studio 17 Community with Visual D. DMD is up to date as is Visual D.


I added a x64 "solution platform" to the configuration manager which 
added a -m64 flag to my linker options. I'm not sure what else I'm meant 
to do to get it to compile as x64?


That usually happens if the DMD bin folder is searched first in the PATH 
variable (unfortunately the linker and other tools have the same name as 
the Microsoft programs).


You should verify that the VC folder is listed first in 
Tools->Options->Projects and Solutions->Visual D Settings->DMD 
Directories->x64->Executable Paths, i.e.


$(VCTOOLSINSTALLDIR)bin\HostX86\x86

should be listed before

$(DMDInstallDir)windows\bin


Re: What the hell is wrong with D?

2017-09-19 Thread Brad Anderson via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:

[snip]

I'm just glad there is at least one sane person that decided to 
chime in... was quite surprised actually. I find it quite 
pathetic when someone tries to justify a wrong by pointing to 
other wrongs. It takes away all credibility that they have.


I have no doubt that had someone thought to propose addressing 
this when the language was new it would have been seriously 
considered and likely accepted (given how frequently this causes 
bugs). D tried to fix a lot of behavior from C that was bug prone 
but it didn't catch everything.


If you want to help, I suggest trying to come up with a DIP that 
addresses it while being conscious of how to avoid breaking an 
enormous amount of code. I suspect it's a hard and maybe 
impossible problem but if you are up for the challenge I'm sure 
your efforts would be welcome.


Re: formattedRead can't work with tab delimiter input

2017-09-19 Thread kdevel via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 13:28:22 UTC, Ky-Anh Huynh wrote:

Hi,

I want to read two fields from STDIN

string key;
double value;
line_st.formattedRead!"%s %f"(key, value);


Well it's so different from C. I would use this:

---
auto t = line_st.split.join (' ');
t.formattedRead!"%s %f"(key, value);
---



Re: What the hell is wrong with D?

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 1:40 PM, EntangledQuanta wrote:


The first returns x + w/2 and the second returns w/2!


Did you mean (x + w) / 2 or x + (w / 2)? Stop being ambiguous!

-Steve


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 19:16:05 UTC, EntangledQuanta 
wrote:


()?: is not ambiguous!

The D community preaches all this safety shit but when it comes 
down to it they don't seem to really care(look at the other 
responses like like "Hey, C does it" or "Hey, look up the 
operator precedence"... as if those responses are meaningful).




I sympathize that it was a difficult to find problem. Happens to 
me a lot. Nevertheless, I pretty much never use ternary operators 
because Matlab was my first language was it doesn't have them. 
I'm always writing out if() { } else { }. So it's not really an 
error that happens for me.


The point that others and myself were making about C is that your 
initial post was very critical of D and Walter. Unduly, IMO. You 
were blaming D for the problem, when it turns out that in 
virtually every language that uses this syntax it works this way 
(and I checked like 10, just to be sure). Harshly criticizing 
Walter for something that is a generally accepted way of doing 
things across many programming languages is unreasonable. D never 
promised to be the greatest language ever whose users never ever 
write any buggy code at all. It's aims are a bit more limited 
than that.


There's an easy solution to your problem: use more parentheses 
with conditional ternary operators.


Re: What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 18:51:51 UTC, Jesse Phillips 
wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:
I assume someone is going to tell me that the compiler treats 
it as


writeln((x + (_win[0] == '@')) ? w/2 : 0);

Yeah, that is really logical!


Yeah, I've been bitten by that in languages like C#. I wish D 
didn't follow in C#'s footsteps and chosen a different syntax: 
`()? :`


That way if there aren't any parentheses the compiler could 
throw out an error until you specify what the operating is 
working with. It would make for a little overhead but these 
complex ternary expressions can be confusing.


Yes, it's not that they are confusing but illogical.

a + b ? c : d

in a complex expression can be hard to interpret if a and b are 
complex. The whole point of parenthesis is to disambiguate and 
group things. To not use them is pretty ignorant.


1 + 2 ? 3 : 4

That is ambiguous. is it (1 + 2) ? 3 : 4 or 1 + (2 ? 3 : 4)?

Well,

()?: is not ambiguous!

The D community preaches all this safety shit but when it comes 
down to it they don't seem to really care(look at the other 
responses like like "Hey, C does it" or "Hey, look up the 
operator precedence"... as if those responses are meaningful).


I'm just glad there is at least one sane person that decided to 
chime in... was quite surprised actually. I find it quite 
pathetic when someone tries to justify a wrong by pointing to 
other wrongs. It takes away all credibility that they have.












Re: What the hell is wrong with D?

2017-09-19 Thread Jesse Phillips via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:
I assume someone is going to tell me that the compiler treats 
it as


writeln((x + (_win[0] == '@')) ? w/2 : 0);

Yeah, that is really logical!


Yeah, I've been bitten by that in languages like C#. I wish D 
didn't follow in C#'s footsteps and chosen a different syntax: 
`()? :`


That way if there aren't any parentheses the compiler could throw 
out an error until you specify what the operating is working 
with. It would make for a little overhead but these complex 
ternary expressions can be confusing.


Re: What the hell is wrong with D?

2017-09-19 Thread Ali Çehreli via Digitalmars-d-learn

On 09/19/2017 11:34 AM, Brad Anderson wrote:
> On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:

>> Pretty sure it would be exactly the same thing in C...
>
> It is (and Java and C# and pretty much every other C style language
> though the nicer implicit conversion rules means it gets caught more
> easily). It is a big source of programmer mistakes. It comes up
> frequently in PVS Studio's open source analysis write ups.

Just a random Google find for some entertainment. :)


http://twistedoakstudios.com/blog/Post5273_how-to-read-nested-ternary-operators

  string result = i % 2 == 0 ? "a" : i % 3 == 0 ? "b" : i % 5 == 0 ? 
"c" : i % 7 == 0 ? "d" : "e";


Ali



Re: What the hell is wrong with D?

2017-09-19 Thread Brad Anderson via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 18:17:47 UTC, jmh530 wrote:
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


It is (and Java and C# and pretty much every other C style 
language though the nicer implicit conversion rules means it gets 
caught more easily). It is a big source of programmer mistakes. 
It comes up frequently in PVS Studio's open source analysis write 
ups.


Re: How to list all process directories under /proc/

2017-09-19 Thread Matt Jones via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 13:32:29 UTC, Ky-Anh Huynh wrote:



Btw, is that a bit weird that range is not supported in glob 
pattern :) Is there a design reason for this?


That is strange. But then again, every glob library I've seen 
works a little bit differently.


Re: What the hell is wrong with D?

2017-09-19 Thread jmh530 via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Pretty sure it would be exactly the same thing in C...


Re: What the hell is wrong with D?

2017-09-19 Thread Eugene Wissner via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:


writeln(x + ((_win[0] == '@') ? w/2 : 0));
writeln(x + (_win[0] == '@') ? w/2 : 0);

The first returns x + w/2 and the second returns w/2!

WTF!!! This stupid bug has caused me considerable waste of 
time. Thanks Walter! I know you care so much about my time!


I assume someone is going to tell me that the compiler treats 
it as


writeln((x + (_win[0] == '@')) ? w/2 : 0);

Yeah, that is really logical! No wonder D sucks and has so many 
bugs! Always wants me to be explicit about the stuff it won't 
figure out but it implicitly does stuff that makes no sense. 
The whole point of the parenthesis is to inform the compiler 
about the expression to use. Not use everything to the left of 
?.


Thanks for wasting some of my life... Just curious about who 
will justify the behavior and what excuses they will give.


Why do you claim that a bug in your code is a compiler bug? Check 
"Operator precedence" [1]. There is really no reason why the 
current precedence is less "logical" than what you're awaiting.


And try to think about things you're writing, nobody forces you 
to use D.


[1] https://wiki.dlang.org/Operator_precedence


What the hell is wrong with D?

2017-09-19 Thread EntangledQuanta via Digitalmars-d-learn


writeln(x + ((_win[0] == '@') ? w/2 : 0));
writeln(x + (_win[0] == '@') ? w/2 : 0);

The first returns x + w/2 and the second returns w/2!

WTF!!! This stupid bug has caused me considerable waste of time. 
Thanks Walter! I know you care so much about my time!


I assume someone is going to tell me that the compiler treats it 
as


writeln((x + (_win[0] == '@')) ? w/2 : 0);

Yeah, that is really logical! No wonder D sucks and has so many 
bugs! Always wants me to be explicit about the stuff it won't 
figure out but it implicitly does stuff that makes no sense. The 
whole point of the parenthesis is to inform the compiler about 
the expression to use. Not use everything to the left of ?.


Thanks for wasting some of my life... Just curious about who will 
justify the behavior and what excuses they will give.


Re: Assertion Error

2017-09-19 Thread Vino.B via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 15:27:30 UTC, Moritz Maxeiner 
wrote:

On Wednesday, 13 September 2017 at 15:12:57 UTC, Vino.B wrote:
On Wednesday, 13 September 2017 at 11:03:38 UTC, Moritz 
Maxeiner wrote:

On Wednesday, 13 September 2017 at 07:39:46 UTC, Vino.B wrote:

 [...]


[...]

---
foreach (string Fs; parallel(SizeDirlst[0 .. $], 1))
{
  MSresult.get ~= coSizeDirList(Fs.strip, SizeDir);
}
---


Hi Max,


It's Moritz, not Max. ;)



 Below is the explanation of the above code.

[...]


AFAICT that's a reason why you want parallelization of 
coSizeDirList, but not why you need to spawn another thread 
inside of an *already parallelelized" task. Try my shortened 
parallel foreach loop vs your longer one and monitor system 
load (threads, memory, etc).


Hi Moritz,

 Thank you very much, it was very helpful and time saving and 
fast.


From,
Vino.B


Re: How to list all process directories under /proc/

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 06:35:18 UTC, Matt Jones wrote:
On Sunday, 17 September 2017 at 08:37:33 UTC, Ky-Anh Huynh 
wrote:



[...]


The problem with matching "[0123456789]*" is that it will match 
files like "1blah" and "8stuff". It looks like glob patterns 
are not robust enough to handle match patterns you want. A 
regex would probably be enough. Something like this works:


[...]



I understand. Thanks a lot.

Btw, is that a bit weird that range is not supported in glob 
pattern :) Is there a design reason for this?


formattedRead can't work with tab delimiter input

2017-09-19 Thread Ky-Anh Huynh via Digitalmars-d-learn

Hi,

I want to read two fields from STDIN

string key;
double value;
line_st.formattedRead!"%s %f"(key, value);

However, if the input line contains \t and it doesn't contain any 
space, the code doesn't work as expected. If there is a space, it 
works well


   a[space]1 # work, key => a, value => 1
   b[space][tab]2# work, key => b, value => 2
   c[tab]3   # not work, key => c[tab]3, value => nan

Can you please help? Thanks a lot.


PS: My program is found here

https://github.com/icy/dusybox/blob/master/src/plotbar/main.d#L59


Re: opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn

19.09.2017 15:38, Steven Schveighoffer пишет:

On 9/19/17 8:01 AM, drug wrote:
I iterate over struct members and check against equality depending on 
member type. is there more simple/cleaner/better way to achieve this 
functionality? Especially without string mixins?


Why not just use tupleof directly instead of having to find the member 
name and using mixins?


-Steve


Hmm, I'm sure I had tried it before and failed, but now I've managed to 
do so and it's really simpler (https://run.dlang.io/is/GJkokW):

```
auto opEquals()(auto ref const(typeof(this)) rhs)
{
import std.math : approxEqual, isNaN;
import std.traits : isFloatingPoint, isIntegral;

static foreach(i; 0..this.tupleof.length)
{
{
alias FType = typeof(this.tupleof[i]);

// a field of this structure
auto tf = this.tupleof[i];
// a field of other structure
auto of = rhs.tupleof[i];

static if (isFloatingPoint!FType)
{
if (!tf.isNaN || !of.isNaN)
{
if (!approxEqual(tf, of))
return false;
}
}
else static if (isIntegral!FType)
{
if (tf != of)
return false;
}
else
static assert (0);
}
}
return true;
}
```

Thank you, Steven!


Re: Basic LDC Linux Install Question

2017-09-19 Thread jmh530 via Digitalmars-d-learn

On Tuesday, 19 September 2017 at 12:37:12 UTC, Daniel Kozak wrote:
Yes you need to add ldc2 to your PATH. So if your ldc2 binary 
is in

/user/something/something/folder_where_is_ldc2/ldc2
you havto add /user/something/something/folder_where_is_ldc2 to 
your PATH.

You can test this by pasting this to terminal:

export 
PATH=$PATH:/user/something/something/folder_where_is_ldc2 ldc2 
--version




Okay, not good enough to just point to the ldc folder, I need to 
point to the ldc/ldc-1.4.0/bin folder. That's just like Windows, 
now that I think of it. Thanks.


Re: opEquals code generation

2017-09-19 Thread Steven Schveighoffer via Digitalmars-d-learn

On 9/19/17 8:01 AM, drug wrote:
I iterate over struct members and check against equality depending on 
member type. is there more simple/cleaner/better way to achieve this 
functionality? Especially without string mixins?


Why not just use tupleof directly instead of having to find the member 
name and using mixins?


-Steve


Re: Basic LDC Linux Install Question

2017-09-19 Thread Daniel Kozak via Digitalmars-d-learn
Yes you need to add ldc2 to your PATH. So if your ldc2 binary is in
/user/something/something/folder_where_is_ldc2/ldc2
you havto add /user/something/something/folder_where_is_ldc2 to your PATH.
You can test this by pasting this to terminal:

export PATH=$PATH:/user/something/something/folder_where_is_ldc2
ldc2 --version

On Tue, Sep 19, 2017 at 2:26 PM, jmh530 via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:

> I'm more of a Windows user than a Linux user. I have the latest DMD on my
> Linux install (linux mint 17.3), but I wanted to test LDC.
>
> I get a message that ldc2 is not found when I type ldc2 --version or sudo
> ldc2 --version (I'm not on root and the existing user does not have root
> privileges, so I have to sudo around that folder).
>
> Here's what I did:
> 1) Download binary from ldc github page
> 2) Unpack and copy to /usr/local/bin/ldc/ldc2-1.4.0-linux-x86_64
>
> I was concerned that the issue is that ldc2 is not in the path. When I
> type $PATH I get
> bash: 
> /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
> No such file or directory
>
> Do I need to add /usr/local/bin/ldc to it also? Or am I missing out on
> some other step?
>


Basic LDC Linux Install Question

2017-09-19 Thread jmh530 via Digitalmars-d-learn
I'm more of a Windows user than a Linux user. I have the latest 
DMD on my Linux install (linux mint 17.3), but I wanted to test 
LDC.


I get a message that ldc2 is not found when I type ldc2 --version 
or sudo ldc2 --version (I'm not on root and the existing user 
does not have root privileges, so I have to sudo around that 
folder).


Here's what I did:
1) Download binary from ldc github page
2) Unpack and copy to /usr/local/bin/ldc/ldc2-1.4.0-linux-x86_64

I was concerned that the issue is that ldc2 is not in the path. 
When I type $PATH I get
bash: 
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games: No such file or directory


Do I need to add /usr/local/bin/ldc to it also? Or am I missing 
out on some other step?


Re: opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn

19.09.2017 15:01, drug пишет:
I iterate over struct members and check against equality depending on 
member type. is there more simple/cleaner/better way to achieve this 
functionality? Especially without string mixins?

oops, https://run.dlang.io/is/PbZE5i


Re: How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Daniel Kozak via Digitalmars-d-learn
this should be ok, can you post error when using with m64

On Tue, Sep 19, 2017 at 1:47 PM, Timothy Foster via Digitalmars-d-learn <
digitalmars-d-learn@puremagic.com> wrote:

> I'm trying to compile my project as a Win64 application but this is
> happening:
>
> Building C:\Users\me\test\test.exe...
> OPTLINK (R) for Win32  Release 8.00.17
> Copyright (C) Digital Mars 1989-2013  All rights reserved.
> http://www.digitalmars.com/ctg/optlink.html
> OPTLINK : Warning 183: Extension not .RES : obj\debug\dummy\test\..\source
> \c.obj
> obj\debug\dummy\test\..\source\b.obj(1) : Error 52: .DEF Syntax Error
> d†š öñÀY$@
>
> ^
> Building C:\Users\me\test\test.exe failed!
>
>
> I'm on a Win64 machine and compiling Win32 works fine. I'm using Visual
> Studio 17 Community with Visual D. DMD is up to date as is Visual D.
>
> I added a x64 "solution platform" to the configuration manager which added
> a -m64 flag to my linker options. I'm not sure what else I'm meant to do to
> get it to compile as x64?
>


Re: How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Nicholas Wilson via Digitalmars-d-learn
On Tuesday, 19 September 2017 at 11:47:00 UTC, Timothy Foster 
wrote:
I'm trying to compile my project as a Win64 application but 
this is happening:


Building C:\Users\me\test\test.exe...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 183: Extension not .RES : 
obj\debug\dummy\test\..\source\c.obj
obj\debug\dummy\test\..\source\b.obj(1) : Error 52: .DEF Syntax 
Error

d†šöñÀY$@

^
Building C:\Users\me\test\test.exe failed!


I'm on a Win64 machine and compiling Win32 works fine. I'm 
using Visual Studio 17 Community with Visual D. DMD is up to 
date as is Visual D.


I added a x64 "solution platform" to the configuration manager 
which added a -m64 flag to my linker options. I'm not sure what 
else I'm meant to do to get it to compile as x64?


I'm not sure why its trying to use opt link for 64-bit, the 
linker banner gives a hint:

OPTLINK (R) for _Win32_.

64 bit should use MS's linker, is -m64 only passed to the linker 
but not the compiler?


opEquals code generation

2017-09-19 Thread drug via Digitalmars-d-learn
I iterate over struct members and check against equality depending on 
member type. is there more simple/cleaner/better way to achieve this 
functionality? Especially without string mixins?


How to compile for Win64 with Visual D? Optlink error?

2017-09-19 Thread Timothy Foster via Digitalmars-d-learn
I'm trying to compile my project as a Win64 application but this 
is happening:


Building C:\Users\me\test\test.exe...
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Warning 183: Extension not .RES : 
obj\debug\dummy\test\..\source\c.obj
obj\debug\dummy\test\..\source\b.obj(1) : Error 52: .DEF Syntax 
Error

d†šöñÀY$@

^
Building C:\Users\me\test\test.exe failed!


I'm on a Win64 machine and compiling Win32 works fine. I'm using 
Visual Studio 17 Community with Visual D. DMD is up to date as is 
Visual D.


I added a x64 "solution platform" to the configuration manager 
which added a -m64 flag to my linker options. I'm not sure what 
else I'm meant to do to get it to compile as x64?


Re: How to list all process directories under /proc/

2017-09-19 Thread Matt Jones via Digitalmars-d-learn

On Sunday, 17 September 2017 at 08:37:33 UTC, Ky-Anh Huynh wrote:

The official documentation here 
https://dlang.org/phobos/std_path.html#.globMatch refers to the 
wiki page https://en.wikipedia.org/wiki/Glob_%28programming%29 
. However I think the popular glob rules (man 7 glob) are not 
supported.


The problem with matching "[0123456789]*" is that it will match 
files like "1blah" and "8stuff". It looks like glob patterns are 
not robust enough to handle match patterns you want. A regex 
would probably be enough. Something like this works:


string[] getProcNumbers() {
import std.file : dirEntries, SpanMode;
import std.path : baseName;
import std.regex : regex, match;
import std.algorithm : map, filter;
import std.array : array;

auto r = regex(`^/proc/[0-9]*$`);

string[] entries =
dirEntries("/proc/", SpanMode.shallow)
.map!(n => n.name)
.filter!(n => match(n, r))
.array();

return entries;
}

int main() {
import std.stdio : stdout;

foreach (entry ; getProcNumbers()) {
stdout.writefln("%s", entry);
}

return 0;
}


Re: Binary serialization of a struct

2017-09-19 Thread Nordlöw via Digitalmars-d-learn

On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote:
Are there any simple direct serialization libraries where I can 
mark elements of a class or struct that I want serialized with 
an attribute and it will take care of all the rest(including 
recursive structures, arrays, etc) then deserialize back in to 
the structs?


I want something straight forward without allot of plumbing on 
my end.


https://github.com/msgpack/msgpack-d

is about as simple as it can get:

import std.file;
import msgpack;

struct S { int x; float y; string z; }

void main()
{
S input = S(10, 25.5, "message");

// serialize data
ubyte[] inData = pack(input);

// write data to a file
write("file.dat", inData);

// read data from a file
ubyte[] outData = cast(ubyte[])read("file.dat");

// unserialize the data
S target = outData.unpack!S();

// verify data is the same
assert(target.x == input.x);
assert(target.y == input.y);
assert(target.z == input.z);
}


Re: Binary serialization of a struct

2017-09-19 Thread spring via Digitalmars-d-learn

On Saturday, 16 September 2017 at 03:30:51 UTC, Joseph wrote:
Are there any simple direct serialization libraries where I can 
mark elements of a class or struct that I want serialized with 
an attribute and it will take care of all the rest(including 
recursive structures, arrays, etc) then deserialize back in to 
the structs?


I want something straight forward without allot of plumbing on 
my end.


https://github.com/huntlabs/common/blob/master/source/zhang2018/common/Serialize.d

only a single file .  can serialize/deserialize 
struct,class,array.