Re: DCOnf 2017 videos online

2017-05-07 Thread WhatMeForget via Digitalmars-d-announce

On Sunday, 7 May 2017 at 18:11:47 UTC, Patrick Schluter wrote:
It looks like the good people of Sociomantic have already 
posted videos of the Dconf2017 on youtube.


https://www.youtube.com/channel/UC54uUlXuGhigMsdaNtP6THQ

Enjoy.


Wow. That was quick!


enum tuple subscript as template parameter => Tuple(A(0)) must be an array or pointer type, not Tuple!(A)

2017-05-07 Thread bastien penavayre via Digitalmars-d-learn

Hi,

I'm having a bit of an issue here and the compiler is not really 
explicit.

Here's the code:

import std.typecons;

struct A { int i; }

void main()
{
   enum t = tuple(A());
   f!(t[0].i); //Error: Tuple(A(0)) must be an array or pointer 
type, not Tuple!(A)

   f!(([0]).i) //Ok
   enum v = t[0];
   f!(v.i); //Error: template instance f!(i) does not match 
template declaration f(int T)()

   f!((v.i)); //Ok
}

void f(int T)() {}


[Issue 16232] std.experimental.logger.core.sharedLog isn't thread-safe

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16232

--- Comment #4 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/7d7ce4a5ebaca7155e754b1bf7b45366e87d0194
Logger sharedLog comment on thread-safety

fix Issue 16232 - std.experimental.logger.core.sharedLog isn't thread-safe

--


Re: DCOnf 2017 videos online

2017-05-07 Thread Jack Stouffer via Digitalmars-d-announce

On Sunday, 7 May 2017 at 21:36:30 UTC, Mike Parker wrote:

On Sunday, 7 May 2017 at 18:11:47 UTC, Patrick Schluter wrote:
It looks like the good people of Sociomantic have already 
posted videos of the Dconf2017 on youtube.


https://www.youtube.com/channel/UC54uUlXuGhigMsdaNtP6THQ

Enjoy.


And here's a direct link to the playlist:

https://www.youtube.com/playlist?list=PL3jwVPmk_PRxo23yyoc0Ip_cP3-rCm7eB


I assume you're handling the reddit post?


[Issue 7016] local import does not create -deps dependency

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=7016

--- Comment #29 from github-bugzi...@puremagic.com ---
Commit pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/29273f261c94e1bbe1042ec58a362d70cb344188
remove .deps file generation

- for development, people can use the much faster std/algorithm.test targets
- for batch unittest recompiling isn't of much interest as all the
  testers just start from a clean slate anyhow
- furthermore the .deps generation is broken anyhow, see Issue 7016

--


Re: reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread bastien penavayre via Digitalmars-d

On Sunday, 7 May 2017 at 23:20:26 UTC, Adam D. Ruppe wrote:


I would just write it `else static if` all on one line and not 
indent further. Then it barely looks any different anyway.


I just realized that I accidentally posted this while editing.
I agree with you on that this is barely different from just 
adding "else".


The example that I wanted to put was the following.

{
enum index = ...;
static if (I >= args.length)
   return ...; //uses index
else
{
   enum result = ...;
   static if (!result[0])
   {
  static if (name.length == 0)
 return ...;
  else static if (result[2] >= txt.length)
 return ...;
  else
 return ...;
   }
   else
   {
  enum next = ...;
  static if (!next[0])
 return ...;
  else
  {
 ...
 return ...;
  }
   }
   }
}


Re: reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread Adam D. Ruppe via Digitalmars-d

On Sunday, 7 May 2017 at 22:34:14 UTC, bastien penavayre wrote:

Why is the code following "return true" evaluated ?


It isn't evaluated, it is just compiled. The compile happens 
before it is run, so it doesn't really know if it is reachable 
yet.



ClLinearExpression opBinary(string op) (double constant)
{
static if (op == "+")
return new ClLinearExpression(this, 1, constant);
else
static if (op == "-")
return new ClLinearExpression(this, 1, 
-constant);

else
static if (op == "*")
return new ClLinearExpression(this, 
constant, 0);

else
static if (op == "/")
return new ClLinearExpression(this, 1.0 
/ constant, 0);

}


I would just write it `else static if` all on one line and not 
indent further. Then it barely looks any different anyway.


reasoning of evaluating code after return in current block (static if return)

2017-05-07 Thread bastien penavayre via Digitalmars-d

Hi something's been bugging me for a while,
for the following code:

{
   auto t = tuple(0,0);
   return true;
   auto v = t[5];
   return false;
}

Why is the code following "return true" evaluated ? I know that 
it's the same

with the C++ but I was wondering why ?
My guess is for goto/labels but I find odd to evaluate it by 
default.
Furthermore one of my issues with this is that it has a negative 
impact on "static if" and make it cumbersome in some situations.


For instance this snippet comming from 
"https://github.com/uncrustify/uncrustify/issues/252;


ClLinearExpression opBinary(string op) (double constant)
{
static if (op == "+")
return new ClLinearExpression(this, 1, constant);
else
static if (op == "-")
return new ClLinearExpression(this, 1, -constant);
else
static if (op == "*")
return new ClLinearExpression(this, constant, 
0);

else
static if (op == "/")
return new ClLinearExpression(this, 1.0 / 
constant, 0);

}


[Issue 16856] D does not work on FreeBSD current (what will eventually be 12) due to libunwind

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16856

--- Comment #5 from github-bugzi...@puremagic.com ---
Commits pushed to master at https://github.com/dlang/druntime

https://github.com/dlang/druntime/commit/c56e8e0d8d599b1742fe85210f07adacf07e5e2a
Fix issue 16856: Apply correct alignment on the Unwind_Exception structure

In libundwind, _Unwind_Exception structure is defined as follows:

```
struct _Unwind_Exception
  {
uint64_t exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
unsigned long private_1;
unsigned long private_2;
  } __attribute__((__aligned__));
```

so the alignment is done on the entire structure, and it
depends on the architecture. This sets the structure
to be 16bit aligned on the X86_64, so the binary layout
matches and that the C++ compiler's optimizations are still
valid (for example, on FreeBSD-12, exception handling was broken
because libunwind assumes correct alignment, so the fast but fragile
instructions were used.

https://github.com/dlang/druntime/commit/c7182eb2ef3d6cc57c3e3366028753306b4dceb7
Merge pull request #1823 from Burgos/exception_alignment

Fix issue 16856: Apply correct alignment on the Unwind_Exception stru…
merged-on-behalf-of: Jonathan M Davis 

--


[Issue 16856] D does not work on FreeBSD current (what will eventually be 12) due to libunwind

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16856

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

   What|Removed |Added

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

--


Re: DLang quarterly EU?

2017-05-07 Thread John Colvin via Digitalmars-d

On Saturday, 6 May 2017 at 23:53:45 UTC, Ethan Watson wrote:
I was speaking to Atila earlier about the things we like about 
DConf. Sitting around talking to a bunch of computer scientists 
is fantastic, and not something people generally get to do in 
their chosen careers as a programmer.


EU nations are quite close together. Rather than a city meet up 
monthly, what about a continental meet up quarterly?


This is quite feasible in Europe, since everything is quite 
close together. I'm keen. Atila is keen. Anyone else think this 
is a great idea?


Great idea. I'm in.


[Issue 17382] void main(){}pragma(msg,main()); crashes DMD

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17382

ag0ae...@gmail.com changed:

   What|Removed |Added

   Keywords||ice
 CC||ag0ae...@gmail.com
   Severity|enhancement |normal

--


[Issue 17382] New: void main(){}pragma(msg,main()); crashes DMD

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17382

  Issue ID: 17382
   Summary: void main(){}pragma(msg,main()); crashes DMD
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: timon.g...@gmx.ch

See Summary.

The code should compile.

--


Re: Working code in an upcoming PR by Timon Gehr

2017-05-07 Thread Steven Schveighoffer via Digitalmars-d-announce

On 5/7/17 7:03 PM, Stanislav Blinov wrote:

On Sunday, 7 May 2017 at 16:57:58 UTC, Andrei Alexandrescu wrote:

Zoom in on the screen for a nice surprise! http://imgur.com/a/qjI4l --
Andrei


I see only unsurprising Jpeg artifacts and not much more :)
It's too low resolution to make anything out.


I think I know :) Timon was telling me about it.

It's a PR to add static foreach to dmd.

-Steve


[Issue 16265] unittest imports should not be counted as dependencies for static ctors

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16265

--- Comment #4 from Steven Schveighoffer  ---
Trial PR: https://github.com/dlang/dmd/pull/6753

--


Re: DLang quarterly EU?

2017-05-07 Thread David Nadlinger via Digitalmars-d

On Saturday, 6 May 2017 at 23:53:45 UTC, Ethan Watson wrote:
This is quite feasible in Europe, since everything is quite 
close together. I'm keen. Atila is keen. Anyone else think this 
is a great idea?


I'd definitely be interested as well. —David


Re: DLang quarterly EU?

2017-05-07 Thread Moritz Maxeiner via Digitalmars-d

On Saturday, 6 May 2017 at 23:53:45 UTC, Ethan Watson wrote:
I was speaking to Atila earlier about the things we like about 
DConf. Sitting around talking to a bunch of computer scientists 
is fantastic, and not something people generally get to do in 
their chosen careers as a programmer.


EU nations are quite close together. Rather than a city meet up 
monthly, what about a continental meet up quarterly?


This is quite feasible in Europe, since everything is quite 
close together. I'm keen. Atila is keen. Anyone else think this 
is a great idea?


Superb!


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread Patrick Schluter via Digitalmars-d-learn

On Sunday, 7 May 2017 at 13:16:16 UTC, bachmeier wrote:

On Sunday, 7 May 2017 at 10:33:25 UTC, k-five wrote:

Although I found D for being more better, nicer,and fun than 
C++ is, but there is a few questions on Stack-Over-Flow, 
videos on Youtube, and  some other forums in my country. So, 
why D is not popular?


If by popular you mean C++ or Java levels of usage, that's a 
pretty high standard. While D is not among the most used 
languages in large enterprises, it is definitely not an obscure 
language. For example, just a few days ago I was reading about 
the new Scala Native project. Among the motivations for that 
project is


"Scala Native provides an interop layer that makes it easy to 
interact with foreign native code. This includes C and other 
languages that can expose APIs via C ABI (e.g. C++, D, Rust 
etc.)" [0]


You have to be careful about using stackoverflow as a measure 
of language popularity. Most activity takes place on this 
mailing list, which was going long before stackoverflow, and 
there was little motivation to move there (Google searches will 
bring you here).


One of the few quantitative measures (and even that's of 
limited use) is DMD downloads from this site. Most recently 
they have been at about 50,000 per month.[1]


[0] http://www.scala-native.org/en/latest/user/interop.html
[1] http://erdani.com/d/downloads.daily.png


If you look on TIOBE [1] newest stats, D does not look so bad 
after all. It's ranked 23 with a 1.38% share. The so fashionable 
and noisy Rust is only ranked 40 with 0.41% of share and classics 
like COBOL, FORTRAN, Lisp, Scala, Ada, bash are all behind. So 
it's not yet in the top 20 but I think that it will continue 
growing, slowly and steadily.


[1]: https://www.tiobe.com/tiobe-index/


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread Patrick Schluter via Digitalmars-d-learn

On Sunday, 7 May 2017 at 12:29:20 UTC, Stanislav Blinov wrote:

On Sunday, 7 May 2017 at 10:33:25 UTC, k-five wrote:

[...]


Because everyone is asking this question instead of actually 
doing something about it :)
To be fair, D has a good amount of usage even today, it's just 
not being screamed about ecstatically.



[...]


Today is the last day of the D Conference 2017, last three days 
it was livestreaming. There were quite a bit of talks on 
current developments and future progress. The videos from those 
streams should appear at 
https://www.youtube.com/user/sociomantic/videos hopefully early 
next week. They also have previous conference videos out there.


Some of them have started to appear already 3 hours ago.


[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17216

Andrew  changed:

   What|Removed |Added

  Component|dmd |tools

--


DCOnf 2017 videos online

2017-05-07 Thread Patrick Schluter via Digitalmars-d-announce
It looks like the good people of Sociomantic have already posted 
videos of the Dconf2017 on youtube.


https://www.youtube.com/channel/UC54uUlXuGhigMsdaNtP6THQ

Enjoy.


[Issue 17379] Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17379

--- Comment #4 from Rainer Schuetze  ---
> I am not sure what you mean by prepend the function name. The suggestion 
> does not prepend the function name. Could you elaborate?

I meant that the demangler has to prepend the function name (including
arguments to disambiguate overloads) to the identifier to print out the full
name (if the demangled name is supposed not to show the transformation). 

> This is not meant as a special case rule. ... It is also not ambiguous since 
> the transformation is equivalent to explicitly writing out the template.

Consider similar structs defined elsewhere, e.g. in nested or chained
functions:

template foo(T)
{
   static struct Result
   {
  int x;
   }

   auto fun(T t)
   {
  static struct Result
  {
 T t;
  }
  return Result(t);
   }

   auto foo(T t)
   {
  return fun(t);
   }
}

What is the mangling of the return type of foo?

--


[Issue 17379] Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17379

--- Comment #3 from Georgi D  ---
(In reply to Rainer Schuetze from comment #2)
> Is this meant as a special rule "if the symbol has only a single identifier,
> prepend the function name and signature"? This could work but only helps for
> some cases. 
> 

I am not sure what you mean by prepend the function name. The suggestion does
not prepend the function name. Could you elaborate?

> Otherwise it easily gets ambiguous and I'd rather see a special token for
> "unspecified return type" that could be demangled as "auto".
> 
> See https://github.com/dlang/dmd/pull/5855 for a more generic approach.

This is not meant as a special case rule. It is a generic lowering of voldemort
types in function templates to be as if defined outside of the function so they
do not grow exponentially in size. It does not have a limit on the number of
template arguments. It is also not ambiguous since the transformation is
equivalent to explicitly writing out the template.

I am aware of https://github.com/dlang/dmd/pull/5855 and think it is a great
idea but it is a compression of the symbol so if the original symbol is shorter
then the compressed symbol is also going to be shorter. This suggestion tackles
the problem of how the original symbol can be shorter.

--


Re: D support for the Meson build system

2017-05-07 Thread Andrew Godfrey via Digitalmars-d-announce
This looks very nice, but I'm having trouble getting it to work 
on Windows with DMD.


What static linker are you using? DmdDCompiler is defined to need 
one,
but the code in detect_static_linker expects the linker to 
support the "--version" command-line parameter (or "/?" if the 
linker is named "lib" or "lib.exe").


DMD's "lib.exe" doesn't support "--version" or "/?".
I suspect this is what I should be pointing it to, but the term 
"static linker" confuses me - maybe I want to be pointing it to 
"link.exe".
DMD's "link.exe" doesn't support "--version" but does support 
"/?".


I can hack around this, but I'm wondering why I'm alone in 
encountering this.

Thanks!


Re: Working code in an upcoming PR by Timon Gehr

2017-05-07 Thread Stanislav Blinov via Digitalmars-d-announce

On Sunday, 7 May 2017 at 16:57:58 UTC, Andrei Alexandrescu wrote:
Zoom in on the screen for a nice surprise! 
http://imgur.com/a/qjI4l -- Andrei


I see only unsurprising Jpeg artifacts and not much more :)
It's too low resolution to make anything out.


Working code in an upcoming PR by Timon Gehr

2017-05-07 Thread Andrei Alexandrescu via Digitalmars-d-announce
Zoom in on the screen for a nice surprise! http://imgur.com/a/qjI4l -- 
Andrei


Re: DLang quarterly EU?

2017-05-07 Thread Adrian Matoga via Digitalmars-d

On Sunday, 7 May 2017 at 16:37:02 UTC, Ethan Watson wrote:

On Sunday, 7 May 2017 at 11:32:53 UTC, Adam Wilson wrote:

On 5/7/17 12:57, Seb wrote:
+1 - maybe its worth considering to make it for two days 
(=one weekend)


That can work. It would be two or three days vacation 
depending on flight schedules.

...
Not to mention a cool way to see new cities if it moves around.


Yes, that was the intention on both counts. There's no point to 
flying somewhere just for the day. Especially since there will 
doubtless be Micro BeerConfs in the evening ;-)


Andrei suggested that Bucharest be the first city we hold this 
in. Sounds like a great plan to me.


Count me in!



Re: File Input

2017-05-07 Thread k-five via Digitalmars-d-learn

On Sunday, 7 May 2017 at 15:59:25 UTC, JV wrote:

On Sunday, 7 May 2017 at 15:16:58 UTC, k-five wrote:

On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote:


I'm kinda getting it but how do i write the stored user 
input(string) varaible into a .txt??im getting confused since D 
has so many read and write


 ->sample below
string num;
auto attendance= File("studAttendance.txt","a+");

writeln("Add Student Attendance");
readf("%s ",);//im not sure if this is correct but 
assuming it works
  //how do i write what is stored in 
num in the studAttendance.txt

  //file??

attendance.close();


--

You have the right for confusing :) there is many read and write 
names. But I assumed you are familiar with [Type] and [Object] 
concept.


in:
auto output_file_stream = File( "file.txt", "w" );

auto = File  == A type
File( "file.txt", "w" ); == Constructor

So this type has its own property, like read for "r" mode and 
write for "w" mode.


So you should use output_file_stream.write(), not readf or so on.

Still I am very new in D, but this is the same concept in other 
language like C++


in C++:
#include 
#include 
#include 

int main(int argc, char **argv)
{

std::ofstream ofs( "file.txt" );
std::string line = "This is the first line";
// write is a method in class ofstream
ofs.write( &*line.begin(), line.length() );
ofs.close();
}


Re: DLang quarterly EU?

2017-05-07 Thread Ethan Watson via Digitalmars-d

On Sunday, 7 May 2017 at 11:32:53 UTC, Adam Wilson wrote:

On 5/7/17 12:57, Seb wrote:
+1 - maybe its worth considering to make it for two days (=one 
weekend)


That can work. It would be two or three days vacation depending 
on flight schedules.

...
Not to mention a cool way to see new cities if it moves around.


Yes, that was the intention on both counts. There's no point to 
flying somewhere just for the day. Especially since there will 
doubtless be Micro BeerConfs in the evening ;-)


Andrei suggested that Bucharest be the first city we hold this 
in. Sounds like a great plan to me.


Re: File Input

2017-05-07 Thread JV via Digitalmars-d-learn

On Sunday, 7 May 2017 at 15:16:58 UTC, k-five wrote:

On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote:

Hi guys

I'd like to know how to get an input from the user to be 
stored in a .txt file using import std.file and is it possible 
to directly write in a .txt file without using a variable to 
store the user input?


Thanks for the answer in advance my mind is kinda jumbled 
about this since im new to this language.


First of all see here:
https://dlang.org/phobos/std_stdio.html#.File

also:

import std.stdio; // for File

void main(){

// an output file with name file.txt
// w for writing
auto ofs = File( "file.txt", "w" );

// output file stream:
ofs.write( stdin.readln() ); // get a line from console
ofs.close();
}


cat file.txt:
This is the first line.


and for std.file:
https://dlang.org/phobos/std_file.html




I'm kinda getting it but how do i write the stored user 
input(string) varaible into a .txt??im getting confused since D 
has so many read and write


 ->sample below
string num;
auto attendance= File("studAttendance.txt","a+");

writeln("Add Student Attendance");
readf("%s ",);//im not sure if this is correct but 
assuming it works
  //how do i write what is stored in num 
in the studAttendance.txt

  //file??

attendance.close();


Re: Upgrading the minimum version of FreeBSD supported

2017-05-07 Thread Jonathan M Davis via Digitalmars-d
On Sunday, April 2, 2017 8:40:15 PM CEST Brad Roberts via Digitalmars-d 
wrote:
> I grabbed the official 10.3-CURRENT vm image from the freebsd website
> and gave it a whirl.  For the 64 bit test run, the only failure was
> std.datetime unit tests failure.  Apparently LocalTime().stdName is null
> and the assert at line 28248 fails. There's at least one additional
> failure on 32 bits in allocator/building_blocks/region.d line 652.  I
> ran out of time to dig for today, but the bottom line is that 10.3 isn't
> ready to be the base platform for dmd as is.  Chances are it could be
> with only a little work though.

The std.datetime failure is due to known FreeBSD bug, but it's affected by
the local time, and apparently, it works in America/Los_Angeles but not in
UTC (which is why I wasn't seeing it). I'll commit a workaround shortly,
though I still need to figure out how to push the fix in FreeBSD through so
that FreeBSD doesn't have the bug anymore...

- Jonathan M Davis



Re: File Input

2017-05-07 Thread Suliman via Digitalmars-d-learn

On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote:

Hi guys

I'd like to know how to get an input from the user to be stored 
in a .txt file using import std.file and is it possible to 
directly write in a .txt file without using a variable to store 
the user input?


Thanks for the answer in advance my mind is kinda jumbled about 
this since im new to this language.


http://nomad.so/2015/09/working-with-files-in-the-d-programming-language/


Deprecation: foo.bar is not visible from module traits

2017-05-07 Thread Anonymouse via Digitalmars-d-learn
I'm reworking my code to use UDAs, and I'm running into a wall of 
text of deprecation warnings when compiling.



import std.traits;

private:

struct SomeUDA {}

@SomeUDA
void foo() {}

@SomeUDA
void bar() {}

@SomeUDA
void etc() {}

public:

void main()
{
mixin("static import thisModule = " ~ __MODULE__ ~ ";");

foreach (symbol; getSymbolsByUDA!(thisModule, SomeUDA))
{
static if (isSomeFunction!symbol)
{
pragma(msg, symbol.stringof);
}
}
}


See https://wandbox.org/permlink/6Z01koyGGRxjsNWG for the output 
it gives. In the real code it's unmanageably many lines.


Is there any way to get rid of these warnings except by making 
everything public? Ideally I wouldn't want to copy the source of 
getSymbolsByUDA into each file doing this either.


-vcg-ast dmd command line switch

2017-05-07 Thread Ali Çehreli via Digitalmars-d

I've just commented on the following thread on the 'internals' newsgroup:

  http://forum.dlang.org/thread/tiiuucwivajgsnoos...@forum.dlang.org

I think this should be improved to display code that is being mixed-in.

Ali


Re: File Input

2017-05-07 Thread k-five via Digitalmars-d-learn

On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote:

Hi guys

I'd like to know how to get an input from the user to be stored 
in a .txt file using import std.file and is it possible to 
directly write in a .txt file without using a variable to store 
the user input?


Thanks for the answer in advance my mind is kinda jumbled about 
this since im new to this language.


First of all see here:
https://dlang.org/phobos/std_stdio.html#.File

also:

import std.stdio; // for File

void main(){

// an output file with name file.txt
// w for writing
auto ofs = File( "file.txt", "w" );

// output file stream:
ofs.write( stdin.readln() ); // get a line from console
ofs.close();
}


cat file.txt:
This is the first line.


and for std.file:
https://dlang.org/phobos/std_file.html


[Issue 17379] Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17379

Rainer Schuetze  changed:

   What|Removed |Added

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

--- Comment #2 from Rainer Schuetze  ---
Is this meant as a special rule "if the symbol has only a single identifier,
prepend the function name and signature"? This could work but only helps for
some cases. 

Otherwise it easily gets ambiguous and I'd rather see a special token for
"unspecified return type" that could be demangled as "auto".

See https://github.com/dlang/dmd/pull/5855 for a more generic approach.

--


[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #6 from Andrew  ---
Second proposed fix (removing the use of .tmp altogether) is at
https://github.com/cqexbesd/tools/tree/dlang_17216_v2. I don't have a copy of
Windows so it needs testing - but it works under OSX.

--


[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #5 from Andrew  ---
I now have a fix at https://github.com/cqexbesd/tools/tree/dlang_17216.

It's not great - it just makes the windows work around only happen under
Windows.

Given
https://github.com/cqexbesd/tools/blob/d27bcc1228863ba0a3b0ae5cf47a8d3a409bda45/rdmd.d#L461-L481
however I'm not sure that the windows workaround should still be needed. The rm
code didn't exist when the workaround was added AFAIK. I might try removing the
workaround and finding a windows user who can test it.

--


Re: DLang quarterly EU?

2017-05-07 Thread Johan Engelen via Digitalmars-d

On Saturday, 6 May 2017 at 23:53:45 UTC, Ethan Watson wrote:
... Rather than a city meet up monthly, what about a 
continental meet up quarterly?


... Anyone else think this is a great idea?


+1 !

-Johan




Error writing file a *.obj

2017-05-07 Thread dummy via Digitalmars-d-learn

Hi :)

  - OS: Winodws 10 Pro KN
  -  DMD: 2.073.2(ofcourse, i tried dmd of 2.074.x version. but 
same result)


When i build some application with dub, i got this error:
--

dub build

xx ~master: building configuration "application"...
Error: Error writing file 
'.dub\build\application-debug-windows-x86-dmd_2073-FEC52DAD217DFEA46ECF98CA4240FA06\xx.obj'

dmd failed with exit code 1
--



What's mean? my dub.json here:
--
{
"name": "xx",
"authors": [
"dummy"
],
"description": "A minimal D application.",
"copyright": "Copyright © 2017, dummy",
"license": "proprietary",
"dependencies": {
"requests": "~>0.4.1"
},
"subConfigurations": {
"requests": "vibed"
}
}
--
app.d is default file, so i didn't modify it.


File Input

2017-05-07 Thread JV via Digitalmars-d-learn

Hi guys

I'd like to know how to get an input from the user to be stored 
in a .txt file using import std.file and is it possible to 
directly write in a .txt file without using a variable to store 
the user input?


Thanks for the answer in advance my mind is kinda jumbled about 
this since im new to this language.









Re: How can I pass an argument to rdmd --evel=

2017-05-07 Thread Vladimir Panteleev via Digitalmars-d-learn

On Sunday, 7 May 2017 at 11:29:30 UTC, k-five wrote:

It should be possible!
rdmd --eval=, without accepting argument is useless.


FWIW, you can still pass input through stdin.



[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17216

--- Comment #4 from Andrew  ---
OK .tmp is added at
https://github.com/dlang/tools/commit/085dc5d000b828be9a3c2dc79548352f63b52db4
to work around a Windows problem so removing it without an alternative wouldn't
be good.

--


[Issue 17216] OSX: `rdmd -shared -oflibfun.dylib fun.d` and otool -L libfun.dylib points to libfun.dylib.tmp

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17216

Andrew  changed:

   What|Removed |Added

 CC||and...@ugh.net.au

--- Comment #3 from Andrew  ---
This is still occurring in HEAD.

When rdmd calls dmd it gives an output name that ends with ".tmp"
(https://github.com/dlang/tools/blob/master/rdmd.d#L483-L488) and that is what
dmd passes to clang (used for linking under OSX). As the install_name arg isn't
given thats what ends up being the install_name of the dylib and hence this
problem.

There are two obvious ways of fixing it - get dmd to call clang with
install_name or run install_name_tool after building.

Neither seem obviously great - IIUC rdmd doesn't know its building a shared
library so doesn't know install_name is important. dmd does know but isn't
aware that rdmd has passed it a dummy output name that will later get mv'ed to
the final name.

I don't yet know if rdmd _needs_ to use the .tmp then mv trick but I'm guessing
its there to cope with some sort of error on some platform - if that could be
avoided the problem would disappear. Anything else seems to require rdmd
learning about shared libraries under OSX or dmd having more awareness of rdmd.

--


[Issue 16856] D does not work on FreeBSD current (what will eventually be 12) due to libunwind

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16856

Nemanja Boric <4bur...@gmail.com> changed:

   What|Removed |Added

 CC||4bur...@gmail.com

--- Comment #4 from Nemanja Boric <4bur...@gmail.com> ---
I've looked into this, and this is the alignment issue.

The faulty instruction happens here:

https://github.com/llvm-mirror/libunwind/blob/master/src/UnwindLevel1.c#L351

```
  exception_object->private_1 = 0;
```

On FreeBSD-Current, this is executed as:

```
  xorps xmm0, xmm0
  movaps XMMWORD PTR [r14+0x10], xmm0
```

where r14 is the pointer to the Unwind_Exception
(https://github.com/llvm-mirror/libunwind/blob/master/include/unwind.h#L119-L124)
or D runtime part:
(https://github.com/dlang/druntime/blob/master/src/rt/unwind.d#L51-L57)

```
struct _Unwind_Exception
{
align(8) _Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
_Unwind_Word private_1;
_Unwind_Word private_2;
}
```

or 

```
struct _Unwind_Exception {
  uint64_t exception_class;
  void (*exception_cleanup)(_Unwind_Reason_Code reason,
_Unwind_Exception *exc);
  uintptr_t private_1; // non-zero means forced unwind
  uintptr_t private_2; // holds sp that phase1 found for phase2 to use
#ifndef __LP64__
  // The implementation of _Unwind_Exception uses an attribute mode on the
  // above fields which has the side effect of causing this whole struct to
  // round up to 32 bytes in size. To be more explicit, we add pad fields
  // added for binary compatibility.
  uint32_t reserved[3];
#endif
  // The Itanium ABI requires that _Unwind_Exception objects are "double-word
  // aligned".  GCC has interpreted this to mean "use the maximum useful
  // alignment for the target"; so do we.
} __attribute__((__aligned__));
```

Now, this happens because `movaps` instruction requires 16-bit aligned memory,
which is not the case for _Unwind_Exceptin.private_1 - where it is aligned to 8
bits.

Making D definition to align this instance (at least D-allocated) to 16 bits
fixes the entire problem - exception handling works:

```
align(16)
struct _Unwind_Exception
{
_Unwind_Exception_Class exception_class;
_Unwind_Exception_Cleanup_Fn exception_cleanup;
_Unwind_Word private_1;
_Unwind_Word private_2;
}
```


Now, the problem is that I don't know how to effectively calculate the
alignment and do whatever the C++ compiler would do. I guess this is necessity,
because we want C++ exceptions (generated by the C++ compiler) to work.

GCC documentation is stating:
https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Type-Attributes.html

```
As in the preceding example, you can explicitly specify the alignment (in
bytes) that you wish the compiler to use for a given struct or union type.
Alternatively, you can leave out the alignment factor and just ask the compiler
to align a type to the maximum useful alignment for the target machine you are
compiling for. For example, you could write:

  struct S { short f[3]; } __attribute__ ((aligned));

Whenever you leave out the alignment factor in an aligned attribute
specification, the compiler automatically sets the alignment for the type to
the largest alignment which is ever used for any data type on the target
machine you are compiling for. Doing this can often make copy operations more
efficient, because the compiler can use whatever instructions copy the biggest
chunks of memory when performing copies to or from the variables which have
types that you have aligned this way.

In the example above, if the size of each short is 2 bytes, then the size of
the entire struct S type is 6 bytes. The smallest power of two which is greater
than or equal to that is 8, so the compiler sets the alignment for the entire
struct S type to 8 bytes.

```

Any ideas?

--


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread bachmeier via Digitalmars-d-learn

On Sunday, 7 May 2017 at 10:33:25 UTC, k-five wrote:

Although I found D for being more better, nicer,and fun than 
C++ is, but there is a few questions on Stack-Over-Flow, videos 
on Youtube, and  some other forums in my country. So, why D is 
not popular?


If by popular you mean C++ or Java levels of usage, that's a 
pretty high standard. While D is not among the most used 
languages in large enterprises, it is definitely not an obscure 
language. For example, just a few days ago I was reading about 
the new Scala Native project. Among the motivations for that 
project is


"Scala Native provides an interop layer that makes it easy to 
interact with foreign native code. This includes C and other 
languages that can expose APIs via C ABI (e.g. C++, D, Rust 
etc.)" [0]


You have to be careful about using stackoverflow as a measure of 
language popularity. Most activity takes place on this mailing 
list, which was going long before stackoverflow, and there was 
little motivation to move there (Google searches will bring you 
here).


One of the few quantitative measures (and even that's of limited 
use) is DMD downloads from this site. Most recently they have 
been at about 50,000 per month.[1]


[0] http://www.scala-native.org/en/latest/user/interop.html
[1] http://erdani.com/d/downloads.daily.png


[Issue 6004] std.range.unzip()

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=6004

Ulrich Küttler  changed:

   What|Removed |Added

 CC||kuett...@gmail.com

--- Comment #4 from Ulrich Küttler  ---
For forward ranges of tuples "unzip" can be implemented in a few lines. E.g.

import std.typecons, std.algorithm, std.range;

Tuple!(int,int) divMod(int n, int m) {
return tuple(n / m, n % m);
}

auto unzip(Range)(Range r)
  if (isForwardRange!Range && isTuple!(ElementType!Range))
{
  import std.conv;

  auto generateElements(size_t length)
  {
const s = iota(length)
  .map!(i => "r.map!(t => t[" ~ i.to!string ~ "])")
  .join(",");
return "tuple(" ~ s ~ ")";
  }

  alias T = ElementType!Range;
  return mixin(generateElements(T.Types.length));
}

void main()
{
  import std.stdio, std.array;
  auto rs = iota(1, 20).map!(m => divMod(20,m)).unzip();
  writeln(rs[0].array);
  writeln(rs[1].array);
}

Not sure if this should go into phobos.

--


Re: Basil, Genesis, Patchup, Pendown and Pepss are now open source

2017-05-07 Thread cym13 via Digitalmars-d-announce

On Sunday, 7 May 2017 at 11:29:08 UTC, Ecstatic Coder wrote:
I have released five of my internal tools on Github under the 
GNU GPL, not only in the hope that they are useful to others, 
but also to indirectly promote the D language, in which most of 
them are implemented.


https://github.com/senselogic

These tools are :
* Basil, a textual database builder (D).
* Genesis, a generic source code preprocessor (D).
* Patchup, a scriptable source code patcher (D).
* Pendown, a lightweight markup for colored documents (JS).
* Pepss, a SCSS preprocessor (D).

All of them are implemented as single file scripts without 
external dependencies, to be easily compilable.


Thank you!


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread Stanislav Blinov via Digitalmars-d-learn

On Sunday, 7 May 2017 at 10:33:25 UTC, k-five wrote:

On Sunday, 7 May 2017 at 09:46:22 UTC, Patrick Schluter wrote:

On Saturday, 6 May 2017 at 10:15:03 UTC, k-five wrote:


If you want to learn the basis of the range concept and their 
link to C++ Iterators, you should definitively read Andrei's 
article on them in the InformIT magazine. Here is the link

http://www.informit.com/articles/printerfriendly/1407357
required read for every aspiring D programmer ;-)


---

Thanks for the article.

Although I found D for being more better, nicer,and fun than 
C++ is, but there is a few questions on Stack-Over-Flow, videos 
on Youtube, and  some other forums in my country. So, why D is 
not popular?


Because everyone is asking this question instead of actually 
doing something about it :)
To be fair, D has a good amount of usage even today, it's just 
not being screamed about ecstatically.



I am a big fan of Perl-one-liner and after seeing
rdmd --evel='one-line-code'
I gasped! Oh, really? a one-liner with D!

Or even Unix Command Line, that D has Uniform Function Call 
Syntax.

line.sort.uniq.writeln();

It may you know about the future of D or may introduce some 
other articles about the future of D to me. Since after 
learning C++ I am not very comfortable with.


Today is the last day of the D Conference 2017, last three days 
it was livestreaming. There were quite a bit of talks on current 
developments and future progress. The videos from those streams 
should appear at https://www.youtube.com/user/sociomantic/videos 
hopefully early next week. They also have previous conference 
videos out there.


Re: Interesting PRs: bringing type system legitimacy to shared allocators

2017-05-07 Thread Stanislav Blinov via Digitalmars-d

On Sunday, 7 May 2017 at 11:46:33 UTC, Andrei Alexandrescu wrote:

On 5/7/17 1:30 PM, Stanislav Blinov wrote:




To follow this discussion up, and in light of yesterday's 
Collections presentation at DConf, I though I'd go ahead and 
make a basic implementation of traits-based IAllocator.


You can find it here:

https://github.com/radcapricorn/alloctraits


Cool, thanks. Before we saw that, Eduard and I are working on a 
similar solution along the lines of IAllocator!(Flag!"nogc", 
Flag!"safe"). -- Andrei


I guess the exact representation of "traits" is something to 
decide on. I have to say, even though I used the BitFlags-based 
solution, I'm not a big fan of that, the syntax is a bit 
unwieldy. Then again, Flag-based would be too.

Perhaps a struct with enum members could be used...


Re: Interesting PRs: bringing type system legitimacy to shared allocators

2017-05-07 Thread Andrei Alexandrescu via Digitalmars-d

On 5/7/17 1:30 PM, Stanislav Blinov wrote:




To follow this discussion up, and in light of yesterday's Collections 
presentation at DConf, I though I'd go ahead and make a basic 
implementation of traits-based IAllocator.


You can find it here:

https://github.com/radcapricorn/alloctraits


Cool, thanks. Before we saw that, Eduard and I are working on a similar 
solution along the lines of IAllocator!(Flag!"nogc", Flag!"safe"). -- Andrei


[Issue 17381] New: Checked format string is permissive after floating point argument

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17381

  Issue ID: 17381
   Summary: Checked format string is permissive after floating
point argument
   Product: D
   Version: D2
  Hardware: All
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: phobos
  Assignee: nob...@puremagic.com
  Reporter: acehr...@yahoo.com

A float argument eliminates subsequent orphan argument checks.

import std.format;

void main() {
static assert(!__traits(compiles, format!"%s"(1.5, 2)));
}

static assert fails because the expression should not compile because there is
an orphan argument. (In real code, it would compile but throw FormatException
at runtime.)

Replacing %s with %f does not make a difference; it still compiles.

You can have more arguments before the floating point argument; it always
breaks the subsequent orphan argument checks.

Ali

--


[Issue 17379] Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17379

--- Comment #1 from Georgi D  ---
I discussed this is Andrey and Walter at D-Conf 2017 and the overall agreement
is that it makes sense to change the mangling of voldemort types this way.

For the example above the mangled name changes like this:

- _D4test10__T3fooTiZ3fooFNaNbNiNfiZS4test10__T3fooTiZ3fooFiZ6Result
+ _D4test10__T3fooTiZ3fooFNaNbNiNfiZS4test10__T3fooTiZ6Result

--


Re: DLang quarterly EU?

2017-05-07 Thread Adam Wilson via Digitalmars-d

On 5/7/17 12:57, Seb wrote:

On Sunday, 7 May 2017 at 06:58:51 UTC, Adam Wilson wrote:

On 5/7/17 07:41, Walter Bright wrote:

Dang, I wish I could participate in that!


Well, technically you could, but it involves a set of rather grueling
flights.

Depending on the day it's held I might be able to attend once a year.
If it's on the weekend, I can make a long weekend out of it.


+1 - maybe its worth considering to make it for two days (=one weekend),
s.t. the flight is not longer than the meetup?


That can work. It would be two or three days vacation depending on 
flight schedules. It is certainly workable. And it would be a lot of fun 
to get together to discuss D and hack on projects. Not to mention a cool 
way to see new cities if it moves around. :)


--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;


Re: Interesting PRs: bringing type system legitimacy to shared allocators

2017-05-07 Thread Stanislav Blinov via Digitalmars-d

On Monday, 1 May 2017 at 13:00:27 UTC, Andrei Alexandrescu wrote:

On 05/01/2017 08:12 AM, Guillaume Piolat wrote:
On Sunday, 30 April 2017 at 21:43:26 UTC, Andrei Alexandrescu 
wrote:


A pass through the root allocators (Mallocator, GCAllocator 
etc)
figuring out what attributes could be meaningfully attached 
would be

welcome. The rest would rely on inference.


Thanks,

Andrei


IAllocator being fully @nogc would be a comforting guarantee, 
as runtime

dispatch makes for lighter types.


As I said (and am encouraging you to do this), this is achieved 
through simple variance:


interface INoGCAllocator : IAllocator {
   ... override all methods here as @nogc ...
}

This is possible because a @nogc method may override one that 
is not @nogc. @nogc being more restrictive it is contravariant 
with no-@nogc.


Also IAllocator should have a few @nogc methods to start with; 
there's no reason e.g. for empty() to create garbage.


Could you please initiate a PR?


Andrei


To follow this discussion up, and in light of yesterday's 
Collections presentation at DConf, I though I'd go ahead and make 
a basic implementation of traits-based IAllocator.


You can find it here:

https://github.com/radcapricorn/alloctraits

It pretty much evades the shortcomings of IAllocator, alleviates 
the need for any additional interfaces (ISharedAllocator et al.), 
at the cost of making user code slightly more verbose. But that 
is a small price to pay if we want to benefit from the type 
system.
The current implementation lacks a few features of 
std.experimental.allocator (i.e. passing implementation by 
pointer), which are easy to add, I was just focused mainly on 
roughing out the design as the first step.


Anyone interested, feel free to comment, improve, bash, destroy...


[Issue 17380] [REG 2.074.0] Compiler segfaults on undefined symbol

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17380

ag0ae...@gmail.com changed:

   What|Removed |Added

   Keywords||ice
 CC||ag0ae...@gmail.com

--- Comment #1 from ag0ae...@gmail.com ---
(In reply to kai from comment #0)
> Created attachment 1645 [details]
> Source file demonstrating the bug.

Reduced:


struct Int128
{
Uint128 opCast()
{
return ThisTypeDoesNotExistsAndCrahesTheCompiler;
}
alias opCast this;
}

struct Uint128
{
Int128 opCast() { return Int128.init; }
alias opCast this;
}


Neither this reduction nor the original code compile for me with dmd 2.073.2.
So this doesn't seem like a regression in 2.074 to me.

--


Basil, Genesis, Patchup, Pendown and Pepss are now open source

2017-05-07 Thread Ecstatic Coder via Digitalmars-d-announce
I have released five of my internal tools on Github under the GNU 
GPL, not only in the hope that they are useful to others, but 
also to indirectly promote the D language, in which most of them 
are implemented.


https://github.com/senselogic

These tools are :
* Basil, a textual database builder (D).
* Genesis, a generic source code preprocessor (D).
* Patchup, a scriptable source code patcher (D).
* Pendown, a lightweight markup for colored documents (JS).
* Pepss, a SCSS preprocessor (D).

All of them are implemented as single file scripts without 
external dependencies, to be easily compilable.




Re: How can I pass an argument to rdmd --evel=

2017-05-07 Thread k-five via Digitalmars-d-learn

On Sunday, 7 May 2017 at 11:11:05 UTC, Vladimir Panteleev wrote:

On Sunday, 7 May 2017 at 10:49:25 UTC, k-five wrote:

After reading about rdmd and --eval, I tried this:

rdmd --eval='auto f=File("ddoc.html");foreach(line;f.byLine) 
if(line.length<10) writeln(line);f.close'


and worked!

Now I am wonder if there is a way to pass "ddoc.html" to this 
one-liner? that can work with --loop.


I mean:
// --loop by default has foreach(line ...
// like perl -n
rdmd --loop='if( line.length < 10 ) writeln( line );' ddoc.html

but it is an error in syntax and rdmd says:
Cannot have both --eval and a program file ('ddoc.html')


Currently it's not possible:


It should be possible!
rdmd --eval=, without accepting argument is useless.


Re: My D tool projects have moved

2017-05-07 Thread Andrei Alexandrescu via Digitalmars-d-announce

On 5/7/17 10:59 AM, Brian Schott wrote:
I moved DCD, D-Scanner, dfmt, and other D tool projects to the 
dlang-community organization on Github:


https://github.com/dlang-community

This should make things more convenient if I get hit by a bus, decide 
that Malbolge* is the one true programming language, or just take too 
long to review a pull request.


* https://en.wikipedia.org/wiki/Malbolge


Thanks, Brian. BTW you are being missed at DConf! -- Andrei


Re: How can I pass an argument to rdmd --evel=

2017-05-07 Thread Vladimir Panteleev via Digitalmars-d-learn

On Sunday, 7 May 2017 at 11:11:05 UTC, Vladimir Panteleev wrote:

Currently it's not possible:


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



Re: How can I pass an argument to rdmd --evel=

2017-05-07 Thread Vladimir Panteleev via Digitalmars-d-learn

On Sunday, 7 May 2017 at 10:49:25 UTC, k-five wrote:

After reading about rdmd and --eval, I tried this:

rdmd --eval='auto f=File("ddoc.html");foreach(line;f.byLine) 
if(line.length<10) writeln(line);f.close'


and worked!

Now I am wonder if there is a way to pass "ddoc.html" to this 
one-liner? that can work with --loop.


I mean:
// --loop by default has foreach(line ...
// like perl -n
rdmd --loop='if( line.length < 10 ) writeln( line );' ddoc.html

but it is an error in syntax and rdmd says:
Cannot have both --eval and a program file ('ddoc.html')


Currently it's not possible:



[Issue 17380] New: [REG 2.074.0] Compiler segfaults on undefined symbol

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17380

  Issue ID: 17380
   Summary: [REG 2.074.0] Compiler segfaults on undefined symbol
   Product: D
   Version: D2
  Hardware: x86_64
OS: Linux
Status: NEW
  Severity: regression
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: k...@redstar.de

Created attachment 1645
  --> https://issues.dlang.org/attachment.cgi?id=1645=edit
Source file demonstrating the bug.

Compiling the attached source with dmd -unittest -main bug.d, dmd segfaults.
When line 88 is replaced by line 89 then it compiles and links.

The culprit is an undefined symbol:

Uint128 opCast(T : Uint128)()
{
return ThisTypeDoesNotExistsAndCrahesTheCompiler(v);
}

Changing to

Uint128 opCast(T : Uint128)()
{
return Uint128(0);
}

dmd does not crash.

--


[Issue 17379] New: Mangle voldemort types as if they are defined in the outer scope to avoid exponential symbol name length with templates

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17379

  Issue ID: 17379
   Summary: Mangle voldemort types as if they are defined in the
outer scope to avoid exponential symbol name length
with templates
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: geor...@outlook.com

This is related to PR 15831.

In this forum thread : 
http://forum.dlang.org/post/nhkje4$jlm$1...@digitalmars.com
there a workaround this removes the exponential growth with a linear growth.

Example:

auto foo(T)(T t) if (someConstraints)
{
   static struct Result
   {
  T t;
   }
   return Result(t);
}

When changed to the functionally equivalent:

template(T) foo if (someConstraints)
{
   static struct Result
   {
  T t;
   }

   auto foo(T t)
   {
  return Result(t);
   }
}

The exponential growth is replaced with linear growth.

It would be very good if DMD lowers the first case to the second when mangling
voldemort types.

--


Re: DLang quarterly EU?

2017-05-07 Thread Seb via Digitalmars-d

On Sunday, 7 May 2017 at 06:58:51 UTC, Adam Wilson wrote:

On 5/7/17 07:41, Walter Bright wrote:

Dang, I wish I could participate in that!


Well, technically you could, but it involves a set of rather 
grueling flights.


Depending on the day it's held I might be able to attend once a 
year. If it's on the weekend, I can make a long weekend out of 
it.


+1 - maybe its worth considering to make it for two days (=one 
weekend), s.t. the flight is not longer than the meetup?


How can I pass an argument to rdmd --evel=

2017-05-07 Thread k-five via Digitalmars-d-learn

After reading about rdmd and --eval, I tried this:

rdmd --eval='auto f=File("ddoc.html");foreach(line;f.byLine) 
if(line.length<10) writeln(line);f.close'


and worked!

Now I am wonder if there is a way to pass "ddoc.html" to this 
one-liner? that can work with --loop.


I mean:
// --loop by default has foreach(line ...
// like perl -n
rdmd --loop='if( line.length < 10 ) writeln( line );' ddoc.html

but it is an error in syntax and rdmd says:
Cannot have both --eval and a program file ('ddoc.html')


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread k-five via Digitalmars-d-learn

On Sunday, 7 May 2017 at 09:46:22 UTC, Patrick Schluter wrote:

On Saturday, 6 May 2017 at 10:15:03 UTC, k-five wrote:


If you want to learn the basis of the range concept and their 
link to C++ Iterators, you should definitively read Andrei's 
article on them in the InformIT magazine. Here is the link

http://www.informit.com/articles/printerfriendly/1407357
required read for every aspiring D programmer ;-)


---

Thanks for the article.

Although I found D for being more better, nicer,and fun than C++ 
is, but there is a few questions on Stack-Over-Flow, videos on 
Youtube, and  some other forums in my country. So, why D is not 
popular?


I am a big fan of Perl-one-liner and after seeing
rdmd --evel='one-line-code'
I gasped! Oh, really? a one-liner with D!

Or even Unix Command Line, that D has Uniform Function Call 
Syntax.

line.sort.uniq.writeln();

It may you know about the future of D or may introduce some other 
articles about the future of D to me. Since after learning C++ I 
am not very comfortable with.


iopipe on github

2017-05-07 Thread Steven Schveighoffer via Digitalmars-d-announce
For anyone interested in iopipe, I have updated my github repository for 
the iopipe[1] library. It's still not IMO ready for a dub link, as I 
want to polish some more. But at least the code shown in my 
presentation[2] will compile.


I also added the very incomplete and under-tested jsoniopipe[3] repository

-Steve

[1] https://github.com/schveiguy/iopipe
[2] http://dconf.org/2017/talks/schveighoffer.html
[3] https://github.com/schveiguy/jsoniopipe


[Issue 5968] std.algorithm.group by key function + groupFull

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=5968

Ulrich Küttler  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||kuett...@gmail.com
 Resolution|--- |FIXED

--- Comment #3 from Ulrich Küttler  ---
There is chunkBy now.

--


Re: Looking for an equivalent to C++ std::getline in D

2017-05-07 Thread Patrick Schluter via Digitalmars-d-learn

On Saturday, 6 May 2017 at 10:15:03 UTC, k-five wrote:


Although I am not sure but it may Range in D, has the same 
concept that C++ has on iterator, like InputIterator or 
OutputIterator, since I realized that the output of [ filter ] 
does not have RandomAccessRange so I can not use input[ 0 ]. 
But I can use input.front().




If you want to learn the basis of the range concept and their 
link to C++ Iterators, you should definitively read Andrei's 
article on them in the InformIT magazine. Here is the link

http://www.informit.com/articles/printerfriendly/1407357
required read for every aspiring D programmer ;-)


[Issue 17377] Empty D program is not valgrind clean

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17377

b2.t...@gmx.com changed:

   What|Removed |Added

 CC||b2.t...@gmx.com

--- Comment #1 from b2.t...@gmx.com ---
There's a PR that should fix it, https://github.com/dlang/druntime/pull/1557,
the status is unclear.

--


Re: Thank You DConf 2017

2017-05-07 Thread Bastiaan Veelo via Digitalmars-d

On Saturday, 6 May 2017 at 16:44:00 UTC, Stanislav Blinov wrote:
Fantastic three days of presentations. A big Thank You to all 
presenters, organizers and sponsors, and a special Thank You to 
the team that made the livestream possible, so even those of us 
who couldn't make it to Berlin could not only learn from the 
conference but actually participate.
An awesome event and lots of food for thought, exploration, 
experimentation and implementation. Thank You!


I agree completely. I have been following previous DConfs online, 
and fantasising that I might attend one, one day. That it would 
be this one I had not anticipated and feel honoured to have been 
asked to present, it is a great compliment that the things that 
occupy me would be interesting to a wider audience. It has been a 
rewarding experience (and still is during this hackathon), the 
conversations and chats I have had with so many smart people will 
bring me closer to my goals, and give me energy. The atmosphere 
here is amazing, and I am enjoying myself tremendously.


So thank you all indeed!

Bastiaan.


[Issue 17378] New: Allow multiple arguments for assert and static assert

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17378

  Issue ID: 17378
   Summary: Allow multiple arguments for assert and static assert
   Product: D
   Version: D2
  Hardware: All
OS: Linux
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: acehr...@yahoo.com

This is for consistency with pragma(msg) and developer and build efficiency
(because std.string.format would not be needed anymore).

void main() {
pragma(msg, "hi ", 42);
// static assert(false, "wat ", 43);
// assert(false, "why ", 44);
}

The commented-out lines should be compilable and output "wat 43" and "why 44"
respectively.

Ali

--


[Issue 17377] New: Empty D program is not valgrind clean

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17377

  Issue ID: 17377
   Summary: Empty D program is not valgrind clean
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: druntime
  Assignee: nob...@puremagic.com
  Reporter: issues.dl...@jmdavisprog.com

When this program

import std.stdio;

void main()
{
}

is run through

valgrind --leak-check=full

it shows that we're leaking memory:

==8668== Memcheck, a memory error detector
==8668== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==8668== Using Valgrind-3.12.0.SVN and LibVEX; rerun with -h for copyright info
==8668== Command: ./empty
==8668== 
==8668== 
==8668== HEAP SUMMARY:
==8668== in use at exit: 88 bytes in 2 blocks
==8668==   total heap usage: 101 allocs, 99 frees, 49,704 bytes allocated
==8668== 
==8668== 16 bytes in 1 blocks are definitely lost in loss record 1 of 2
==8668==at 0x4C2CB3F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8668==by 0x15D0DD: _D2rt5tlsgc4initFNbNiZPv (in /home/jmdavis/empty)
==8668==by 0x157F51: thread_attachThis (in /home/jmdavis/empty)
==8668==by 0x157DDA: thread_init (in /home/jmdavis/empty)
==8668==by 0x144464: gc_init (in /home/jmdavis/empty)
==8668==by 0x13D437: rt_init (in /home/jmdavis/empty)
==8668==by 0x13A3C9: _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFNlZv
(in /home/jmdavis/empty)
==8668==by 0x13A36B:
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFNlMDFZvZv (in
/home/jmdavis/empty)
==8668==by 0x13A2DB: _d_run_main (in /home/jmdavis/empty)
==8668==by 0x13A0F7: main (in /home/jmdavis/empty)
==8668== 
==8668== 72 bytes in 1 blocks are definitely lost in loss record 2 of 2
==8668==at 0x4C2EB55: calloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8668==by 0x15CFFF:
_D2rt8monitor_13ensureMonitorFNbC6ObjectZPOS2rt8monitor_7Monitor (in
/home/jmdavis/empty)
==8668==by 0x15CF5E: _d_monitorenter (in /home/jmdavis/empty)
==8668==by 0x157B6C: _D4core6thread6Thread8isDaemonMFNdNiNfZb (in
/home/jmdavis/empty)
==8668==by 0x143EDE: thread_joinAll (in /home/jmdavis/empty)
==8668==by 0x13D4E4: rt_term (in /home/jmdavis/empty)
==8668==by 0x13A3F9: _D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFNlZv
(in /home/jmdavis/empty)
==8668==by 0x13A36B:
_D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ7tryExecMFNlMDFZvZv (in
/home/jmdavis/empty)
==8668==by 0x13A2DB: _d_run_main (in /home/jmdavis/empty)
==8668==by 0x13A0F7: main (in /home/jmdavis/empty)
==8668==
==8668== LEAK SUMMARY:
==8668==definitely lost: 88 bytes in 2 blocks
==8668==indirectly lost: 0 bytes in 0 blocks
==8668==  possibly lost: 0 bytes in 0 blocks
==8668==still reachable: 0 bytes in 0 blocks
==8668== suppressed: 0 bytes in 0 blocks
==8668==
==8668== For counts of detected and suppressed errors, rerun with: -v
==8668== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)


There's a good chance that this really doesn't matter normally, but if not even
an empty program is valgrind clean, then it's likely to be problematic to
verify that we don't have memory problems when using allocators or integrating
with C/C++.

It would not surprise me if we need a way to run druntime that indicates that
we're running valgrind so that it does cleanup that it doesn't normally do
(e.g. force the GC to clean up everything on shutdown, which it normally
wouldn't), but I don't know. Either way, valgrind indicates that we're
currently leaking with an empty main.

--


My D tool projects have moved

2017-05-07 Thread Brian Schott via Digitalmars-d-announce
I moved DCD, D-Scanner, dfmt, and other D tool projects to the 
dlang-community organization on Github:


https://github.com/dlang-community

This should make things more convenient if I get hit by a bus, 
decide that Malbolge* is the one true programming language, or 
just take too long to review a pull request.


* https://en.wikipedia.org/wiki/Malbolge


[Issue 17376] modify global variable with pure method

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17376

Walter Bright  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 CC||bugzi...@digitalmars.com
 Resolution|--- |INVALID

--- Comment #1 from Walter Bright  ---
This compiles successfully because the 'this' reference is treated like any
other parameter.

--


[Issue 16232] std.experimental.logger.core.sharedLog isn't thread-safe

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=16232

--- Comment #3 from Robert Schadek  ---
I will add a comment to make that clear

--


[Issue 17376] New: modify global variable with pure method

2017-05-07 Thread via Digitalmars-d-bugs
https://issues.dlang.org/show_bug.cgi?id=17376

  Issue ID: 17376
   Summary: modify global variable with pure method
   Product: D
   Version: D2
  Hardware: x86
OS: All
Status: NEW
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: arbm...@gmail.com

Consider this test code:

int ga;
struct Tester {
int* pa;

this(int) { pa =  }

void test() pure {
*pa = 3;
}
}

void main() {
  auto t = Tester(1);

  assert(ga == 0);
  t.test();
  assert(ga == 3);
}

>From the perspective of the caller, he is calling a pure function, but can
observe a global state change.

It is also possible to change a static member of the struct in the same manner.

I guess that this inhibits some opportunities for optimizations.

--


London DLang

2017-05-07 Thread Russel Winder via Digitalmars-d
Really a message to John Colvin, but I lost his email…

Kingsley made two attempts to start a DLang London meet up, maybe third
time lucky?

It is worth noting that Phil Nash started a C++ London group a few
months back and now gets 100+ at each meeting. Clearly there is huge
interest in C++ in London that was untapped till recently. Maybe we
could do a D pitch to the C++ folk, especially based on mixed
codebases?

Given C++17 and it's parallelism support, plus that Herb may well get
metaclasses into C++20, what is the angle that gets C++ folk to D these
days? Or is it that that opportunity has now passed given the changes
in C++?

Gerald did a great pitch for D as the replacement for Vala (and C++)
for Gtk. Maybe that is an angle, maybe get D as an official binging
based on LDC?
 
Then there is the Python angle. I know the "data science" mindset is
Python/NumPy/Pandas/Matplotlib (yes R is still a factor) and that is
unlikely ever to be supplanted successfully in the short and medium
term. But maybe worth thinking what a D-centric approach might be.
Laeeth has often championed D over Python in finance.

I suspect I will be doing a Python/Chapel pitch at PyConUK this year,
trying to get Pythonistas to understand what real computation is: 10
processors, pah, I want 10,000 processors working on this. If anyone
wants to get a Python/D pitch in there, I'd be there to cheer.

One thing that is clear in the Python community is that presentational
sessions get an audience, and code dojo, actual programming sessions
get an audience. Maybe there is a role for a D meeting where people
turn up and actually just do some programming, either code dojo, or
working on something specific.

Sadly working on the IntelliJ IDEA plugin would be great but that is
Kotlin (and Java) programming.

Oh and are people thinking of proposing D-related sessions to ACCU
2018? The call for proposals will go out 2017-10.

-- 
Russel.
=
Dr Russel Winder  t: +44 20 7585 2200   voip: sip:russel.win...@ekiga.net
41 Buckmaster Roadm: +44 7770 465 077   xmpp: rus...@winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder

signature.asc
Description: This is a digitally signed message part


Re: DLang quarterly EU?

2017-05-07 Thread Mike Parker via Digitalmars-d

On Sunday, 7 May 2017 at 06:58:51 UTC, Adam Wilson wrote:

On 5/7/17 07:41, Walter Bright wrote:

Dang, I wish I could participate in that!


Well, technically you could, but it involves a set of rather 
grueling flights.


Depending on the day it's held I might be able to attend once a 
year. If it's on the weekend, I can make a long weekend out of 
it.


It's a long haul for me, but I'd also be willing to hop over once 
a year beyond DConf. Good excuse for a vacation.


Re: DLang quarterly EU?

2017-05-07 Thread Adam Wilson via Digitalmars-d

On 5/7/17 07:41, Walter Bright wrote:

Dang, I wish I could participate in that!


Well, technically you could, but it involves a set of rather grueling 
flights.


Depending on the day it's held I might be able to attend once a year. If 
it's on the weekend, I can make a long weekend out of it.


--
Adam Wilson
IRC: LightBender
import quiet.dlang.dev;