Re: Please review these pull requests (DMD #7097 & Phobos #5704)

2017-08-27 Thread Michael V. Franklin via Digitalmars-d
On Monday, 28 August 2017 at 00:21:00 UTC, Michael V. Franklin 
wrote:
These pull request were submitted a few days ago, but appear to 
have gone unnoticed.


https://github.com/dlang/dmd/pull/7097
https://github.com/dlang/phobos/pull/5704

I'm assuming that is because neither currently passes the test 
suite.


Based on some advise I received in IRC, I've broken the fix into 
a series of 3 pull request that should be green with each step.  
That is:


Step 1 should already be green.
After Step 1 is pulled, Step 2 should become green.
After Step 2 is pulled, Step 3 should become green.

Step 1: https://github.com/dlang/phobos/pull/5709 - Deletes an 
incorrect Phobos unittest that is preventing Step 2 from passing 
its test suite.
Step 2: https://github.com/dlang/dmd/pull/7097 - The actual fix 
for issue 11246
Step 3: https://github.com/dlang/phobos/pull/5704 - Repairs the 
unittest that was deleted in Step 1 so it properly tests for 
correct behavior.


Hopefully it won't be such a leap of faith to pull Step 1 given 
that it appears to be testing positive for incorrect behavior.


Thanks,
Mike


Re: No CTFE of function

2017-08-27 Thread Mike Parker via Digitalmars-d-learn

On Sunday, 27 August 2017 at 17:47:54 UTC, Cecil Ward wrote:


I wonder if there is anything written up anywhere about what 
kinds of things are blockers to either CTFE or to successful 
constant-folding optimisation in particular compilers or in 
general?


Would be useful to know what to stay away from if you really 
need to make sure that horrendously slow code does not get run 
at runtime. Sometimes it is possible or even relatively easy to 
reorganise things and do without certain practices in order to 
win such a massive reward.


The rules for CTFE are outlined in the docs [1]. What is 
described there is all there is to it. If those criteria are not 
met, the function cannot be executed at compile time. More 
importantly, as mentioned earlier in the thread, CTFE will only 
occur if a function *must* be executed at compile time, i.e. it 
is in a context where the result of the function is required at 
compile-time. An enum declaration is such a situation, a variable 
initialization is not.


There are also a couple of posts on the D Blog. Stefan has 
written about the new CTFE engine [1] and I posted something 
showing a compile-time sort. These illustrate the points laid out 
in the documentation.


As for compiler optimizations, there are some basic optimizations 
that will be common across all compilers, and you can google for 
compiler optimizations to find such generalities. Many of these 
apply across languages, and those specific to the C-family 
languages will likely be found in D compilers. Beyond that, I'm 
unaware of any documentation that outlines optimizations in D 
compilers.


[1] https://dlang.org/spec/function.html#interpretation
[2] https://dlang.org/blog/2017/04/10/the-new-ctfe-engine/
[3] https://dlang.org/blog/2017/06/05/compile-time-sort-in-d/


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Dmitry via Digitalmars-d

On Sunday, 27 August 2017 at 23:22:06 UTC, Ecstatic Coder wrote:

Done !

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

Thanks for the advice :)


Also you could fork the site (main page), make changes and share 
result. Then will be possible see changes, how it'll look "live". 
And people can vote - like/dislike. For example, 
https://forum.dlang.org/thread/odbtivxmrggaywcbe...@forum.dlang.org


Re: C callbacks getting a value of 0! Bug in D?

2017-08-27 Thread Johnson Jones via Digitalmars-d-learn

Looking at the assembly shows something like this:

0041ea98  push 0x0
0041ea9a  push 0x0
0041ea9c  push 0x0
0041ea9e  push dword 0x100
0041eaa3  mov ecx, [typeid(PaStreamParameters)+0xe36fc (0x80d4cc)]
0041eaa9  mov eax, [fs:0x2c]
0041eaaf  mov edx, [eax+ecx*4]
0041eab2  push dword [edx+0x1c]
0041eab8  push dword [edx+0x18]
0041eabe  push dword [ebp-0x54]
0041eac1  push dword [ebp-0x5c]
0041eac4  mov ebx, PA.stream (0x823f30)
0041eac9  push ebx
0041eaca  call dword near [Pa_OpenStream (0x823f18)]

I noticed that those 0's were the values being fed in to the 
function.


I remember converting c_ulong's to ulong's and that they were 
probably uint's in D. Converting those fixed the problem and the 
callback is now called! I converted all the ulongs to uint's but 
there were a few longs and I don't know if they are c_longs or 
d_longs...


Anyways, At least I'm on the right track.



C callbacks getting a value of 0! Bug in D?

2017-08-27 Thread Johnson Jones via Digitalmars-d-learn
Trying to set a callback for portaudio and it's seeing zero for 
the value passed.


Pa_OpenStream(, input, output, sampleRate, cast(ulong)0, 
cast(PaStreamFlags)(PaStreamFlags.NoFlag + 
0*PaStreamFlags.PrimeOutputBuffersUsingStreamCallback),

 
cast(PaStreamCallback)(a,b,c,d,e,f){
callbackCalled = true;

 return 0;
 }, 
null);

I am using a debug build of portaudio that prints out all the 
parameters before anything else, so it's not an issue with 
portaudio.


I've tried passing a normal function:

__gshared int sawtooth(const(void)* inputBuffer, void* 
outputBuffer, ulong framesPerBuffer, 
const(PaStreamCallbackTimeInfo)* timeInfo, PaStreamCallbackFlags 
statusFlags, void *userData)

{ return 0; }

and passing it as 

with the same issue.

I've tried changing the calling convention and using __gshared 
but the value is always 0. It seems other values are 0 too and 
can't seem to get any value in to the callback(Even a random one).



The output essentially always looks like this:


Opening Stream!
Pa_OpenStream called:
PaStream** stream: 0x00823EA0
PaStreamParameters *inputParameters: NULL
PaStreamParameters *outputParameters: 0x02C6C1C0
PaDeviceIndex outputParameters->device: 3
int outputParameters->channelCount: 4
PaSampleFormat outputParameters->sampleFormat: 1
PaTime outputParameters->suggestedLatency: 0.135000
void *outputParameters->hostApiSpecificStreamInfo: 
0x

double sampleRate: 44100
unsigned long framesPerBuffer: 256
PaStreamFlags streamFlags: 0x0
PaStreamCallback *streamCallback: 0x
void *userData: 0x
Pa_GetSampleSize called:
PaSampleFormat format: 8
Pa_GetSampleSize returned:
int: 2
Pa_GetSampleSize called:
PaSampleFormat format: 8
Pa_GetSampleSize returned:
int: 2
Pa_GetSampleSize called:
PaSampleFormat format: 1
Pa_GetSampleSize returned:
int: 4
Pa_GetSampleSize called:
PaSampleFormat format: 8
Pa_GetSampleSize returned:
int: 2
Pa_GetSampleSize called:
PaSampleFormat format: 8
Pa_GetSampleSize returned:
int: 2
Pa_OpenStream returned:
*(PaStream** stream): 0x03BEAD50
PaError: 0 ( Success )


everything seems correct except:

PaStreamCallback *streamCallback: 0x
void *userData: 0x

You can find the full code at

https://forum.dlang.org/thread/lkbswgpsgxynhfyzw...@forum.dlang.org 



This is either a bug in D, an issue with calling conventions, or 
how one passes the data.



The original portaudio open stream function, so you can see that 
it simply prints it's arguments:


PaError Pa_OpenStream( PaStream** stream,
   const PaStreamParameters *inputParameters,
   const PaStreamParameters *outputParameters,
   double sampleRate,
   unsigned long framesPerBuffer,
   PaStreamFlags streamFlags,
   PaStreamCallback *streamCallback,
   void *userData )
{
PaError result;
PaUtilHostApiRepresentation *hostApi = 0;
PaDeviceIndex hostApiInputDevice = paNoDevice, 
hostApiOutputDevice = paNoDevice;
PaStreamParameters hostApiInputParameters, 
hostApiOutputParameters;
PaStreamParameters *hostApiInputParametersPtr, 
*hostApiOutputParametersPtr;



#ifdef PA_LOG_API_CALLS
PA_LOGAPI_ENTER_PARAMS( "Pa_OpenStream" );
PA_LOGAPI(("\tPaStream** stream: 0x%p\n", stream ));

if( inputParameters == NULL ){
PA_LOGAPI(("\tPaStreamParameters *inputParameters: 
NULL\n" ));

}else{
PA_LOGAPI(("\tPaStreamParameters *inputParameters: 
0x%p\n", inputParameters ));
PA_LOGAPI(("\tPaDeviceIndex inputParameters->device: 
%d\n", inputParameters->device ));
PA_LOGAPI(("\tint inputParameters->channelCount: %d\n", 
inputParameters->channelCount ));
PA_LOGAPI(("\tPaSampleFormat 
inputParameters->sampleFormat: %d\n", 
inputParameters->sampleFormat ));
PA_LOGAPI(("\tPaTime inputParameters->suggestedLatency: 
%f\n", inputParameters->suggestedLatency ));
PA_LOGAPI(("\tvoid 
*inputParameters->hostApiSpecificStreamInfo: 0x%p\n", 
inputParameters->hostApiSpecificStreamInfo ));

}

if( outputParameters == NULL ){
PA_LOGAPI(("\tPaStreamParameters *outputParameters: 
NULL\n" ));

}else{
PA_LOGAPI(("\tPaStreamParameters *outputParameters: 
0x%p\n", outputParameters ));
PA_LOGAPI(("\tPaDeviceIndex outputParameters->device: 
%d\n", outputParameters->device ));
PA_LOGAPI(("\tint outputParameters->channelCount: %d\n", 
outputParameters->channelCount ));

Please review these pull requests (DMD #7097 & Phobos #5704)

2017-08-27 Thread Michael V. Franklin via Digitalmars-d
These pull request were submitted a few days ago, but appear to 
have gone unnoticed.


https://github.com/dlang/dmd/pull/7097
https://github.com/dlang/phobos/pull/5704

I'm assuming that is because neither currently passes the test 
suite.


I'm making this forum post to bring attention to the fact that 
the reason they don't pass the test suite is an unfortuante 
consequence of them depending on each other.The Phobos PR won't 
pass until the DMD PR is pulled, and the DMD PR won't pass until 
the Phobos PR is pulled.


Please give them your attention despite their current test status.

I'm not sure how such a thing is typically handled, but if there 
is something I need to do please let me know.


Thanks,
Mike


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d

On Sunday, 27 August 2017 at 20:31:03 UTC, Moritz Maxeiner wrote:

On Sunday, 27 August 2017 at 20:13:35 UTC, Ecstatic Coder wrote:
Following what you said, I've just looked at both Github 
accounts, and I can clearly see that it's much above my skill 
set to merge the content of both D-based websites so that the 
main page of the Dlang website looks exactly like what I want.


Fair enough, in that case could you open an enhancement request 
over at [1], so it doesn't get lost?


[1] https://issues.dlang.org/


Done !

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

Thanks for the advice :)


[Issue 17789] New: Use a much more practical and beginner-friendly landing page on Dlang.org, integrating Dlang-Tour try-it-online examples

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17789

  Issue ID: 17789
   Summary: Use a much more practical and beginner-friendly
landing page on Dlang.org, integrating Dlang-Tour
try-it-online examples
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: ecstatic.co...@gmail.com

My proposal is change the Dlang.org main page so that it just :

1. Say "Welcome to D"

2. Show how D is nice, ending with a link to the feature page

3. Show how simple D code looks like, using 4 well chosen examples, with the
first on the right of the main page.

4. Show how easy it is to learn D.

5. Show how easy it is to install DMD and a simple editor like CoEdit on any
win/mac/linux computer.

So in practice, I'd advice the landing page to become something like that :

"Welcome to D

What is D?

D is the culmination of decades of experience implementing compilers for many
diverse languages and has a unique set of features:

high level constructs for great modeling power
high performance, compiled language
static typing
direct interface to the operating system API's and hardware
blazingly fast compile-times
memory-safe subset (SafeD)
maintainable, easy to understand code
gradual learning curve (C-like syntax, similar to Java and others)
compatible with C application binary interface
limited compatibility with C++ application binary interface
multi-paradigm (imperative, structured, object oriented, generic,
functional programming purity, and even assembly)
built-in error detection (contracts, unittests)

... and many more {features}.

Take a tour

Want to try D online ? Simply click on the "run" button (or Ctrl-enter) below
the example on the right to compile and run it. And the example can be freely
edited if you want to experiment with D programming.

If you want to see other examples, click on the "next" button below to see the
next example of the dlang-tour.

Further readings

* New to programming? Learn programming quickly and easily with the D language,
using these freely downloadable books :

  * {http://ddili.org/ders/d.en/index.html}
  * {https://www.tutorialspoint.com/d_programming/}

* Already an experienced programmer? ...

  * etc etc ...

Installing D

...

* {https://dlang.org/download.html}

* {https://github.com/BBasile/Coedit};

Moreover I advice there are at least the following code samples for the
Dlang-Tour :

  1. How to declare, initialise and print simple variables (bool, int, float,
string, int[], int[string]).
  2. How to declare simple imperative functions (something like
v=GetFibonacci(n) and GetFibonacci(v,n) with a ref argument)
  3. How to declare classes with attributes and methods
  4. How to declare and use a function like a class method
  5. How to declare and use structs and pointers
  6. How to declare and use a template function

This probably implies that Dlang.org and Dlang-Tour.org are to be merged.

--


Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote:

[..]
Is there a workaround, maybe?


To expand on the earlier workaround: You can also adapt a 
floating point to string algorithm in order to dynamically 
determine an upper bound on the number of after decimal point 
digits required. Below is an untested adaption of the reference C 
implementation of errol0[1] for that purpose (MIT license as that 
is what the original code is under):


---
void main()
{
assert(gcd(0.5, 32) == 0.5);
assert(gcd(0.2, 32) == 0.2);

assert(gcd(1.3e2, 3e-5) == 1e-5);
}

template gcd(T)
{
import std.traits : isFloatingPoint;

T gcd(T a, T b)
{
static if (isFloatingPoint!T)
{
return fgcd(a, b);
}
else
{
import std.numeric : igcd = gcd;
return igcd(a, b);
}
}

static if (isFloatingPoint!T)
{
import std.math : nextUp, nextDown, pow, abs, isFinite;
import std.algorithm : max;

T fgcd(T a, T b)
in
{
assert (a.isFinite);
assert (b.isFinite);
assert (a < ulong.max);
assert (b < ulong.max);
}
body
{
short a_exponent;
int a_digitCount = errol0CountOnly(abs(a), 
a_exponent);


short b_exponent;
int b_digitCount = errol0CountOnly(abs(b), 
b_exponent);


a_digitCount -= a_exponent;
if (a_digitCount < 0)
{
a_digitCount = 0;
}

b_digitCount -= b_exponent;
if (b_digitCount < 0)
{
b_digitCount = 0;
}

auto coeff = pow(10, max(a_digitCount, b_digitCount));
assert (a * coeff < ulong.max);
assert (b * coeff < ulong.max);
return (cast(T) euclid(cast(ulong) (a * coeff),
   cast(ulong) (b * coeff))) / 
coeff;

}

ulong euclid(ulong a, ulong b)
{
while (b != 0)
{
auto t = b;
b = a % b;
a = t;
}
return a;
}

struct HighPrecisionFloatingPoint
{
T base, offset;

void normalize()
{
T base = this.base;

this.base   += this.offset;
this.offset += base - this.base;
}

void mul10()
{
T base = this.base;

this.base   *= T(10);
this.offset *= T(10);

T offset = this.base;
offset -= base * T(8);
offset -= base * T(2);

this.offset -= offset;

normalize();
}

void div10()
{
T base = this.base;

this.base   /= T(10);
this.offset /= T(10);

base -= this.base * T(8);
base -= this.base * T(2);

this.offset += base / T(10);

normalize();
}
}
alias HP = HighPrecisionFloatingPoint;

enum epsilon = T(0.001);
ushort errol0CountOnly(T f, out short exponent)
{
ushort digitCount;

T ten = T(1);
exponent = 1;

auto mid = HP(f, T(0));

while (((mid.base > T(10)) || ((mid.base == T(10)) && 
(mid.offset >= T(0 && (exponent < 308))

{
exponent += 1;
mid.div10();
ten /= T(10);
}

while (((mid.base < T(1)) || ((mid.base == T(1)) && 
(mid.offset < T(0 && (exponent > -307))

{
exponent -= 1;
mid.mul10();
ten *= T(10);
}

auto inhi = HP(mid.base, mid.offset + (nextUp(f) - f) 
* ten / (T(2) + epsilon));
auto inlo = HP(mid.base, mid.offset + (nextDown(f) - 
f) * ten / (T(2) + epsilon));


inhi.normalize();
inlo.normalize();

while (inhi.base > T(10) || (inhi.base == T(10) && 
(inhi.offset >= T(0

{
exponent += 1;
inhi.div10();
inlo.div10();
}

while (inhi.base < T(1) || (inhi.base == T(1) && 
(inhi.offset < T(0

{
exponent -= 1;
inhi.mul10();
inlo.mul10();
}

while (inhi.base != T(0) || inhi.offset != T(0))
{
auto hdig = cast(ubyte) inhi.base;
if ((inhi.base == hdig) && (inhi.offset < T(0)))
{
hdig -= 1;
}

auto ldig = cast(ubyte) inlo.base;
if ((inlo.base == ldig) && (inlo.offset < 0))
{
ldig -= 1;

Re: Comparison of Enumerations with base type of String?

2017-08-27 Thread Jonathan M Davis via Digitalmars-d-learn
On Sunday, August 27, 2017 22:01:52 Michael Reiland via Digitalmars-d-learn 
wrote:
> whoa, you can use a struct as a basetype for an enum?  I'm
> guessing it allows you to associate more information with the
> enum without using lookup tables and the like?  And equality is
> probably just a memberwise comparison of the struct itself?
>
> That seems interesting like an interesting idea, although I'm not
> sure if I'd ever use it.

Yeah, you can use pretty much any type as a base type for an enum - though
once you're dealing with heap-allocated objects, it gets a bit entertaining,
just like it does with enums that are manifest constants. e.g.

enum a = [1, 2, 3];

will allocate that array every time that you use the enum. I don't think
that mutable or const classes will work, but you can also use immutable
classes, which should not result in an allocation every time (since they're
immutable, they can be put in the read-only segment by the compiler like
with string literals), but using structs almost certainly makes more sense
if you really want a user-defined type.

Basically, any time you have a group of constants that you want to treat as
a group of constants, an enum can make sense, even if those constants are
structs. Java implemented enums as classes, so this enables similar
capabilities to what you could do with enums in Java. I can't remember if
I've ever used a enum with a base type of struct though. Usually, I either
need ints or strings. I've definitely used manifest constants that are
structs, but actual enums that are structs are not something that I'v
frequently found useful, much as I'm glad that it's possible.

Ultimately, enums really aren't all that different from anything else with
the same base type except that you can't take their address, they're
basically copy-pasted wherever they're used (though it's the value that's
copy-pasted, not the expression used to create the value - so you wouldn't
end up with something like a struct constructor being called), some
operations aren't legal on them which are legal on the base type (mostly
assignment from non-enums), and anything which explicitly checks that
they're an enum may treat them differently. But overall, you'll mostly get
out of an enum what you'd expect from the base type. The only caveat that I
can think of at the moment with regards to performance is that dynamic
arrays (other than strings) result in an allocation every time they're used,
which can be surprising if you're not aware of it, and that applies to
manifest constants as well as proper enums. Really, manifest constants and
proper enums are pretty much the same thing except that proper enums declare
an actual type with a known set of values, whereas a manifest constant
retains its original type. The performance implications should be the same
though. And the fact that they're so similar is part of why the enum keyword
was reused, even though that annoys some folks, since a manifest constant
isn't really an enum.

- Jonathan M Davis



Re: Unable to set static data member of a class (results in default value 0)

2017-08-27 Thread Adam D. Ruppe via Digitalmars-d-learn

On Sunday, 27 August 2017 at 22:21:11 UTC, Enjoys Math wrote:

   static int dataReadDelay;


That's thread-local. Use shared to make it shared across all 
threads, and/or initialize it in the same thread as the use.



See:
https://dlang.org/migrate-to-shared.html
https://tour.dlang.org/tour/en/multithreading/thread-local-storage


D Tour is down

2017-08-27 Thread Mengu via Digitalmars-d
d tour page is down for at least a week now. someone please fix 
that.


thanks.


Unable to set static data member of a class (results in default value 0)

2017-08-27 Thread Enjoys Math via Digitalmars-d-learn



I have:

class DataSignal : Thread
{
public:
   static int dataReadDelay;

   void run() {
   while (true) {
   Thread.sleep(dur!"msecs"(dataReadDelay));
   // Read in the new file data
   }
   }
}


in main I have:

DataSignal.dataReadDelay = 8000;

// initialize a bunch of signals


Then when each thread is running they sleep for 0 seconds, and I 
can verify that dataReadDelay is staying at 0.  I have 
initialized it no where else.  This seems like a major bug.


Re: Comparison of Enumerations with base type of String?

2017-08-27 Thread Michael Reiland via Digitalmars-d-learn
whoa, you can use a struct as a basetype for an enum?  I'm 
guessing it allows you to associate more information with the 
enum without using lookup tables and the like?  And equality is 
probably just a memberwise comparison of the struct itself?


That seems interesting like an interesting idea, although I'm not 
sure if I'd ever use it.


I'm mostly just trying to get a feel for how things work 
underneath so I have a general understanding of the performance 
implications of things (in a very general sense).


Thanks for the indepth responses, I've learned a few things from 
them.





Re: gcd with doubles

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 27 August 2017 at 19:47:59 UTC, Alex wrote:

Hi, all.
Can anybody explain to me why

void main()
{
import std.numeric;
assert(gcd(0.5,32) == 0.5);
assert(gcd(0.2,32) == 0.2);
}

fails on the second assert?

I'm aware, that calculating gcd on doubles is not so obvios, as 
on integers. But if the library accepts doubles, and basically 
the return is correct occasionally, why it is not always the 
case?


If the type isn't a builtin integral and can't be bit shifted, 
the gcd algorithm falls back to using the Euclidean algorithm in 
order to support custom number types, so the above gdc in the 
above reduces to:


---
double gcd(double a, double b)
{
while (b != 0)
{
auto t = b;
b = a % b;
a = t;
}
return a;
}
---

The issue boils down to the fact that `32 % 0.2` yield `0.2` 
instead of `0.0`, so the best answer I can give is "because 
floating points calculations are approximations". I'm actually 
not sure if this is a bug in fmod or expected behaviour, but I'd 
tend to the latter.



Is there a workaround, maybe?


If you know how many digits of precision after the decimal dot 
you can multiply beforehand, gcd in integer realm, and div 
afterwards (be warned, the below is only an example 
implementation for readability, it does not do the required 
overflow checks for the double -> ulong conversion!):


---
import std.traits : isFloatingPoint;
T gcd(ubyte precision, T)(T a, T b) if (isFloatingPoint!T)
{
import std.numeric : _gcd = gcd;
immutable T coeff = 10 * precision;
return (cast(T) _gcd(cast(ulong) (a * coeff),
 cast(ulong) (b * coeff))) / coeff;
}
---


Re: gcd with doubles

2017-08-27 Thread Alex via Digitalmars-d-learn

ok... googled a little bit.
Seems to be the problem of the kind floating poing <--> decimal...
Will try to get by with some division and lrint logic, as there 
is a lack of definition, how to define a gcd in general case.

For example with 30 and 0.16.
Never mind...


Re: Editor recommendations for new users.

2017-08-27 Thread Ecstatic Coder via Digitalmars-d
I only use vim, including the GUI version when I was on Windows 
a couple years ago, but I recently saw this blog post that 
suggests Sublime would be a good choice for noobs, who might be 
overwhelmed by vim's learning curve and want a more GUI-like 
experience:


https://medium.freecodecamp.org/why-i-still-use-vim-67afd76b4db6


I've already tried Sublime Text, and I agree that it's much more 
user-friendly than Vim.


But Geany is quite close to Sublime Text.

And it's 100% free and open source, really cross-platform, easy 
to download and install (14mb for the windows installer), while 
using very little resources and being very complete and 
user-friendly.


If you need a simple D IDE with all batteries included, I still 
think that CoEdit may be the best option, for the same reasons...


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread ag0aep6g via Digitalmars-d

On 08/27/2017 10:13 PM, Ecstatic Coder wrote:
I still do not understand why they have made so many separated Github 
account for just one website. Just using sub folders on the same Github 
account would have been a much simpler solution, so that it's easy to 
make changes to the website on a more global scale...


The beauty of decentralized, volunteer-driven development.

forum.dlang.org, code.dlang.org, and tour.dlang.org started as 
independent projects by different authors. They were later integrated 
into dlang.org, but so far they remain as separate projects, using 
different technology, having their own maintainers, etc.


I agree that dealing with multiple repositories can be annoying. But 
people have to prioritize what they work on, and merging everything into 
one is probably not high on the list. For the people who maintain it, it 
works reasonably well as it is.


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 20:13:35 UTC, Ecstatic Coder wrote:
Following what you said, I've just looked at both Github 
accounts, and I can clearly see that it's much above my skill 
set to merge the content of both D-based websites so that the 
main page of the Dlang website looks exactly like what I want.


Fair enough, in that case could you open an enhancement request 
over at [1], so it doesn't get lost?


[1] https://issues.dlang.org/


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 19:29:03 UTC, Ryion wrote:
On Sunday, 27 August 2017 at 18:51:00 UTC, Moritz Maxeiner 
wrote:
Thanks, but as I pointed out, the website's design is of no 
interest to me personally.


As I said, you aren't going to change my interests (and I'm 
reasonable convinced you won't change other peoples', either).


Add my voice to that corpus - I honestly don't care what the 
website looks like.


This whole topic is about improving the website. The fact that 
you are already a well versed D programmer that sees no 
usefulness in actually improving the readability of the site is 
irrelevant.


That's a strawmen, since I didn't voice an opinion about it's 
usefulness. I said it doesn't interest me; what *does* interest 
me is trying to ensure that peoples' ideas don't have to die off 
in the forum, i.e. that they know (if they have the time and 
interest) what to do in order for them to be incorporated.




The constant repeating that it does not interest you, simply 
discourages people.


If you recall my initial post, all I did was point out the places 
to send a PR to if he wants the changes to be incorporated. 
W.r.t. expressing my disinterest in the particulars of the topic: 
I've only done so when I judged him to attempt to engage me about 
them in a way where just not replying would've been rude.


Same with pointing out that ( you think ) he can not change 
other people his minds.


My (apparently too implicit) point was that he shouldn't have to 
care about what I, or others, are interested in. If he cares 
about it and has the time and will to do it (which so far I've 
not seen a contrary statement of his to), the way to go is to 
make a PR, because that'll (eventually) yield an official 
reaction by the appropriate people.


I personally think he is right and the site is not information 
friendly. Lots of content does not mean its useful if that 
content is badly presented.


You don't seem to want me to express my (dis)interest in the 
particulars of the topic, yet you respond to me in a way that's 
designed to elicit that response from me. I find that confusing.




If somebody is spending a lot of time simply writing issues 
that they think can be improved, let them try. Even if it dies 
later in the topic.


Why do you imply that I'm trying to stop someone?



If this topic did not exist, i will not have found out that 
Adam has a experimental library, that hands over heels wins 
compared to the current massive text blob. Even if its a few 
versions behind, its way more clean and easy to use the what is 
now on the website.


http://dpldocs.info/experimental-docs/std.html

So at minimum one positive thing came from the topic.


That's why one of my earlier responses contained

Starting and/or participating in discussions can be valuable 
to the community


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d

On Sunday, 27 August 2017 at 19:11:19 UTC, ag0aep6g wrote:

On 08/27/2017 08:07 PM, Ecstatic Coder wrote:
I've already received enough "No, not interested" answers 
till now to the same proposal to think that this will be ok 
this time.


Add my voice to that corpus - I honestly don't care what the 
website looks like.


Ok, message received. At least I've got my answer for the PR. 
Thanks for your honesty. Sincerely.


I'm not sure what you're saying here. Are you not going to make 
a pull request because Moritz isn't interested? If so, you 
should know that he is not the one who decides about this stuff 
(not that he claimed to be). Neither am I. We're just engaging 
in discussion.


Following what you said, I've just looked at both Github 
accounts, and I can clearly see that it's much above my skill set 
to merge the content of both D-based websites so that the main 
page of the Dlang website looks exactly like what I want.


I still do not understand why they have made so many separated 
Github account for just one website. Just using sub folders on 
the same Github account would have been a much simpler solution, 
so that it's easy to make changes to the website on a more global 
scale...


Re: LDC 1.4.0-beta1

2017-08-27 Thread bitwise via Digitalmars-d-announce

On Sunday, 27 August 2017 at 18:30:36 UTC, Joakim wrote:


Yes.

[...]


This is awesome. I appreciate all the hard work.

As far as testing, it will be a while before my current project 
is ready for an android port.






gcd with doubles

2017-08-27 Thread Alex via Digitalmars-d-learn

Hi, all.
Can anybody explain to me why

void main()
{
import std.numeric;
assert(gcd(0.5,32) == 0.5);
assert(gcd(0.2,32) == 0.2);
}

fails on the second assert?

I'm aware, that calculating gcd on doubles is not so obvios, as 
on integers. But if the library accepts doubles, and basically 
the return is correct occasionally, why it is not always the case?

Is there a workaround, maybe?


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ryion via Digitalmars-d

On Sunday, 27 August 2017 at 18:51:00 UTC, Moritz Maxeiner wrote:
Thanks, but as I pointed out, the website's design is of no 
interest to me personally.


As I said, you aren't going to change my interests (and I'm 
reasonable convinced you won't change other peoples', either).


Add my voice to that corpus - I honestly don't care what the 
website looks like.


This whole topic is about improving the website. The fact that 
you are already a well versed D programmer that sees no 
usefulness in actually improving the readability of the site is 
irrelevant.


The constant repeating that it does not interest you, simply 
discourages people. Same with pointing out that ( you think ) he 
can not change other people his minds. I personally think he is 
right and the site is not information friendly. Lots of content 
does not mean its useful if that content is badly presented.


If somebody is spending a lot of time simply writing issues that 
they think can be improved, let them try. Even if it dies later 
in the topic.


If this topic did not exist, i will not have found out that Adam 
has a experimental library, that hands over heels wins compared 
to the current massive text blob. Even if its a few versions 
behind, its way more clean and easy to use the what is now on the 
website.


http://dpldocs.info/experimental-docs/std.html

So at minimum one positive thing came from the topic.


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread ag0aep6g via Digitalmars-d

On 08/27/2017 08:07 PM, Ecstatic Coder wrote:
I've already received enough "No, not interested" answers till now to 
the same proposal to think that this will be ok this time.


Add my voice to that corpus - I honestly don't care what the website 
looks like.


Ok, message received. At least I've got my answer for the PR. Thanks for 
your honesty. Sincerely.


I'm not sure what you're saying here. Are you not going to make a pull 
request because Moritz isn't interested? If so, you should know that he 
is not the one who decides about this stuff (not that he claimed to be). 
Neither am I. We're just engaging in discussion.


Re: Editor recommendations for new users.

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 18:14:07 UTC, Adam D. Ruppe wrote:
On Sunday, 27 August 2017 at 18:08:52 UTC, Moritz Maxeiner 
wrote:
Indeed, but that's only the raw executable, not the full 
package (which includes things like syntax highlighting), 
which adds another 26MB.
But, yes, Textadept and vim+vim-core (Gentoo speak) are both 
gigantic required to bare bones vim. But bare bones vim 
doesn't fulfill the syntax highlighting requirement IIRC.


I don't know how it is packaged on your system, but the vim 
syntax highlighting for D is like 12 KB and pretty easy to just 
drop in and use on its own.


One can definitely splice together one's own minimal vim with D 
support, but that would require more work than simply installing 
the right packages (which I assumed the requirement "simple to 
install" to exclude).
The 26MB I spoke of are localizations (manual, messages, 
keymaps), default shipped .vim files (like netrw, color schemes, 
languages, compiler support), docfiles, and vim-tutor, all of 
which are AFAIK part of the canonical vim distribution.


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 18:07:27 UTC, Ecstatic Coder wrote:
I've already received enough "No, not interested" answers 
till now to the same proposal to think that this will be ok 
this time.


Add my voice to that corpus - I honestly don't care what the 
website looks like.


Ok, message received.


Considering what follows, I'm not sure about that, but OK.


At least I've got my answer for the PR.


Not sure what you mean here, unless you've opened a PR and I 
missed it?
My personal interests have nothing to do with whether a PR would 
get accepted or not by the people in charge of the website, so I 
can't see how you got "your answer for the PR".



Thanks for your honesty. Sincerely.

Now, to be 100% honest with you, I'm still convinced it DOES 
matter, because many people who have heard about D, whether 
it's in a conference, on a blog or article or by a colleague, 
will eventually land on the main page of this website.


Then they will have to decide if they install the compiler and 
learn D, or not.


And I'm pretty sure many won't, for the reasons explained.


That a possibility, but I don't care about whether or not they do.
I care about the quality of D itself as a PL, which in my 
(heavily) biased opinion won't be impacted by people who base 
their tool choices on website design.




Now you know EXACTLY, to the smallest detail, what I would 
personally do to fix that...


So what's stopping you other than pre approval?



And yes, call it masochism, I continue proposing the change 
over and over, because I'm totally convinced that those 
changes to the dlang.org landing page are REALLY needed.


I haven't called it anything, yet, but if I were to call it 
something, it would be insanity, because I see no causal link 
between proposing the same thing repeatedly and other peoples' 
interests.


LOL. Ok so let's be insane once again... ;)

My proposal is to :

[...]


As I said, you aren't going to change my interests (and I'm 
reasonable convinced you won't change other peoples', either). 
The only reason I replied initially was so that whatever the 
prevalent idea was had a chance not to die off in the forum like 
most others who don't have a champion; the particulars of the 
topic itself weren't relevant to me.

What you do with that is up to you.



Still not convinced ?


Convinced of what, exactly?


[...]

Anyway, feel free to copy-paste the changes I've suggested, 
they are 100% free to use...


Thanks, but as I pointed out, the website's design is of no 
interest to me personally.


Re: Editor recommendations for new users.

2017-08-27 Thread Joakim via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic


I only use vim, including the GUI version when I was on Windows a 
couple years ago, but I recently saw this blog post that suggests 
Sublime would be a good choice for noobs, who might be 
overwhelmed by vim's learning curve and want a more GUI-like 
experience:


https://medium.freecodecamp.org/why-i-still-use-vim-67afd76b4db6


Re: LDC 1.4.0-beta1

2017-08-27 Thread Joakim via Digitalmars-d-announce

On Sunday, 27 August 2017 at 15:45:00 UTC, bitwise wrote:

On Saturday, 26 August 2017 at 22:35:11 UTC, kinke wrote:

* Shipping with ldc-build-runtime, a small D tool to easily 
(cross-)compile the runtime libraries yourself.

* Full Android support, incl. emulated TLS.


Does this mean I can actually build D static libraries, link 
them into an NDK shared lib, and use it in a phone app that I 
can submit to Google Play?


Yes.  Just follow these instructions to generate the standard 
library for Android/ARM;


https://wiki.dlang.org/Building_LDC_runtime_libraries

We're still cleaning up loose ends and refining the process 
though.  I forgot that you need to disable building one module 
when cross-compiling the stdlib, as mentioned here:


http://forum.dlang.org/post/jmucnjekkcmiszpag...@forum.dlang.org

Then, you can use a variation of these instructions to build D 
code:


https://wiki.dlang.org/Build_D_for_Android

The problem is those instructions assume you have a ldc2.conf set 
up properly, whereas the new ldc 1.4 beta won't do that for you.  
I'm looking into adding that.


Basically, you can do what you asked now, but while all the 
functionality is there, we're refining the build setup with this 
ldc beta process.  By the final 1.4 release, it should be really 
easy to cross-compile the stdlib and use it, but we're not quite 
there yet.


If you're adventurous, try it out know and let us know what you 
think.  Otherwise, it will get even simpler soon.


Re: Editor recommendations for new users.

2017-08-27 Thread Adam D. Ruppe via Digitalmars-d

On Sunday, 27 August 2017 at 18:08:52 UTC, Moritz Maxeiner wrote:
Indeed, but that's only the raw executable, not the full 
package (which includes things like syntax highlighting), which 
adds another 26MB.
But, yes, Textadept and vim+vim-core (Gentoo speak) are both 
gigantic required to bare bones vim. But bare bones vim doesn't 
fulfill the syntax highlighting requirement IIRC.


I don't know how it is packaged on your system, but the vim 
syntax highlighting for D is like 12 KB and pretty easy to just 
drop in and use on its own.


Re: Editor recommendations for new users.

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 16:22:44 UTC, Jerry wrote:
On Sunday, 27 August 2017 at 15:17:51 UTC, Moritz Maxeiner 
wrote:

On Sunday, 27 August 2017 at 13:15:41 UTC, Ryion wrote:
On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson 
wrote:

The following are a must:
no large install footprint


Visual Studio Code seems to be what you need.

[...]

Relative low memory footprint for the functionality ( 
compared to several IDEs that do the same ).


[...]


The (must) requirement was install footprint, not memory 
footprint, and as Visual Studio code uses the electron 
framework[1] its install footprint is gigantic (about 180MB vs 
e.g. TextAdept's 20MB).


It isn't that gigantic in comparison.


It's nearly ten times the size, so yeah, it is relative to 
Textadept.


You can say the same thing in comparison with vim which is only 
a 2MB install size,

20MB in comparison is gigantic.


Indeed, but that's only the raw executable, not the full package 
(which includes things like syntax highlighting), which adds 
another 26MB.
But, yes, Textadept and vim+vim-core (Gentoo speak) are both 
gigantic required to bare bones vim. But bare bones vim doesn't 
fulfill the syntax highlighting requirement IIRC.


The requirements are rather vague, you can interpret it in a 
number of ways.


The sensible interpretation imho is "as low an install footprint 
as possible while still fulfilling the other requirements". I'm 
not aware of anything below ~20MB install footprint that fulfills 
the other requirements, but I'd be interested if you know any.


I wouldn't consider 200MB gigantic in comparison to 20MB cause 
there is literally no difference of use for me.


The thread is about OP's requirements.


You'd have to have a really shitty laptop for it to be an issue.


Not relevant.


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d
I've already received enough "No, not interested" answers till 
now to the same proposal to think that this will be ok this 
time.


Add my voice to that corpus - I honestly don't care what the 
website looks like.


Ok, message received. At least I've got my answer for the PR. 
Thanks for your honesty. Sincerely.


Now, to be 100% honest with you, I'm still convinced it DOES 
matter, because many people who have heard about D, whether it's 
in a conference, on a blog or article or by a colleague, will 
eventually land on the main page of this website.


Then they will have to decide if they install the compiler and 
learn D, or not.


And I'm pretty sure many won't, for the reasons explained.

Now you know EXACTLY, to the smallest detail, what I would 
personally do to fix that...


And yes, call it masochism, I continue proposing the change 
over and over, because I'm totally convinced that those 
changes to the dlang.org landing page are REALLY needed.


I haven't called it anything, yet, but if I were to call it 
something, it would be insanity, because I see no causal link 
between proposing the same thing repeatedly and other peoples' 
interests.


LOL. Ok so let's be insane once again... ;)

My proposal is to :

1. Say "Welcome"

2. Show how D is nice, ending with a link to the feature page

3. Show how simple D code looks like, using 4 well chosen 
examples, with the first on the right of the main page.


4. Show how easy it is to learn D.

5. Show how easy it is to install DMD and a simple editor like 
CoEdit on any win/mac/linux computer.


In practice, the landing page should be something like that :

"Welcome to D

What is D?

D is the culmination of decades of experience implementing 
compilers for many diverse languages and has a unique set of 
features:


high level constructs for great modeling power
high performance, compiled language
static typing
direct interface to the operating system API's and hardware
blazingly fast compile-times
memory-safe subset (SafeD)
maintainable, easy to understand code
gradual learning curve (C-like syntax, similar to Java and 
others)

compatible with C application binary interface
limited compatibility with C++ application binary interface
multi-paradigm (imperative, structured, object oriented, 
generic, functional programming purity, and even assembly)

built-in error detection (contracts, unittests)

... and many more {features}.

Take a tour

Want to try D online ? Simply click on the "run" button (or 
Ctrl-enter) below the example on the right to compile and run it. 
And the example can be freely edited if you want to experiment 
with D programming.


If you want to see other examples, click on the "next" button 
below to see the next example of the dlang-tour.


Further readings

* New to programming? Learn programming quickly and easily with 
the D language, using these freely downloadable books :


  * {http://ddili.org/ders/d.en/index.html}
  * {https://www.tutorialspoint.com/d_programming/}

* Already an experienced programmer? ...

  * etc etc ...

Installing D

...

* {https://dlang.org/download.html}

* {https://github.com/BBasile/Coedit};

Four D examples for the Dlang-Tour :

  * How to declare, use and print variables (bool, int, float, 
string, int[], int[string]).

  * How to declare imperative functions
  * How to declare classes with attributes and methods
  * How to call functions and methods with the dot notation, with 
or without parentheses


Still not convinced ?

No problem, I don't even know why I care in making D grows its 
community to have more money, and thus more manpower to get 
improved, while the current version is already perfect to my 
personal scripting needs.


Anyway, feel free to copy-paste the changes I've suggested, they 
are 100% free to use...




Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn

On Sunday, 27 August 2017 at 17:36:54 UTC, Cecil Ward wrote:

On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote:

[...]


Static had already been tried. Failed. Thanks to your tip, I 
tried enum next. Failed as well, wouldn't compile with GDC.


[...]


I wonder if there is anything written up anywhere about what 
kinds of things are blockers to either CTFE or to successful 
constant-folding optimisation in particular compilers or in 
general?


Would be useful to know what to stay away from if you really need 
to make sure that horrendously slow code does not get run at 
runtime. Sometimes it is possible or even relatively easy to 
reorganise things and do without certain practices in order to 
win such a massive reward.


Re: No CTFE of function

2017-08-27 Thread Cecil Ward via Digitalmars-d-learn

On Sunday, 27 August 2017 at 00:20:47 UTC, ag0aep6g wrote:

On 08/27/2017 01:53 AM, Cecil Ward wrote:

On Saturday, 26 August 2017 at 23:49:30 UTC, Cecil Ward wrote:

[...]
I think I understand, but I'm not sure. I should have 
explained properly. I suspect what I should have said was 
that I was expecting an _optimisation_ and I didn't see it. I 
thought that a specific instance of a call to my pure 
function that has all compile-time-known arguments would just 
produce generated code that returned an explicit constant 
that is worked out by CTFE calculation, replacing the actual 
code for the general function entirely. So for example


auto foo() { return bar( 2, 3 ); }

(where bar is strongly pure and completely CTFE-able) should 
have been replaced by generated x64 code looking exactly 
literally like

auto foo() { return 5; }
expect that the returned result would be a fixed-length 
literal array of 32-but numbers in my case (no dynamic arrays 
anywhere, these I believe potentially involve RTL calls and 
the allocator internally).


I was expecting this optimisation to 'return literal constant 
only' because I have seen it before in other cases with GDC. 
Obviously generating a call that involves running the 
algorithm at runtime is a performance disaster when it 
certainly could have all been thrown away in the particular 
case in point and been replaced by a return of a precomputed 
value with zero runtime cost. So this is actually an issue 
with specific compilers, but I was wondering if I have missed 
anything about any D general rules that make CTFE evaluation 
practically impossible?


I don't know what might prevent the optimization.

You can force (actual) CTFE with an enum or static variable.
Then you don't have to rely on the optimizer. And the compiler 
will reject the code if you try something that can't be done at 
compile time.


Example:

auto foo() { enum r = bar(2, 3); return r; }


Please don't use the term "CTFE" for the optimization. The two 
are related, of course. The optimizer may literally evaluate 
functions at compile time. But I think we better reserve the 
acronym "CTFE" for the guaranteed/forced kind of 
precomputation, to avoid confusion.


Static had already been tried. Failed. Thanks to your tip, I 
tried enum next. Failed as well, wouldn't compile with GDC.


I tried LDC, which did the right thing in all cases. Optimised 
correctly in every use case to not compute in the generated code, 
just return the literal compile-time calculated result array by 
writing a load of immediate values straight to the destination. 
Hurrah for LDC.


Then tried DMD via web-based edit/compile feature at dlang.org 
website. Refused to compile in the enum case and actually told me 
why, in a very very cryptic way. I worked out that it has a 
problem internally (this is a now an assignment into an enum, so 
I have permission to use the term CTFE now) in that it refuses to 
do CTFE if any variable is declared using an =void initialiser to 
stop the wasteful huge pre-fill with zeros which could take half 
an hour on a large object with slow memory and for all I know 
play havoc with the cache. So simply deleting the = void fixed 
the problem with DMD.


So that's it. There are unknown random internal factors that 
prevent CTFE or CTFE-type optimisation.


I had wondered if pointers might present a problem. The function 
in question originally was specced something like

pure nothrow @nogc @safe
void pure_compute( result_t * p_result, in input_t x )

and just as a test, I tried changing it to

result_t  pure_compute( in input_t x )

instead. I don't think it makes any difference though. I 
discovered the DMD -void thing at that point so this was not 
checked out properly.


Your enum tip was very helpful.

Ps
GDC errors: Another thing that has wasted a load of time is that 
GDC signals errors on lines where there is a function call that 
is fine, yet the only problem is in the body of the function that 
is _being_ called itself, and fixing the function makes the 
phantom error at the call-site go away. This nasty behaviour has 
you looking for errors at and before the call-site, or thinking 
you have the spec of the call args wrong or incorrect types. 
[Compiler-Explorer problem : I am perhaps blaming GDC unfairly, 
because I have only ever used it through the telescope that is 
d.godbolt.org and I am assuming that reports errors on the 
correct source lines. It doesn't show error message text tho, 
which is a nightmare, but nothing to do with the compiler 
obviously.]





Re: Editor recommendations for new users.

2017-08-27 Thread Jerry via Digitalmars-d

On Sunday, 27 August 2017 at 15:17:51 UTC, Moritz Maxeiner wrote:

On Sunday, 27 August 2017 at 13:15:41 UTC, Ryion wrote:
On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson 
wrote:

The following are a must:
no large install footprint


Visual Studio Code seems to be what you need.

[...]

Relative low memory footprint for the functionality ( compared 
to several IDEs that do the same ).


[...]


The (must) requirement was install footprint, not memory 
footprint, and as Visual Studio code uses the electron 
framework[1] its install footprint is gigantic (about 180MB vs 
e.g. TextAdept's 20MB).


It isn't that gigantic in comparison. You can say the same thing 
in comparison with vim which is only a 2MB install size, 20MB in 
comparison is gigantic. The requirements are rather vague, you 
can interpret it in a number of ways. I wouldn't consider 200MB 
gigantic in comparison to 20MB cause there is literally no 
difference of use for me. You'd have to have a really shitty 
laptop for it to be an issue.


Re: How to implement Timeout function

2017-08-27 Thread Saigon via Digitalmars-d-learn

On Sunday, 27 August 2017 at 15:56:55 UTC, Jerry wrote:

On Sunday, 27 August 2017 at 15:56:14 UTC, Saigon wrote:

Hi,

Can I have Timeout function like this one [1] in Ruby? I want 
to check if a TCP service is running, and the check would 
return error if timeout occurs.


Thanks a lot

[1] https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb


Can it be blocking?


Yes it can in my case.


Re: How to implement Timeout function

2017-08-27 Thread Jerry via Digitalmars-d-learn

On Sunday, 27 August 2017 at 15:56:14 UTC, Saigon wrote:

Hi,

Can I have Timeout function like this one [1] in Ruby? I want 
to check if a TCP service is running, and the check would 
return error if timeout occurs.


Thanks a lot

[1] https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb


Can it be blocking?



How to implement Timeout function

2017-08-27 Thread Saigon via Digitalmars-d-learn

Hi,

Can I have Timeout function like this one [1] in Ruby? I want to 
check if a TCP service is running, and the check would return 
error if timeout occurs.


Thanks a lot

[1] https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb


Re: LDC 1.4.0-beta1

2017-08-27 Thread bitwise via Digitalmars-d-announce

On Saturday, 26 August 2017 at 22:35:11 UTC, kinke wrote:

* Shipping with ldc-build-runtime, a small D tool to easily 
(cross-)compile the runtime libraries yourself.

* Full Android support, incl. emulated TLS.


Does this mean I can actually build D static libraries, link them 
into an NDK shared lib, and use it in a phone app that I can 
submit to Google Play?


[Issue 17788] New: MSCOFF: TLS broken when linking with linker from VS2017 15.3.1

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17788

  Issue ID: 17788
   Summary: MSCOFF: TLS broken when linking with linker from
VS2017 15.3.1
   Product: D
   Version: D2
  Hardware: x86_64
OS: Windows
Status: NEW
  Severity: major
  Priority: P1
 Component: druntime
  Assignee: nob...@puremagic.com
  Reporter: r.sagita...@gmx.de

When linking with the recent update 15.3.1 of VS2017, TLS ranges are broken:

/
module tls;
import core.stdc.stdio;

int x = 7;

extern(C) extern
{
int _tls_start;
int _tls_end;
}

void[] initTLSRanges() nothrow @nogc
{
auto pbeg = cast(void*)&_tls_start;
auto pend = cast(void*)&_tls_end;
return pbeg[0 .. pend - pbeg];
}

void main()
{
printf("%p: %d\n", , x);

auto r = initTLSRanges();
printf("%p: %d\n", r.ptr, r.length);

assert(r.ptr <=  &&  < r.ptr + r.length);
}

/

compile with "dmd -m64 tls.d" or "dmd -m32mscoff tls.d" to produce an
executable that triggers the assert.

This works with older VS linker versions (up to update 2 of VS2017). 

This seems caused by the linker treating _tls_start and _tls_end no longer as
thread local (or rather the segments they are in). TLS segments are no longer a
separate section in the final image, but just part of the DATA section.

--


Re: Editor recommendations for new users.

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 13:15:41 UTC, Ryion wrote:
On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson 
wrote:

The following are a must:
no large install footprint


Visual Studio Code seems to be what you need.

[...]

Relative low memory footprint for the functionality ( compared 
to several IDEs that do the same ).


[...]


The (must) requirement was install footprint, not memory 
footprint, and as Visual Studio code uses the electron 
framework[1] its install footprint is gigantic (about 180MB vs 
e.g. TextAdept's 20MB).


Re: LDC 1.4.0-beta1

2017-08-27 Thread Jon Degenhardt via Digitalmars-d-announce

On Saturday, 26 August 2017 at 22:35:11 UTC, kinke wrote:

Hi everyone,

on behalf of the LDC team, I'm glad to announce LDC 
1.4.0-beta1. The highlights of version 1.4 in a nutshell:


* Based on D 2.074.1.
* Shipping with ldc-build-runtime, a small D tool to easily 
(cross-)compile the runtime libraries yourself.

* Full Android support, incl. emulated TLS.
* Improved support for AddressSanitizer and libFuzzer. The 
libraries are shipped with the prebuilt Linux x86_64 and OSX 
packages.
* Prebuilt Linux x86_64 package shipping with LTO plugin, 
catching up with the OSX package.


Full release log and downloads: 
https://github.com/ldc-developers/ldc/releases/tag/v1.4.0-beta1


Thanks to everybody contributing!


Wow, this looks fantastic, congrats!

--Jon


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 13:12:22 UTC, Ecstatic Coder wrote:
I agree, but here it's not a local modification I've done to a 
D library that I want to push so that other people can use it 
too.


It's a change to the main landing page of the dlang.org 
website, which is by definition global and can ONLY be 
validated by those in charge of it.


Which - as I've pointed out - is much likelier to occur if you 
open a PR.




If those people in charge like the idea, then it's fine by me 
to translate the idea into physical changes through a PR.


That's your prerogative, but preapproval is extremely unlikely to 
occur.




But if not, it's a complete loss of time, and sorry to say it, 
but from what I've seen, there are VERY LITTLE chances these 
changes gets validated.


I've already received enough "No, not interested" answers till 
now to the same proposal to think that this will be ok this 
time.


Add my voice to that corpus - I honestly don't care what the 
website looks like.




And yes, call it masochism, I continue proposing the change 
over and over, because I'm totally convinced that those changes 
to the dlang.org landing page are REALLY needed.


I haven't called it anything, yet, but if I were to call it 
something, it would be insanity, because I see no causal link 
between proposing the same thing repeatedly and other peoples' 
interests.
I'm reasonably confident it would've taken you less time to do 
that PR than writing your posts on this topic and reading 
peoples' replies already took from you; the difference between 
the two being that you're no closer to getting your changes 
through right now (or even receiving a definite answer), whereas 
if you had opened the PR you could've already moved on to the 
next thing of interest to you, instead of remaining in the 
current loop of "post idea" -> "wait -> "don't get preapproval" 
-> "wait" -> ...
If you open a PR, it's likely to eventually receive a review that 
will either result in rejection, merging, or a discussion. In 
either case, you're free to pursue other things in the meantime 
and as long as the PR remains open, the changes aren't lost.




That's what the other languages do, it works well for them, and 
NO, I don't see the advantages in doing the opposite of what 
works well for the others.


And if you want to see change, it'll take you to champion it via 
a PR (and defending it in the resulting discussion).




It's not plagiarism, it's just common sense...


No idea why you think I would care, since programming languages 
have always been about copying good stuff from others.




Re: getting dcd completions for dub installed modules

2017-08-27 Thread user123 via Digitalmars-d

On Sunday, 27 August 2017 at 14:26:20 UTC, Fra Mecca wrote:

Hi all,
I was wondering how do you get dcd-server to import packages 
installed from dub in ~/.dub


The most generic way is to use the config file:

https://github.com/dlang-community/DCD#configuration-files

but your editor may have a system that does the same.
The one i use does this automatically for the projects lelvel 1 
deps and has also a GUI to edit the path that are known by DCD.


getting dcd completions for dub installed modules

2017-08-27 Thread Fra Mecca via Digitalmars-d

Hi all,
I was wondering how do you get dcd-server to import packages 
installed from dub in ~/.dub


Re: Getting error in dmd testsuite

2017-08-27 Thread Joakim via Digitalmars-d-learn

On Saturday, 26 August 2017 at 21:59:10 UTC, Thomas Mader wrote:

Hello,

I am building ldc on Nix (https://nixos.org/nix/) but keep 
getting an error while running the cppa.d test from the dmd 
testsuite (https://github.com/ldc-developers/dmd-testsuite).


1588:  ... runnable/cppa.d -L-lstdc++ (-g) -O
1588: Test failed.  The logged output:
1588: /tmp/nix-build-ldc-1.3.0.drv-0/build/bin/ldmd2 -conf= 
-m64 -Irunnable  -L-lstdc++  
-od/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable 
-of/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0 runnable/cppa.d /tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppb.cpp.o
1588: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0.o: In function `_Dmain':
1588: runnable/cppa.d:(.text._Dmain[_Dmain]+0x49f): undefined 
reference to `int foo15372(int)'
1588: runnable/cppa.d:(.text._Dmain[_Dmain]+0x4b2): undefined 
reference to `Foo15802::boo(int)'
1588: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0.o:(.data.rel.ro._D4cppa6C131616__vtblZ[_D4cppa6C131616__vtblZ]+0x0): undefined reference to `C13161::dummyfunc()'
1588: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0.o:(.data.rel.ro._D4cppa4Test6__vtblZ[_D4cppa4Test6__vtblZ]+0x0): undefined reference to `C13161::dummyfunc()'
1588: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0.o:(.data.rel.ro._D4cppa7C13161a6__vtblZ[_D4cppa7C13161a6__vtblZ]+0x0): undefined reference to `C13161a::dummyfunc()'
1588: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa_0.o:(.data.rel.ro._D4cppa5Testa6__vtblZ[_D4cppa5Testa6__vtblZ]+0x0): undefined reference to `C13161a::dummyfunc()'

1588: collect2: error: ld returned 1 exit status
1588: Error: 
/nix/store/df84hkmhrhx1c2zpvrhmk6aprhlzkasx-gcc-wrapper-6.4.0/bin/gcc failed with status: 1

1588:
1588:
1588: ==
1588: Test failed: expected rc == 0, exited with rc == 1
1588:
1588: make[2]: *** [Makefile:335: 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppa.d.out] Error 1


Apart from that all other tests pass.
Any ideas?

It's running on Linux with gcc 6.4.0.


That module tests linking with C++ files, looks like you have 
some symbols that don't match up.  That's weird, because those 
normally work with gcc.  For each of them, use the readelf 
command from binutils to compare the symbols generated and see 
how they differ.  For example,


readelf -sW 
/tmp/nix-build-ldc-1.3.0.drv-0/build/dmd-testsuite/runnable/cppb.cpp.o |grep foo15372


Then run the same command on the D side, ie for cppa_0.o, and 
compare the symbols.


File a bug on the ldc github if you can't figure it out:

https://github.com/ldc-developers/ldc/issues


Re: 2 Dimensional Array Sorting

2017-08-27 Thread Vino.B via Digitalmars-d-learn

On Sunday, 27 August 2017 at 11:53:29 UTC, Vino.B wrote:

On Saturday, 26 August 2017 at 10:53:03 UTC, Vino.B wrote:

[...]


Hi,

  After analyzing a bit further was able to find that the  out 
data before sorting is like below(4 - 2 dimensional array) 
hence the sorting is not working, so may i know how do i make 
this as a single 2 dimensional array like below


[...]


Hi,

  Thank you very much, was able to resolve the issue.

From,
Vino.B


Re: Editor recommendations for new users.

2017-08-27 Thread Ryion via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?


Visual Studio Code seems to be what you need.

https://code.visualstudio.com/

Easy to install, Support Windows, Linux, Mac. Has plugin support 
from WebFreak001 his Code-D / Serve-D(beta) plugin.


Kitchen and sink support. Easy to use ( as seen with the 
popularity ). Relative low memory footprint for the functionality 
( compared to several IDEs that do the same ).


Moved to Visual Studio Code a long time ago and loving it. They 
are now adding multiple workspaces to the editor, to make things 
more easy for people and plugin architecture. Did i mention 
massive plugins?


Git Integration to make it easier to teach people what Git is and 
what the difference it makes in programming projects.


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d
I agree, but here it's not a local modification I've done to a D 
library that I want to push so that other people can use it too.


It's a change to the main landing page of the dlang.org website, 
which is by definition global and can ONLY be validated by those 
in charge of it.


If those people in charge like the idea, then it's fine by me to 
translate the idea into physical changes through a PR.


But if not, it's a complete loss of time, and sorry to say it, 
but from what I've seen, there are VERY LITTLE chances these 
changes gets validated.


I've already received enough "No, not interested" answers till 
now to the same proposal to think that this will be ok this time.


And yes, call it masochism, I continue proposing the change over 
and over, because I'm totally convinced that those changes to the 
dlang.org landing page are REALLY needed.


That's what the other languages do, it works well for them, and 
NO, I don't see the advantages in doing the opposite of what 
works well for the others.


It's not plagiarism, it's just common sense...


Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote:

[...]

Oh interesting.  Does DUB support passing through the 
--enable-contracts flag to ldc?  Also, if this is an ldc 
specific thing it's probably not a good idea i'd imagine, since 
in the future one may want to use a GDC, or DMD?


Also, with regards to gdc, its release mode `-frelease` option is 
explicitly specified in the manual as being shorthand for a 
specific set of options:



This is equivalent to compiling with the following options:

gdc -fno-assert -fbounds-check=safe -fno-invariants \
-fno-postconditions -fno-preconditions -fno-switch-errors


As it doesn't seem to turn on/off any other options / 
optimizations, you can use `"dflags-gdc": [...]` to specify your 
own set of "release" options without losing anything.
In particular, I would overwrite dub's default "release" build 
type [1] and add your own per compiler build settings, so dub 
won't pass `-frelease` to gdc when using `dub --build=release`.


[1] https://code.dlang.org/package-format?lang=json#build-types


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 11:50:18 UTC, Ecstatic Coder wrote:
On Sunday, 27 August 2017 at 11:36:57 UTC, Moritz Maxeiner 
wrote:
On Sunday, 27 August 2017 at 11:26:58 UTC, Ecstatic Coder 
wrote:

[...]

Just add the 4 examples I suggested, and you have a brand-new 
beginner-friendly website without changing anything else to 
the website canvas.


If you want a change in D's web presence submit a PR to [1] or 
one of [2] as appropriate.


[1] https://github.com/dlang/dlang.org
[2] https://github.com/dlang-tour


No problem, but first I'd like to have the design changes 
validated prior to making them.


That's how web developers do with their customers.

1. suggest the changes
2. have the changes accepted
3. make the changes


Unless I've missed you being contracted to do these changes, this 
model doesn't apply. It's not other people who want you to do 
some work (and as they are paying you have a vested interest in 
evaluating it), it's you who wants changes.




Because there is no interest in making changes that won't be 
accepted eventually...


To be frank, this is how things usually get done in open source 
(outside of corporate interests):
One commits to doing something, does it, then asks for people to 
review the result, and finally tries to get it accepted.
One does this often enough successfully in a particular group of 
people and one earns recognition by their group peers 
(reputation).
Starting and/or participating in discussions can be valuable to 
the community and may yield reputation, as well, but one can't 
realistically expect receiving preapproval for ideas unless one 
has proven to actually follow through on them and contribute 
tangible results.


[1] And you do this often enough successfully in a particular 
project you earn recognition there


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ryion via Digitalmars-d

On Sunday, 27 August 2017 at 00:05:00 UTC, Adam D. Ruppe wrote:

On Saturday, 26 August 2017 at 23:53:27 UTC, Ryion wrote:
I have the same issue with the Library. The flow of 
information is bad, too much walls of text, with too much 
assumption that


Have you tried my alternative? It is the same content (well it 
lags a version or two cuz i haven't updated my computer yet) 
but laid out differently.


http://dpldocs.info/

http://dpldocs.info/experimental-docs/std.stdio.html
for example


It looks a lot better Adam, especially compared to the D website 
design. I am even willing to bet that it has much better results 
with Search Engines, because it has separate pages.


In my opinion its much more inline with my expectation for a 
programming language documentation. Nice job Adam! Going to 
bookmark it and use that as my reference.


Re: Editor recommendations for new users.

2017-08-27 Thread Ecstatic Coder via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic


+1 for Geany

If it's to learn D programming, then I strongly advice CoEdit 
(despite I think that Geany's automatic brace insertion and copy 
paste features work MUCH better).


Re: Editor recommendations for new users.

2017-08-27 Thread via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic


vim or SublimeText


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d

On Sunday, 27 August 2017 at 11:36:57 UTC, Moritz Maxeiner wrote:

On Sunday, 27 August 2017 at 11:26:58 UTC, Ecstatic Coder wrote:

[...]

Just add the 4 examples I suggested, and you have a brand-new 
beginner-friendly website without changing anything else to 
the website canvas.


If you want a change in D's web presence submit a PR to [1] or 
one of [2] as appropriate.


[1] https://github.com/dlang/dlang.org
[2] https://github.com/dlang-tour


No problem, but first I'd like to have the design changes 
validated prior to making them.


That's how web developers do with their customers.

1. suggest the changes
2. have the changes accepted
3. make the changes

Because there is no interest in making changes that won't be 
accepted eventually...


Re: 2 Dimensional Array Sorting

2017-08-27 Thread Vino.B via Digitalmars-d-learn

On Saturday, 26 August 2017 at 10:53:03 UTC, Vino.B wrote:

On Saturday, 26 August 2017 at 10:45:13 UTC, Vino.B wrote:

On Saturday, 26 August 2017 at 10:07:53 UTC, user1234 wrote:

[...]


Hi,

 Now there is no duplicate , but the sequence is still not 
correct


[...]


Hi,

  If I execute the script several time's i still get the 
duplicate entries.


From,
Vino.B


Hi,

  After analyzing a bit further was able to find that the  out 
data before sorting is like below(4 - 2 dimensional array) hence 
the sorting is not working, so may i know how do i make this as a 
single 2 dimensional array like below


Required:
[["C:\\Temp\\TEAM2\\TEAM\\DIR1", "40"], 
["C:\\Temp\\TEAM2\\TEAM\\DIR2", "2228"], 
["C:\\Temp\\TEAM3\\EXPORT\\dir2", "61"], 
["C:\\Temp\\TEAM2\\PROD_TEAM\\dir1", "35772"], 
["C:\\Temp\\TEAM2\\BACKUP\\dir1", "35732"], 
["C:\\Temp\\TEAM3\\BACKUP\\dir1", "71465"], 
["C:\\Temp\\TEAM2\\EXPORT\\dir2", "30"]]


Output:
[["C:\\Temp\\TEAM2\\TEAM\\DIR1", "40"], 
["C:\\Temp\\TEAM2\\TEAM\\DIR2", "2228"], 
["C:\\Temp\\TEAM3\\EXPORT\\dir2", "61"]] - 2darray 1


[["C:\\Temp\\TEAM2\\PROD_TEAM\\dir1", "35772"]] - 2darray 2

[["C:\\Temp\\TEAM2\\BACKUP\\dir1", "35732"], 
["C:\\Temp\\TEAM3\\BACKUP\\dir1", "71465"]]  - 2darray 3


[["C:\\Temp\\TEAM2\\EXPORT\\dir2", "30"]]  - 2darray 4

From,
Vino.B



Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d
And I'd like to point out that maybe I'm not the best web 
developer in the world, but what I suggest is quite close to what 
you can see on the website of very successful programming 
languages.


I'm only suggesting to have a SIMPLE and PRACTICAL landing page, 
which is also tailored for those who are completely NEW to D or 
even to programming, and just landed on this web page by 
CURIOSITY about the language.


If you succeed in convincing them that D is good for them, and 
that D can be easily installed and learned, then there are great 
chances they will become D programmers.


So basically my advice for the landing page is as simple as that :

1. Say "Welcome"

2. Show how D is nice, ending with a link to the feature page

3. Show how simple D code looks like, using 4 well chosen 
examples, with the first on the right of the main page.


4. Show how easy it is to learn D.

5. Show how easy it is to install DMD and a simple editor like 
CoEdit on any win/mac/linux computer.


That's all I suggest...


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 11:26:58 UTC, Ecstatic Coder wrote:

[...]

Just add the 4 examples I suggested, and you have a brand-new 
beginner-friendly website without changing anything else to the 
website canvas.


If you want a change in D's web presence submit a PR to [1] or 
one of [2] as appropriate.


[1] https://github.com/dlang/dlang.org
[2] https://github.com/dlang-tour


Re: Promoting TutorialsPoint's D tutorial

2017-08-27 Thread Ecstatic Coder via Digitalmars-d
You're reading the spec. Teaching is not the spec's first 
priority. It's not a tutorial or a programming textbook.


Have you tried Ali's book? The page on modules is here:

http://ddili.org/ders/d.en/modules.html

Wait a second. Large parts of that are word-for-word the same 
as on the tutorialspoint page [1]. Looks like one of the 
authors copied from the other one. From the bad impression I've 
got of tutorialspoint, I'd guess that they copied from Ali.



[1] 
https://www.tutorialspoint.com/d_programming/d_programming_modules.htm


Ok I understand your point.

But sorry to repeat myself, but IMO, for D beginners, dlang.org 
is at best, a labyrinth, at worst, a complete mess.


Very honestly.

https://tour.dlang.org/

I'm still convinced that this page is tweaked to become the new 
main landing page.


"Welcome to D

What is D?

D is the culmination of decades of experience implementing 
compilers for many diverse languages and has a unique set of 
features:


high level constructs for great modeling power
high performance, compiled language
static typing
direct interface to the operating system API's and hardware
blazingly fast compile-times
memory-safe subset (SafeD)
maintainable, easy to understand code
gradual learning curve (C-like syntax, similar to Java and 
others)

compatible with C application binary interface
limited compatibility with C++ application binary interface
multi-paradigm (imperative, structured, object oriented, 
generic, functional programming purity, and even assembly)

built-in error detection (contracts, unittests)

... and many more {features}.

Take a tour

Want to try D online ? Simply click on the "run" button (or 
Ctrl-enter) below the example on the right to compile and run it. 
And the example can be freely edited if you want to experiment 
with D programming.


If you want to see other examples, click on the "next" button 
below to see the next example of the dlang-tour.


Further readings

* New to programming? Learn programming quickly and easily with 
the D language, using these freely downloadable books :


  * {http://ddili.org/ders/d.en/index.html}
  * {https://www.tutorialspoint.com/d_programming/}

* Already an experienced programmer? ...

etc"

Just add the 4 examples I suggested, and you have a brand-new 
beginner-friendly website without changing anything else to the 
website canvas.




Re: Editor recommendations for new users.

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic


Textadept [1] matches your requirements.
I found it lightweight, responsive, and easy to use
I'm only on Sublime Text [2][3] because it's shinier.

[1] https://foicica.com/textadept/
[2] https://www.sublimetext.com/
[3] Depending on your definition of free (libre vs beer) it might 
also qualify


Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 27 August 2017 at 10:46:53 UTC, Andrew Chapman wrote:
On Sunday, 27 August 2017 at 10:37:50 UTC, Moritz Maxeiner 
wrote:

[...]


Oh interesting.  Does DUB support passing through the 
--enable-contracts flag to ldc?


Sure, using platform specific build settings [1] such as 
`"dflags-ldc": ["--enable-contracts"]`.


Also, if this is an ldc specific thing it's probably not a good 
idea i'd imagine, since in the future one may want to use a 
GDC, or DMD?


If you want to use another compiler that supports it, add the 
appropriate "dflags-COMPILER" setting to your package file.
With regards to dmd: Don't use it for release builds, use gdc or 
ldc (better optimizations).


https://code.dlang.org/package-format?lang=json#build-settings


Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn

On Sunday, 27 August 2017 at 10:37:50 UTC, Moritz Maxeiner wrote:

On Sunday, 27 August 2017 at 10:17:47 UTC, Andrew Chapman wrote:

On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote:

[...]


Thanks, that explains it.  I think it's a bit of a shame that 
the "in" blocks can't be used in release mode as the clarity 
they provide for precondition logic is wonderful.


If you need that, you could compile using ldc in release mode 
(which you probably want to do anyway):


--- test.d ---
import std.exception;
import std.stdio;

void foo(int x) in { enforce(x > 0); } body
{

}

void bar(int x) in { assert(x > 0); } body
{

}

void baz(int x) in { if (!(x > 0)) assert(0); } body
{

}

void main()
{
(-1).foo.assertThrown;
(-1).bar;
(-1).baz;
}
--

$ ldc2 test.d
-> failed assert in bar's in contract terminates the program

$ ldc2 -release test.d
-> failed assertThrown in main terminates the program

$ ldc2 -release -enable-contracts test.d
-> failed assert in baz's in contract terminates the program

$ ldc2 -release -enable-contracts -enable-asserts test.d
-> failed assert in bar's in contract terminates the program


Oh interesting.  Does DUB support passing through the 
--enable-contracts flag to ldc?  Also, if this is an ldc specific 
thing it's probably not a good idea i'd imagine, since in the 
future one may want to use a GDC, or DMD?


Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Moritz Maxeiner via Digitalmars-d-learn

On Sunday, 27 August 2017 at 10:17:47 UTC, Andrew Chapman wrote:

On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote:

On 08/27/2017 12:02 PM, Andrew Chapman wrote:
However, I am finding that BOTH enforce and assert are 
compiled out by dmd and ldc in release mode.  Is there a 
standard way of doing what enforce does inside an "in" 
contract block that will work in release mode?


I'm guessing I should write my own function for now.
The whole `in` block is ignored in release mode. Doesn't 
matter what you put in there. Nothing of it will be compiled.


Thanks, that explains it.  I think it's a bit of a shame that 
the "in" blocks can't be used in release mode as the clarity 
they provide for precondition logic is wonderful.


If you need that, you could compile using ldc in release mode 
(which you probably want to do anyway):


--- test.d ---
import std.exception;
import std.stdio;

void foo(int x) in { enforce(x > 0); } body
{

}

void bar(int x) in { assert(x > 0); } body
{

}

void baz(int x) in { if (!(x > 0)) assert(0); } body
{

}

void main()
{
(-1).foo.assertThrown;
(-1).bar;
(-1).baz;
}
--

$ ldc2 test.d
-> failed assert in bar's in contract terminates the program

$ ldc2 -release test.d
-> failed assertThrown in main terminates the program

$ ldc2 -release -enable-contracts test.d
-> failed assert in baz's in contract terminates the program

$ ldc2 -release -enable-contracts -enable-asserts test.d
-> failed assert in bar's in contract terminates the program


Re: Editor recommendations for new users.

2017-08-27 Thread Dukc via Digitalmars-d

On Sunday, 27 August 2017 at 10:05:29 UTC, Nicholas Wilson wrote:
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic


Those all apply to Geany. It's much like Notepad++ but 
crossplatform.


I'm sure there are other good options too. The problem with geany 
is that it's syntax highlighting and auto-completion depend on 
having the file where the symbol's defined open. But that's 
because it's primarily a lightweight editor, not so much an IDE. 
It has some ide features, but I am not using them and don't know 
whether you can could solve these by creating a geny project.


Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn

On Sunday, 27 August 2017 at 10:08:15 UTC, ag0aep6g wrote:

On 08/27/2017 12:02 PM, Andrew Chapman wrote:
However, I am finding that BOTH enforce and assert are 
compiled out by dmd and ldc in release mode.  Is there a 
standard way of doing what enforce does inside an "in" 
contract block that will work in release mode?


I'm guessing I should write my own function for now.
The whole `in` block is ignored in release mode. Doesn't matter 
what you put in there. Nothing of it will be compiled.


Thanks, that explains it.  I think it's a bit of a shame that the 
"in" blocks can't be used in release mode as the clarity they 
provide for precondition logic is wonderful.


Editor recommendations for new users.

2017-08-27 Thread Nicholas Wilson via Digitalmars-d
So I will be doing a workshop on programming for the biology 
department at my university and I was wondering what would best 
suit the users.


The following are a must:
support windows & mac ( the more consistent between the two 
the better)

free
no large install footprint, preferably simple install 
procedure (running on laptops)

syntax highlighting
straightforward to use

anything else is a bonus.

Whats your experience with what you use?

Many thanks
Nic




Re: Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread ag0aep6g via Digitalmars-d-learn

On 08/27/2017 12:02 PM, Andrew Chapman wrote:
However, I am finding that BOTH enforce and assert are compiled out by 
dmd and ldc in release mode.  Is there a standard way of doing what 
enforce does inside an "in" contract block that will work in release mode?


I'm guessing I should write my own function for now.
The whole `in` block is ignored in release mode. Doesn't matter what you 
put in there. Nothing of it will be compiled.


Making a repo of downloaded dub package

2017-08-27 Thread Dukc via Digitalmars-d-learn
More than once I have downloaded a DUB package which almost 
compiles but not quite. The fixes are often so trivial that even 
the user can do them, and the package starts working.


But one may want to create a pull request to fix those issues for 
others too. Is there any way to make the automatically downloaded 
dub package into a git repository which acts as if cloned from 
GitHub before making the changes?


[Issue 17787] Add a BetterC predefined version so libraries can adapt

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17787

ZombineDev  changed:

   What|Removed |Added

   Keywords||betterC, spec
   See Also||https://issues.dlang.org/sh
   ||ow_bug.cgi?id=17786

--


[Issue 17786] Define the FreeStanding subset of betterC

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17786

ZombineDev  changed:

   What|Removed |Added

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

--


Confusion over enforce and assert - both are compiled out in release mode

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn
In the docs regarding contract programming and the use of enforce 
/ assert:

https://dlang.org/library/std/exception/enforce.html

it says:

"enforce is used to throw exceptions and is therefore intended to 
aid in error handling. It is not intended for verifying the logic 
of your program. That is what assert is for. Also, do not use 
enforce inside of contracts (i.e. inside of in and out blocks and 
invariants), because they will be compiled out when compiling 
with -release. Use assert in contracts."


However, I am finding that BOTH enforce and assert are compiled 
out by dmd and ldc in release mode.  Is there a standard way of 
doing what enforce does inside an "in" contract block that will 
work in release mode?


I'm guessing I should write my own function for now.


[Issue 17787] New: Add a BetterC predefined version so libraries can adapt

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17787

  Issue ID: 17787
   Summary: Add a BetterC predefined version so libraries can
adapt
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: petar.p.ki...@gmail.com

Currently libraries have no way of knowing if they are compiled with `-betterC`
and have no way to disable or adapt parts of their functionality for this mode.

--


Re: How to store data when using parallel processing

2017-08-27 Thread Andrew Chapman via Digitalmars-d-learn

On Sunday, 27 August 2017 at 01:58:04 UTC, Jonathan M Davis wrote:

[...]


Thanks Jonathan, that makes sense.  As it turns out, the Mutex 
approach actually makes things slower.  In this case I believe 
trying to use multiple cores isn't worth it.


Cheers.


[Issue 17786] Define the FreeStanding subset of betterC

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17786

ZombineDev  changed:

   What|Removed |Added

   Keywords||bare-metal, betterC, spec

--


[Issue 17786] New: Define the FreeStanding subset of betterC

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17786

  Issue ID: 17786
   Summary: Define the FreeStanding subset of betterC
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: petar.p.ki...@gmail.com

As it stands, `-betterC` is a subset of D under which features requiring
druntime are unavailable (and should probably be disallowed).

`-betterC` however still assumes that the C runtime / standard library is
available and the compiler freely emits references to it (such as to memset).

As of several releases, the compiler has a FreeStanding predefined version,
which according to the spec
(https://dlang.org/spec/version.html#predefined-versions) is defined as:

An environment without an operating system (such as Bare-metal targets)

We should:
* Add a compiler switch, so that code targeting bare-metal can actually use
this predefined version, and third party libraries could offer bare-metal
friendly implementations of their functionalities.
* Teach the compiler to not emit references to the C runtime.
* Define in the language specification all the features that are not available.

--


[Issue 17747] extern(C) shared static module constructor should be called in betterC programs

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17747

--- Comment #5 from ZombineDev  ---
> It can be called in start before main, without DRuntime.

Agreed.

--


[Issue 17747] extern(C) shared static module constructor should be called in betterC programs

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17747

--- Comment #4 from ZombineDev  ---
> __attribute__ ((constructor)) is in C. It can be called in start before main, 
> without DRuntime.

Technically this is a compiler extension, not a feature part of the ISO C
standard. My point was that C standard does not require such feature and
therefore we shouldn't rely on its existence.

On the other hand, C++ does due to the need to be able to call class
constructors for static/global variables.

--


[Issue 1938] member of scope-class-type behavior undefined

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1938

ZombineDev  changed:

   What|Removed |Added

   Keywords||C++, spec

--- Comment #1 from ZombineDev  ---
Re-targeting to D2 as I believe this is a good enhancement request.
Also may benefit C++ interoperability.

--


[Issue 17785] Add a page detailing all undefined behavior to the language specification

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17785

ZombineDev  changed:

   What|Removed |Added

   Keywords||safe, spec

--


[Issue 17785] New: Add a page detailing all undefined behavior to the language specification

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17785

  Issue ID: 17785
   Summary: Add a page detailing all undefined behavior to the
language specification
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: petar.p.ki...@gmail.com

Examples in other languages:

Rust:
https://doc.rust-lang.org/reference/behavior-considered-undefined.html#behavior-considered-undefined

Note that Rust makes the distinction between defined behavior in unsafe code
(but disallowed in safe code) and actually undefined behavior in unsafe code.
Probably a good model to follow.

C++: http://en.cppreference.com/w/cpp/language/ub

--


[Issue 1938] member of scope-class-type behavior undefined

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=1938

ZombineDev  changed:

   What|Removed |Added

 CC||petar.p.ki...@gmail.com
   Hardware|x86 |All
Version|D1 (retired)|D2
 OS|Windows |All

--


[Issue 17780] Malformed DDOC links in std.range

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17780

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

   What|Removed |Added

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

--


[Issue 17780] Malformed DDOC links in std.range

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17780

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

https://github.com/dlang/phobos/commit/cf422b0521d6b63ebfc50dd7ae9e273408b49b39
fix issue 17780 -  Malformed DDOC links in std.range

https://github.com/dlang/phobos/commit/694d87fe02f9ca062e89d7434651b8f6cc59f912
Merge pull request #5708 from BBasile/issue-17780-stable

fix issue 17780 -  Malformed DDOC links in std.range
merged-on-behalf-of: Petar Kirov 

--


Re: LDC 1.4.0-beta1

2017-08-27 Thread Kai Nacke via Digitalmars-d-announce

On Saturday, 26 August 2017 at 22:35:11 UTC, kinke wrote:

Hi everyone,

on behalf of the LDC team, I'm glad to announce LDC 
1.4.0-beta1. The highlights of version 1.4 in a nutshell:


* Based on D 2.074.1.
* Shipping with ldc-build-runtime, a small D tool to easily 
(cross-)compile the runtime libraries yourself.

* Full Android support, incl. emulated TLS.
* Improved support for AddressSanitizer and libFuzzer. The 
libraries are shipped with the prebuilt Linux x86_64 and OSX 
packages.
* Prebuilt Linux x86_64 package shipping with LTO plugin, 
catching up with the OSX package.


Full release log and downloads: 
https://github.com/ldc-developers/ldc/releases/tag/v1.4.0-beta1


Thanks to everybody contributing!


Well done! It's great work you all are doing!

Regards,
Kai


Re: Building (and including libraries) without dub

2017-08-27 Thread zabruk70 via Digitalmars-d-learn

On Saturday, 26 August 2017 at 09:03:03 UTC, Hasen Judy wrote:
What if I want to include a 3rd party library? Surely before 
dub existed, people were incorporating other libraries in their 
projects.


sometimes pragma("lib", ...) very usefull (if i understand you 
correctly)


https://dlang.org/spec/pragma.html#lib


[Issue 17784] [scope][DIP1000] Confusing error message for escaping local via new-expression

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17784

ZombineDev  changed:

   What|Removed |Added

   Keywords||diagnostic, safe

--


[Issue 17784] New: [scope][DIP1000] Confusing error message for escaping local via new-expression

2017-08-27 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17784

  Issue ID: 17784
   Summary: [scope][DIP1000] Confusing error message for escaping
local via new-expression
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: petar.p.ki...@gmail.com

With PR https://github.com/dlang/dmd/pull/7101, given the following code:
```
#line 1300

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

void test1300() @safe
{
int i;
auto p = new S1300().oops; // line 1306
}

struct S1300
{
int* oops;
//this(int* p) @safe { oops = p; }
}
```

The compiler produces the following error message:
scope_test.d(1306): Error: returning `& i` escapes a reference to local
variable `i`

Which is confusing to the user, because there are no return statements in the
whole file. I suggest the following error message:

scope_test.d(1306): Error: reference to local variable `i` assigned to
heap-allocated `S1300.oops` with possibly longer lifetime

--